forked from edificeio/entcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-noDocker.sh
executable file
·159 lines (145 loc) · 4.16 KB
/
build-noDocker.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
#!/bin/bash
if [ ! -e node_modules ]
then
mkdir node_modules
fi
# options
SPRINGBOARD="recette"
MODULE=""
for i in "$@"
do
case $i in
-s=*|--springboard=*)
SPRINGBOARD="${i#*=}"
shift
;;
-m=*|--module=*)
MODULE="${i#*=}"
shift
;;
*)
;;
esac
done
if [ "$MODULE" = "" ]; then
GRADLE_OPTION=""
NODE_OPTION=""
else
GRADLE_OPTION=":$MODULE:"
NODE_OPTION="--module $MODULE"
fi
BRANCH_NAME=`echo $GIT_BRANCH | sed -e "s|origin/||g"`
if [ "$BRANCH_NAME" = "" ]; then
echo "[buildNode] Get branch name from git..."
BRANCH_NAME=`git branch | sed -n -e "s/^\* \(.*\)/\1/p"`
fi
if [ ! -z "$FRONT_TAG" ]; then
echo "[buildNode] Get tag name from jenkins param... $FRONT_TAG"
BRANCH_NAME="$FRONT_TAG"
fi
if [ "$BRANCH_NAME" = "" ]; then
echo "[buildNode] Branch name should not be empty!"
exit -1
fi
echo "======================"
echo "BRANCH_NAME = $BRANCH_NAME"
echo "======================"
clean () {
gradle clean
}
buildNode () {
if [ "$MODULE" = "" ] || [ ! "$MODULE" = "admin" ]; then
if [ "$BRANCH_NAME" = 'master' ] || [ "$BRANCH_NAME" = 'fix' ]; then
echo "[buildNode] Use entcore version from package.json ($BRANCH_NAME)"
case `uname -s` in
MINGW*)
npm install --no-bin-links && npm update ode-ts-client ode-ngjs-front && npm update entcore && node_modules/gulp/bin/gulp.js build $NODE_OPTION
;;
*)
npm install --legacy-peer-deps && npm update ode-ts-client ode-ngjs-front --legacy-peer-deps && npm update entcore--legacy-peer-deps && node_modules/gulp/bin/gulp.js build $NODE_OPTION --springboard=/home/node/$SPRINGBOARD
esac
else
echo "[buildNode] Use entcore tag $BRANCH_NAME"
case `uname -s` in
MINGW*)
npm install --no-bin-links && npm update ode-ts-client ode-ngjs-front && npm rm --no-save entcore && npm install --no-save entcore@$BRANCH_NAME && node_modules/gulp/bin/gulp.js build $NODE_OPTION
;;
*)
npm install --legacy-peer-deps && npm update ode-ts-client ode-ngjs-front --legacy-peer-deps && npm rm --no-save entcore --legacy-peer-deps && npm install --no-save entcore@$BRANCH_NAME --legacy-peer-deps && node_modules/gulp/bin/gulp.js build $NODE_OPTION --springboard=/home/node/$SPRINGBOARD
esac
fi
fi
}
buildAdminNode() {
if [ "$MODULE" = "" ] || [ "$MODULE" = "admin" ]; then
DEFAULT_PATH=$PWD
cd admin/src/main/ts
case `uname -s` in
MINGW*)
cd admin/src/main/ts
npm install --no-bin-links && npm rm --no-save ngx-ode-core ngx-ode-sijil ngx-ode-ui && npm install --no-save ngx-ode-core@$BRANCH_NAME ngx-ode-sijil@$BRANCH_NAME ngx-ode-ui@$BRANCH_NAME && npm run build-prod
;;
*)
npm install --legacy-peer-deps && npm rm --no-save ngx-ode-core ngx-ode-sijil ngx-ode-ui --legacy-peer-deps && npm install --no-save ngx-ode-core@$BRANCH_NAME ngx-ode-sijil@$BRANCH_NAME ngx-ode-ui@$BRANCH_NAME --legacy-peer-deps && npm run build-prod --legacy-peer-deps
esac
cd $DEFAULT_PATH
fi
}
buildGradle () {
gradle "$GRADLE_OPTION"shadowJar "$GRADLE_OPTION"install "$GRADLE_OPTION"publishToMavenLocal
}
localDep () {
for dep in ode-ts-client ode-ngjs-front ; do
if [ -e $PWD/../$dep ]; then
rm -rf $dep.tar $dep.tar.gz
mkdir $dep.tar && mkdir $dep.tar/dist \
&& cp -R $PWD/../$dep/dist $PWD/../$dep/package.json $dep.tar
tar cfzh $dep.tar.gz $dep.tar
npm install --no-save $dep.tar.gz
rm -rf $dep.tar $dep.tar.gz
fi
done
}
watch () {
node_modules/gulp/bin/gulp.js watch-$MODULE --springboard=$SPRINGBOARD
}
ngWatch () {
DEFAULT_PATH=$PWD
cd admin/src/main/ts
npm run start
cd $DEFAULT_PATH
}
for param in "$@"
do
case $param in
clean)
clean
;;
buildAdminNode)
buildAdminNode
;;
buildNode)
buildNode
;;
buildGradle)
buildGradle
;;
install)
buildNode && buildAdminNode && buildGradle
;;
localDep)
localDep
;;
watch)
watch
;;
ngWatch)
ngWatch
;;
*)
echo "Invalid argument : $param"
esac
if [ ! $? -eq 0 ]; then
exit 1
fi
done