# Developer convenience targets (POSIX shells). Windows PowerShell: scripts/dev.ps1 <target>.
.PHONY: help bootstrap web dev test lint smoke backup restore

help:
	@echo "bootstrap  install Python (uv) and dashboard (npm) dependencies"
	@echo "web        build the dashboard into src/keyladder/static/app"
	@echo "dev        run the gateway on http://127.0.0.1:8787 (dashboard dev server: cd web && npm run dev)"
	@echo "test       run the test suite"
	@echo "lint       ruff check, ruff format --check, mypy (strict)"
	@echo "smoke      Docker build/up/health/down (scripts/docker-smoke.sh)"
	@echo "backup     write a backup archive to data/backups"
	@echo "restore    restore a backup: make restore FILE=path/to/backup.klbak [FORCE=1] (stop the server first)"

bootstrap:
	uv sync --locked
	cd web && npm ci

web:
	cd web && npm run build

dev:
	uv run keyladder serve

test:
	uv run pytest -q

lint:
	uv run ruff check
	uv run ruff format --check
	uv run mypy src/keyladder

smoke:
	scripts/docker-smoke.sh

backup:
	uv run keyladder backup

restore:
	@test -n "$(FILE)" || (echo "usage: make restore FILE=path/to/backup.klbak [FORCE=1]" && exit 2)
	uv run keyladder restore "$(FILE)" $(if $(FORCE),--force,)
