.PHONY: help install dev test lint format type migrate migrate-fresh clean

help:
	@echo "artifact-store — make targets"
	@echo "  install        install / sync dependencies via uv"
	@echo "  dev            run the FastAPI app with reload (uvicorn)"
	@echo "  test           run the pytest suite"
	@echo "  lint           ruff check + ruff format --check"
	@echo "  format         ruff format (write changes)"
	@echo "  type           mypy --strict over src and tests"
	@echo "  migrate        alembic upgrade head"
	@echo "  migrate-fresh  drop the local SQLite DB and re-run migrations"
	@echo "  clean          remove caches and build artefacts"

install:
	uv sync --all-extras

dev:
	uv run uvicorn artifactstore.api.http:app --reload --host 127.0.0.1 --port 8000

test:
	uv run pytest

lint:
	uv run ruff check .
	uv run ruff format --check .

format:
	uv run ruff format .
	uv run ruff check --fix .

type:
	uv run mypy

migrate:
	@mkdir -p var
	uv run alembic upgrade head

migrate-fresh:
	@rm -f var/artifactstore.db var/artifactstore.db-journal
	@mkdir -p var
	uv run alembic upgrade head

clean:
	rm -rf .pytest_cache .mypy_cache .ruff_cache build dist *.egg-info
	find . -type d -name __pycache__ -prune -exec rm -rf {} +
