.PHONY: help install dev build test docker-up docker-down docker-logs docker-ps docker-build docker-restart docker-test clean

# Default target
help:
	@echo "Mosaic Stack - Available commands:"
	@echo ""
	@echo "Development:"
	@echo "  make install          Install dependencies"
	@echo "  make dev              Start development servers"
	@echo "  make build            Build all applications"
	@echo "  make test             Run all tests"
	@echo "  make lint             Run linters"
	@echo "  make format           Format code"
	@echo ""
	@echo "Docker:"
	@echo "  make docker-up              Start Docker services (core)"
	@echo "  make docker-up-full         Start Docker services (all)"
	@echo "  make docker-up-traefik      Start with bundled Traefik"
	@echo "  make docker-down            Stop Docker services"
	@echo "  make docker-logs            View Docker logs"
	@echo "  make docker-ps              Show Docker service status"
	@echo "  make docker-build           Rebuild Docker images"
	@echo "  make docker-restart         Restart Docker services"
	@echo "  make docker-test            Run Docker smoke test"
	@echo "  make docker-test-traefik    Run Traefik integration tests"
	@echo ""
	@echo "Database:"
	@echo "  make db-migrate       Run database migrations"
	@echo "  make db-seed          Seed development data"
	@echo "  make db-studio        Open Prisma Studio"
	@echo "  make db-reset         Reset database (WARNING: deletes data)"
	@echo ""
	@echo "Cleanup:"
	@echo "  make clean            Clean build artifacts"
	@echo "  make clean-all        Clean everything including node_modules"
	@echo "  make docker-clean     Remove Docker containers and volumes"

# Development
install:
	pnpm install

dev:
	pnpm dev

build:
	pnpm build

test:
	pnpm test

lint:
	pnpm lint

format:
	pnpm format

# Docker operations
docker-up:
	docker compose up -d

docker-up-full:
	docker compose --profile full up -d

docker-up-traefik:
	docker compose --profile traefik-bundled up -d

docker-down:
	docker compose down

docker-logs:
	docker compose logs -f

docker-ps:
	docker compose ps

docker-build:
	docker compose build

docker-restart:
	docker compose restart

docker-test:
	./scripts/test-docker-deployment.sh

docker-test-traefik:
	./tests/integration/docker/traefik.test.sh all

# Database operations
db-migrate:
	cd apps/api && pnpm prisma:migrate

db-seed:
	cd apps/api && pnpm prisma:seed

db-studio:
	cd apps/api && pnpm prisma:studio

db-reset:
	cd apps/api && pnpm prisma:reset

# Cleanup
clean:
	pnpm clean

clean-all:
	pnpm clean
	rm -rf node_modules

docker-clean:
	docker compose down -v
	docker system prune -f
