# Makefile for forj — a stdlib-only CLI for Forgejo/Gitea/Codeberg REST APIs.

.PHONY: help install format lint typecheck test test-cov gates gates-fix clean

VENV = .venv
PYTHON = $(VENV)/bin/python
PIP = $(VENV)/bin/pip

help:
	@echo "forj developer targets:"
	@echo "  make install    - Create the venv and install forj + dev tools (editable)"
	@echo "  make format     - Apply code formatting (ruff format)"
	@echo "  make lint       - Run ruff / pylint / bandit / vulture / interrogate"
	@echo "  make typecheck  - Run the strict type-checker (pyright)"
	@echo "  make test       - Run the test suite (pytest)"
	@echo "  make test-cov   - Run tests with a terminal coverage report"
	@echo "  make gates      - Run the full check-only quality gate suite"
	@echo "  make gates-fix  - Run the gates with auto-formatting applied"
	@echo "  make clean      - Remove build/coverage/cache artifacts"

install: $(VENV)/bin/activate
$(VENV)/bin/activate: pyproject.toml
	python3 -m venv $(VENV)
	$(PIP) install --upgrade pip
	$(PIP) install -e '.[dev]'
	$(VENV)/bin/pre-commit install
	@echo "✓ venv ready and pre-commit hook installed."

format: install
	$(VENV)/bin/ruff format .

lint: install
	$(VENV)/bin/ruff check .
	$(VENV)/bin/pylint src/forj scripts
	$(VENV)/bin/bandit -r src scripts
	$(VENV)/bin/vulture src tests scripts vulture_whitelist.py
	$(VENV)/bin/interrogate src scripts

typecheck: install
	$(VENV)/bin/pyright

test: install
	$(VENV)/bin/pytest

test-cov: install
	$(VENV)/bin/pytest --cov=forj --cov-report=term-missing

gates: install
	$(PYTHON) scripts/gates.py

gates-fix: install
	$(PYTHON) scripts/gates.py --fix

clean:
	rm -rf build/ dist/ *.egg-info/ .coverage .pytest_cache/ .ruff_cache/
	find . -type d -name "__pycache__" -exec rm -rf {} +
	@echo "✓ caches cleared."
