2023-12-23 22:10:39 +01:00
#! /usr/bin/env bash
echo "Starting prepare-build"
2025-02-06 12:45:29 +01:00
nvm use
2023-12-23 22:10:39 +01:00
# 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"
2024-07-16 16:11:14 +02:00
VERSION = $( cat package.json | grep '"version": ' | sed "s/^.*://" | tr -d " \"," )
sed " s/= \"0.0.0\"/= \" $VERSION \"/ " -i public/service-worker.js
2023-12-23 22:10:39 +01:00
# This script ends every line with '&&' to chain everything. A failure will thus stop the build
2024-07-10 11:52:30 +02:00
npm run download:editor-layer-index &&
2023-12-23 22:10:39 +01:00
npm run prep:layeroverview &&
2025-04-22 03:13:22 +02:00
# Done by 'deploy_hosted':
# npm run generate:licenses; npm run generate:images; npm run generate:charging-stations; npm run generate:service-worker; npm run download:editor-layer-index
# npm run generate:translations
npm run reset:layeroverview &&
2023-12-30 16:41:39 +01:00
npm run generate:mapcomplete-changes-theme &&
2023-12-23 22:10:39 +01:00
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 "
2024-07-16 16:11:14 +02:00
2023-12-23 22:10:39 +01:00
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