.DEFAULT_GOAL := check

# Run the full local check suite — same order as CI would.
check: fmt-check clippy test
	@echo "✅ All checks passed"

# Apply rustfmt to all files.
fmt:
	cargo fmt

# Check formatting without modifying files (CI-safe).
fmt-check:
	cargo fmt --check

# Run Clippy and treat warnings as errors.
clippy:
	cargo clippy -- -D warnings

# Run the test suite.
test:
	cargo test

# Apply fmt + clippy auto-fixes in one shot.
fix:
	cargo fmt
	cargo clippy --fix --allow-dirty --allow-staged

# Build the frontend SPA.
build-app:
	cd app && npm run build

# Run the backend (builds frontend first if needed).
dev: build-app
	JWT_SECRET=dev-secret ALLOW_REGISTRATION=true cargo run -p presentation

# Run backend only (skip frontend build, assumes build-app was run).
dev-api:
	JWT_SECRET=dev-secret ALLOW_REGISTRATION=true cargo run -p presentation

# Build and push Docker image to private registry.
deploy:
	./deploy.sh

.PHONY: check fmt fmt-check clippy test fix build-app dev dev-api deploy
