53 lines
1.4 KiB
Bash
Executable file
53 lines
1.4 KiB
Bash
Executable file
#!/bin/bash -ea
|
|
target=${1-dev}
|
|
mode=${2-build}
|
|
|
|
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 challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule simul perfStat dasher"
|
|
|
|
YARN_MUTEX="${TMPDIR-/tmp}/.yarn-mutex"
|
|
build_ts() {
|
|
echo "build_ts" "$@"
|
|
set -ev
|
|
cd ui/$1
|
|
yarn install --non-interactive --mutex file:$YARN_MUTEX
|
|
if [ $mode == "upgrade" ]; then
|
|
yarn upgrade --non-interactive --mutex file:$YARN_MUTEX
|
|
fi
|
|
yarn run compile --non-interactive
|
|
}
|
|
|
|
build() {
|
|
echo "build" "$@"
|
|
set -ev
|
|
app=$1
|
|
cd ui/$app
|
|
yarn install --non-interactive --mutex file:$YARN_MUTEX
|
|
if [ $mode == "upgrade" ]; then
|
|
yarn upgrade --non-interactive --mutex file:$YARN_MUTEX
|
|
fi
|
|
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
|