|
| 1 | +.PHONY: help build test clean docs serve-docs dev install-tools |
| 2 | + |
| 3 | +# Default target |
| 4 | +help: ## Show this help message |
| 5 | + @echo "Available targets:" |
| 6 | + @awk 'BEGIN {FS = ":.*##"; OFS = ": "} /^[a-zA-Z_-]+:.*##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
| 7 | + |
| 8 | +# Build the application |
| 9 | +build: ## Build the voiceflow-cli binary |
| 10 | + @echo "🔨 Building voiceflow-cli..." |
| 11 | + go build -o voiceflow-cli . |
| 12 | + |
| 13 | +# Run tests |
| 14 | +test: ## Run all tests |
| 15 | + @echo "🧪 Running tests..." |
| 16 | + go test -v ./... |
| 17 | + |
| 18 | +# Clean build artifacts |
| 19 | +clean: ## Clean build artifacts and generated files |
| 20 | + @echo "🧹 Cleaning up..." |
| 21 | + rm -f voiceflow-cli |
| 22 | + rm -rf dist/ |
| 23 | + |
| 24 | +# Install development tools |
| 25 | +install-tools: ## Install required development tools |
| 26 | + @echo "🔧 Installing development tools..." |
| 27 | + go install github.com/swaggo/swag/cmd/swag@latest |
| 28 | + go install github.com/go-swagger/go-swagger/cmd/swagger@latest |
| 29 | + @echo "✅ Development tools installed" |
| 30 | + |
| 31 | +# Generate API documentation |
| 32 | +docs: ## Generate OpenAPI/Swagger documentation |
| 33 | + @echo "📚 Generating API documentation..." |
| 34 | + ./scripts/cmd_docs.sh |
| 35 | + |
| 36 | +# Serve documentation locally (requires Python) |
| 37 | +serve-docs: docs ## Generate and serve documentation locally |
| 38 | + @echo "🌐 Starting documentation server..." |
| 39 | + @if command -v python3 >/dev/null 2>&1; then \ |
| 40 | + cd server/docs && python3 -m http.server 8000 & \ |
| 41 | + echo "📖 Documentation server started at http://localhost:8000"; \ |
| 42 | + echo " • swagger.json: http://localhost:8000/swagger.json"; \ |
| 43 | + echo " • swagger.yaml: http://localhost:8000/swagger.yaml"; \ |
| 44 | + echo "Press Ctrl+C to stop the server"; \ |
| 45 | + wait; \ |
| 46 | + else \ |
| 47 | + echo "❌ Python3 not found. Please install Python3 to serve docs locally."; \ |
| 48 | + echo " Alternatively, run 'make dev' to start the API server with Swagger UI"; \ |
| 49 | + fi |
| 50 | + |
| 51 | +# Development server with live reload |
| 52 | +dev: docs ## Build and run development server with Swagger UI |
| 53 | + @echo "🚀 Starting development server..." |
| 54 | + go run . server --debug --port 8080 |
| 55 | + @echo "🎉 Server started at http://localhost:8080" |
| 56 | + @echo "📖 Swagger UI available at http://localhost:8080/swagger/index.html" |
| 57 | + |
| 58 | +# Build for multiple platforms |
| 59 | +build-all: ## Build for multiple platforms |
| 60 | + @echo "🏗️ Building for multiple platforms..." |
| 61 | + GOOS=linux GOARCH=amd64 go build -o dist/voiceflow-cli-linux-amd64 . |
| 62 | + GOOS=darwin GOARCH=amd64 go build -o dist/voiceflow-cli-darwin-amd64 . |
| 63 | + GOOS=darwin GOARCH=arm64 go build -o dist/voiceflow-cli-darwin-arm64 . |
| 64 | + GOOS=windows GOARCH=amd64 go build -o dist/voiceflow-cli-windows-amd64.exe . |
| 65 | + @echo "✅ Multi-platform builds completed in dist/" |
| 66 | + |
| 67 | +# Run linting |
| 68 | +lint: ## Run linting |
| 69 | + @echo "🔍 Running linters..." |
| 70 | + @if command -v golangci-lint >/dev/null 2>&1; then \ |
| 71 | + golangci-lint run; \ |
| 72 | + else \ |
| 73 | + echo "⚠️ golangci-lint not found. Install it with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \ |
| 74 | + fi |
| 75 | + |
| 76 | +# Format code |
| 77 | +fmt: ## Format Go code |
| 78 | + @echo "✨ Formatting code..." |
| 79 | + go fmt ./... |
| 80 | + goimports -w . |
| 81 | + |
| 82 | +# Watch for changes and regenerate docs |
| 83 | +watch-docs: ## Watch for changes and regenerate docs automatically |
| 84 | + @echo "👀 Watching for changes to regenerate docs..." |
| 85 | + @if command -v fswatch >/dev/null 2>&1; then \ |
| 86 | + fswatch -o server/handlers/ server/server.go | xargs -n1 -I{} make docs; \ |
| 87 | + elif command -v inotifywait >/dev/null 2>&1; then \ |
| 88 | + while inotifywait -r -e modify server/handlers/ server/server.go; do make docs; done; \ |
| 89 | + else \ |
| 90 | + echo "❌ Neither fswatch nor inotifywait found."; \ |
| 91 | + echo " Install fswatch (macOS: brew install fswatch) or inotify-tools (Linux)"; \ |
| 92 | + fi |
| 93 | + |
| 94 | +# Validate OpenAPI spec |
| 95 | +validate-docs: docs ## Validate generated OpenAPI specification |
| 96 | + @echo "✅ Validating OpenAPI specification..." |
| 97 | + @if command -v swagger >/dev/null 2>&1; then \ |
| 98 | + swagger validate server/docs/swagger.yaml; \ |
| 99 | + else \ |
| 100 | + echo "⚠️ swagger CLI not found. Install it with: go install github.com/go-swagger/go-swagger/cmd/swagger@latest"; \ |
| 101 | + echo " Using basic validation..."; \ |
| 102 | + @if [ -f server/docs/swagger.json ]; then \ |
| 103 | + echo "📄 swagger.json exists and is valid JSON"; \ |
| 104 | + else \ |
| 105 | + echo "❌ swagger.json not found or invalid"; \ |
| 106 | + fi \ |
| 107 | + fi |
0 commit comments