-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
203 lines (167 loc) · 5.84 KB
/
Makefile
File metadata and controls
203 lines (167 loc) · 5.84 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
project_name = query-json
opam_file = $(project_name).opam
DUNE = opam exec -- dune
VITE = ./node_modules/.bin/vite
.PHONY: help
help: ## Print this help message
@echo "";
@echo "List of available make commands";
@echo "";
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}';
@echo "";
.PHONY: build
build: ## Build the project, including non installable libraries and executables
$(DUNE) build @all
.PHONY: build-prod
build-prod: ## Build for production (--profile=prod)
$(DUNE) build --profile=release @all
$(DUNE) install
.PHONY: dev
dev: ## Build everything in watch mode
$(DUNE) build -w @all
.PHONY: dev-core
dev-core: ## Build in watch mode
$(DUNE) build -w source
.PHONY: repl
repl: ## Run repl with "package.json"
$(DUNE) exec ./cli/cli.exe -- --repl package.json
.PHONY: web-dev
web-dev: ## Build and serve the website via HMR
$(VITE) --host --config website/vite.config.js --force
.PHONY: web-clean
web-clean: ## Clear Vite's cache
rm -rf node_modules/.vite
.PHONY: web-build
web-build: ## Bundle the website
$(VITE) build --config website/vite.config.js
.PHONY: web-preview
web-preview: ## Preview the website
$(VITE) preview --config website/vite.config.js
.PHONY: web-serve
web-serve: ## Serve the dist directory
npx serve dist
.PHONY: clean
clean: ## Clean artifacts
$(DUNE) clean
.PHONY: test
test: ## Run the unit tests
$(DUNE) build @runtest
.PHONY: test-watch
test-watch: ## Run the unit tests in watch mode
$(DUNE) build @runtest -w
.PHONY: test-promote
test-promote: ## Updates snapshots and promotes it to correct
$(DUNE) build @runtest --auto-promote
.PHONY: setup-githooks
setup-githooks: ## Setup githooks
git config core.hooksPath .githooks
.PHONY: format
format: ## Format the codebase with ocamlformat
@DUNE_CONFIG__GLOBAL_LOCK=disabled $(DUNE) build @fmt --auto-promote
.PHONY: format-check
format-check: ## Checks if format is correct
@DUNE_CONFIG__GLOBAL_LOCK=disabled $(DUNE) build @fmt
.PHONY: subst
subst: ## Run dune substitute
$(DUNE) subst
.PHONY: pin
pin: # pin dependencies
opam pin add toffee.dev "https://github.com/tmattio/mosaic.git#12e4c090f941442e9d55d2816873f596399eb8df" -y
opam pin add matrix.dev "https://github.com/tmattio/mosaic.git#12e4c090f941442e9d55d2816873f596399eb8df" -y
opam pin add mosaic.dev "https://github.com/tmattio/mosaic.git#12e4c090f941442e9d55d2816873f596399eb8df" -y
.PHONY: create-switch
create-switch: ## Create opam switch
opam switch create . 5.4.0 --deps-only --with-test --no-install -y
.PHONY: install
install: ## Install opam deps
opam install . --deps-only --with-test --with-doc --with-dev-setup -y
.PHONY: npm-install
npm-install: ## Install npm dependencies
npm install
.PHONY: init
init: setup-githooks create-switch pin install npm-install ## Create a local dev enviroment
DEMO_FILES = \
repl-demo \
cli-basic \
cli-advanced \
comparison \
jq-compat-demos/00-error-messages \
jq-compat-demos/01-stricter-null-handling \
jq-compat-demos/02-fn-vs-def \
jq-compat-demos/03-snake-case-naming \
jq-compat-demos/04-clearer-naming \
jq-compat-demos/05-group-by-behavior \
jq-compat-demos/06-keys-insertion-order \
jq-compat-demos/07-unique-insertion-order \
jq-compat-demos/08-infinite-generator \
jq-compat-demos/09-optional-access-functions \
jq-compat-demos/10-additional-features \
jq-compat-demos/all-demos
.PHONY: demo
demo: demo-cast demo-gif ## Generate cast+gif demo (usage: make demo FILE=cli-basic)
.PHONY: demo-cast
demo-cast: ## Record demo cast (usage: make demo-cast FILE=cli-basic)
@if [ -z "$(FILE)" ]; then \
echo "Error: FILE is required. Usage: make demo FILE=repl-demo"; \
exit 1; \
fi
$(DUNE) install
@if [ "$(FILE)" = "repl-demo" ]; then \
asciinema rec --overwrite --cols 140 --rows 48 -c "python3 docs/record-repl-demo.py" docs/repl-demo.cast; \
elif [ -f "docs/demo-scripts/$(FILE).sh" ]; then \
asciinema rec --overwrite --cols 140 --rows 48 -c "bash docs/demo-scripts/$(FILE).sh" "docs/$(FILE).cast"; \
else \
echo "Error: unknown demo '$(FILE)'. Expected docs/demo-scripts/$(FILE).sh"; \
exit 1; \
fi
.PHONY: demo-gif
demo-gif: ## Render demo gif from cast (usage: make demo-gif FILE=cli-basic)
@if [ -z "$(FILE)" ]; then \
echo "Error: FILE is required. Usage: make demo-gif FILE=repl-demo"; \
exit 1; \
fi
@if [ ! -f "docs/$(FILE).cast" ]; then \
echo "Error: docs/$(FILE).cast not found. Run: make demo-cast FILE=$(FILE)"; \
exit 1; \
fi
@if ! command -v agg >/dev/null 2>&1; then \
echo "Error: agg is required to render GIFs."; \
echo "Install it from: https://github.com/asciinema/agg"; \
exit 1; \
fi
agg "docs/$(FILE).cast" "docs/$(FILE).gif"
.PHONY: demo-all-cast
demo-all-cast: ## Record all demos as .cast files
@for demo in $(DEMO_FILES); do \
$(MAKE) demo-cast FILE=$$demo || exit 1; \
done
.PHONY: demo-all-gif
demo-all-gif: ## Render all demos as .gif files
@for demo in $(DEMO_FILES); do \
$(MAKE) demo-gif FILE=$$demo || exit 1; \
done
.PHONY: demo-all
demo-all: demo-all-cast demo-all-gif ## Record and render all demos
.PHONY: bench
bench: ## Run benchmarks
./benchmarks/bench.sh
.PHONY: bench-parser
bench-parser: ## Run parser-only benchmark
$(DUNE) exec benchmarks/bench_parser.exe
.PHONY: release
release: ## Create a new release (usage: make release VERSION=1.2.3)
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION is required. Usage: make release VERSION=1.2.3"; \
exit 1; \
fi
@echo "Creating release $(VERSION)"
@sed -i.bak "s/^(version .*)/(version $(VERSION))/" dune-project && rm -f dune-project.bak
@$(DUNE) build
@git add dune-project *.opam
@git commit -m "Bump version to $(VERSION)"
@git push origin main
@git tag -d $(VERSION) 2>/dev/null || true
@git push origin :refs/tags/$(VERSION) 2>/dev/null || true
@git tag $(VERSION)
@git push origin $(VERSION)
@echo "Release $(VERSION) created and pushed!"