|
1 | | -.PHONY: help docs docs-serve docs-clean website website-dev website-build |
| 1 | +.PHONY: help docs docs-serve docs-clean website website-dev website-build dev |
2 | 2 |
|
3 | 3 | help: ## Show this help message |
4 | 4 | @echo 'Usage: make [target]' |
5 | 5 | @echo '' |
6 | 6 | @echo 'Available targets:' |
7 | 7 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' |
8 | 8 |
|
| 9 | +dev: ## Start development environment with Air (backend) and Vite (frontend) |
| 10 | + @echo "🚀 Starting development environment..." |
| 11 | + @# Ensure air is installed |
| 12 | + @if ! command -v air >/dev/null 2>&1; then \ |
| 13 | + echo "⚠️ 'air' command not found."; \ |
| 14 | + echo "📦 Auto-installing 'air' for live reload..."; \ |
| 15 | + GOPATH=$$(go env GOPATH); \ |
| 16 | + if [[ ":$$PATH:" != *":$$GOPATH/bin:"* ]]; then \ |
| 17 | + echo "⚠️ $$GOPATH/bin is not in your PATH. Adding it temporarily..."; \ |
| 18 | + export PATH=$$PATH:$$GOPATH/bin; \ |
| 19 | + fi; \ |
| 20 | + go install github.com/air-verse/air@latest; \ |
| 21 | + if ! command -v air >/dev/null 2>&1; then \ |
| 22 | + echo "❌ Failed to install 'air'. Falling back to 'go run'..."; \ |
| 23 | + USE_GO_RUN=true; \ |
| 24 | + else \ |
| 25 | + echo "✅ 'air' installed successfully."; \ |
| 26 | + USE_GO_RUN=false; \ |
| 27 | + fi; \ |
| 28 | + else \ |
| 29 | + USE_GO_RUN=false; \ |
| 30 | + fi; \ |
| 31 | + \ |
| 32 | + mkdir -p internal/web/dist; \ |
| 33 | + if [ -z "$$(ls -A internal/web/dist)" ]; then \ |
| 34 | + echo "📄 Creating placeholder files for Go embed..."; \ |
| 35 | + echo "<!-- Placeholder for development -->" > internal/web/dist/index.html; \ |
| 36 | + echo "placeholder" > internal/web/dist/dummy_asset; \ |
| 37 | + fi; \ |
| 38 | + \ |
| 39 | + trap 'echo ""; echo "🛑 Stopping development servers..."; kill 0; exit 0' INT TERM; \ |
| 40 | + \ |
| 41 | + if [ "$$USE_GO_RUN" = true ]; then \ |
| 42 | + echo "🔧 Starting Go backend (standard run)..."; \ |
| 43 | + go run cmd/server/main.go & \ |
| 44 | + else \ |
| 45 | + echo "🔥 Starting Go backend (with Air live reload)..."; \ |
| 46 | + air & \ |
| 47 | + fi; \ |
| 48 | + \ |
| 49 | + echo "⚛️ Starting React frontend (Vite)..."; \ |
| 50 | + cd web/frontend && npm run dev & \ |
| 51 | + \ |
| 52 | + wait |
| 53 | + |
9 | 54 | docs: ## Generate API documentation from Go code annotations |
10 | 55 | @echo "Generating API documentation..." |
11 | 56 | @command -v swag >/dev/null 2>&1 || { echo "Error: swag not installed. Run: go install github.com/swaggo/swag/cmd/swag@latest"; exit 1; } |
|
0 commit comments