-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-web.sh
executable file
·74 lines (63 loc) · 1.55 KB
/
build-web.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
#!/usr/bin/env bash
readonly VER="v0.2.0"
function version() {
echo $VER
}
function Help() {
# Displays Help
echo "Builds the web version & prepares it for deployment."
echo
echo "Syntax: ./build-web.sh [-h|v|b|s|p]"
echo
echo "Options:"
echo " -h, Print command line options."
echo " -v Print software version and exit."
echo " -b Create build for web target."
echo " -s Serve the build (for testing)."
echo " -p Build->Add->Commit to PROD."
echo
}
function build() {
# builds the prod ready PWA
expo export:web # npx expo export:web
}
function adjust_subfolder() {
# creates proper subfolder for serving
mkdir -p web
mv web-build/* ./web
mv web web-build
}
function start_server() {
# serves the build right away
cd web-build && python3 -m http.server
}
function move_to_prod() {
cd ../Promin-App-Website
git rm -r ./web
cd -
mv web-build/web ../Promin-App-Website
rm -rf web-build
}
function create_build() {
build && adjust_subfolder
}
function prod() {
build && adjust_subfolder && move_to_prod
cd ../Promin-App-Website
git add .
git commit -m "Updated static for the WEB target"
}
while getopts ":hvbsp" flag
do
case $flag in
h) Help && exit;;
v) version && exit;;
b) create_build && exit;;
s) start_server && exit;;
p) prod && exit;;
?) # Invalid option
echo "[Error]: Invalid option"
exit 1;;
esac
done
Help && exit;