forked from Qortal/qortal-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·106 lines (92 loc) · 2.32 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
declare -a YARN_PACKAGE_DEPS=("qortal-ui-core" "qortal-ui-plugins" "qortal-ui-crypto")
YARN_LINK_DIR="${HOME}/.config/yarn/link"
SHOW_HELP=0
FORCE_LINK=0
YARN_WATCH=0
RUN_SERVER=0
RUN_ELECTRON=0
while [ -n "$*" ]; do
case $1 in
-h)
# Show help
SHOW_HELP=1
;;
-f)
# Force relink and reinstall dependencies
FORCE_LINK=1
;;
-w)
# Use "yarn watch" instead of "yarn build", to enable hot swapping
YARN_WATCH=1
;;
-s)
# Run server after building
RUN_SERVER=1
;;
-e)
# Run electron after building
RUN_ELECTRON=1
;;
esac
shift
done
if [ "${SHOW_HELP}" -eq 1 ]; then
echo
echo "Usage:"
echo "build.sh [-h] [-f] [-s] [-e]"
echo
echo "-h: show help"
echo "-f: force relink and reinstall dependencies"
echo "-w: use 'yarn watch' instead of 'yarn build', to enable hot swapping"
echo "-s: run UI server after completing the build"
echo "-e: run electron server after completing the build"
echo
exit
fi
echo "Checking dependencies..."
for PACKAGE in "${YARN_PACKAGE_DEPS[@]}"; do
if [ "${FORCE_LINK}" -eq 1 ]; then
echo "Unlinking ${PACKAGE}..."
yarn --cwd "${PACKAGE}" unlink "${PACKAGE}"
yarn --cwd "${PACKAGE}" unlink
fi
if [ ! -d "${YARN_LINK_DIR}/${PACKAGE}" ]; then
echo "Installing and linking ${PACKAGE}..."
yarn --cwd "${PACKAGE}" install
yarn --cwd "${PACKAGE}" link
yarn link "${PACKAGE}"
else
echo "${PACKAGE} is already linked."
fi
done
WATCH_PID=$(cat "watch.pid" || echo "")
if [ ! -z "${WATCH_PID}" ]; then
echo "Stopping existing watch process..."
kill "${WATCH_PID}"
rm -f "watch.pid"
fi
if [ "${YARN_WATCH}" -eq 1 ]; then
echo "Building qortal-ui in watch mode..."
yarn run watch &
echo "$!" > "watch.pid";
else
yarn run build
fi
if [ "${RUN_SERVER}" -eq 1 ]; then
echo "Running UI server..."
trap : INT
yarn run server
elif [ "${RUN_ELECTRON}" -eq 1 ]; then
echo "Starting electron..."
trap : INT
yarn run start-electron
fi
WATCH_PID=$(cat "watch.pid" || echo "")
if [ ! -z "${WATCH_PID}" ]; then
echo "Stopping watch process..."
kill "${WATCH_PID}"
rm -f "watch.pid"
fi
# Catch-all to kill any remaining processes
pkill -P $$