-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
262 lines (248 loc) · 6.75 KB
/
run
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/usr/bin/bash
helpText="
Usage: . run COMMAND
Some shortcuts for project management.
Installation
setup pipenv and npm installation.
Git commands
gitp git push origin --all command.
gitpbase git push base_github base_project.
PugJs commands:
pug <app> pug translation command.
Django commands:
app <app> django startapp command.
NPM commands:
ni <library> npm i -D command.
nu <library> npm uninstall command.
ndev npm run dev command.
nbuild npm run build command.
nlint npm run lint command.
ntest npm run test command.
Pipenv commands:
i <library> pipenv install command.
idev <library> pipenv install --dev command.
u <library> pipenv uninstall command.
Docker commands:
clean clean your docker.
UP build and start the services.
up only start the services.
build only build the services.
rmvolumes remove the docker volumes.
djbash docker django shell command.
restart <service> restart the service.
djtest run the django tests.
djselenium run the selenium tests.
repop migrate and populate the database.
otp get an otp static token, for admin.
"
if [[ $1 == "LC_ALL=C.UTF-8" ]] || [[ $# -eq 0 ]]
then
echo "${helpText}"
fi
DOCKERFILES='-f services/docker-compose.yml -f services/docker-compose.dev.yml'
PARAMS=""
while (( "$#" )); do
case "$1" in
#
# -- Installation --
#
# Install pipenv and npm.
setup)
shift 1
cd services/django/project
pipenv install && npm install
cd ../../../
;;
#
# -- GIT --
#
# Git push origin --all command.
gitp)
shift 1
git push origin --all
;;
# Git push base_github base_project command.
gitpbase)
shift 1
git push base_github base_project
;;
#
# -- PUG --
#
# Pug translation command.
pug)
APP=$2
shift 2
cd services/django/project
pug $APP
cd ../../../
;;
#
# -- Django --
#
# Django startapp command.
app)
APP=$2
shift 2
cd services/django/project
pipenv run python manage.py startapp $APP
cd ../../../
;;
#
# -- NPM --
#
# npm run build command.
nbuild)
shift 1
cd services/django/project
npm run build
cd ../../../
;;
# npm run dev command.
ndev)
shift 1
cd services/django/project
npm run dev
cd ../../../
;;
# npm install --dev command.
ni)
LIBRARY=$2
shift 2
cd services/django/project
npm i -D $LIBRARY
cd ../../../
;;
# npm run lint command.
nlint)
shift 1
cd services/django/project
npm run lint
cd ../../../
;;
# npm run test command.
ntest)
shift 1
cd services/django/project
npm run test
cd ../../../
;;
#
# -- PIPENV --
#
# Pipenv install
i)
LIBRARY=$2
shift 2
cd services/django/project
pipenv install $LIBRARY
cd ../../../
;;
# Pipenv install --dev
idev)
LIBRARY=$2
shift 2
cd services/django/project
pipenv install --dev $LIBRARY
cd ../../../
;;
# Pipenv uninstall.
u)
LIBRARY=$2
shift 2
cd services/django/project
pipenv uninstall $LIBRARY
cd ../../../
;;
#
# -- DOCKER --
#
# Build and start services.
UP)
shift 1
docker-compose $DOCKERFILES build
docker-compose $DOCKERFILES up --force-recreate
;;
# Start services.
up)
shift 1
docker-compose $DOCKERFILES up --force-recreate
;;
# Build services.
build)
shift 1
docker-compose $DOCKERFILES build
;;
# Clean docker.
clean)
shift 1
docker-compose $DOCKERFILES down
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker image prune -f
;;
# Remove volumes.
rmvolumes)
shift 1
docker-compose $DOCKERFILES down
docker volume rm $(docker volume ls -q)
;;
# Restart the service.
restart)
CONTAINER=$2
shift 2
docker-compose $DOCKERFILES restart $CONTAINER
;;
# Docker django shell command.
djbash)
shift 1
docker-compose $DOCKERFILES exec django bash
;;
# Run the django tests.
djtest)
shift 1
TEST='pipenv run python3 manage.py test --exclude-tag=selenium'
docker-compose $DOCKERFILES exec django bash -c "$TEST"
;;
# Run the selenium tests.
djselenium)
shift 1
TEST='pipenv run python3 manage.py test --tag=selenium'
docker-compose $DOCKERFILES exec django bash -c "$TEST"
;;
# Migrate and populate the db.
repop)
shift 1
MIGRATE='pipenv run python3 manage.py migrate'
POPULATE='pipenv run python3 manage.py setup_dev_db'
docker-compose $DOCKERFILES exec django bash -c "$MIGRATE && $POPULATE"
;;
# Get an otp static token.
otp)
shift 1
OTPKEY='pipenv run python3 manage.py addstatictoken admin'
docker-compose $DOCKERFILES exec django bash -c "$OTPKEY"
;;
#
#
# Help text.
--help | -h)
shift 1
echo "${helpText}"
;;
--) # end argument parsing
shift
break
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
# set positional arguments in their proper place
eval set -- "$PARAMS"