Skip to content

Commit 9f81634

Browse files
authored
Merge branch 'main' into make-group-for-dropdown-checkboxes
2 parents 27901c9 + 5af586b commit 9f81634

24 files changed

+537
-562
lines changed

concourse/update-content/script.bash

+11-5
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ fi
1111
# this is here so the creds don't get pasted to the output
1212
set -e; if [ -n "$DEBUG" ]; then set -x; fi
1313

14-
approved_books_default_branch=$(curl -s https://api.github.com/repos/openstax/content-manager-approved-books | jq -r .default_branch)
1514
rex_default_branch=$(curl -s https://api.github.com/repos/openstax/rex-web | jq -r .default_branch)
1615

17-
data=$(curl -sL "https://github.com/openstax/content-manager-approved-books/raw/$approved_books_default_branch/approved-book-list.json")
18-
19-
# script will return a JSON object with book ids and new versions only for books that doesn't mach current config
20-
book_ids_and_versions=$(node script/entry.js transform-approved-books-data --data "$data")
16+
# consumer: Limit entries to those where consumer == <consumer>
17+
# code_version: Limit entries to those where code_version <= <code_version>
18+
archive_version="$(jq -r '.REACT_APP_ARCHIVE' "src/config.archive-url.json")"
19+
search="consumer=REX&code_version=$archive_version"
20+
abl_url="https://corgi.ce.openstax.org/api/abl/?$search"
21+
22+
book_ids_and_versions="$(
23+
bash script/transform-approved-books-data.bash \
24+
<(curl -sL --fail --show-error "$abl_url") \
25+
"src/config.books.json"
26+
)"
2127
book_entries=$(echo "$book_ids_and_versions" | jq -c 'to_entries | .[]')
2228

2329
git remote set-branches origin 'update-content-*'
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
: "${1:?'First argument should be a file containing CORGI ABL array'}"
6+
: "${2:?'Second argument should be a file containing configured books object'}"
7+
8+
jq --slurp --compact-output '
9+
.[0] as $corgi_abl |
10+
.[1] as $configured_books |
11+
$corgi_abl |
12+
if (type != "array") then error("Bad ABL data") else . end |
13+
$configured_books |
14+
if (type != "object") then error("Bad book config") else . end |
15+
[
16+
# Get the newest version of each book
17+
$corgi_abl | group_by(.uuid) | .[] | sort_by(.commited_at) | .[-1] |
18+
19+
# Store information about the entry (uuid and short sha)
20+
.uuid as $uuid |
21+
(.commit_sha | .[0:7]) as $commit_sha |
22+
23+
# Select entries that do not match configured books
24+
select($configured_books | .[$uuid] | .defaultVersion != $commit_sha) |
25+
{ key: .uuid, value: $commit_sha }
26+
] | from_entries
27+
' "$@"

script/transform-approved-books-data.ts

-314
This file was deleted.

script/validate-abl-import/test.bash

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -e
44

@@ -26,9 +26,10 @@ for input_file in "$my_dir"/*.input.json; do
2626
# -------------------------
2727
# Actual test goes here
2828
# -------------------------
29-
json=$(cat "$input_file")
30-
node "$my_dir/../entry.js" transform-approved-books-data --data "$json" > "$output_file"
3129

30+
bash "$my_dir/../transform-approved-books-data.bash" \
31+
<(jq -e '.abl_data' "$input_file") \
32+
<(jq -e '.configured_books' "$input_file") > "$output_file"
3233

3334
diff "$snapshot_file" "$output_file"
3435

0 commit comments

Comments
 (0)