# PicoBot Web UI Makefile

.PHONY: dev dev-backend dev-frontend build clean install

# Default target
all: build

# Install dependencies
install:
	@echo "Installing frontend dependencies..."
	cd web && npm install

# Development - start both backend and frontend
dev:
	@echo "Starting development servers..."
	@make dev-backend &
	@sleep 3
	@make dev-frontend
	@wait

# Start backend only
dev-backend:
	@echo "Starting Rust backend..."
	cargo run -- gateway

# Start frontend only
dev-frontend:
	@echo "Starting frontend dev server..."
	cd web && npm run dev

# Build for production
build:
	@echo "Building PicoBot Web UI..."
	cd web && npm run build
	cargo build --release
	@echo "Build complete!"

# Run production build
run:
	cargo run --release -- gateway

# Clean build artifacts
clean:
	@echo "Cleaning build artifacts..."
	rm -rf static/*
	cd web && rm -rf dist node_modules
	cargo clean

# Check code formatting and linting
check:
	@echo "Checking frontend..."
	cd web && npm run build
	@echo "Checking Rust code..."
	cargo check
	cargo clippy

# Help
help:
	@echo "PicoBot Web UI Makefile"
	@echo ""
	@echo "Available targets:"
	@echo "  make install      - Install frontend dependencies"
	@echo "  make dev          - Start both backend and frontend (development)"
	@echo "  make dev-backend  - Start Rust backend only"
	@echo "  make dev-frontend - Start frontend dev server only"
	@echo "  make build        - Build for production"
	@echo "  make run          - Run production build"
	@echo "  make clean        - Clean build artifacts"
	@echo "  make check        - Check code formatting and linting"
	@echo "  make help         - Show this help message"
