lila/ui/build

60 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash -ea
2014-12-24 14:28:48 -07:00
target=${1-dev}
2019-05-11 01:04:35 -06:00
mode=${2-build} # build | upgrade | css | js
2017-12-03 14:03:34 -07:00
echo "building ui modules with target=$target and mode=$mode"
2014-12-24 14:28:48 -07:00
echo "node: $(node --version)"
echo "yarn: $(yarn --version)"
cd "$(git rev-parse --show-toplevel)"
2019-12-06 03:50:42 -07:00
ls -l node_modules node_modules/@* ui/node_modules ui/*/node_modules | grep /yarn/link/ || true
2014-12-24 14:28:48 -07:00
mkdir -p public/compiled
apps1="common"
apps2="chess ceval game tree chat nvui"
apps3="site swiss msg chat cli challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul dasher speech palantir serviceWorker"
2017-12-03 14:03:34 -07:00
if [ $mode == "upgrade" ]; then
yarn upgrade --non-interactive
else
yarn install --non-interactive
fi
2017-11-30 08:37:17 -07:00
build() {
echo "### build" "$@" "###"
set -ev
2019-06-25 05:19:33 -06:00
if [[ $1 == "css" ]]; then
cd ui
gulp "css-$target"
else
cd ui/$1
yarn run $target
2019-06-25 05:19:33 -06:00
fi
}
2019-02-08 19:42:51 -07:00
2019-05-11 01:04:35 -06:00
if [ $mode != "upgrade" ] && [ $mode != "js" ]; then
apps3="css $apps3"
2019-04-16 02:27:54 -06:00
fi
2019-02-13 02:39:47 -07:00
2019-06-25 05:19:33 -06:00
if [ $mode == "css" ]; then
(build css)
else
2019-05-11 01:04:35 -06:00
if type -p parallel; then # parallel execution!
if [ -z "$P_OPTS" -a ! -e ~/.parallel/config ]; then
P_OPTS="-j+4 --halt 2"
2020-06-17 17:33:48 -06:00
[ -n "$GITHUB_WORKFLOW" ] || P_OPTS+=" --bar"
2019-05-11 01:04:35 -06:00
fi
set -x
parallel --gnu $P_OPTS build ::: $apps1
parallel --gnu $P_OPTS build ::: $apps2
parallel --gnu $P_OPTS build ::: $apps3
2019-05-11 01:04:35 -06:00
else # sequential execution
echo "For faster builds, install GNU parallel."
for app in $apps1 $apps2 $apps3; do (build $app); done
fi
fi