-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·111 lines (100 loc) · 2.77 KB
/
deploy.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
#!/bin/bash
BOLD=$(tput bold)
RESET=$(tput sgr0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
echo "============================================================"
echo "${BOLD}${PWD##*/}${RESET}"
echo "============================================================"
#============================================================
# serve with hot reload at localhost:8020
#============================================================
npm_run_dev() {
while true; do
printf "\n"
read -p "${BOLD}${GREEN}npm run dev? (Y/n) ${RESET}" yn
case ${yn} in
[Yy]* ) cd docs && npm run dev && cd -; break;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
#============================================================
# build for production with minification
#============================================================
npm_run_build() {
while true; do
printf "\n"
read -p "${BOLD}${GREEN}npm run build? (Y/n) ${RESET}" yn
case ${yn} in
[Yy]* ) cd docs && npm run build && cd -; break;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
#============================================================
# git commit
#============================================================
git_commit() {
while true; do
printf "\n"
read -p "${BOLD}${GREEN}git commit? (Y/n) ${RESET}" yn
case ${yn} in
[Yy]* )
IFS= read -r -p "${BOLD}Enter commit message: ${RESET}" commitmsg
# if commitmsg empty
if [ -z "$commitmsg" ]
then
echo "${BOLD}${RED}Commit message is empty${RESET}"
commitmsg="Add files via upload"
fi
printf "\n"
git add .
git commit -m "$commitmsg"
break;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
#============================================================
# git push
#============================================================
git_push() {
while true; do
printf "\n"
read -p "${BOLD}${GREEN}git push? (Y/n) ${RESET}" yn
case ${yn} in
[Yy]* ) git push; break;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
#============================================================
# npm publish
#============================================================
npm_publish() {
while true; do
printf "\n"
read -p "${BOLD}${GREEN}npm publish? (Y/n) ${RESET}" yn
case ${yn} in
[Yy]* ) npm publish; break;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
#============================================================
# main
#============================================================
main() {
npm_run_dev
npm_run_build
git_commit
git_push
npm_publish
}
main