-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): reformatted
Makefile
(#56)
- Loading branch information
Showing
4 changed files
with
1,407 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,171 +1,232 @@ | ||
SHELL := /bin/bash | ||
|
||
# ============================================================================= | ||
# Variables | ||
# 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)") | ||
|
||
# ============================================================================= | ||
# Help and Documentation | ||
# ============================================================================= | ||
|
||
.PHONY: help | ||
help: ## Display this help text for Makefile | ||
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) | ||
|
||
.PHONY: release | ||
release: ## bump the version and create the release tag | ||
make docs | ||
make clean | ||
make build | ||
uv lock --upgrade-package litestar-vite | ||
uv run bump-my-version bump $(bump) | ||
|
||
# ============================================================================= | ||
# Developer Utils | ||
# Installation and Environment Setup | ||
# ============================================================================= | ||
|
||
.PHONY: install-uv | ||
install-uv: ## Install latest version of uv | ||
@curl -LsSf https://astral.sh/uv/install.sh | sh | ||
install-uv: ## Install latest version of uv | ||
@echo "${INFO} Installing uv..." | ||
@curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 | ||
@uv tool install nodeenv >/dev/null 2>&1 | ||
@echo "${OK} UV installed successfully" | ||
|
||
.PHONY: install | ||
install: destroy clean ## Install the project, dependencies, and pre-commit for local development | ||
@uv python pin 3.12 | ||
@uv venv | ||
install: destroy clean ## Install the project, dependencies, and pre-commit | ||
@echo "${INFO} Starting fresh installation..." | ||
@uv python pin 3.12 >/dev/null 2>&1 | ||
@uv venv >/dev/null 2>&1 | ||
@uv sync --all-extras --dev | ||
@if ! command -v npm >/dev/null 2>&1; then \ | ||
uvx nodeenv .venv --force --quiet; \ | ||
echo "${INFO} Installing Node environment... π¦"; \ | ||
uvx nodeenv .venv --force --quiet >/dev/null 2>&1; \ | ||
fi | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install | ||
@echo "=> Install complete!" | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install --no-fund >/dev/null 2>&1 | ||
@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 the latest stable versions | ||
@echo "=> Updating all dependencies" | ||
upgrade: ## Upgrade all dependencies to latest stable versions | ||
@echo "${INFO} Updating all dependencies... π" | ||
@uv lock --upgrade | ||
@echo "=> Dependencies Updated" | ||
@uv run pre-commit autoupdate | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm upgrade --latest | ||
@echo "=> Updated Pre-commit" | ||
|
||
.PHONY: clean | ||
clean: ## Cleanup temporary build artifacts | ||
@echo "=> 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 | ||
@find . -name '*.egg-info' -exec rm -rf {} + | ||
@find . -type f -name '*.egg' -exec rm -f {} + | ||
@find . -name '*.pyc' -exec rm -f {} + | ||
@find . -name '*.pyo' -exec rm -f {} + | ||
@find . -name '*~' -exec rm -f {} + | ||
@find . -name '__pycache__' -exec rm -rf {} + | ||
@find . -name '.ipynb_checkpoints' -exec rm -rf {} + | ||
$(MAKE) docs-clean | ||
|
||
.PHONY: destroy | ||
destroy: ## Destroy the virtual environment | ||
@uv run pre-commit clean | ||
@rm -rf .venv | ||
@echo "${OK} Dependencies updated π" | ||
@uv run pre-commit autoupdate | ||
@echo "${OK} Updated Pre-commit hooks π" | ||
|
||
.PHONY: lock | ||
lock: ## Rebuild lockfiles from scratch, updating all dependencies | ||
@uv lock --upgrade | ||
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: | ||
@echo "=> Building package..." | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm run build | ||
@uv build -o dist/py | ||
@echo "=> Package build complete..." | ||
build: ## Build the package | ||
@echo "${INFO} Building package... π¦" | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install >/dev/null 2>&1 | ||
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm run build >/dev/null 2>&1 | ||
@uv build -o dist/py >/dev/null 2>&1 | ||
@echo "${OK} Package build complete" | ||
|
||
.PHONY: release | ||
release: ## Bump version and create release tag | ||
@echo "${INFO} Preparing for release... π¦" | ||
@make docs | ||
@make clean | ||
@make build | ||
@uv lock --upgrade-package litestar-vite >/dev/null 2>&1 | ||
@uv run bump-my-version bump $(bump) | ||
@echo "${OK} Release complete π" | ||
|
||
# ============================================================================= | ||
# Tests, Linting, Coverage | ||
# 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 >/dev/null 2>&1 | ||
@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) docs-clean | ||
|
||
# ============================================================================= | ||
# Testing and Quality Checks | ||
# ============================================================================= | ||
|
||
.PHONY: test | ||
test: ## Run the tests | ||
@echo "${INFO} Running test cases... π§ͺ" | ||
@npm run test >/dev/null 2>&1 | ||
@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 -n auto --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 "=> Running mypy" | ||
mypy: ## Run mypy | ||
@echo "${INFO} Running mypy... π" | ||
@uv run dmypy run | ||
@echo "=> mypy complete" | ||
@echo "${OK} Mypy checks passed β¨" | ||
|
||
.PHONY: mypy-nocache | ||
mypy-nocache: ## Run Mypy without cache | ||
@echo "=> Running mypy without a cache" | ||
mypy-nocache: ## Run Mypy without cache | ||
@echo "${INFO} Running mypy without cache... π" | ||
@uv run mypy | ||
@echo "=> mypy complete" | ||
@echo "${OK} Mypy checks passed β¨" | ||
|
||
.PHONY: pyright | ||
pyright: ## Run pyright | ||
@echo "=> Running pyright" | ||
pyright: ## Run pyright | ||
@echo "${INFO} Running pyright... π" | ||
@uv run pyright | ||
@echo "=> pyright complete" | ||
@echo "${OK} Pyright checks passed β¨" | ||
|
||
.PHONY: basedpyright | ||
basedpyright: ## Run basedpyright | ||
@echo "=> Running basedpyright" | ||
@echo "${INFO} Running basedpyright... π" | ||
@uv run basedpyright | ||
@echo "=> pyright complete" | ||
@echo "${OK} Basedpyright checks passed β¨" | ||
|
||
.PHONY: type-check | ||
type-check: mypy pyright ## Run all type checking | ||
type-check: mypy pyright ## Run all type checking | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Linting and Formatting | ||
# ----------------------------------------------------------------------------- | ||
|
||
.PHONY: pre-commit | ||
pre-commit: ## Runs pre-commit hooks; includes ruff formatting and linting, codespell | ||
@echo "=> Running pre-commit process" | ||
pre-commit: ## Run pre-commit hooks | ||
@echo "${INFO} Running pre-commit checks... π" | ||
@uv run pre-commit run --color=always --all-files | ||
@echo "=> Pre-commit complete" | ||
@echo "${OK} Pre-commit checks passed β¨" | ||
|
||
.PHONY: slotscheck | ||
slotscheck: ## Run slotscheck | ||
@echo "=> Running slotscheck" | ||
slotscheck: ## Run slotscheck | ||
@echo "${INFO} Running slots check... π" | ||
@uv run slotscheck -m litestar_vite | ||
@echo "=> slotscheck complete" | ||
@echo "${OK} Slots check passed β¨" | ||
|
||
.PHONY: fix | ||
fix: ## Run formatting scripts | ||
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 | ||
|
||
.PHONY: coverage | ||
coverage: ## Run the tests and generate coverage report | ||
@echo "=> Running tests with coverage" | ||
@uv run pytest --cov -n auto | ||
@uv run coverage html | ||
@uv run coverage xml | ||
@echo "=> Coverage report generated" | ||
|
||
.PHONY: test | ||
test: ## Run the tests | ||
@echo "=> Running test cases" | ||
@npm run test | ||
@uv run pytest -n 2 | ||
@echo "=> Tests complete" | ||
lint: pre-commit type-check slotscheck ## Run all linting checks | ||
|
||
.PHONY: check-all | ||
check-all: lint test coverage ## Run all linting, tests, and coverage checks | ||
|
||
check-all: lint test coverage ## Run all checks (lint, test, coverage) | ||
|
||
# ============================================================================= | ||
# Docs | ||
# Documentation | ||
# ============================================================================= | ||
docs-clean: ## Dump the existing built docs | ||
@echo "=> Cleaning documentation build assets" | ||
@rm -rf docs/_build | ||
@echo "=> Removed existing documentation build assets" | ||
|
||
docs-serve: docs-clean ## Serve the docs locally | ||
@echo "=> Serving documentation" | ||
uv run sphinx-autobuild docs docs/_build/ -j auto --watch src/py/litestar_vite --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002 | ||
.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 tests --watch CONTRIBUTING.rst --port 8002 | ||
|
||
docs: docs-clean ## Dump the existing built docs and rebuild them | ||
@echo "=> Building documentation" | ||
@uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going | ||
.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 >/dev/null 2>&1 | ||
@echo "${OK} Documentation built successfully" | ||
|
||
.PHONY: docs-linkcheck | ||
docs-linkcheck: ## Run the link check on the docs | ||
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 the full link check on the docs | ||
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" |
Oops, something went wrong.