.PHONY: format
format:
	@uv run ruff format .
	@uv run ruff check . --fix --unsafe-fixes
	@uv run ruff format .
	@make lint-md

.PHONY: check
check:
	@uv run ruff check .
	@uv run mypy .
	@uv run complexipy

.PHONY: test
test:
	@uv run pytest

.PHONY: sync
sync:
	@uv sync --all-extras

.PHONY: lint-md
lint-md: 
	@command -v markdownlint-cli2 > /dev/null 2>&1 && markdownlint-cli2 "**/*.md" || true

.PHONY: build
build: clean
	@uv run python -m build
	@twine check dist/*

.PHONY: release-test
release-test: build
	@twine upload --repository testpypi dist/*

.PHONY: release
release: build
	@twine upload --verbose dist/*
	
.PHONY: clean
clean:
	@rm -rf dist/ build/ *.egg-info
	@find . -type d -name "__pycache__" -exec rm -rf {} +
	@find . -type d -name ".pytest_cache" -exec rm -rf {} +
	@find . -type d -name ".mypy_cache" -exec rm -rf {} +
	@find . -type d -name ".ruff_cache" -exec rm -rf {} +
	@find . -type d -name ".uv" -exec rm -rf {} +