Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/babel/traverse-7.23.2
Browse files Browse the repository at this point in the history
  • Loading branch information
staxly[bot] authored Jul 18, 2024
2 parents 9224cff + 5af586b commit 7b64a57
Show file tree
Hide file tree
Showing 24 changed files with 537 additions and 562 deletions.
16 changes: 11 additions & 5 deletions concourse/update-content/script.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ fi
# this is here so the creds don't get pasted to the output
set -e; if [ -n "$DEBUG" ]; then set -x; fi

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

data=$(curl -sL "https://github.com/openstax/content-manager-approved-books/raw/$approved_books_default_branch/approved-book-list.json")

# script will return a JSON object with book ids and new versions only for books that doesn't mach current config
book_ids_and_versions=$(node script/entry.js transform-approved-books-data --data "$data")
# consumer: Limit entries to those where consumer == <consumer>
# code_version: Limit entries to those where code_version <= <code_version>
archive_version="$(jq -r '.REACT_APP_ARCHIVE' "src/config.archive-url.json")"
search="consumer=REX&code_version=$archive_version"
abl_url="https://corgi.ce.openstax.org/api/abl/?$search"

book_ids_and_versions="$(
bash script/transform-approved-books-data.bash \
<(curl -sL --fail --show-error "$abl_url") \
"src/config.books.json"
)"
book_entries=$(echo "$book_ids_and_versions" | jq -c 'to_entries | .[]')

git remote set-branches origin 'update-content-*'
Expand Down
27 changes: 27 additions & 0 deletions script/transform-approved-books-data.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -e

: "${1:?'First argument should be a file containing CORGI ABL array'}"
: "${2:?'Second argument should be a file containing configured books object'}"

jq --slurp --compact-output '
.[0] as $corgi_abl |
.[1] as $configured_books |
$corgi_abl |
if (type != "array") then error("Bad ABL data") else . end |
$configured_books |
if (type != "object") then error("Bad book config") else . end |
[
# Get the newest version of each book
$corgi_abl | group_by(.uuid) | .[] | sort_by(.commited_at) | .[-1] |
# Store information about the entry (uuid and short sha)
.uuid as $uuid |
(.commit_sha | .[0:7]) as $commit_sha |
# Select entries that do not match configured books
select($configured_books | .[$uuid] | .defaultVersion != $commit_sha) |
{ key: .uuid, value: $commit_sha }
] | from_entries
' "$@"
314 changes: 0 additions & 314 deletions script/transform-approved-books-data.ts

This file was deleted.

7 changes: 4 additions & 3 deletions script/validate-abl-import/test.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

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

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

diff "$snapshot_file" "$output_file"

Expand Down
Loading

0 comments on commit 7b64a57

Please sign in to comment.