-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·83 lines (71 loc) · 1.64 KB
/
run.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
#! /bin/bash
action=$1
picoTtyPath=$2
needTty=$3
actionMap=("typegen" "build-mobile" "start-mobile" "bundle-mobile" "build-mcu" "flash-mcu" "shell-mcu", "start-mcu")
actionArgs=("" "" "" "" "" "[tty-path]" "[tty-path]" "[tty-path]")
if [ -z "$action" ]; then
echo "No action provided"
# print actionMap items to new line
for x in "${!actionMap[@]}"; do
echo " > run ${actionMap[$x]} ${actionArgs[$x]}"
done
exit 1
fi
typegen() {
echo "Generating types..."
npm run typegen
}
buildMobileApp() {
echo "Building mobile app..."
npm run build:app
}
startMobileApp() {
echo "Starting mobile app..."
npm run start:app
}
bundleMobileApp() {
echo "Bundling mobile app..."
npm run bundle:app
}
buildMcuFirmware() {
echo "Building MCU firmware..."
typegen
npm run build:mcu
}
flashMcuFirmware() {
echo "Starting MCU firmware..."
npm run flash:mcu -- -p $picoTtyPath
}
shellMcuFirmware() {
echo "Connecting to MCU firmware..."
npm run shell:mcu -- -p $picoTtyPath
}
startMcuFirmware() {
buildMcuFirmware
flashMcuFirmware
if [ "$needTty" == "tty" ]; then
shellMcuFirmware
fi
}
if [ "$action" == "build-mobile" ]; then
buildMobileApp
elif [ "$action" == "start-mobile" ]; then
startMobileApp
elif [ "$action" == "bundle-mobile" ]; then
bundleMobileApp
elif [ "$action" == "build-mcu" ]; then
buildMcuFirmware
elif [ "$action" == "start-mcu" ]; then
startMcuFirmware
elif [ "$action" == "flash-mcu" ]; then
flashMcuFirmware
elif [ "$action" == "shell-mcu" ]; then
shellMcuFirmware
elif [ "$action" == "typegen" ]; then
typegen
else
echo "Invalid action"
echo "Valid actions: ${actionMap[@]}"
exit 1
fi