-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·122 lines (98 loc) · 2.17 KB
/
install
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
115
116
117
118
119
120
121
122
#!/bin/bash
usage() {
echo "Usage: no parameters attempts to perform a fresh install"
echo " [-r] reinstall application." 1>&2;
echo " [-n] re/install dependencies." 1>&2;
echo " [-s] install/reset settings." 1>&2;
echo " [-g] keep git." 1>&2;
echo " [-h] show usage." 1>&2;
exit 1;
}
depsInstalled=false
settingsInstalled=false
verbose=false
keepGit=false
runDeps=false
runSettings=false
runFinalize=false
installDependencies() {
if [ "$depsInstalled" = false ]; then
echo " - Installing dependencies" >&2
depsInstalled=true
if [ -d node_modules ]; then
echo "Deleteing node_modules"
rm -rf node_modules >&2
fi
yarn install
fi
}
installSettings() {
if [ "$settingsInstalled" = false ]; then
echo " - Installing settings" >&2
settingsInstalled=true
if [ -f "src/settings.json" ]; then
rm "src/settings.json"
fi
cp src/default-settings.json src/settings.json
fi
}
finalize(){
if [ "$1" = false ]; then
rm -rf .git
fi
if [ -d docs ]; then
rm -rf docs
fi
if [ -f _config.yml ]; then
rm -f _config.yml
fi
touch .installed
}
while getopts ":ns :rg :h" opt; do
case "${opt}" in
r)
runDeps=true
runSettings=true
runFinalize=true
yarn run build
echo "Application reinstalled"
echo "yarn run watch to watch directory"
echo "yarn run dev and load http://localhost:8080"
;;
n)
runDeps=true
;;
s)
runSettings=true
;;
g)
keepGit=true
;;
h)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -f .installed ]; then
if [ $OPTIND -eq 1 ]; then
echo "Application already installed."
fi
if [ "$runDeps" = true ]; then
installDependencies
fi
if [ "$runSettings" = true ]; then
installSettings
fi
if [ "$runFinalize" = true ]; then
finalize "$keepGit"
fi
exit 0
fi
installDependencies
installSettings
finalize "$keepGit"
yarn run build
echo "Application installed."
echo "command: yarn run watch to watch directory"
echo "command: yarn run dev then load http://localhost:8080"