forked from cables-gl/cables_dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_repos.sh
executable file
·226 lines (208 loc) · 6.14 KB
/
update_repos.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
#!/bin/bash -l
#
# updates all repositories and merge develop
#
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
branch=`git rev-parse --abbrev-ref HEAD`
git fetch || true
reslog=$(git log HEAD..origin/${branch} --oneline)
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull
fi
ls ~/.nvm/nvm.sh > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo -e "LOADING NODEJS VERSION" `cat .nvmrc`
. ~/.nvm/nvm.sh
nvm install `cat .nvmrc`
nvm use `cat .nvmrc`
nvm use
nvm alias --no-colors default `cat .nvmrc`
else
echo -e "NVM NOT FOUND, RUNNING NODEJS WITH VERSION" `node --version` ", WANTED" `cat .nvmrc`;
fi
set -e
set -o pipefail
echo -e ""
echo -e "${GREEN}UPDATING DEV...${NC}"
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
npm install --no-save
else
echo -e "no changes in git, skipping update"
fi
echo -e ""
echo -e "${GREEN}UPDATING SHARED...${NC}"
cd shared
if [ -n "${1}" ] && ! [[ "${1}" =~ ^(clean|force)$ ]]; then
git checkout "${1}"
fi
# get current branch
branch=`git rev-parse --abbrev-ref HEAD`
# ignore errors here, since branch might not be on remote
git fetch || true
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull origin "$branch" || true
# merge current remote develop if branch is not master
if [ "master" != "${branch}" ]; then
echo -e "merging current state of origin/develop into ${branch}";
git merge origin/develop;
else
echo -e "{$RED}not merging origin/develop into master!${NC}"
fi
if [ "clean" == "${1}" ]; then
rm -rf node_modules/
fi
npm install --no-save
npm run build
else
echo -e "no changes in git, skipping update"
fi
cd "$BASEDIR"
echo -e ""
echo -e "${GREEN}UPDATING CORE...${NC}"
cd cables
if [ -n "${1}" ] && ! [[ "${1}" =~ ^(clean|force)$ ]]; then
git checkout "${1}"
fi
# get current branch
branch=`git rev-parse --abbrev-ref HEAD`
# ignore errors here, since branch might not be on remote
git fetch || true
reslog=$(git log HEAD..origin/${branch} --oneline)
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull origin "$branch" || true
# merge current remote develop if branch is not master
if [ "master" != "${branch}" ]; then
echo -e "merging current state of origin/develop into ${branch}";
git merge origin/develop;
else
echo -e "{$RED}not merging origin/develop into master!${NC}"
fi
if [ "clean" == "${1}" ]; then
rm -rf node_modules/
fi
npm install --no-save
else
echo -e "no changes in git, skipping update"
fi
cd "$BASEDIR"
if [ -d cables_api ]; then
if [ -f cables_api/package.json ]; then
echo -e ""
echo -e "${GREEN}UPDATING API...${NC}"
cd cables_api
if [ -n "${1}" ] && ! [[ "${1}" =~ ^(clean|force)$ ]]; then
git checkout "${1}"
fi
# get current branch
branch=`git rev-parse --abbrev-ref HEAD`
# ignore errors here, since branch might not be on remote
git fetch || true
reslog=$(git log HEAD..origin/${branch} --oneline)
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull origin "$branch" || true
# merge current remote develop if branch is not master
if [ "master" != "${branch}" ]; then
echo -e "merging current state of origin/develop into ${branch}";
git merge origin/develop;
else
echo -e "{$RED}not merging origin/develop into master!${NC}"
fi
if [ "clean" == "${1}" ]; then
rm -rf node_modules/
fi
npm install --no-save
else
echo -e "no changes in git, skipping update"
fi
fi
fi
cd "$BASEDIR"
echo -e ""
echo -e "${GREEN}UPDATING UI...${NC}"
cd cables_ui
if [ -n "${1}" ] && ! [[ "${1}" =~ ^(clean|force)$ ]]; then
git checkout "${1}"
fi
# get current branch
branch=`git rev-parse --abbrev-ref HEAD`
# ignore errors here, since branch might not be on remote
git fetch || true
reslog=$(git log HEAD..origin/${branch} --oneline)
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull origin "${branch}" || true
# merge current remote develop if branch is not master
if [ "master" != "${branch}" ]; then
echo -e "merging current state of origin/develop into ${branch}";
git merge origin/develop;
else
echo -e "{$RED}not merging origin/develop into master!${NC}"
fi
if [ "clean" == "${1}" ]; then
rm -rf node_modules/
fi
npm install --no-save
else
echo -e "no changes in git, skipping update"
fi
cd "$BASEDIR"
if [ -d cables_electron ]; then
echo -e ""
echo -e "${GREEN}UPDATING ELECTRON...${NC}"
cd cables_electron
if [ -n "${1}" ] && ! [[ "${1}" =~ ^(clean|force)$ ]]; then
git checkout "${1}"
fi
# get current branch
branch=`git rev-parse --abbrev-ref HEAD`
# ignore errors here, since branch might not be on remote
git fetch || true
reslog=$(git log HEAD..origin/${branch} --oneline)
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull origin "${branch}" || true
# merge current remote develop if branch is not master
if [ "master" != "${branch}" ]; then
echo -e "merging current state of origin/develop into ${branch}";
git merge origin/develop;
else
echo -e "{$RED}not merging origin/develop into master!${NC}"
fi
if [ "clean" == "${1}" ]; then
rm -rf node_modules/
fi
npm install --no-save
else
echo -e "no changes in git, skipping update"
fi
fi
cd "$BASEDIR"
echo -e ""
echo -e "${GREEN}UPDATING EXTENSIONS...${NC}"
OPSDIR=cables/src/ops/extensions/
if [ -d "$OPSDIR" ]; then
cd $OPSDIR
if [ -d ".git" ]; then
git fetch || true
if [ -n "${1}" ] && ! [[ "${1}" =~ ^(clean|force)$ ]]; then
git checkout "${1}"
fi
branch=`git rev-parse --abbrev-ref HEAD`
reslog=$(git log HEAD..origin/${branch} --oneline)
if [[ "${reslog}" != "" || "force" = "${1}" ]] ; then
git pull
else
echo -e "no changes in git, skipping update"
fi
else
echo -e "{$RED} NOT A GIT REPO AT $OPSDIR, SKIPPING${NC}";
fi
else
echo -e "{$RED}DIR NOT FOUND AT $OPSDIR, SKIPPING${NC}";
fi
cd "$BASEDIR"
echo -e ""
echo -e "${GREEN}DONE${NC}"