lila/ui/build

49 lines
1.1 KiB
Bash
Executable File

#!/bin/bash -ea
target=${1-dev}
mode=${2-build} # use "upgrade" to upgrade all deps
echo "building ui modules with target=$target and mode=$mode"
cd "$(git rev-parse --show-toplevel)"
mkdir -p public/compiled
ts_apps1="common chess"
ts_apps2="ceval game tree chat"
apps="site chat cli challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule simul perfStat dasher"
if [ $mode == "upgrade" ]; then
yarn upgrade --non-interactive
else
yarn install --non-interactive
fi
build_ts() {
echo "build_ts" "$@"
set -ev
cd ui/$1
yarn run compile
}
build() {
echo "build" "$@"
set -ev
cd ui/$1
gulp $target
}
if type -p parallel; then # parallel execution!
if [ -z "$P_OPTS" -a ! -e ~/.parallel/config ]; then
P_OPTS="-j+4 --halt 2"
[ "$TRAVIS" = "true" ] || P_OPTS+=" --bar"
fi
set -x
parallel --gnu $P_OPTS build_ts ::: $ts_apps1
parallel --gnu $P_OPTS build_ts ::: $ts_apps2
parallel --gnu $P_OPTS build ::: $apps
else # sequential execution
echo "For faster builds, install GNU parallel."
for app in $ts_apps1 $ts_apps2; do (build_ts $app); done
for app in $apps; do (build $app); done
fi