-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
213 lines (159 loc) · 6.42 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
#VERSION := $(shell cat patzilla/version.py | awk '{ print $$3 }' | tr -d "'")
#$(error VERSION=$(VERSION))
$(eval venvpath := .venv2)
$(eval pip := $(venvpath)/bin/pip)
$(eval twine := $(venvpath)/bin/twine)
$(eval python := $(venvpath)/bin/python)
$(eval pserve := $(venvpath)/bin/pserve)
$(eval pytest := $(venvpath)/bin/pytest)
$(eval bumpversion := $(venvpath)/bin/bumpversion)
$(eval fab := $(venvpath)/bin/fab)
$(eval venv3path := .venv)
$(eval yarn := $(venv3path)/bin/yarn)
$(eval npx := $(venv3path)/bin/npx)
setup: setup-py
jswatch:
npx yarn watch
pywatch:
HUPPER_DEFAULT_MONITOR=hupper.watchdog.WatchdogFileMonitor $(pserve) --reload patzilla/config/development-local.ini
js:
# url cleaner
npx uglifyjs \
patzilla/navigator/templates/urlcleaner.js \
--mangle --compress \
> patzilla/navigator/templates/urlcleaner.min.js
-git diff --quiet --exit-code || git commit \
patzilla/navigator/templates/urlcleaner.min.js \
-uno --untracked-files=no \
--message='release: minify javascript resources'
js-release: js
@echo ------------------------------------------
@echo Bundling Javascript/CSS resources.
@echo This might take a while, please stay patient...
@echo ------------------------------------------
npx yarn release
sdist:
$(python) setup.py sdist
upload-legacy:
rsync -auv ./dist/PatZilla-* ${PATZILLA_HOST}:~/install/patzilla/
upload-pypi:
@echo ------------------------------------------
@echo Uploading Python package to PyPI.
@echo This might take a while, please stay patient...
@echo ------------------------------------------
$(eval filename := "dist/patzilla-*.tar.gz")
@echo Uploading '$(filename)' to PyPI
$(twine) upload --skip-existing $(filename)
# $(eval version := $(shell cat setup.py | grep "version='" | sed -rn "s/.*version='(.+?)'.*/\1/p"))
# $(eval filename := "dist/patzilla-$(version).tar.gz")
# Setup Python virtualenv.
setup-virtualenv:
@test -e $(python) || virtualenv --python=python2 $(venvpath)
setup-py: setup-virtualenv
$(pip) install --editable=.[test]
setup-test: setup-py
setup-deployment:
$(pip) install --requirement requirements-deploy.txt
setup-release:
$(pip) install --requirement requirements-release.txt
install: setup-deployment
@# make install target=patoffice version=0.29.0
$(fab) install:target=$(target),version=$(version)
#package-and-install: sdist upload install
bumpversion:
$(bumpversion) $(bump)
push:
git push && git push --tags
#release:
# $(MAKE) js && $(MAKE) bumpversion bump=$(bump) && $(MAKE) push
release: setup-release js-release bumpversion push sdist upload-pypi
install-nginx-auth:
fab upload_nginx_auth
test:
@$(pytest) $(options)
test-coverage:
@$(MAKE) test options="$(options) --cov --no-cov-on-fail --cov-report=term-missing --cov-report=xml"
test-parallel:
@$(pytest) $(options) --numprocesses=auto
# --all-modules
# --traverse-namespace
# --doctest-options=doctestencoding=utf-8,+ELLIPSIS,+NORMALIZE_WHITESPACE,+REPORT_UDIFF
# +REPORT_ONLY_FIRST_FAILURE
# --nocapture
# --nologcapture
nginx:
nginx -c `pwd`/nginx-auth/etc/nginx.conf -g "daemon off; error_log /dev/stdout info;"
nginx-start: nginx
mongodb:
mkdir -p ./var/lib/mongodb
docker run -it --rm --publish=27017:27017 --volume ${PWD}/var/lib/mongodb:/data/db mongo:5
mongodb-start: mongodb
mongodb-sip-export:
mkdir -p var/tmp/mongodb
mongoexport --db patzilla_development --collection sip_country > var/tmp/mongodb/sip_country.mongodb
mongoexport --db patzilla_development --collection sip_ipc_class > var/tmp/mongodb/sip_ipc_class.mongodb
mongoexport --db patzilla_development --collection sip_cpc_class > var/tmp/mongodb/sip_cpc_class.mongodb
mongodb-sip-import:
mongoimport --db patzilla_development --collection sip_country < var/tmp/mongodb/sip_country.mongodb
mongoimport --db patzilla_development --collection sip_ipc_class < var/tmp/mongodb/sip_ipc_class.mongodb
mongoimport --db patzilla_development --collection sip_cpc_class < var/tmp/mongodb/sip_cpc_class.mongodb
sloccount:
sloccount patzilla
sloccount patzilla-ui/{access,common,lib,navigator}
genlicenses:
$(pip) install third-party-license-file-generator
$(pip) freeze > /tmp/requirements.txt
$(python) -m third_party_license_file_generator \
--requirements-path /tmp/requirements.txt --python-path $(python) \
--permit-gpl --permit-commercial \
--output-file licenses-backend.txt
npx yarn licenses generate-disclaimer > licenses-frontend.txt
clear-cache:
mongo beaker --eval 'db.dropDatabase();'
docs-virtualenv:
$(eval venvpath := ".venv_sphinx")
@test -e $(venvpath)/bin/python || `command -v virtualenv` --python=`command -v python2` $(venvpath)
@$(venvpath)/bin/pip --quiet install --requirement requirements-docs.txt
docs-html: docs-virtualenv
$(eval venvpath := ".venv_sphinx")
touch docs/index.rst
export SPHINXBUILD="`pwd`/$(venvpath)/bin/sphinx-build"; cd docs; make html
docs-linkcheck: docs-virtualenv
$(eval venvpath := ".venv_sphinx")
export SPHINXBUILD="`pwd`/$(venvpath)/bin/sphinx-build"; cd docs; make linkcheck
pdf-EP666666:
/usr/local/bin/wkhtmltopdf \
--no-stop-slow-scripts --debug-javascript \
--print-media-type \
--page-size A4 --orientation portrait --viewport-size 1024 \
'http://localhost:6543/navigator?query=pn%3DEP666666&mode=print' var/tmp/patzilla-EP666666.pdf
# --zoom 0.8
pdf-mammut:
/usr/local/bin/wkhtmltopdf \
--no-stop-slow-scripts \
--print-media-type \
--page-size A4 --orientation portrait --viewport-size 1024 \
'http://localhost:6543/navigator?query=pa=mammut&mode=print' var/tmp/patzilla-mammut.pdf
# --debug-javascript \
# ==========================================
# ptrace.getkotori.org
# ==========================================
# Don't commit media assets (screenshots, etc.) to the repository.
# Instead, upload them to https://ptrace.getkotori.org/
ptrace_target := [email protected]:/srv/www/organizations/ip-tools/ptrace.ip-tools.org/htdocs/
ptrace_http := https://ptrace.ip-tools.org/
ptrace: check-ptrace-options
$(eval prefix := $(shell gdate --iso-8601))
$(eval name := $(shell basename $(source)))
$(eval id := $(prefix)_$(name))
@# debugging
@#echo "name: $(name)"
@#echo "id: $(id)"
@scp '$(source)' '$(ptrace_target)$(id)'
$(eval url := $(ptrace_http)$(id))
@echo "Access URL: $(url)"
check-ptrace-options:
@if test "$(source)" = ""; then \
echo "ERROR: 'source' not set"; \
exit 1; \
fi