-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
330 lines (283 loc) Β· 14.4 KB
/
Makefile
File metadata and controls
330 lines (283 loc) Β· 14.4 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
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
# =============================================================================
# Configuration and Environment Variables
# =============================================================================
.DEFAULT_GOAL:=help
.ONESHELL:
.EXPORT_ALL_VARIABLES:
MAKEFLAGS += --no-print-directory
# -----------------------------------------------------------------------------
# Display Formatting and Colors
# -----------------------------------------------------------------------------
BLUE := $(shell printf "\033[1;34m")
GREEN := $(shell printf "\033[1;32m")
RED := $(shell printf "\033[1;31m")
YELLOW := $(shell printf "\033[1;33m")
NC := $(shell printf "\033[0m")
INFO := $(shell printf "$(BLUE)βΉ$(NC)")
OK := $(shell printf "$(GREEN)β$(NC)")
WARN := $(shell printf "$(YELLOW)β $(NC)")
ERROR := $(shell printf "$(RED)β$(NC)")
NODEENV ?= 0
EXTRAS ?=
UV_SYNC_EXTRAS := $(foreach extra,$(EXTRAS),--extra $(extra))
# =============================================================================
# Help and Documentation
# =============================================================================
.PHONY: help
help: ## Display this help text for Makefile
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
# =============================================================================
# Installation and Environment Setup
# =============================================================================
.PHONY: install-uv
install-uv: ## Install latest version of uv
@echo "${INFO} Installing uv..."
@curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1
@echo "${OK} UV installed successfully"
.PHONY: install
install: destroy clean ## Install the project, dependencies, and pre-commit
@echo "${INFO} Starting fresh installation..."
@uv venv >/dev/null 2>&1
@uv sync --dev $(UV_SYNC_EXTRAS)
@if [ "$(NODEENV)" = "1" ]; then \
echo "${INFO} Installing Node environment via nodeenv... π¦"; \
uvx nodeenv .venv --force --quiet >/dev/null 2>&1; \
elif ! command -v npm >/dev/null 2>&1; then \
echo "${WARN} npm not found. Re-run with NODEENV=1 to provision nodeenv or install Node.js manually."; \
exit 1; \
fi
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install --no-fund
@echo "${OK} Installation complete! π"
.PHONY: destroy
destroy: ## Destroy the virtual environment
@echo "${INFO} Destroying virtual environment... ποΈ"
@uv run pre-commit clean >/dev/null 2>&1
@rm -rf .venv
@echo "${OK} Virtual environment destroyed ποΈ"
# =============================================================================
# Dependency Management
# =============================================================================
.PHONY: upgrade
upgrade: ## Upgrade all dependencies to latest stable versions
@echo "${INFO} Updating all dependencies... π"
@uv lock --upgrade
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm update --no-fund
@echo "${OK} Dependencies updated π"
@uv run pre-commit autoupdate
@echo "${OK} Updated Pre-commit hooks π"
.PHONY: lock
lock: ## Rebuild lockfiles from scratch
@echo "${INFO} Rebuilding lockfiles... π"
@uv lock --upgrade >/dev/null 2>&1
@echo "${OK} Lockfiles updated"
# =============================================================================
# Build and Release
# =============================================================================
.PHONY: build
build: ## Build the package
@echo "${INFO} Building package... π¦"
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install --no-fund --quiet
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm run build --quiet
@LITESTAR_VITE_SKIP_JS_BUILD=1 uv build -o dist/py
@echo "${OK} Package build complete"
.PHONY: release
release: ## Bump version and create release tag (bump=major|minor|patch)
@echo "${INFO} Preparing for release... π¦"
@make docs
@make clean
@make build
@uv run bump-my-version bump $(bump)
@uv lock --upgrade-package litestar-vite >/dev/null 2>&1
@echo "${OK} Release complete π"
.PHONY: pre-release
pre-release: ## Start a pre-release: make pre-release version=0.15.0-alpha.1
@if [ -z "$(version)" ]; then \
echo "${ERROR} Usage: make pre-release version=X.Y.Z-alpha.N"; \
echo ""; \
echo "Pre-release workflow:"; \
echo " 1. Start alpha: make pre-release version=0.15.0-alpha.1"; \
echo " 2. Next alpha: make pre-release version=0.15.0-alpha.2"; \
echo " 3. Move to beta: make pre-release version=0.15.0-beta.1"; \
echo " 4. Move to rc: make pre-release version=0.15.0-rc.1"; \
echo " 5. Final release: make release bump=pre (from rc) OR bump=patch/minor (from stable)"; \
exit 1; \
fi
@echo "${INFO} Preparing pre-release $(version)... π§ͺ"
@make clean
@make build
@uv run bump-my-version bump --new-version $(version) pre
@uv lock --upgrade-package litestar-vite >/dev/null 2>&1
@echo "${OK} Pre-release $(version) complete π§ͺ"
@echo ""
@echo "${INFO} Next steps:"
@echo " 1. Push: git push origin HEAD"
@echo " 2. Create a GitHub pre-release: gh release create v$(version) --prerelease --title 'v$(version)'"
@echo " 3. This will publish to PyPI/npm with pre-release tags"
# =============================================================================
# Cleaning and Maintenance
# =============================================================================
.PHONY: clean
clean: ## Cleanup temporary build artifacts
@echo "${INFO} Cleaning working directory... π§Ή"
@rm -rf pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/ .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/**/.pytest_cache .mypy_cache .unasyncd_cache/ .auto_pytabs_cache node_modules docs-build coverage >/dev/null 2>&1
@rm -f .litestar*.json >/dev/null 2>&1 || true
@find . -name '*.egg-info' -exec rm -rf {} + >/dev/null 2>&1
@find . -type f -name '*.egg' -exec rm -f {} + >/dev/null 2>&1
@find . -name '*.pyc' -exec rm -f {} + >/dev/null 2>&1
@find . -name '*.pyo' -exec rm -f {} + >/dev/null 2>&1
@find . -name '*~' -exec rm -f {} + >/dev/null 2>&1
@find . -name '__pycache__' -exec rm -rf {} + >/dev/null 2>&1
@find . -name '.ipynb_checkpoints' -exec rm -rf {} + >/dev/null 2>&1
@echo "${OK} Working directory cleaned"
$(MAKE) clean-examples
$(MAKE) docs-clean
.PHONY: clean-examples
clean-examples: ## Clean all example build artifacts
@echo "${INFO} Cleaning example artifacts... π§Ή"
@find examples -maxdepth 2 -type d -name "node_modules" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type d -name "public" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type d -name ".vite" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type d -name ".angular" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type d -name ".nuxt" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type d -name ".output" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type d -name ".svelte-kit" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 3 -type d -name "generated" -exec rm -rf {} + >/dev/null 2>&1 || true
@find examples -maxdepth 2 -type f -name ".litestar*.json" -exec rm -f {} + >/dev/null 2>&1 || true
@echo "${OK} Example artifacts cleaned"
# =============================================================================
# Testing and Quality Checks
# =============================================================================
.PHONY: test
test: ## Run the tests
@echo "${INFO} Running test cases... π§ͺ"
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm run test
@uv run pytest -n 2 --quiet
@echo "${OK} Tests passed β¨"
.PHONY: coverage
coverage: ## Run tests with coverage report
@echo "${INFO} Running tests with coverage... π"
@uv run pytest --cov=src/py/litestar_vite -n 2 --quiet
@uv run coverage html >/dev/null 2>&1
@uv run coverage xml >/dev/null 2>&1
@echo "${OK} Coverage report generated β¨"
# -----------------------------------------------------------------------------
# Type Checking
# -----------------------------------------------------------------------------
.PHONY: mypy
mypy: ## Run mypy
@echo "${INFO} Running mypy... π"
@uv run dmypy run
@echo "${OK} Mypy checks passed β¨"
.PHONY: mypy-nocache
mypy-nocache: ## Run Mypy without cache
@echo "${INFO} Running mypy without cache... π"
@uv run mypy
@echo "${OK} Mypy checks passed β¨"
.PHONY: pyright
pyright: ## Run pyright
@echo "${INFO} Running pyright... π"
@uv run pyright
@echo "${OK} Pyright checks passed β¨"
.PHONY: basedpyright
basedpyright: ## Run basedpyright
@echo "${INFO} Running basedpyright... π"
@uv run basedpyright
@echo "${OK} Basedpyright checks passed β¨"
.PHONY: type-check
type-check: mypy pyright ## Run all type checking
# -----------------------------------------------------------------------------
# Linting and Formatting
# -----------------------------------------------------------------------------
.PHONY: pre-commit
pre-commit: ## Run pre-commit hooks
@echo "${INFO} Running pre-commit checks... π"
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" uv run pre-commit run --color=never --all-files
@echo "${OK} Pre-commit checks passed β¨"
.PHONY: slotscheck
slotscheck: ## Run slotscheck
@echo "${INFO} Running slots check... π"
@uv run slotscheck -m litestar_vite
@echo "${OK} Slots check passed β¨"
.PHONY: fix
fix: ## Run code formatters
@echo "${INFO} Running code formatters... π§"
@uv run ruff check --fix --unsafe-fixes
@echo "${OK} Code formatting complete β¨"
.PHONY: lint
lint: pre-commit type-check slotscheck ## Run all linting checks
.PHONY: check-all
check-all: lint test coverage ## Run all checks (lint, test, coverage)
# =============================================================================
# Documentation
# =============================================================================
.PHONY: docs-clean
docs-clean: ## Clean documentation build
@echo "${INFO} Cleaning documentation build assets... π§Ή"
@rm -rf docs/_build >/dev/null 2>&1
@echo "${OK} Documentation assets cleaned"
.PHONY: docs-serve
docs-serve: docs-clean ## Serve documentation locally
@echo "${INFO} Starting documentation server... π"
@uv run sphinx-autobuild docs docs/_build/ -j auto --watch src/py/litestar_vite --watch docs --watch CONTRIBUTING.rst --port 8002
.PHONY: docs
docs: docs-clean ## Build documentation
@echo "${INFO} Building documentation... π"
@uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going
@echo "${OK} Documentation built successfully"
.PHONY: docs-linkcheck
docs-linkcheck: ## Check documentation links
@echo "${INFO} Checking documentation links... π"
@uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_ignore='http://.*','https://.*'
@echo "${OK} Link check complete"
.PHONY: docs-linkcheck-full
docs-linkcheck-full: ## Run full documentation link check
@echo "${INFO} Running full link check... π"
@uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_anchors=0
@echo "${OK} Full link check complete"
.PHONY: docs-demos
docs-demos: ## Generate demo GIFs locally (requires vhs)
@echo "${INFO} Generating demo GIFs... π¬"
@command -v vhs >/dev/null 2>&1 || { echo "${ERROR} VHS required. Install with: brew install vhs (macOS) or see https://github.com/charmbracelet/vhs"; exit 1; }
@mkdir -p docs/_static/demos
@for tape in docs/_tapes/*.tape; do \
echo "${INFO} Processing $$tape..."; \
VHS_NO_SANDBOX=true vhs "$$tape"; \
done
@echo "${OK} Demo GIFs generated successfully"
.PHONY: docs-all
docs-all: docs-demos docs ## Generate demos and build documentation
# =============================================================================
# Example Management
# =============================================================================
.PHONY: install-examples
install-examples: ## Install dependencies for all examples
@echo "${INFO} Installing example dependencies... π¦"
@for dir in examples/*/; do \
if [ -f "$${dir}package.json" ]; then \
echo "${INFO} Installing $${dir}..."; \
uv run litestar --app-dir "$${dir%/}" assets install || exit 1; \
fi \
done
@echo "${OK} Example dependencies installed"
.PHONY: build-examples
build-examples: ## Build all frontend examples
@echo "${INFO} Building all examples... π¦"
@for dir in examples/*/; do \
if [ -f "$${dir}package.json" ]; then \
echo "${INFO} Building $${dir}..."; \
uv run litestar --app-dir "$${dir%/}" assets build || exit 1; \
fi \
done
@echo "${OK} All examples built successfully"
.PHONY: test-examples
test-examples: build-examples ## Build and test all examples
@echo "${INFO} Testing examples... π§ͺ"
@uv run pytest src/py/tests/integration/test_examples.py -v
@echo "${OK} Example tests passed"
.PHONY: test-examples-e2e
test-examples-e2e: ## Run end-to-end example suite
@echo "${INFO} Running E2E example tests... π§ͺ"
@uv run pytest -n auto -m e2e src/py/tests/e2e -v --maxfail=1
@echo "${OK} E2E example tests passed"