Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (64 loc) · 3.42 KB
/
Copy pathMakefile
File metadata and controls
79 lines (64 loc) · 3.42 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
SWITCH ?= solidtype
OPAM = opam exec --switch=$(SWITCH) --
DOCS_PORT ?= 4321
GENERATORS = html kobalte heroui rhp internationalized_date gravity_icons
REFERENCE = solidtype solidtype-kobalte solidtype-headless solidtype-heroui solidtype-rhp solidtype-internationalized-date solidtype-gravity-icons ppx_solidtype odoc.support
.DEFAULT_GOAL := help
.PHONY: help setup build test lint fmt example example-serve docs docs-serve generate release
help: ## list targets
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}'
setup: ## create the switch and install dependencies
@command -v bun >/dev/null 2>&1 || echo "The plugin and the example need Bun 1.3 or later."
@opam switch list --short | grep -qx $(SWITCH) || opam switch create $(SWITCH) --empty -y
opam repo add open-opam https://github.com/open-opam/opam-repository.git --switch=$(SWITCH) --rank=1
opam install . --switch=$(SWITCH) --deps-only --with-test --with-dev-setup -y
bun install --frozen-lockfile
build: ## build everything
$(OPAM) dune build @all
node_modules: package.json docs/package.json bun.lock
bun install --frozen-lockfile
@touch node_modules
# The plugin's and the example's suites read Melange's output, so the build
# comes first.
test: build node_modules ## run the tests
$(OPAM) dune test --force
$(OPAM) bun run test
# Release is the profile opam installs with.
lint: node_modules ## check formatting, types, litany, the release build and bindings
$(OPAM) dune build @all @fmt
$(OPAM) dune build --profile release @all
$(OPAM) litany check
bun run tsc -p vite-plugin
bun run tsc -p generate
$(OPAM) bun test generate/test
@for g in $(GENERATORS); do echo "generate/$$g.ts --check"; $(OPAM) bun generate/$$g.ts --check || exit 1; done
fmt: ## format the code
$(OPAM) dune fmt
example: build node_modules ## build the example, as a Vite page and an Astro one
bun --bun vite build --config example/vite.config.ts
bun --bun astro build --root example
BOARD_DB ?= example/board.db
example-serve: example ## serve the example and its API on http://localhost:4420
@test -f $(BOARD_DB) || { $(OPAM) rowtype-migrate create --url sqlite:$(BOARD_DB) \
&& $(OPAM) rowtype-migrate up --dir example/migrations --url sqlite:$(BOARD_DB) \
&& sqlite3 $(BOARD_DB) < example/seed.sql; }
$(OPAM) rowtype-migrate up --dir example/migrations --url sqlite:$(BOARD_DB)
BOARD_DB=$(BOARD_DB) _build/default/example/server/serve.exe
docs: build node_modules ## build the documentation site
$(OPAM) dune build @doc
rm -rf docs/public/reference
mkdir -p docs/public/reference
cd _build/default/_doc/_html && cp -R $(REFERENCE) $(CURDIR)/docs/public/reference/
chmod -R u+w docs/public/reference
bun --bun astro build --root docs
# The built documentation, as a host serves it: Pagefind's index exists only
# in a build, and a page served as it changes loads its styles after its
# text. Run from docs/, where Astro finds its config again.
docs-serve: docs ## serve the built documentation site
cd docs && bun --bun astro preview --open --port $(DOCS_PORT)
generate: node_modules ## write the generated bindings
@for g in $(GENERATORS); do echo "generate/$$g.ts"; $(OPAM) bun generate/$$g.ts || exit 1; done
release: node_modules ## tag VERSION and make its release
rm -rf _build/plugin && bun vite-plugin/pack.ts $(VERSION) _build/plugin
open-opam release $(VERSION) --attach _build/plugin/vite-plugin-solidtype-$(VERSION).tgz