diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..8eb3564a3e3c6d1515bbfd10e1a5696857d2b27f --- /dev/null +++ b/build.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +# set -euxo pipefail + +node scripts/bundle.js spec/set-payload.schema.json \ + dist/set-payload.schema.json + +rm -rf examples examples_fail +mkdir -p examples examples_fail + +# Create examples using template files +for template in templates/*.json; do + + # Get the name of the template + template_name=$(basename "$template") + + # Create the example + set -- "1.0.0" "1.0.1" "1.0.2" "1.0.11" "1.1.0" "1.5.11" + for version in "$@"; do + sed -e "s|SCHEMA_VERSION|$version|g" "$template" > ./examples/"$template_name"_"$version".json + done + + set -- "2.0.0" "3.0.1" "2.0.2" "2.0.11" "2.1.0" "3.5.11" + for version in "$@"; do + sed -e "s|SCHEMA_VERSION|$version|g" "$template" > ./examples_fail/"$template_name"_"$version".json + done + +done diff --git a/bundle.sh b/bundle.sh deleted file mode 100755 index fc8503328ed4db77f646457d23df607adf495b4a..0000000000000000000000000000000000000000 --- a/bundle.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh - -# set -euxo pipefail - -node scripts/bundle.js spec/authentication-tags.schema.json dist/authentication-tags.schema.json -node scripts/bundle.js spec/problems.schema.json dist/problems.schema.json -node scripts/bundle.js spec/set-payload.schema.json dist/set-payload.schema.json -sh create_examples.sh diff --git a/create_examples.sh b/create_examples.sh deleted file mode 100755 index b112e7180ae7c120a2753d687ba20377e8c5b9d2..0000000000000000000000000000000000000000 --- a/create_examples.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env sh - -# Create a directory for the examples -rm -rf examples -rm -rf examples_fail -mkdir -p examples -mkdir examples_fail - - -# Run over Templates and create examples -for template in templates/*.json; do - # Get the name of the template - template_name=$(basename $template) - - # Get the name of the example - example_name=${template_name%.template} - - # Create the example - set -- "1.0.0" "1.0.1" "1.0.2" "1.0.11" "1.1.0" "1.5.11" - for version in "$@"; do - cat $template | sed -e "s|SCHEMA_VERSION|$version|g" > ./examples/"$template_name"_"$version".json - done - - set -- "2.0.0" "3.0.1" "2.0.2" "2.0.11" "2.1.0" "3.5.11" - for version in "$@"; do - cat $template | sed -e "s|SCHEMA_VERSION|$version|g" > ./examples_fail/"$template_name"_"$version".json - done - -done diff --git a/package.json b/package.json index 0718a195f85bdfd38af2ea51a2efd2c140996651..ff2f015a2c4fea5cccbac98f67fa86c3660c06d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "scripts": { - "bundle": "sh bundle.sh", + "bundle": "sh build.sh", "lint": "ajv compile --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json", "test": "ajv validate --errors=text --verbose --all-errors -d examples/**/*.json --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json", "test_higher_version": "! ajv validate --errors=text --verbose --all-errors -d examples_fail/**/*.json --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json"