-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathctl.sh
executable file
·49 lines (40 loc) · 1.04 KB
/
ctl.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
#!/usr/bin/env bash
# Actions
serve=0
build=0
deploy=0
help=0
while [[ "$#" -gt 0 ]]; do
case "$1" in
--serve) serve=1 ;;
--build) build=1 ;;
--deploy) build=1; deploy=1 ;;
-h|--help) help=1 ;;
--) shift; break ;;
esac
shift
done
if [[ $help == 1 ]] || [[ $serve == 1 && $build == 1 ]] || [[ $serve == 0 && $build == 0 ]]; then
echo "Usage: ./ctl.sh [--serve] [--build] [--help]"
echo ""
echo "--serve: Serve the app for local development on http://localhost:8000"
echo " JavaScript will be live transpiled"
echo "--build: Build the app for production"
echo "--deploy: Build and deploy to production"
echo "--help: Show this help text"
exit 0
fi
if [[ $serve == 1 ]]; then
# Transpile JS
npx swc src/js --out-dir src/build/ --watch &
# Serve
echo "Starting server at http://localhost:8000"
cd src
python3 -m http.server
fi
if [[ $build == 1 ]]; then
npx swc src/js --out-dir src/build/
fi
if [[ $deploy == 1 ]]; then
scp -r src/* web:/var/www/wordle.danstewart.xyz
fi