Skip to content

Commit

Permalink
Map supported version to commit hashes in build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuester committed Jan 6, 2024
1 parent 96e77d0 commit b6285e7
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env bash
declare -A cht_versions=(
["cht-core-4-6"]="42807deaae818bf2085d0457f9f161073493aec1"
)

exit_on_error() {
exit_code=$?
if [[ $exit_code -ne 0 ]]; then
Expand All @@ -11,27 +15,29 @@ set -e
trap exit_on_error EXIT

if [ "$1" == "--force" ]; then
FORCE=true
FORCE=1
fi

npm ci --legacy-peer-deps
rm -Rf build

if [[ 1 == "$FORCE" ]]; then
rm -Rf dist
else
for item in `ls dist | grep -v cht-core`; do
rm -rf dist/"$item"
done
fi

for item in `ls build | grep -v cht-core`; do
rm -rf $item
done

declare -a versions=("cht-core-4-6")
for version in "${versions[@]}"; do
if [ -z ${FORCE+x} ] && [ -d dist/"$version" ]; then
for version in "${!cht_versions[@]}"; do
if [[ ! 1 == "$FORCE" ]] && [ -d dist/"$version" ]; then
printf "\033[0;32m== SKIPPING $version ==\n"
continue
fi

if [ -d build/"$version" ]; then
(cd build/"$version" && git fetch && git reset --hard origin/master)
else
git clone -b master https://github.com/medic/cht-core.git build/"$version"
fi
git clone https://github.com/medic/cht-core.git build/"$version"
(cd build/"$version" && git reset --hard "${cht_versions[$version]}")
(cd build/"$version" && git clean -df)

(cd build/"$version" && npm ci)

Expand All @@ -47,9 +53,9 @@ for version in "${versions[@]}"; do
mkdir -p dist/"$version"/enketo-transformer/xsl
cp ./build/cht-core-4-6/api/src/xsl/openrosa2html5form.xsl dist/"$version"/xsl
cp ./build/cht-core-4-6/api/src/enketo-transformer/xsl/* dist/"$version"/enketo-transformer/xsl
done

npx webpack --config cht-bundles/webpack.config.cht-core.js --env.cht='cht-core-4-6'
npx webpack --config cht-bundles/webpack.config.cht-core.js --env.cht="$version"
done

npx webpack

Expand Down

0 comments on commit b6285e7

Please sign in to comment.