# Minimal ASGI Example Makefile
# Demonstrates wilco integration with raw ASGI (no framework)

.PHONY: help install setup test build start-dev start-prod clean

# Environment
export VIRTUAL_ENV := $(CURDIR)/.venv

HTTP_PORT ?= 8500

help:
	@echo "Minimal ASGI Example"
	@echo ""
	@echo "Commands:"
	@echo "  make start-dev   - Start the development server"
	@echo "  make start-prod  - Start production server (pre-built components)"
	@echo "  make install     - Install Python dependencies"
	@echo "  make setup       - Set up database and fixtures"
	@echo "  make test        - Run tests"
	@echo "  make build       - Build for production (pre-compile components)"
	@echo "  make clean       - Clean up generated files"

install:
	uv sync

setup: install
	uv run python -m app.database setup

test:
	uv run pytest tests/ -v

build:  ## Build for production (pre-compile components)
	uv run python -m wilco build --output dist/wilco/ --components-dir ../common/components/store --prefix store

start-dev: setup  ## Start development server
	uv run uvicorn app.asgi:app --host 0.0.0.0 --port $(HTTP_PORT) --reload

start-prod: setup build  ## Start production server (pre-built components)
	uv run uvicorn app.asgi:app --host 0.0.0.0 --port $(HTTP_PORT)

clean:
	rm -rf .venv __pycache__ .pytest_cache dist
	rm -f resources/media/*.jpg resources/media/*.png
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
