.PHONY: help install build publish format locales deps-check

install:  ## Install Python dependencies with uv.
	uv sync
	uv run pre-commit install

build: format locales ## Build the package.
	rm -rf dist
	uv build

publish: build ## Publish the package to pypi.org.
	uv publish

format: ## Format Python sources with Ruff.
	uv run ruff check --fix
	uv run ruff format ./

deps-check: ## Scan locked dependencies for vulnerabilities with OSV Scanner.
	osv-scanner scan source --lockfile=uv.lock

locales:  ## Generate Gettext files.
	@uv run python manage.py makemessages --ignore .venv --ignore "*.txt" --ignore dist --ignore manage.py --locale=en --no-wrap
	@sed -i.bak '/#, fuzzy/d' 	modshib/locale/en/LC_MESSAGES/django.po && rm modshib/locale/en/LC_MESSAGES/django.po.bak
	@echo "Compiling translation files"
	@uv run python manage.py compilemessages -v 0

help: ## Show this help.
	@awk 'BEGIN {FS = ":.*##"; printf "\nDjango CERTIC modshib:\n\n"} /^[a-zA-Z0-9_-]+:.*##/ {printf "  %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
