forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·81 lines (69 loc) · 2.62 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash -ea
target=${1-dev}
mode=${2-build} # build | upgrade | css | js
echo "building ui modules with target=$target and mode=$mode"
nodever="$(node --version)"
echo "node: $nodever"
echo "yarn: $(yarn --version)"
[[ "$nodever" =~ ^(v14\.1[3-9]\.[0-9]+)|(v1[5-8]\.[0-9]+\.[0-9]+)$ ]] || { echo "Node version >=14.13 and <=18 required. Found: $nodever"; exit 1; }
cd "$(git rev-parse --show-toplevel)"
mkdir -p public/compiled
apps1="common"
apps2="chess palantir"
apps3="ceval game tree chat nvui puz keyboardMove"
apps4="site swiss msg tutor cli challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul dasher serviceWorker dgt storm racer coordinateTrainer"
site_plugins="tvEmbed puzzleEmbed analyseEmbed user clas captcha expandText team forum account coachShow coachForm challengePage checkout plan login passwordComplexity tourForm teamBattleForm gameSearch userComplete infiniteScroll flatpickr appeal publicChats contact userGamesDownload tvGames ublog ublogForm speech"
other_plugins="round:nvui analyse:nvui analyse:studyTopicForm puzzle:nvui puzzle:dashboard puzzle:opening chart:ratingDistribution chart:ratingHistory chart:game mod:user mod:inquiry mod:search mod:games mod:activity mod:teamAdmin "
if [ $mode == "upgrade" ]; then
yarn upgrade --non-interactive
else
yarn install --non-interactive
fi
build() {
echo
echo "### ui/$@ ###"
set -ev
if [[ $1 == "css" ]]; then
cd ui
yarn run gulp "css-$target"
else
cd ui/$1
yarn run $target
fi
}
build_plugin() {
echo $1
module="$(cut -d':' -f1 <<<$1)"
plugin="$(cut -d':' -f2 <<<$1)"
echo "### ui/$module plugin $plugin ###"
set -ev
cd ui/$module
yarn run plugin-$target $plugin
}
build_site_plugin() {
build_plugin "site:$1"
}
if [ $mode != "upgrade" ] && [ $mode != "js" ]; then
apps4="css $apps4"
fi
if [ $mode == "css" ]; then
(build css)
else
if type -p parallel; then # parallel execution!
if [ -z "$P_OPTS" -a ! -e ~/.parallel/config ]; then
P_OPTS="-j+4 --halt 2"
fi
set -x
parallel --gnu $P_OPTS build ::: $apps1
parallel --gnu $P_OPTS build ::: $apps2
parallel --gnu $P_OPTS build ::: $apps3
parallel --gnu $P_OPTS build ::: $apps4
parallel --gnu $P_OPTS build_site_plugin ::: $site_plugins
parallel --gnu $P_OPTS build_plugin ::: $other_plugins
else # sequential execution
echo "For faster builds, install GNU parallel."
for app in $apps1 $apps2 $apps3 $apps4; do (build $app); done
for plugin in $site_plugins; do (build_site_plugin $plugin); done
for plugin in $other_plugins; do (build_plugin $plugin); done
fi
fi