|
1 | 1 | SHELL := /bin/bash |
| 2 | + |
2 | 3 | # ============================================================================= |
3 | | -# Variables |
| 4 | +# Configuration and Environment Variables |
4 | 5 | # ============================================================================= |
5 | 6 |
|
6 | 7 | .DEFAULT_GOAL:=help |
7 | 8 | .ONESHELL: |
8 | 9 | .EXPORT_ALL_VARIABLES: |
| 10 | +MAKEFLAGS += --no-print-directory |
| 11 | + |
| 12 | +# ----------------------------------------------------------------------------- |
| 13 | +# Display Formatting and Colors |
| 14 | +# ----------------------------------------------------------------------------- |
| 15 | +BLUE := $(shell printf "\033[1;34m") |
| 16 | +GREEN := $(shell printf "\033[1;32m") |
| 17 | +RED := $(shell printf "\033[1;31m") |
| 18 | +YELLOW := $(shell printf "\033[1;33m") |
| 19 | +NC := $(shell printf "\033[0m") |
| 20 | +INFO := $(shell printf "$(BLUE)ℹ$(NC)") |
| 21 | +OK := $(shell printf "$(GREEN)✓$(NC)") |
| 22 | +WARN := $(shell printf "$(YELLOW)⚠$(NC)") |
| 23 | +ERROR := $(shell printf "$(RED)✖$(NC)") |
9 | 24 |
|
| 25 | +# ============================================================================= |
| 26 | +# Help and Documentation |
| 27 | +# ============================================================================= |
10 | 28 |
|
11 | 29 | .PHONY: help |
12 | | -help: ## Display this help text for Makefile |
| 30 | +help: ## Display this help text for Makefile |
13 | 31 | @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) |
14 | 32 |
|
15 | | -.PHONY: upgrade |
16 | | -upgrade: ## Upgrade all dependencies to the latest stable versions |
17 | | - @echo "=> Updating all dependencies" |
18 | | - @uv lock --upgrade |
19 | | - @echo "=> Dependencies Updated" |
20 | | - @uv run pre-commit autoupdate |
21 | | - @echo "=> Updated Pre-commit" |
22 | | - |
23 | 33 | # ============================================================================= |
24 | | -# Developer Utils |
| 34 | +# Installation and Environment Setup |
25 | 35 | # ============================================================================= |
| 36 | + |
26 | 37 | .PHONY: install-uv |
27 | | -install-uv: ## Install latest version of uv |
28 | | - @curl -LsSf https://astral.sh/uv/install.sh | sh |
| 38 | +install-uv: ## Install latest version of uv |
| 39 | + @echo "${INFO} Installing uv..." |
| 40 | + @curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 |
| 41 | + @uv tool install nodeenv >/dev/null 2>&1 |
| 42 | + @echo "${OK} UV installed successfully" |
29 | 43 |
|
30 | 44 | .PHONY: install |
31 | | -install: clean ## Install the project, dependencies, and pre-commit for local development |
| 45 | +install: destroy clean ## Install the project, dependencies, and pre-commit |
| 46 | + @echo "${INFO} Starting fresh installation..." |
| 47 | + @uv python pin 3.12 >/dev/null 2>&1 |
| 48 | + @uv venv >/dev/null 2>&1 |
32 | 49 | @uv sync --all-extras --dev |
33 | | - @echo "=> Install complete!" |
34 | | - |
35 | | -.PHONY: clean |
36 | | -clean: ## Cleanup temporary build artifacts |
37 | | - @echo "=> Cleaning working directory" |
38 | | - @rm -rf .pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/ |
39 | | - @find . -name '*.egg-info' -exec rm -rf {} + |
40 | | - @find . -type f -name '*.egg' -exec rm -f {} + |
41 | | - @find . -name '*.pyc' -exec rm -f {} + |
42 | | - @find . -name '*.pyo' -exec rm -f {} + |
43 | | - @find . -name '*~' -exec rm -f {} + |
44 | | - @find . -name '__pycache__' -exec rm -rf {} + |
45 | | - @find . -name '.ipynb_checkpoints' -exec rm -rf {} + |
46 | | - @rm -rf .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/**/.pytest_cache .mypy_cache |
47 | | - $(MAKE) docs-clean |
| 50 | + @echo "${OK} Installation complete! 🎉" |
48 | 51 |
|
49 | 52 | .PHONY: destroy |
50 | | -destroy: ## Destroy the virtual environment |
| 53 | +destroy: ## Destroy the virtual environment |
| 54 | + @echo "${INFO} Destroying virtual environment... 🗑️" |
| 55 | + @uv run pre-commit clean >/dev/null 2>&1 |
51 | 56 | @rm -rf .venv |
| 57 | + @echo "${OK} Virtual environment destroyed 🗑️" |
52 | 58 |
|
53 | | -.PHONY: lock |
54 | | -lock: ## Rebuild lockfiles from scratch, updating all dependencies |
| 59 | +# ============================================================================= |
| 60 | +# Dependency Management |
| 61 | +# ============================================================================= |
| 62 | + |
| 63 | +.PHONY: upgrade |
| 64 | +upgrade: ## Upgrade all dependencies to latest stable versions |
| 65 | + @echo "${INFO} Updating all dependencies... 🔄" |
55 | 66 | @uv lock --upgrade |
| 67 | + @echo "${OK} Dependencies updated 🔄" |
| 68 | + @uv run pre-commit autoupdate |
| 69 | + @echo "${OK} Updated Pre-commit hooks 🔄" |
| 70 | + |
| 71 | +.PHONY: lock |
| 72 | +lock: ## Rebuild lockfiles from scratch |
| 73 | + @echo "${INFO} Rebuilding lockfiles... 🔄" |
| 74 | + @uv lock --upgrade >/dev/null 2>&1 |
| 75 | + @echo "${OK} Lockfiles updated" |
| 76 | + |
| 77 | +# ============================================================================= |
| 78 | +# Build and Release |
| 79 | +# ============================================================================= |
| 80 | + |
| 81 | +.PHONY: build |
| 82 | +build: ## Build the package |
| 83 | + @echo "${INFO} Building package... 📦" |
| 84 | + @uv build >/dev/null 2>&1 |
| 85 | + @echo "${OK} Package build complete" |
| 86 | + |
| 87 | +.PHONY: release |
| 88 | +release: ## Bump version and create release tag |
| 89 | + @echo "${INFO} Preparing for release... 📦" |
| 90 | + @make docs |
| 91 | + @make clean |
| 92 | + @make build |
| 93 | + @uv lock --upgrade-package advanced-alchemy >/dev/null 2>&1 |
| 94 | + @uv run bump-my-version bump $(bump) |
| 95 | + @echo "${OK} Release complete 🎉" |
56 | 96 |
|
57 | 97 | # ============================================================================= |
58 | | -# Tests, Linting, Coverage |
| 98 | +# Cleaning and Maintenance |
59 | 99 | # ============================================================================= |
| 100 | + |
| 101 | +.PHONY: clean |
| 102 | +clean: ## Cleanup temporary build artifacts |
| 103 | + @echo "${INFO} Cleaning working directory... 🧹" |
| 104 | + @rm -rf .pytest_cache .ruff_cache .hypothesis build/ 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 >/dev/null 2>&1 |
| 105 | + @find . -name '*.egg-info' -exec rm -rf {} + >/dev/null 2>&1 |
| 106 | + @find . -type f -name '*.egg' -exec rm -f {} + >/dev/null 2>&1 |
| 107 | + @find . -name '*.pyc' -exec rm -f {} + >/dev/null 2>&1 |
| 108 | + @find . -name '*.pyo' -exec rm -f {} + >/dev/null 2>&1 |
| 109 | + @find . -name '*~' -exec rm -f {} + >/dev/null 2>&1 |
| 110 | + @find . -name '__pycache__' -exec rm -rf {} + >/dev/null 2>&1 |
| 111 | + @find . -name '.ipynb_checkpoints' -exec rm -rf {} + >/dev/null 2>&1 |
| 112 | + @echo "${OK} Working directory cleaned" |
| 113 | + $(MAKE) docs-clean |
| 114 | + |
| 115 | +# ============================================================================= |
| 116 | +# Testing and Quality Checks |
| 117 | +# ============================================================================= |
| 118 | + |
| 119 | +.PHONY: test |
| 120 | +test: ## Run the tests |
| 121 | + @echo "${INFO} Running test cases... 🧪" |
| 122 | + @uv run pytest -n 2 --quiet |
| 123 | + @echo "${OK} Tests passed ✨" |
| 124 | + |
| 125 | +.PHONY: coverage |
| 126 | +coverage: ## Run tests with coverage report |
| 127 | + @echo "${INFO} Running tests with coverage... 📊" |
| 128 | + @uv run pytest --cov -n auto --quiet |
| 129 | + @uv run coverage html >/dev/null 2>&1 |
| 130 | + @uv run coverage xml >/dev/null 2>&1 |
| 131 | + @echo "${OK} Coverage report generated ✨" |
| 132 | + |
| 133 | +# ----------------------------------------------------------------------------- |
| 134 | +# Type Checking |
| 135 | +# ----------------------------------------------------------------------------- |
| 136 | + |
60 | 137 | .PHONY: mypy |
61 | | -mypy: ## Run mypy |
62 | | - @echo "=> Running mypy" |
| 138 | +mypy: ## Run mypy |
| 139 | + @echo "${INFO} Running mypy... 🔍" |
63 | 140 | @uv run dmypy run |
64 | | - @echo "=> mypy complete" |
| 141 | + @echo "${OK} Mypy checks passed ✨" |
65 | 142 |
|
66 | 143 | .PHONY: mypy-nocache |
67 | | -mypy-nocache: ## Run Mypy without cache |
68 | | - @echo "=> Running mypy without a cache" |
| 144 | +mypy-nocache: ## Run Mypy without cache |
| 145 | + @echo "${INFO} Running mypy without cache... 🔍" |
69 | 146 | @uv run mypy |
70 | | - @echo "=> mypy complete" |
| 147 | + @echo "${OK} Mypy checks passed ✨" |
71 | 148 |
|
72 | 149 | .PHONY: pyright |
73 | | -pyright: ## Run pyright |
74 | | - @echo "=> Running pyright" |
| 150 | +pyright: ## Run pyright |
| 151 | + @echo "${INFO} Running pyright... 🔍" |
75 | 152 | @uv run pyright |
76 | | - @echo "=> pyright complete" |
| 153 | + @echo "${OK} Pyright checks passed ✨" |
77 | 154 |
|
78 | 155 | .PHONY: type-check |
79 | | -type-check: mypy pyright ## Run all type checking |
| 156 | +type-check: mypy pyright ## Run all type checking |
| 157 | + |
| 158 | +# ----------------------------------------------------------------------------- |
| 159 | +# Linting and Formatting |
| 160 | +# ----------------------------------------------------------------------------- |
80 | 161 |
|
81 | 162 | .PHONY: pre-commit |
82 | | -pre-commit: ## Runs pre-commit hooks; includes ruff formatting and linting, codespell |
83 | | - @echo "=> Running pre-commit process" |
84 | | - @uv run pre-commit run --all-files |
85 | | - @echo "=> Pre-commit complete" |
| 163 | +pre-commit: ## Run pre-commit hooks |
| 164 | + @echo "${INFO} Running pre-commit checks... 🔎" |
| 165 | + @NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" uv run pre-commit run --color=always --all-files |
| 166 | + @echo "${OK} Pre-commit checks passed ✨" |
86 | 167 |
|
87 | 168 | .PHONY: slotscheck |
88 | | -slotscheck: ## Run slotscheck |
89 | | - @echo "=> Running slotscheck" |
90 | | - @uv run slotscheck litestar_htmx/ |
91 | | - @echo "=> slotscheck complete" |
92 | | - |
93 | | -.PHONY: lint |
94 | | -lint: pre-commit type-check slotscheck ## Run all linting |
| 169 | +slotscheck: ## Run slotscheck |
| 170 | + @echo "${INFO} Running slots check... 🔍" |
| 171 | + @uv run slotscheck |
| 172 | + @echo "${OK} Slots check passed ✨" |
95 | 173 |
|
96 | | -.PHONY: coverage |
97 | | -coverage: ## Run the tests and generate coverage report |
98 | | - @echo "=> Running tests with coverage" |
99 | | - @uv run pytest tests --cov -n auto |
100 | | - @uv run coverage html |
101 | | - @uv run coverage xml |
102 | | - @echo "=> Coverage report generated" |
| 174 | +.PHONY: fix |
| 175 | +fix: ## Run code formatters |
| 176 | + @echo "${INFO} Running code formatters... 🔧" |
| 177 | + @uv run ruff check --fix --unsafe-fixes |
| 178 | + @echo "${OK} Code formatting complete ✨" |
103 | 179 |
|
104 | | -.PHONY: test |
105 | | -test: ## Run the tests |
106 | | - @echo "=> Running test cases" |
107 | | - @uv run pytest tests |
108 | | - @echo "=> Tests complete" |
109 | | - |
110 | | -.PHONY: test-examples |
111 | | -test-examples: ## Run the examples tests |
112 | | - @uv run pytest docs/examples |
113 | | - |
114 | | -.PHONY: test-all |
115 | | -test-all: test test-examples ## Run all tests |
| 180 | +.PHONY: lint |
| 181 | +lint: pre-commit type-check slotscheck ## Run all linting checks |
116 | 182 |
|
117 | 183 | .PHONY: check-all |
118 | | -check-all: lint test-all coverage ## Run all linting, tests, and coverage checks |
119 | | - |
| 184 | +check-all: lint test coverage ## Run all checks (lint, test, coverage) |
120 | 185 |
|
121 | 186 | # ============================================================================= |
122 | | -# Docs |
| 187 | +# Documentation |
123 | 188 | # ============================================================================= |
124 | | -docs-clean: ## Dump the existing built docs |
125 | | - @echo "=> Cleaning documentation build assets" |
126 | | - @rm -rf docs/_build |
127 | | - @echo "=> Removed existing documentation build assets" |
128 | 189 |
|
129 | | -docs-serve: docs-clean ## Serve the docs locally |
130 | | - @echo "=> Serving documentation" |
131 | | - uv run sphinx-autobuild docs docs/_build/ -j auto --watch litestar_htmx --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002 |
| 190 | +.PHONY: docs-clean |
| 191 | +docs-clean: ## Clean documentation build |
| 192 | + @echo "${INFO} Cleaning documentation build assets... 🧹" |
| 193 | + @rm -rf docs/_build >/dev/null 2>&1 |
| 194 | + @echo "${OK} Documentation assets cleaned" |
| 195 | + |
| 196 | +.PHONY: docs-serve |
| 197 | +docs-serve: docs-clean ## Serve documentation locally |
| 198 | + @echo "${INFO} Starting documentation server... 📚" |
| 199 | + @uv run sphinx-autobuild docs docs/_build/ -j auto --watch litestar_htmx --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002 |
132 | 200 |
|
133 | | -docs: docs-clean ## Dump the existing built docs and rebuild them |
134 | | - @echo "=> Building documentation" |
135 | | - @uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going |
| 201 | +.PHONY: docs |
| 202 | +docs: docs-clean ## Build documentation |
| 203 | + @echo "${INFO} Building documentation... 📝" |
| 204 | + @uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going >/dev/null 2>&1 |
| 205 | + @echo "${OK} Documentation built successfully" |
136 | 206 |
|
137 | 207 | .PHONY: docs-linkcheck |
138 | | -docs-linkcheck: ## Run the link check on the docs |
| 208 | +docs-linkcheck: ## Check documentation links |
| 209 | + @echo "${INFO} Checking documentation links... 🔗" |
139 | 210 | @uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_ignore='http://.*','https://.*' |
| 211 | + @echo "${OK} Link check complete" |
140 | 212 |
|
141 | 213 | .PHONY: docs-linkcheck-full |
142 | | -docs-linkcheck-full: ## Run the full link check on the docs |
| 214 | +docs-linkcheck-full: ## Run full documentation link check |
| 215 | + @echo "${INFO} Running full link check... 🔗" |
143 | 216 | @uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_anchors=0 |
| 217 | + @echo "${OK} Full link check complete" |
0 commit comments