forked from garrettjwilke/ep_133_sample_tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·114 lines (103 loc) · 3.08 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
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
VERSION_NUMBER=$(cat .version_number)
write_version_number() {
sed "s/VERSION_NUMBER/$VERSION_NUMBER/g" data/.index.html.blank > data/index.html
sed "s/VERSION_NUMBER/$VERSION_NUMBER/g" .package.json.blank > package.json
temp_message "Version number changed to: $VERSION_NUMBER"
echo $VERSION_NUMBER > .version_number
}
message() {
MESSAGE_1=$1
MESSAGE_2=$2
echo ""
echo "-------------------"
echo "$MESSAGE_1"
echo "-------------------"
echo ""
if [ "$MESSAGE_2" == "" ]
then
return
fi
echo "$MESSAGE_2"
echo ""
}
change_version_number() {
OLD_NUMBER=$VERSION_NUMBER
clear
message "Input New Version Number" "Current Version Number: $VERSION_NUMBER"
echo "New Version Number: "
read NEW_NUMBER
if [ "$NEW_NUMBER" == "" ]
then
temp_message "No version number input."
version_number_check
return
else
temp_message "New Version Number: $NEW_NUMBER"
message "Write changes?" "Version will change from: $OLD_NUMBER to $NEW_NUMBER"
echo "Write changes to project? (y/N)"
read YESNO
case $YESNO in
y|Y|yes|Yes|YES) temp_message "Writing new version number to project.";VERSION_NUMBER=$NEW_NUMBER;write_version_number;;
n|N|no|No|NO) temp_message "skipping version number change";;
q|Q|quit|Quit|QUIT) temp_message "exiting.";exit;;
"") temp_message "skipping version number change";;
*) temp_message "invalid input.";change_version_number;;
esac
fi
}
temp_message() {
clear
echo "$1"
sleep 0.5
}
version_number_check() {
message "Change Version Number?" "Would you like to change the version number?"
echo "Input y/N: "
read YESNO
case $YESNO in
y|Y|yes|Yes|YES) change_version_number;;
n|N|no|No|NO) temp_message "skipping version number change";;
q|Q|quit|Quit|QUIT) temp_message "exiting.";exit;;
"") temp_message "skipping version number change";;
*) temp_message "invalid input.";version_number_check;;
esac
}
run_locally() {
npm update
npm start
}
RUN_LOCAL="false"
run_check() {
clear
message "Would you like to run locally?" "Run a local instance of the sample tool?"
echo "Yes or No (y/N)"
read YESNO
case $YESNO in
y|Y|yes|Yes|YES) temp_message "starting local instance.";RUN_LOCAL="true";;
n|N|no|No|NO) temp_message "Skipping Local instance.";RUN_LOCAL="false";;
q|Q|quit|Quit|QUIT) temp_message "exiting.";exit;;
"") temp_message "Skipping Local instance.";RUN_LOCAL="false";;
*) temp_message "invalid input.";run_check;;
esac
}
build_check() {
message "Would you like to build for this platform?" "This will generate a binary executable in the dist directory"
echo "Yes or No (y/N)"
read YESNO
case $YESNO in
y|Y|yes|Yes|YES) temp_message "building project to dist directory.";npm install;npm run package;;
n|N|no|No|NO) temp_message "exiting.";exit;;
q|Q|quit|Quit|QUIT) temp_message "exiting.";exit;;
"") temp_message "exiting.";exit;;
*) temp_message "invalid input.";build_check;;
esac
}
run_check
if [ "$RUN_LOCAL" == "true" ]
then
run_locally
else
version_number_check
build_check
fi