-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (57 loc) · 1.27 KB
/
build.sh
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
usage() {
echo " [Vinki Build Scripts]"
echo "[Params] default='--all'"
echo
echo "--all build all project (frontend end backend)"
echo "--front build web files (including generate static go file system)"
echo "--back build go project"
}
if [[ $# == 0 ]];then
usage
exit 0
fi
REPO=$(cd $(dirname $0); pwd)
buildFrontend () {
cd "$REPO" || exit
rm -rf frontend/build
rm -f statik/statik.go
export CI=false
cd "$REPO"/frontend || exit
yarn install
echo "[INFO] yarn install finished"
yarn run build
echo "[INFO] yarn build finished"
if ! [ -x "$(command -v statik)" ]; then
export CGO_ENABLED=0
go get github.com/rakyll/statik
fi
cd "$REPO" || exit
statik -src=frontend/build/ -include="*.html,*.js,*.json,*.css,*.png,*.svg,*.ico,*.woff,*.woff2,*.txt" -f
echo "[INFO] static/statik.go generated"
echo "[SUCCESS] build frontend done"
}
buildBackend () {
cd "$REPO" || exit
echo "[INFO] go build -a -o vinki"
go build -a -o vinki
echo "[INFO] vinki binary generated"
echo "[SUCCESS] build backend done"
}
buildAll () {
buildFrontend
buildBackend
}
case $1 in
-a|--all)
buildAll
;;
-f | --front)
buildFrontend
;;
-b | --back)
buildBackend
;;
*)
usage
;;
esac