# <<project_name>> — FastAPI service task runner (pure Make).
#
# Run `uv sync` then `make test` before committing.
#
#   make help     list targets
#   make install  uv sync (install deps into .venv)
#   make run      run the server (uv run python main.py)
#   make dev      run with hot-reload on (SERVER__RELOAD=true)
#   make test     pytest
#   make fmt      format (ruff format)
#   make lint     ruff check
#   make check    fmt-check + lint + test
#   make clean    remove caches / build artifacts

.DEFAULT_GOAL := help

.PHONY: help install run dev test fmt lint check clean

help: ## Show this help
	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort \
		| awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-10s\033[0m %s\n", $$1, $$2}'

install: ## Sync the environment (install deps into .venv)
	@uv sync

run: ## Run the FastAPI server (uv run python main.py)
	@uv run python main.py

dev: ## Run the server with hot-reload enabled
	@SERVER__RELOAD=true uv run python main.py

test: ## Run tests (pytest)
	@uv run pytest -q

fmt: ## Format code (ruff format)
	@uv run ruff format .

lint: ## Run ruff lint
	@uv run ruff check .

check: ## Full local verification (fmt-check + lint + test)
	@uv run ruff format --check .
	@uv run ruff check .
	@uv run pytest -q
	@echo "All checks passed."

clean: ## Remove caches / build artifacts
	@rm -rf __pycache__ .pytest_cache .ruff_cache logs/
	@find . -type d -name __pycache__ -prune -exec rm -rf {} + 2>/dev/null || true
