diff --git a/package.json b/package.json index 825a2d538..aa350f9ae 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,8 @@ "prep:layeroverview": "mkdir -p ./src/assets/generated/layers; echo {\\\"themes\\\":[]} > ./src/assets/generated/known_themes.json && echo {\\\"layers\\\": []} > ./src/assets/generated/known_layers.json && rm -f ./src/assets/generated/layers/*.json && rm -f ./src/assets/generated/themes/*.json && cp ./assets/layers/usersettings/usersettings.json ./src/assets/generated/layers/usersettings.json && echo '{}' > ./src/assets/generated/layers/favourite.json", "generate": "npm run generate:licenses && npm run generate:images && npm run generate:charging-stations && npm run generate:translations && npm run refresh:layeroverview && npm run generate:service-worker", "generate:charging-stations": "cd ./assets/layers/charging_station && vite-node csvToJson.ts && cd -", - "prepare-deploy": "npm run generate:service-worker && ./scripts/build.sh", + "prepare-deploy": "npm run generate:service-worker && ./scripts/prepare-build.sh && npm run build", + "build": "./scripts/build.sh", "lint": "npm run lint:prettier && npm run lint:eslint", "lint:eslint": "eslint ./src", "lint:prettier": "prettier --check '**/*.ts' '**/*.svelte'", diff --git a/scripts/build.sh b/scripts/build.sh old mode 100755 new mode 100644 index ec1507aff..1d1b5b8a0 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,45 +4,8 @@ echo "Starting build" # The build script; we build the application step by step as building everything at once takes too much RAM # Should be run from the repository root # This is the main deployment script -rm -rf dist/* -rm -rf .cache -mkdir dist 2> /dev/null -mkdir dist/assets 2> /dev/null -export NODE_OPTIONS="--max-old-space-size=16384" - -# This script ends every line with '&&' to chain everything. A failure will thus stop the build -npm run generate:editor-layer-index && -npm run prep:layeroverview && -npm run generate && # includes a single "refresh:layeroverview". Resetting the files is unnecessary as they are not in there in the first place -npm run refresh:layeroverview && # run refresh:layeroverview a second time to propagate all calls -npm run refresh:layeroverview && # run refresh:layeroverview a third time to fix some issues with the favourite layer all calls - -npm run generate:layouts - -if [ $? -ne 0 ]; then - echo "ERROR - stopping the build" - exit 1 -fi - - - -BRANCH=`git rev-parse --abbrev-ref HEAD` -echo "The branch name is $BRANCH" - -if [ $BRANCH = "master" ] || [ $BRANCH = "develop" ] -then - ASSET_URL="./" - export ASSET_URL - echo "$ASSET_URL" -else - # ASSET_URL="$BRANCH" - ASSET_URL="./" - export ASSET_URL - echo "$ASSET_URL" -fi - # sanity check if [[ -f "bookcases.html" ]] then diff --git a/scripts/prepare-build.sh b/scripts/prepare-build.sh new file mode 100755 index 000000000..e25890919 --- /dev/null +++ b/scripts/prepare-build.sh @@ -0,0 +1,53 @@ +#! /usr/bin/env bash + +echo "Starting prepare-build" +# The build script; we build the application step by step as building everything at once takes too much RAM +# Should be run from the repository root +# This is the main deployment script +rm -rf dist/* +rm -rf .cache +mkdir dist 2> /dev/null +mkdir dist/assets 2> /dev/null + + +export NODE_OPTIONS="--max-old-space-size=16384" + +# This script ends every line with '&&' to chain everything. A failure will thus stop the build +npm run generate:editor-layer-index && +npm run prep:layeroverview && +npm run generate && # includes a single "refresh:layeroverview". Resetting the files is unnecessary as they are not in there in the first place +npm run refresh:layeroverview && # run refresh:layeroverview a second time to propagate all calls +npm run refresh:layeroverview && # run refresh:layeroverview a third time to fix some issues with the favourite layer all calls + +npm run generate:layouts + +if [ $? -ne 0 ]; then + echo "ERROR - stopping the build" + exit 1 +fi + + + +BRANCH=`git rev-parse --abbrev-ref HEAD` +echo "The branch name is $BRANCH" + +if [ $BRANCH = "master" ] || [ $BRANCH = "develop" ] +then + ASSET_URL="./" + export ASSET_URL + echo "$ASSET_URL" +else + # ASSET_URL="$BRANCH" + ASSET_URL="./" + export ASSET_URL + echo "$ASSET_URL" +fi + +# sanity check +if [[ -f "bookcases.html" ]] +then + echo "Bookcases exists" +else + echo "Bookcases.html does not exist - aborting" + exit 1 +fi