forked from cubing/cubing.js
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
263 lines (255 loc) · 8.36 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
BUN=bun
BUNX=${BUN} x
BUN_RUN=${BUN} run
BIOME=${BUN} x @biomejs/biome
NODE=node
NPM=npm
WEB_TEST_RUNNER=${BUNX} @web/test-runner
.PHONY: default
default:
@echo "To work on the project, run:"
@echo ""
@echo " make dev"
@echo ""
@echo "To build the project, run:"
@echo ""
@echo " make setup"
@echo " make build"
@echo ""
@echo "To see available tests, run:"
@echo ""
@echo " make setup"
@echo " make test-info"
@echo ""
######## Shared with `package.json` ########
# By convention, we'd normally place `build-bin` first, but `build-lib` is the main target and
# it can be less confusing to build first (especially if the build aborts with
# an error).
.PHONY: build
build: clean build-lib build-bin build-sites
.PHONY: build-lib
build-lib: build-lib-js build-lib-types
.PHONY: build-lib-js
build-lib-js:
${BUN_RUN} ./script/build/lib/build-lib-js.ts
.PHONY: build-lib-types
build-lib-types:
${BUN_RUN} ./script/build/lib/build-lib-types.ts
.PHONY: build-bin
build-bin: build-lib-js
${BUN_RUN} ./script/build/bin/build-bin.ts
chmod +x ./dist/bin/*.js
.PHONY: build-sites
build-sites: build-site-twizzle build-site-experiments
.PHONY: build-site-twizzle
build-site-twizzle:
${BUN_RUN} ./script/build/sites/build-site-twizzle.ts
.PHONY: build-site-experiments
build-site-experiments:
${BUN_RUN} ./script/build/sites/build-site-experiments.ts
.PHONY: build-site-docs
build-site-docs:
rm -rf ./dist/sites/js.cubing.net/
${BUNX} typedoc src/cubing/*/index.ts
cp -R ./src/docs/js.cubing.net/* ./dist/sites/js.cubing.net/
@echo "\n\nNote: The js.cubing.net docs are deployed to GitHub Pages using GitHub Actions when a commit is pushed to the \`main\` branch:\nhttps://github.com/cubing/cubing.js/actions/workflows/pages.yml"
.PHONY: generate-js
generate-js: generate-js-parsers generate-js-svg
.PHONY: generate-js-parsers
generate-js-parsers:
${BUNX} peggy --format es src/cubing/kpuzzle/parser/parser-peggy.peggy
.PHONY: generate-js-svg
generate-js-svg:
@echo "TODO: Generating JS for SVGs is not implemented yet."
.PHONY: dev
dev: quick-setup
${BUN_RUN} ./script/build/sites/dev.ts
.PHONY: link
link: build
${BUN} link
.PHONY: clean
clean:
rm -rf \
dist .temp coverage script/bin/screenshot-src/main.js \
./alg ./bluetooth ./kpuzzle ./notation ./protocol ./puzzle-geometry ./puzzles ./scramble ./search ./stream ./twisty
.PHONY: test
test: test-info
.PHONY: test-info
test-info:
@echo "Run one of the following."
@echo "(Time estimates are based on a fast computer.)"
@echo ""
@echo " make test-spec (≈2s, unit tests only)"
@echo ""
@echo " make test-src (≈5s, includes \`make test-spec\`)"
@echo " make test-build (≈13s)"
@echo " make test-dist (≈10s)"
@echo ""
@echo " make test-all (≈27s, runs all of the above)"
@echo " make test-fast (≈2s, runs a subset of the above)"
@echo ""
# The following deps are in a custom order so that the more "useful" tests are first.
# In case of failure, this is likely to be more helpful.
.PHONY: test-fast
test-fast: \
build-lib-js test-spec-bun-fast build-bin build-sites \
lint \
test-src-import-restrictions test-src-scripts-consistency \
test-dist-lib-plain-esbuild-compat \
test-dist-bin-shebang
.PHONY: test-all
test-all: test-src test-build test-dist
.PHONY: test-src
test-src: \
test-spec \
lint-ci \
test-src-tsc \
test-src-import-restrictions \
test-src-scripts-consistency # keep CI.yml in sync with this
.PHONY: test-spec
test-spec: test-spec-bun test-spec-dom
.PHONY: test-spec-bun
test-spec-bun:
${BUN} test
.PHONY: test-spec-bun-fast
test-spec-bun-fast:
env CUBING_JS_SKIP_SLOW_TESTS=true ${BUN} test
.PHONY: test-spec-bun-with-coverage
test-spec-bun-with-coverage:
${BUN} test
.PHONY: test-spec-dom
test-spec-dom:
${WEB_TEST_RUNNER}
.PHONY: test-spec-dom-with-coverage
test-spec-dom-with-coverage:
${WEB_TEST_RUNNER} --coverage
.PHONY: playwright-install
playwright-install:
${BUNX} playwright install
.PHONY: test-src-import-restrictions
test-src-import-restrictions:
${BUN_RUN} ./script/test/src/import-restrictions/main.ts
.PHONY: test-src-tsc
test-src-tsc:
${BUNX} tsc --project ./tsconfig.json
.PHONY: test-src-scripts-consistency
test-src-scripts-consistency:
${BUN_RUN} ./script/test/src/scripts-consistency/main.ts
.PHONY: fix-src-scripts-consistency
fix-src-scripts-consistency:
${BUN_RUN} ./script/test/src/scripts-consistency/main.ts --fix
.PHONY: test-build
test-build: \
build-lib-js \
build-bin \
build-lib-types \
build-sites \
build-site-docs # keep CI.yml in sync with this
.PHONY: test-dist
test-dist: test-dist-lib test-dist-bin
.PHONY: test-dist-lib
test-dist-lib: \
test-dist-lib-node-import \
test-dist-lib-bun-scramble-all-events \
test-dist-lib-perf \
test-dist-lib-plain-esbuild-compat \
test-dist-lib-build-size \
test-dist-sites-experiments # keep CI.yml in sync with this
.PHONY: test-dist-lib-node-import
test-dist-lib-node-import: build-lib-js
${NODE} script/test/dist/lib/cubing/node/import/main.js
.PHONY: test-dist-lib-bun-scramble-all-events
test-dist-lib-bun-scramble-all-events: build-lib-js
${BUN} script/test/dist/lib/cubing/node/scramble-all-events/main.js
.PHONY: test-dist-lib-perf
test-dist-lib-perf: build-lib-js
${BUN} script/test/dist/lib/cubing/perf/*.js
.PHONY: test-dist-lib-plain-esbuild-compat
test-dist-lib-plain-esbuild-compat: build-lib-js
${BUN_RUN} script/test/dist/lib/cubing/plain-esbuild-compat/main.ts
.PHONY: test-dist-lib-build-size
test-dist-lib-build-size: build-lib-js
${BUN_RUN} ./script/test/dist/lib/cubing/build-size/main.ts
.PHONY: test-dist-sites-experiments
test-dist-sites-experiments: playwright-install build-sites
${BUN} ./script/test/dist/sites/experiments.cubing.net/main.js
.PHONY: test-dist-bin
test-dist-bin: test-dist-bin-shebang test-dist-bin-npm-exec
.PHONY: test-dist-bin-shebang
test-dist-bin-shebang: build-bin
# Note: we're not testing the output, just that these don't exit with an error.
time dist/bin/order.js 3x3x3 "R U R'"
time dist/bin/puzzle-geometry-bin.js --svg 2x2x2
time dist/bin/scramble.js 222
.PHONY: test-dist-bin-npm-exec
test-dist-bin-npm-exec: build-bin
time ${NPM} exec scramble -- 222
.PHONY: format
format:
${BIOME} format --write ./script ./src
.PHONY: setup
setup:
${BUN} install # TODO: was `npm ci`
.PHONY: quick-setup
quick-setup: | node_modules
.PHONY: lint
lint:
${BIOME} check ./script ./src
.PHONY: lint-ci
lint-ci:
${BIOME} ci ./script ./src
.PHONY: prepack
prepack: clean build test-dist-lib-node-import test-dist-lib-plain-esbuild-compat
.PHONY: prepublishOnly
prepublishOnly:
# Lucas is usually the one publishing, and `mak` is over twice as fast. So we use it when available.
# https://github.com/lgarron/mak
mak test-all || make test-all
.PHONY: postpublish
postpublish: update-cdn update-create-cubing-app deploy
.PHONY: deploy
deploy: deploy-twizzle deploy-experiments
.PHONY: deploy-twizzle
deploy-twizzle: build-site-twizzle
${BUN_RUN} script/deploy/twizzle.ts
.PHONY: deploy-experiments
deploy-experiments: build-site-experiments
${BUN_RUN} script/deploy/experiments.ts
.PHONY: roll-vendored-twsearch
roll-vendored-twsearch:
test -d ../twsearch/ || exit
rm -rf ../twsearch/dist/wasm/
cd ../twsearch/ && make build-rust-wasm
mkdir -p ./src/cubing/vendor/mpl/twsearch
rm -rf ./src/cubing/vendor/mpl/twsearch/*
cp -R ../twsearch/dist/wasm/* ./src/cubing/vendor/mpl/twsearch/
${BUN_RUN} script/fix-vendored-twsearch.ts
.PHONY: update-create-cubing-app
update-create-cubing-app:
cd ../create-cubing-app && make roll-cubing-commit && git push
.PHONY: update-cdn
update-cdn:
@echo "--------------------------------"
@echo "Updating CDN to the latest \`cubing.js\` release, per:"
@echo "https://github.com/cubing/cdn.cubing.net/blob/main/docs/maintenance.md#updating-cdncubingnet-to-a-new-cubing-version"
@echo ""
test -d ../cdn.cubing.net/ || exit
cd ../cdn.cubing.net/ && make roll-cubing
######## Only in `Makefile` ########
# Not .PHONY(!)
node_modules:
${BUN_RUN} ./script/quick-setup/main.ts
.PHONY: publish
.PHONY: publish
publish:
${NPM} publish
.PHONY: pack
.PHONY: pack
pack:
# Note that we need to use `./dist/` rather than `./dist/pack/`, because `make
# prepack` removes the entire `./dist/` folder (but creates a new `./dist/`
# folder). This prevents us from creating a `./dist/pack/` folder (or
# similarly, `./.temp/pack/` folder) that will stick around long enough for
# `npm pack` to use. The simplest is just to place the result directly in
# `./dist/`.
${NPM} pack --pack-destination ./dist/