TeaWeb/scripts/web_build.sh

92 lines
2.2 KiB
Bash
Raw Normal View History

2018-10-28 23:59:15 +01:00
#!/usr/bin/env bash
2019-02-11 20:12:37 +01:00
source `dirname $0`/resolve_commands.sh
2018-10-28 23:59:15 +01:00
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
2019-02-09 20:23:15 +01:00
if [[ "$1" == "development" ]] || [[ "$1" == "dev" ]]; then
2018-10-28 23:59:15 +01:00
source_path="web/environment/development"
type="development"
2019-02-09 20:23:15 +01:00
elif [[ "$1" == "release" ]] || [[ "$1" == "rel" ]]; then
2018-10-28 23:59:15 +01:00
source_path="web/environment/release"
type="release"
else
2019-02-09 20:23:15 +01:00
if [[ $# -lt 1 ]]; then
2018-10-28 23:59:15 +01:00
echo "Invalid argument count!"
else
echo "Invalid option $1"
fi
echo 'Available options are: "development" or "dev", "release" or "rel"'
exit 1
fi
echo "Generating style files"
npm run compile-sass
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to generate style files"
exit 1
fi
echo "Generating web workers"
npm run build-worker
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to build web workers"
exit 1
fi
2018-12-26 14:17:12 +01:00
#Lets build some tools
#dtsgen should be already build by build_declarations.sh
2018-12-26 14:18:32 +01:00
./tools/build_trgen.sh
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-12-26 14:17:12 +01:00
echo "Failed to build typescript translation generator"
exit 1
fi
2018-10-28 23:59:15 +01:00
#Now lets build the declarations
echo "Building declarations"
./scripts/build_declarations.sh
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to generate declarations"
exit 1
fi
2019-02-09 20:23:15 +01:00
if [[ "$type" == "release" ]]; then #Compile everything for release mode
2018-10-28 23:59:15 +01:00
#Compile the shared source first
echo "Building shared source"
./shared/generate_packed.sh
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to build shared source"
exit 1
fi
#Now compile the web client itself
echo "Building web client"
./web/generate_packed.sh
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to build web client"
exit 1
fi
2019-02-09 20:23:15 +01:00
elif [[ "$type" == "development" ]]; then
2018-10-28 23:59:15 +01:00
echo "Building shared source"
execute_ttsc -p ./shared/tsconfig/tsconfig.json
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to compile shared sources"
exit 1
fi
echo "Building web client source"
execute_ttsc -p ./web/tsconfig/tsconfig.json
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to compile web sources"
exit 1
fi
fi
echo "Generating environment"
php files.php generate web ${type}
2019-02-09 20:23:15 +01:00
if [[ $? -ne 0 ]]; then
2018-10-28 23:59:15 +01:00
echo "Failed to generate environment"
exit 1
fi
echo "Successfully build!"