forked from HybirdCorp/creme_crm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
362 lines (307 loc) · 11.4 KB
/
Makefile
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!make
# Load dotenv file if exists
-include .env
SHELL := /bin/bash
.DEFAULT_GOAL := help
MAKE_NPROCS ?= $(shell nproc)
CREME_LANGUAGE ?= fr
PORT ?= 8000
## clean - Basic cleanup, mostly temporary files.
.PHONY: clean
clean:
find . -name '*.pyc' -delete
find . -name '*.pyo' -delete
find . -name '__pycache__' -delete
rm -rf *.egg
rm -rf ./build
rm -rf ./package
rm -rf ./dist
rm -rf ./package
rm -rf ./.coverage
rm -rf ./htmlcov
rm -rf ./.pytest_cache
rm -rf ./.hypothesis
rm -rf ./artifacts
find . -type d -empty -print -delete
## Upgrade the Python development requirements
## .PHONY: install-dev
## install-dev:
## pip install --upgrade -e .[dev,mysql,pgsql,graphs]
## Upgrade the Python requirements, run the migrations, the creme_populate and generatemedia commands
## .PHONY: update
## update: install-dev
## creme migrate
## creme creme_populate
## creme generatemedia
## Install or upgrade nodejs requirements
.PHONY: node-update
node-update:
npm install --no-save
npm run eslint-install
## Generate the media files
## The package django-extensions is required and can be installed with "make install-dev")
__media:
ifeq (${DJANGO_SETTINGS_MODULE},)
$(error DJANGO_SETTINGS_MODULE is not defined. Hint: Set it with the settings module path (e.g. 'my_project.settings') in the shell or '.env' file)
endif
$(eval CREME_MEDIA ?= $(shell creme print_settings --settings=${DJANGO_SETTINGS_MODULE} --skip-checks --no-color STATIC_ROOT --format value))
creme generatemedia --settings=${DJANGO_SETTINGS_MODULE}
## Run the Django test suite
## .PHONY: test
## test:
## creme test --keepdb --noinput \
## \
## --parallel=${MAKE_NPROCS} \
## $(filter-out $@,$(MAKECMDGOALS))
## Run the Django test suite and generate coverage reports
## .PHONY: test-cov
## test-cov:
## $(eval targets := $(filter-out $@,$(MAKECMDGOALS)))
##
## COVERAGE_PROCESS_START=setup.cfg \
## coverage run --source creme/ creme/manage.py test --noinput --keepdb \
## \
## --parallel=${MAKE_NPROCS} \
## ${targets}
##
## @if [ "$(targets)" ]; then\
## coverage combine -a;\
## else \
## coverage combine;\
## fi
##
## coverage report
## coverage html
## @echo "file://$(shell pwd)/artifacts/coverage_html/index.html"
## Cleanup karma coverage html output
.PHONY: karma-clean
karma-clean:
rm -f artifacts/karma_coverage/html/static/*.html
rm -f artifacts/karma_coverage/html/*.html
## Run the Javascript test suite
.PHONY: karma
karma: __media karma-clean
KARMA_DJANGOSTATICS=${CREME_MEDIA} \
node_modules/.bin/karma start .karma.conf.js \
--browsers=FirefoxHeadless \
--targets=$(filter-out $@,$(MAKECMDGOALS))
@echo "file://$(shell pwd)/artifacts/karma_coverage/html/index.html"
karma-browsers: __media karma-clean
CHROME_BIN=/usr/bin/google-chrome \
KARMA_DJANGOSTATICS=${CREME_MEDIA} \
node_modules/.bin/karma start .karma.conf.js \
--browsers=FirefoxHeadless,ChromiumHeadless,ChromeHeadless \
--concurrency 3\
--targets=$(filter-out $@,$(MAKECMDGOALS))
@echo "file://$(shell pwd)/artifacts/karma_coverage/html/index.html"
## Run the Javascript test suite in CI (generatemedia is supposed to be already done)
## .PHONY: karma-ci
## karma-ci:
## node_modules/.bin/karma start .circleci/.karma.conf.js --targets=$(filter-out $@,$(MAKECMDGOALS))
## Run the application
.PHONY: serve
serve: __media
creme runserver ${PORT}
## Run the jobs
## .PHONY: serve-jobs
## serve-jobs:
## creme creme_job_manager
## Run shell
## .PHONY: shell
## shell:
## creme shell_plus
## Run the Javascript linters
.PHONY: eslint-diff
eslint-diff:
git diff --name-only --diff-filter=MARC origin/main creme/ | { grep -E '.js$$' || true; } | xargs --no-run-if-empty \
node_modules/.bin/eslint \
--config .eslintrc \
--ignore-path .eslintignore \
--format stylish \
--quiet
git diff --name-only --diff-filter=MARC origin/main creme/ | { grep -E '.html$$' || true; } | xargs --no-run-if-empty \
node_modules/.bin/eslint \
--config .eslintrc \
--ignore-path .eslintignore \
--plugin template \
--rule 'template/no-template-branch: 2' \
--global '____' \
--format stylish \
--quiet
.PHONY: eslint
eslint:
$(eval targets := $(or $(filter-out $@,$(MAKECMDGOALS)),creme/))
find ${targets} -iname *.js | xargs --no-run-if-empty \
node_modules/.bin/eslint \
--config .eslintrc \
--ignore-path .eslintignore \
--format stylish \
--quiet
find ${targets} -iname *.html | xargs --no-run-if-empty \
node_modules/.bin/eslint \
--config .eslintrc \
--ignore-path .eslintignore \
--plugin template \
--rule 'template/no-template-branch: 2' \
--global '____' \
--format stylish \
--quiet
## Validates the Python imports with isort
.PHONY: isort-check
isort-check:
isort creme/ --check --diff --atomic
## Sort the Python imports with isort
.PHONY: isort-fix
isort-fix:
isort creme/ --atomic
## Validates the Python code with flake8
.PHONY: flake8
flake8:
flake8 creme
## Run all the Python linter checks
.PHONY: lint
lint: isort-check flake8
## Run all the Python linter fixes
.PHONY: format
format: isort-fix
## Collect the messages to translate for the entire project or the given app directories
.PHONY: gettext-collect
gettext-collect:
$(eval appdirs := $(filter-out $@,$(MAKECMDGOALS)))
@# TODO : This is a hack before the deployment of better gettext collection tools like pybabel
@if [ "$(appdirs)" ]; then\
for appdir in ${appdirs}; do (\
pushd $${appdir} > /dev/null && \
echo "Building messages $$(pwd)..." && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" -i "tests.py" -e "html,txt,py,xml" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "*/js/tests/*" -e js --no-location && \
popd > /dev/null \
); done; \
else \
pushd ./creme/products && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/opportunities && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/mobile && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/reports && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/reports/js/tests/*" --no-location && \
popd; \
pushd ./creme/creme_core && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" -i "templates/creme_core/tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/creme_core/js/tests/*" --no-location && \
popd; \
pushd ./creme/sms && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/events && \
django-admin makemessages -l ${CREME_LANGUAGE} -i tests.py --no-location && \
popd; \
pushd ./creme/projects && \
django-admin makemessages -l ${CREME_LANGUAGE} -i tests.py --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/projects/js/tests/*" --no-location && \
popd; \
pushd ./creme/crudity && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" -e py -e html --no-location && \
popd; \
pushd ./creme/emails && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/emails/js/tests/*" --no-location && \
popd; \
pushd ./creme/tickets && \
django-admin makemessages -l ${CREME_LANGUAGE} -i tests.py --no-location && \
popd; \
pushd ./creme/commercial && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme && \
django-admin makemessages -l ${CREME_LANGUAGE} --no-location -i "activities/*" -i "assistants/*" -i "billing/*" -i "commercial/*" -i "creme_config/*" -i "creme_core/*" -i "crudity/*" -i "cti/*" -i "documents/*" -i "emails/*" -i "events/*" -i "geolocation/*" -i "graphs/*" -i "mobile/*" -i "opportunities/*" -i "persons/*" -i "polls/*" -i "products/*" -i "projects/*" -i "recurrents/*" -i "reports/*" -i "sms/*" -i "static/*" -i "tickets/*" -i "vcfs/*" && \
popd; \
pushd ./creme/graphs && \
django-admin makemessages -l ${CREME_LANGUAGE} -i tests.py --no-location && \
popd; \
pushd ./creme/polls && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/assistants && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/activities && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/activities/js/tests/*" --no-location && \
popd; \
pushd ./creme/creme_config && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/creme_config/js/tests/*" --no-location && \
popd; \
pushd ./creme/vcfs && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/recurrents && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/documents && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
popd; \
pushd ./creme/cti && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests.py" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/cti/js/tests/*" --no-location && \
popd; \
pushd ./creme/persons && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/persons/js/tests/*" --no-location && \
popd; \
pushd ./creme/geolocation && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} -i "static/geolocation/js/tests/*" --no-location && \
popd; \
pushd ./creme/billing && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} --no-location && \
popd; \
pushd ./creme/sketch && \
django-admin makemessages -l ${CREME_LANGUAGE} -i "tests/*" --no-location && \
django-admin makemessages -d djangojs -l ${CREME_LANGUAGE} --no-location && \
popd; \
fi
## Compile the translation files
.PHONY: gettext-compile
gettext-compile:
django-admin compilemessages -l ${CREME_LANGUAGE}
## Print this message
.PHONY: help
help:
@printf "Usage\n";
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)