This repository has been archived by the owner on Dec 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·239 lines (156 loc) · 3.81 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/bin/bash
set -e
# Ensure that the CWD is set to script's location
cd "${0%/*}"
CWD=$(pwd)
## TASKS
install-doc-generators () {
cd $CWD
echo "Installing node modules... Requires Yarn"
yarn --ignore-engines > /dev/null
}
gen-server-docs () {
cd $CWD
echo "Generating server side code documentation... Requires Doxygen"
rm -rf src/wwwroot/docs/server
mkdir -p src/wwwroot/docs/server
doxygen Doxyfile > /dev/null
mv src/wwwroot/docs/server/html/* src/wwwroot/docs/server
}
gen-client-docs () {
cd $CWD
echo "Generating client side code documentation... Requires TypeDoc (Installed by Yarn)"
mkdir -p src/wwwroot/docs/client
$(yarn bin)/typedoc --logger none client/ts/ > /dev/null
printf "\n"
}
gen-api-docs () {
cd $CWD
echo "Generating API documentation... Requires Spectacle (Installed by Yarn)"
mkdir -p src/wwwroot/docs/api
$(yarn bin)/spectacle api.yml -t src/wwwroot/docs/api > /dev/null
}
install-client-libs () {
cd $CWD/client
echo "Installing front-end libraries... Requires Yarn"
yarn --ignore-engines > /dev/null
}
install-typings () {
cd $CWD
echo "Installing TypeScript typings... Requires Typings (Installed by Yarn)"
mkdir -p client/typings
$(yarn bin)/typings install > /dev/null
}
generate-client-bundle () {
cd $CWD
echo "Bundling front-end libraries... Requires Webpack (Installed by Yarn)"
rm -rf src/wwwroot/{js,css}/*
# KNOWN TEMPORARY ISSUE
$(yarn bin)/webpack --context client/ --env prod --config client/webpack.config.js --output-path src/wwwroot/js > /dev/null || true
mkdir -p src/wwwroot/css/
mv src/wwwroot/js/app.css src/wwwroot/css/
rm src/wwwroot/js/*.map
rm src/wwwroot/js/less.*
}
generate-ccs-libs () {
cd $CWD/client/lib/css
echo "Generating CSS libs... Requires Yarn"
rm -rf $CWD/src/wwwroot/lib/css/*
yarn --ignore-engines > /dev/null
mkdir -p $CWD/src/wwwroot/lib/css
cp -r node_modules/* $CWD/src/wwwroot/lib/css
}
generate-js-libs () {
cd $CWD/client/lib/js
echo "Generating JS libs..."
rm -rf $CWD/src/wwwroot/lib/js/*
mkdir -p $CWD/src/wwwroot/lib/js
cp -r ./* $CWD/src/wwwroot/lib/js
}
restore-dotnet () {
cd $CWD/src
echo "Restoring .NET dependencies... Requires .NET SDK"
dotnet restore > /dev/null
}
build-dotnet () {
cd $CWD/src
echo "Building and publishing .NET app... Requires .NET SDK"
dotnet publish -c release > /dev/null
}
build-dev-client () {
cd $CWD/client
echo "Cleaning dist/"
rm -rf dist/
echo "Copying source files"
mkdir -p dist/{ts,less}
cp -R ts/* dist/ts/
cp -R less/* dist/less/
echo "Bundling front-end libraries... Requires Webpack (Installed globally)"
webpack --env dev --display-error-details --output-path ./dist/ts
echo "Copying generated code"
mkdir -p ../src/wwwroot/js/ts
mkdir -p ../src/wwwroot/css
cp -R dist/ts/* ../src/wwwroot/js/ts/
cp dist/ts/app.css ../src/wwwroot/css/app.css
echo "Removing temporary directory"
rm -rf dist/
echo "Done!"
}
## APP BUILDERS
build-app-parallel () {
install-doc-generators &
install-client-libs &
restore-dotnet &
gen-server-docs &
generate-ccs-libs &
generate-js-libs &
wait %install-doc-generators
gen-client-docs &
gen-api-docs &
wait %install-client-libs
install-typings &
wait %install-typings
generate-client-bundle &
wait
build-dotnet
echo "Build completed!"
}
build-app-sequential () {
install-doc-generators
install-client-libs
gen-server-docs
gen-client-docs
gen-api-docs
install-typings
generate-client-bundle
generate-ccs-libs
generate-js-libs
restore-dotnet
build-dotnet
echo "Build completed!"
}
usage () {
echo "Usage: $0 [-d -f <string>]" 1>&2
}
while getopts "f:d" o; do
case "${o}" in
f)
eval $OPTARG
exit 0
;;
d)
build-dev-client
exit 0
;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
build-app-sequential