.PHONY: install dev_back dev_front dev test docker docker-build release

# Installe les dependances backend + frontend (a refaire par worktree)
install:
	uv sync
	cd frontend && npm install

# Backend avec auto-reload uvicorn
dev_back:
	uv run plesna-gerance serve --reload

# Frontend avec hot-reload Vite
dev_front:
	cd frontend && npm run dev

# Lance les deux en parallèle
dev:
	$(MAKE) dev_back & $(MAKE) dev_front & wait

# Ce que la CI verifie avant de publier une image (cf. .gitea/workflows)
test:
	uv run ruff check .
	uv run pytest
	cd frontend && npm test

# Tire l'image publiee (registre Gitea) et lance via podman-compose
docker:
	podman-compose pull
	podman-compose up -d

# Construit l'image en local (test avant publication)
docker-build:
	podman build -f backend.Dockerfile -t plesna-gerance:local .

# Pose une version : aligne les fichiers, commite, tague (sans pousser).
# Usage : make release VERSION=0.2.0
release:
	@test -n "$(VERSION)" || { echo "Usage : make release VERSION=0.2.0"; exit 1; }
	uv run python scripts/release.py $(VERSION)
