.PHONY: help init plan apply destroy output clean backend-setup setup-backend deploy-frontend dev test test-local install-deps lint format help: ## Show this help message @echo "Available targets:" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' # ===== Infrastructure ===== backend-setup: ## Set up S3 backend infrastructure (run this first) cd infra && terraform init cd infra && terraform apply -target=aws_s3_bucket.terraform_state -target=aws_dynamodb_table.terraform_state_lock -auto-approve setup-backend: ## Configure Terraform to use S3 backend (run after backend-setup) cd infra && sed -i 's/# backend "s3" {/backend "s3" {/' versions.tf cd infra && sed -i 's/# bucket/ bucket/' versions.tf cd infra && sed -i 's/# key/ key/' versions.tf cd infra && sed -i 's/# region/ region/' versions.tf cd infra && sed -i 's/# dynamodb_table/ dynamodb_table/' versions.tf cd infra && sed -i 's/# encrypt/ encrypt/' versions.tf cd infra && sed -i 's/# }/}/' versions.tf cd infra && terraform init -migrate-state init: ## Initialize Terraform cd infra && terraform init plan: ## Show Terraform plan cd infra && terraform plan apply: ## Apply Terraform changes cd infra && terraform apply -auto-approve destroy: ## Destroy Terraform infrastructure cd infra && terraform destroy -auto-approve output: ## Show Terraform outputs cd infra && terraform output clean: ## Clean up Terraform state and lock files cd infra && rm -f .terraform.lock.hcl cd infra && rm -rf .terraform/ deploy-frontend: ## Deploy frontend files to S3 bucket aws s3 sync public/ s3://calculator-127local-net --delete --exclude "*.DS_Store" --exclude "*.tmp" aws cloudfront create-invalidation --distribution-id E35YHG58GE55V5 --paths "/*" deploy: backend-setup setup-backend plan apply output ## Full deployment pipeline with backend setup # ===== Local Development ===== dev: ## Start local development server PORT=8008 python dev_server.py dev-server: dev ## Alias for dev target # ===== Testing ===== test: ## Run all tests (requires local dev server running) pytest tests/ -v test-local: ## Run tests with local dev server (starts server, runs tests, stops server) @echo "Starting local development server..." @python dev_server.py & @echo "Waiting for server to start..." @sleep 3 @echo "Running tests..." @pytest tests/ -v @echo "Stopping server..." @pkill -f "python dev_server.py" || true test-watch: ## Run tests in watch mode (requires local dev server) pytest tests/ -v -f --tb=short # ===== Dependencies ===== venv: ## Create virtual environment python3 -m venv venv @echo "Virtual environment created. Activate with: source venv/bin/activate" install-deps: venv ## Install Python development dependencies in virtual environment @echo "Installing dependencies in virtual environment..." venv/bin/pip install -r requirements.txt @echo "Dependencies installed. Activate virtual environment with: source venv/bin/activate" install-test-deps: install-deps ## Alias for install-deps activate: ## Show activation command @echo "To activate virtual environment, run:" @echo "source venv/bin/activate" @echo "" @echo "Then you can run:" @echo "make test" @echo "make dev" # ===== Code Quality ===== lint: ## Run code linting and style checks @echo "Checking Python files..." @python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || true @echo "Checking JavaScript files..." @echo "Note: Consider adding ESLint for JavaScript linting" format: ## Format Python code (requires black) @echo "Formatting Python files..." @python -m black . --check || echo "Black not installed. Install with: pip install black" format-fix: ## Format Python code and fix issues (requires black) @echo "Formatting Python files..." @python -m black . || echo "Black not installed. Install with: pip install black" # ===== Utility ===== clean-all: clean ## Clean all generated files @echo "Cleaning Python cache..." @find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true @find . -type f -name "*.pyc" -delete 2>/dev/null || true @echo "Cleaning test cache..." @rm -rf .pytest_cache/ || true status: ## Show current project status @echo "=== Project Status ===" @echo "Python version: $(shell python --version)" @echo "Pip packages: $(shell pip list | grep -E "(pytest|selenium)" || echo "Test dependencies not installed")" @echo "Local server: $(shell pgrep -f 'python dev_server.py' >/dev/null && echo 'Running' || echo 'Not running')" @echo "Terraform: $(shell cd infra && terraform version 2>/dev/null | head -1 || echo 'Not initialized')" # ===== Quick Development Workflow ===== dev-test: dev test ## Start dev server and run tests (in separate terminals) @echo "Development server started. Run 'make test' in another terminal to run tests." quick-test: ## Quick test run (assumes server is running) pytest tests/ -v -x --tb=short # ===== Documentation ===== docs: ## Generate documentation (placeholder) @echo "Documentation generation not yet implemented" @echo "Consider adding Sphinx or similar for documentation" help-dev: ## Show development-specific help @echo "=== Development Commands ===" @echo "make dev - Start local development server" @echo "make test - Run tests (requires server running)" @echo "make test-local - Start server, run tests, stop server" @echo "make install-deps - Install test dependencies" @echo "make lint - Run code quality checks" @echo "make format - Check code formatting" @echo "make status - Show project status"