.PHONY: test preflight release tag versions build publish site-build site-dev site-deploy site-deploy-preview

test:
	PYTHONPATH=src uv run pytest tests/ -v

# Everything checkable without leaving the machine: clean tree, generated schema
# in sync with the models, schema published under its version, changelog dated,
# tag not already taken.
preflight:
	uv run scripts/preflight.py

# One command from a clean tree to artefacts ready to ship. The three steps that
# touch the outside world — deploy, tag, publish — stay manual and are printed.
release: preflight test site-build build
	@echo
	@echo "Artefacts built. To ship:"
	@echo "  make site-deploy"
	@echo "  make tag && git push --tags"
	@echo "  make publish"

# Two version lines, two tag namespaces: spec/vX.Y.Z for the format,
# python/vX.Y.Z for the library. scripts/versions.py is the single source for
# both numbers and both tag names, so this cannot drift from what preflight checks.
tag:
	uv run scripts/versions.py --tag

versions:
	uv run scripts/versions.py

build:
	rm -rf dist
	uvx --from build pyproject-build --installer uv

publish: build
	uvx twine upload dist/*

site-build:
	uv run scripts/build_site.py
	cd website && npm install --silent
	cd website && node build-validator.js
	cd website && uv run zensical build

# Live-reload dev server for content and template editing.
# To test with the API: make site-build && cd website && npx wrangler pages dev site
site-dev:
	uv run scripts/build_site.py
	cd website && uv run zensical serve -a localhost:8005

site-deploy: site-build
	cd website && npx wrangler pages deploy site --project-name structuredworkoutformat

site-deploy-preview: site-build
	cd website && npx wrangler pages deploy site --project-name structuredworkoutformat --branch preview
