Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
401 lines (349 loc) · 16 KB
/
Copy pathMakefile
File metadata and controls
401 lines (349 loc) · 16 KB
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# Makefile for copying files downloaded using composer
# into the proper location for use with WebCalendar.
# We only copy the min number of files required from the vendor directory.
# Also, compute the SHA hash to use with the integrity tag.
# We don't want WebCalendar releases to bundle
# every single file in the vendor directory.
#
# Also, composer dependency management sucks at asset management.
#
# NOTE: This Makefile does not work on macos, just linux.
# This is because there is no sha384sum command on macos.
# If you're on a Mac, you can use docker to setup
# a linux container where (after installing xdd),
# you can run make to generate the sha files.
PHPMAILER_DIR = includes/classes/phpmailer
PHPMAILER_VENDOR_DIR = vendor/phpmailer/phpmailer/src
BOOTSTRAP_ICON_DIR = images/bootstrap-icons
BOOTSTRAP_ICON_VENDOR_DIR = vendor/twbs/bootstrap-icons/icons
TINYMCE_VENDOR_DIR = vendor/tinymce
SHA384SUM = /usr/bin/sha384sum
_DEFAULT: _phpmailer includes/load_assets.php \
_ICONS pub/tinymce/CHANGELOG.md mcp-sdk
# The MCP SDK and its dependencies ship in includes/classes/mcp-sdk/ so the
# release zip and the Docker image can run the MCP server without Composer.
# Rerun after `composer update mcp/sdk`; tests/McpSdkBundleTest.php fails
# until the committed bundle matches composer.lock and vendor/.
.PHONY: mcp-sdk
mcp-sdk:
php tools/build-mcp-sdk.php
_phpmailer: $(PHPMAILER_DIR)/PHPMailer.php \
$(PHPMAILER_DIR)/Exception.php \
$(PHPMAILER_DIR)/OAuth.php \
$(PHPMAILER_DIR)/POP3.php \
$(PHPMAILER_DIR)/SMTP.php
$(PHPMAILER_DIR)/PHPMailer.php: $(PHPMAILER_VENDOR_DIR)/PHPMailer.php
cp $< $@
$(PHPMAILER_DIR)/Exception.php: $(PHPMAILER_VENDOR_DIR)/Exception.php
cp $< $@
$(PHPMAILER_DIR)/OAuth.php: $(PHPMAILER_VENDOR_DIR)/OAuth.php
cp $< $@
$(PHPMAILER_DIR)/POP3.php: $(PHPMAILER_VENDOR_DIR)/POP3.php
cp $< $@
$(PHPMAILER_DIR)/SMTP.php: $(PHPMAILER_VENDOR_DIR)/SMTP.php
cp $< $@
_ICONS: \
$(BOOTSTRAP_ICON_DIR)/printer.svg \
$(BOOTSTRAP_ICON_DIR)/search.svg \
$(BOOTSTRAP_ICON_DIR)/arrow-left.svg \
$(BOOTSTRAP_ICON_DIR)/arrow-right-circle.svg \
$(BOOTSTRAP_ICON_DIR)/arrow-left-circle.svg \
$(BOOTSTRAP_ICON_DIR)/arrow-up-short.svg \
$(BOOTSTRAP_ICON_DIR)/arrow-down-short.svg \
$(BOOTSTRAP_ICON_DIR)/plus-circle.svg \
$(BOOTSTRAP_ICON_DIR)/rss-fill.svg \
$(BOOTSTRAP_ICON_DIR)/circle-fill.svg \
$(BOOTSTRAP_ICON_DIR)/exclamation-triangle-fill.svg \
$(BOOTSTRAP_ICON_DIR)/question-circle-fill.svg \
$(BOOTSTRAP_ICON_DIR)/arrow-90deg-up.svg \
$(BOOTSTRAP_ICON_DIR)/dash-circle.svg \
$(BOOTSTRAP_ICON_DIR)/check-circle.svg \
$(BOOTSTRAP_ICON_DIR)/trash.svg \
$(BOOTSTRAP_ICON_DIR)/key-fill.svg \
$(BOOTSTRAP_ICON_DIR)/info-circle-fill.svg \
$(BOOTSTRAP_ICON_DIR)/circle.svg
$(BOOTSTRAP_ICON_DIR)/printer.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/printer.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/search.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/search.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/arrow-right-circle.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/arrow-right-circle.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/arrow-left.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/arrow-left.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/arrow-left-circle.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/arrow-left-circle.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/arrow-up-short.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/arrow-up-short.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/arrow-down-short.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/arrow-down-short.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/plus-circle.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/plus-circle.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/rss-fill.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/rss-fill.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/circle-fill.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/circle-fill.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/exclamation-triangle-fill.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/exclamation-triangle-fill.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/question-circle-fill.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/question-circle-fill.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/arrow-90deg-up.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/arrow-90deg-up.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/dash-circle.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/dash-circle.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/check-circle.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/check-circle.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/trash.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/trash.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/key-fill.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/key-fill.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/info-circle-fill.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/info-circle-fill.svg
cp $< $@
$(BOOTSTRAP_ICON_DIR)/circle.svg: $(BOOTSTRAP_ICON_VENDOR_DIR)/circle.svg
cp $< $@
includes/load_assets.php: \
pub/bootstrap.min.css \
pub/bootstrap.min.css.sha \
pub/bootstrap.bundle.min.js \
pub/bootstrap.bundle.min.js.sha \
pub/jquery.min.js \
pub/jquery.min.js.sha
echo '<?php' > $@
echo '// Auto-generated by make. Do not hand-edit.' >> $@
echo '// See Makefile in source for details..' >> $@
echo '// Last updated: ' | tr -d '\012' >> $@
date >> $@
echo "XASSETS =" | tr X '\044' >> $@
echo ' _<link rel="stylesheet" href="pub/bootstrap.min.css" integrity="sha384-' | tr -d '\012' | tr _ '\047' >> $@
cat pub/bootstrap.min.css.sha | tr -d '\012' >> $@
echo '">_ .' | tr _ '\047' >> $@
echo ' _<script src="pub/jquery.min.js" integrity="sha384-' | tr -d '\012' | tr _ '\047' >> $@
cat pub/jquery.min.js.sha | tr -d '\012' >> $@
echo '"></script>_ .' | tr _ '\047' >> $@
echo ' _<script src="pub/bootstrap.bundle.min.js" integrity="sha384-' | tr -d '\012' | tr _ '\047' >> $@
cat pub/bootstrap.bundle.min.js.sha | tr -d '\012' >> $@
echo '"></script>_ .' | tr _ '\047' >> $@
echo ' "\\n";' >> $@
echo '?>' >> $@
pub/bootstrap.min.css: vendor/twbs/bootstrap/dist/css/bootstrap.min.css
cp $< $@
pub/bootstrap.min.css.sha: pub/bootstrap.min.css $(SHA384SUM)
$(SHA384SUM) $< | head -c 96 | xxd -r -p | base64 > $@
pub/bootstrap.bundle.min.js: vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js
cp $< $@
pub/bootstrap.bundle.min.js.sha: pub/bootstrap.bundle.min.js $(SHA384SUM)
$(SHA384SUM) $< | head -c 96 | xxd -r -p | base64 > $@
pub/jquery.min.js: vendor/components/jquery/jquery.min.js
cp $< $@
pub/jquery.min.js.sha: pub/jquery.min.js $(SHA384SUM)
$(SHA384SUM) $< | head -c 96 | xxd -r -p | base64 > $@
# TINYMCE files
# NOTE: This Makefile is assuming that the 'CHANGELOG.md' file gets
# updated with each TinyMCE update (seems like a safe assumption)
TINYMCE_FILES = \
pub/tinymce/models/dom/model.js \
pub/tinymce/models/dom/model.min.js \
pub/tinymce/models/dom/index.js \
pub/tinymce/icons/default/icons.js \
pub/tinymce/icons/default/icons.min.js \
pub/tinymce/icons/default/index.js \
pub/tinymce/plugins/autoresize/plugin.min.js \
pub/tinymce/plugins/autoresize/plugin.js \
pub/tinymce/plugins/autoresize/index.js \
pub/tinymce/plugins/link/plugin.min.js \
pub/tinymce/plugins/link/plugin.js \
pub/tinymce/plugins/link/index.js \
pub/tinymce/plugins/advlist/plugin.min.js \
pub/tinymce/plugins/advlist/plugin.js \
pub/tinymce/plugins/advlist/index.js \
pub/tinymce/plugins/autolink/plugin.min.js \
pub/tinymce/plugins/autolink/plugin.js \
pub/tinymce/plugins/autolink/index.js \
pub/tinymce/plugins/code/plugin.min.js \
pub/tinymce/plugins/code/plugin.js \
pub/tinymce/plugins/code/index.js \
pub/tinymce/plugins/lists/plugin.min.js \
pub/tinymce/plugins/lists/plugin.js \
pub/tinymce/plugins/lists/index.js \
pub/tinymce/plugins/table/plugin.min.js \
pub/tinymce/plugins/table/plugin.js \
pub/tinymce/plugins/table/index.js \
pub/tinymce/skins/ui/oxide-dark/skin.shadowdom.js \
pub/tinymce/skins/ui/oxide-dark/content.inline.css \
pub/tinymce/skins/ui/oxide-dark/content.css \
pub/tinymce/skins/ui/oxide-dark/content.inline.js \
pub/tinymce/skins/ui/oxide-dark/content.min.css \
pub/tinymce/skins/ui/oxide-dark/content.js \
pub/tinymce/skins/ui/oxide-dark/skin.shadowdom.css \
pub/tinymce/skins/ui/oxide-dark/skin.min.css \
pub/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css \
pub/tinymce/skins/ui/oxide-dark/content.inline.min.css \
pub/tinymce/skins/ui/oxide-dark/skin.js \
pub/tinymce/skins/ui/oxide-dark/skin.css \
pub/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.js \
pub/tinymce/skins/ui/tinymce-5-dark/content.inline.css \
pub/tinymce/skins/ui/tinymce-5-dark/content.css \
pub/tinymce/skins/ui/tinymce-5-dark/content.inline.js \
pub/tinymce/skins/ui/tinymce-5-dark/content.min.css \
pub/tinymce/skins/ui/tinymce-5-dark/content.js \
pub/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.css \
pub/tinymce/skins/ui/tinymce-5-dark/skin.min.css \
pub/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.css \
pub/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css \
pub/tinymce/skins/ui/tinymce-5-dark/skin.js \
pub/tinymce/skins/ui/tinymce-5-dark/skin.css \
pub/tinymce/skins/ui/oxide/skin.shadowdom.js \
pub/tinymce/skins/ui/oxide/content.inline.css \
pub/tinymce/skins/ui/oxide/content.css \
pub/tinymce/skins/ui/oxide/content.inline.js \
pub/tinymce/skins/ui/oxide/content.min.css \
pub/tinymce/skins/ui/oxide/content.js \
pub/tinymce/skins/ui/oxide/skin.shadowdom.css \
pub/tinymce/skins/ui/oxide/skin.min.css \
pub/tinymce/skins/ui/oxide/skin.shadowdom.min.css \
pub/tinymce/skins/ui/oxide/content.inline.min.css \
pub/tinymce/skins/ui/oxide/skin.js \
pub/tinymce/skins/ui/oxide/skin.css \
pub/tinymce/skins/ui/tinymce-5/skin.shadowdom.js \
pub/tinymce/skins/ui/tinymce-5/content.inline.css \
pub/tinymce/skins/ui/tinymce-5/content.css \
pub/tinymce/skins/ui/tinymce-5/content.inline.js \
pub/tinymce/skins/ui/tinymce-5/content.min.css \
pub/tinymce/skins/ui/tinymce-5/content.js \
pub/tinymce/skins/ui/tinymce-5/skin.shadowdom.css \
pub/tinymce/skins/ui/tinymce-5/skin.min.css \
pub/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.css \
pub/tinymce/skins/ui/tinymce-5/content.inline.min.css \
pub/tinymce/skins/ui/tinymce-5/skin.js \
pub/tinymce/skins/ui/tinymce-5/skin.css \
pub/tinymce/skins/content/tinymce-5-dark/content.css \
pub/tinymce/skins/content/tinymce-5-dark/content.min.css \
pub/tinymce/skins/content/tinymce-5-dark/content.js \
pub/tinymce/skins/content/document/content.css \
pub/tinymce/skins/content/document/content.min.css \
pub/tinymce/skins/content/document/content.js \
pub/tinymce/skins/content/default/content.css \
pub/tinymce/skins/content/default/content.min.css \
pub/tinymce/skins/content/default/content.js \
pub/tinymce/skins/content/dark/content.css \
pub/tinymce/skins/content/dark/content.min.css \
pub/tinymce/skins/content/dark/content.js \
pub/tinymce/skins/content/writer/content.css \
pub/tinymce/skins/content/writer/content.min.css \
pub/tinymce/skins/content/writer/content.js \
pub/tinymce/skins/content/tinymce-5/content.css \
pub/tinymce/skins/content/tinymce-5/content.min.css \
pub/tinymce/skins/content/tinymce-5/content.js \
pub/tinymce/tinymce.min.js \
pub/tinymce/themes/silver/theme.min.js \
pub/tinymce/themes/silver/theme.js \
pub/tinymce/themes/silver/index.js
# TINYMCE
pub/tinymce/CHANGELOG.md: $(TINYMCE_VENDOR_DIR)/tinymce/CHANGELOG.md
(cd pub/tinymce; mkdir -p models models/dom icons icons/default plugins plugins/autoresize \
plugins/link plugins/advlist plugins/autolink plugins/code plugins/lists plugins/table \
skins skins/ui skins/ui/oxide-dark skins/ui/tinymce-5-dark skins/ui/oxide \
skins/ui/tinymce-5 skins/content skins/content/tinymce-5-dark skins/content/document \
skins/content/default skins/content/dark skins/content/writer skins/content/tinymce-5 \
themes themes/silver)
cp $(TINYMCE_VENDOR_DIR)/tinymce/CHANGELOG.md pub/tinymce/CHANGELOG.md
for f in $(TINYMCE_FILES); do\
a="$(TINYMCE_VENDOR_DIR)/"`echo $${f} | sed 's?pub/??'`; \
echo "Copying file: $${f}"; \
cp $${a} $${f}; \
done
# ---------------------------------------------------------------------------
# Quality gate. Runs what CI runs, in the order CI runs it, so a green `make
# check` predicts a green pipeline. Each step prints its own output and the
# first failure stops the target, giving a meaningful exit code.
#
# phpcs is deliberately absent. There is no phpcs.xml, and the codebase uses
# 2-space indentation rather than PSR-12, so an unconfigured run would emit
# thousands of complaints and the target would never pass. Adopting a standard
# for the legacy tree is its own piece of work.
# ---------------------------------------------------------------------------
# --- Disposable sandbox -------------------------------------------------
#
# A throwaway installation in a container, for trying anything that writes.
# This working copy is frequently also a live install, so the sandbox never
# touches it: the code is mounted read-only and the database settings come
# from the environment, which means do_config() ignores includes/settings.php
# entirely. See docker/docker-compose-sqlite-dev.yml for the details.
#
# make sandbox start it and install
# make sandbox-cli CMD="export --login=admin" run bin/webcal.php in it
# make sandbox-reset throw the data away, reinstall
# make sandbox-clean stop it and drop the volume
SANDBOX_COMPOSE = docker/docker-compose-sqlite-dev.yml
SANDBOX_DC = docker compose -f $(SANDBOX_COMPOSE)
# www-data, not root: a root-owned SQLite file leaves Apache unable to write
# it, which surfaces as "attempt to write a readonly database".
SANDBOX_EXEC = $(SANDBOX_DC) exec -T -u www-data webcalendar
SANDBOX_PORT ?= 8081
export SANDBOX_PORT
SANDBOX_URL = http://localhost:$(SANDBOX_PORT)/
SANDBOX_ADMIN = admin
SANDBOX_PASSWORD = sandbox-admin
sandbox:
@# Docker's own message for a taken port is a wall of text ending in
@# "port is already allocated", which does not say what to do about it.
@#
@# Only checked when we are about to bind the port: on a re-run our own
@# container already holds it, and refusing then made this target usable
@# exactly once, with an error suggesting the port that had just failed.
@if ! $(SANDBOX_DC) ps --status=running -q webcalendar 2>/dev/null \
| grep -q .; then \
if command -v ss >/dev/null 2>&1 && \
ss -ltn 2>/dev/null | grep -qE ':$(SANDBOX_PORT)[[:space:]]'; then \
echo "port $(SANDBOX_PORT) is in use by something else." >&2; \
echo "choose another, e.g. make sandbox SANDBOX_PORT=9099" >&2; \
exit 1; \
fi; \
fi
@$(SANDBOX_DC) up -d --build
@printf 'waiting for the container'
@until $(SANDBOX_EXEC) php -r 'exit(0);' >/dev/null 2>&1; do \
printf '.'; sleep 1; \
done; echo
@# db check exits 2 when webcal_config has no version row, which is the
@# one reliable way to ask "has this been installed yet" without a
@# settings.php to look for.
@if $(SANDBOX_EXEC) php bin/webcal.php db check >/dev/null 2>&1; then \
echo "already installed"; \
else \
echo "installing..."; \
$(SANDBOX_EXEC) php wizard/headless.php --use-env \
--admin-login=$(SANDBOX_ADMIN) --admin-password=$(SANDBOX_PASSWORD) \
--admin-email=admin@example.invalid --user-auth=web \
--install-password=sandbox-install --force \
|| { echo "install failed, see the output above" >&2; exit 1; }; \
$(SANDBOX_EXEC) php bin/webcal.php db check >/dev/null 2>&1 \
|| { echo "the installer reported success but db check cannot reach \
the database" >&2; exit 1; }; \
fi
@echo
@echo " sandbox: $(SANDBOX_URL)"
@echo " login: $(SANDBOX_ADMIN) / $(SANDBOX_PASSWORD)"
@echo " cli: make sandbox-cli CMD=\"db check\""
@echo " seed: make sandbox-cli CMD=\"seed --scenario=month --force\""
@echo " discard: make sandbox-clean"
sandbox-cli:
@test -n "$(CMD)" || { echo 'usage: make sandbox-cli CMD="db check"' >&2; exit 1; }
@$(SANDBOX_EXEC) php bin/webcal.php $(CMD)
sandbox-reset:
@$(SANDBOX_DC) down -v
@$(MAKE) sandbox
sandbox-clean:
@$(SANDBOX_DC) down -v
@echo "sandbox removed; the working copy was never written to"
.PHONY: check check-compile check-stan check-tests sandbox sandbox-cli sandbox-reset sandbox-clean
check: check-compile check-stan check-tests
@echo "=== all checks passed ==="
check-compile:
@echo "=== compile ==="
./tests/compile_test.sh
check-stan:
@echo "=== phpstan ==="
vendor/bin/phpstan analyse --no-progress
check-tests:
@echo "=== phpunit ==="
vendor/bin/phpunit -c tests/phpunit.xml