-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
210 lines (178 loc) · 4.87 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
BUILD_ID ?= 20
COMPOSER_BIN ?= $(shell which composer)
ESBUILD_TARGET_DIRECTORY ?= docs/build/assets
PHP_BIN ?= $(shell which php)
SHELL_PWD := $(shell pwd)
CSS_SOURCES := $(wildcard resources/css/*.css)
CSS_ENTRYPOINTS := $(wildcard resources/css/docs-*.css)
MD_SOURCES := \
$(wildcard docs/pages/*.md) \
$(wildcard docs/pages/*/*.md) \
$(wildcard docs/pages/*/*/*.md) \
$(wildcard docs/pages/*/*/*/*.md) \
$(wildcard docs/pages/*/*/*/*/*.md)
PHP_SOURCES := \
$(wildcard app/*.php) \
$(wildcard app/*/*.php)
TS_ENTRYPOINTS := \
$(wildcard resources/ts/docs/controller_*.ts) \
$(wildcard resources/ts/docs/global_*.ts)
TS_SOURCES := \
$(wildcard resources/ts/*.js) \
$(wildcard resources/ts/*.jsx) \
$(wildcard resources/ts/*.ts) \
$(wildcard resources/ts/*.tsx) \
$(wildcard resources/ts/*/*.js) \
$(wildcard resources/ts/*/*.jsx) \
$(wildcard resources/ts/*/*.ts) \
$(wildcard resources/ts/*/*.tsx) \
$(wildcard resources/ts/*/*/*.js) \
$(wildcard resources/ts/*/*/*.jsx) \
$(wildcard resources/ts/*/*/*.ts) \
$(wildcard resources/ts/*/*/*.tsx)
# -----------------------------------------------------------------------------
# Real targets
# -----------------------------------------------------------------------------
.pnp.cjs: yarn.lock
yarnpkg install --immutable;
touch .pnp.cjs;
config.ini: config.ini.example
cp config.ini.example config.ini;
composer.lock: composer.json
${PHP_BIN} ${COMPOSER_BIN} update;
touch composer.lock;
docs/artifact.tar: docs/build
tar \
--dereference --hard-dereference \
-cvf "docs/artifact.tar" \
--exclude=.git \
--exclude=.github \
--directory "docs/build" .
docs/build: config.ini esbuild vendor $(MD_SOURCES) $(PHP_SOURCES)
${PHP_BIN} ./bin/resonance.php static-pages:build;
cp resources/images/* docs/build;
tools/php-cs-fixer/vendor/bin/php-cs-fixer:
$(MAKE) -C tools/php-cs-fixer vendor
tools/psalm/vendor/bin/psalm:
$(MAKE) -C tools/psalm vendor
vendor: composer.lock
${PHP_BIN} ${COMPOSER_BIN} install --no-interaction --prefer-dist --optimize-autoloader;
touch vendor;
yarn.lock: package.json
yarnpkg install;
touch yarn.lock;
# -----------------------------------------------------------------------------
# Phony targets
# -----------------------------------------------------------------------------
.PHONY: build
build: esbuild vendor
.PHONY: clean
clean:
$(MAKE) -C tools/php-cs-fixer clean
rm -rf ./.php-cs-fixer.cache
rm -rf ./.phpunit.cache
rm -rf ./.phpunit.result.cache
rm -rf ./.pnp.cjs
rm -rf ./.pnp.loader.mjs
rm -rf ./.yarn
rm -rf ./coverage
rm -rf ./docs/build
rm -rf ./esbuild-meta-docs.json
rm -rf ./vendor
.PHONY: esbuild
esbuild: $(CSS_SOURCES) .pnp.cjs
yarnpkg run esbuild \
--bundle \
--asset-names="./[name]_[hash]" \
--entry-names="./[name]_[hash]" \
--format=esm \
--loader:.jpg=file \
--loader:.otf=file \
--loader:.png=file \
--loader:.svg=file \
--loader:.ttf=file \
--loader:.webp=file \
--metafile=esbuild-meta-docs.json \
--minify \
--outdir=$(ESBUILD_TARGET_DIRECTORY) \
--sourcemap \
--splitting \
--target=safari16 \
--tree-shaking=true \
--tsconfig=tsconfig.json \
$(CSS_ENTRYPOINTS) \
$(TS_ENTRYPOINTS) \
;
.PHONY: eslint
eslint: .pnp.cjs
yarnpkg run eslint resources/ts
.PHONY: eslint.fix
eslint.fix: .pnp.cjs
yarnpkg run eslint --fix resources/ts
.PHONY: eslint.watch
eslint.watch: .pnp.cjs
yarnpkg run nodemon \
--ext ts,tsx,frag,vert \
--watch ./resources/ts \
--exec '$(MAKE) eslint || exit 1'
.PHONY: fmt
fmt: php-cs-fixer prettier
.PHONY: jest
jest: .pnp.cjs
yarnpkg run jest
.PHONY: php-cs-fixer
php-cs-fixer: tools/php-cs-fixer/vendor/bin/php-cs-fixer
./tools/php-cs-fixer/vendor/bin/php-cs-fixer --allow-risky=yes fix
.PHONY: phpunit
phpunit: config.ini vendor
./vendor/bin/phpunit
.PHONY: prettier
prettier: .pnp.cjs
yarnpkg run prettier \
--write \
"resources/{css,ts}/**/*.{js,css,ts,tsx}"
.PHONY: psalm
psalm: tools/psalm/vendor/bin/psalm vendor
./tools/psalm/vendor/bin/psalm \
--no-cache \
--show-info=true \
--root=$(CURDIR)
.PHONY: psalm.taint
psalm.taint: .pnp.cjs vendor
./tools/psalm/vendor/bin/psalm \
--no-cache \
--show-info=true \
--root=$(CURDIR) \
--taint-analysis
.PHONY: psalm.watch
psalm.watch: .pnp.cjs vendor
yarnpkg run nodemon \
--ext ini,php \
--signal SIGTERM \
--watch ./app \
--watch ./config.schema.php \
--watch ./constants.php \
--watch ./resonance \
--watch ./src \
--exec '$(MAKE) psalm || exit 1'
.PHONY: ssg
ssg: docs/build
.PHONY: ssg.watch
ssg.watch: .pnp.cjs
yarnpkg run nodemon \
--ext css,ini,md,php,ts \
--signal SIGTERM \
--watch ./app \
--watch ./docs/pages \
--watch ./src \
--watch ./resources \
--exec '$(MAKE) ssg || exit 1'
.PHONY: ssg.serve
ssg.serve: .pnp.cjs ssg
yarnpkg run esbuild --serve=8080 --servedir=docs/build
.PHONY: tsc
tsc: .pnp.cjs
yarnpkg run tsc --noEmit
.PHONY: tsc.watch
tsc.watch: .pnp.cjs
yarnpkg run tsc --noEmit --watch