forked from smart-mcp-proxy/mcpproxy-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (111 loc) · 4.81 KB
/
Makefile
File metadata and controls
127 lines (111 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# MCPProxy Makefile
.PHONY: help build swagger swagger-verify frontend-build frontend-dev backend-dev clean test test-coverage test-e2e test-e2e-oauth lint dev-setup
SWAGGER_BIN ?= $(HOME)/go/bin/swag
SWAGGER_OUT ?= oas
SWAGGER_ENTRY ?= cmd/mcpproxy/main.go
# Default target
help:
@echo "MCPProxy Build Commands:"
@echo " make build - Build complete project (swagger + frontend + backend)"
@echo " make swagger - Generate OpenAPI specification"
@echo " make swagger-verify - Regenerate OpenAPI and fail if artifacts are dirty"
@echo " make frontend-build - Build frontend for production"
@echo " make frontend-dev - Start frontend development server"
@echo " make backend-dev - Build backend with dev flag (loads frontend from disk)"
@echo " make clean - Clean build artifacts"
@echo " make test - Run unit tests"
@echo " make test-coverage - Run tests with coverage"
@echo " make test-e2e - Run all E2E tests"
@echo " make test-e2e-oauth - Run OAuth E2E tests with Playwright"
@echo " make lint - Run linter"
@echo " make dev-setup - Install development dependencies (swag, frontend, Playwright)"
# Generate OpenAPI specification
swagger:
@echo "📚 Generating OpenAPI 3.1 specification..."
@[ -x "$(SWAGGER_BIN)" ] || { echo "⚠️ swag binary not found at $(SWAGGER_BIN). Run 'go install github.com/swaggo/swag/v2/cmd/swag@v2.0.0-rc4'"; exit 1; }
@mkdir -p $(SWAGGER_OUT)
$(SWAGGER_BIN) init -g $(SWAGGER_ENTRY) --output $(SWAGGER_OUT) --outputTypes go,yaml --v3.1 --exclude specs
@echo "✅ OpenAPI 3.1 spec generated: $(SWAGGER_OUT)/swagger.yaml and $(SWAGGER_OUT)/docs.go"
swagger-verify: swagger
@echo "🔎 Verifying OpenAPI artifacts are committed..."
@if git status --porcelain -- $(SWAGGER_OUT)/swagger.yaml $(SWAGGER_OUT)/docs.go | grep -q .; then \
echo "❌ OpenAPI artifacts are out of date. Run 'make swagger' and commit the regenerated files."; \
git diff --stat -- $(SWAGGER_OUT)/swagger.yaml $(SWAGGER_OUT)/docs.go || true; \
exit 1; \
fi
@echo "✅ OpenAPI artifacts are up to date."
# Build complete project
build: swagger frontend-build
@echo "🔨 Building Go binary with embedded frontend..."
go build -o mcpproxy ./cmd/mcpproxy
go build -o mcpproxy-tray ./cmd/mcpproxy-tray
@echo "✅ Build completed! Run: ./mcpproxy serve"
@echo "🌐 Web UI: http://localhost:8080/ui/"
@echo "📚 API Docs: http://localhost:8080/swagger/"
# Build frontend for production
frontend-build:
@echo "🎨 Generating TypeScript types from Go contracts..."
go run ./cmd/generate-types
@echo "🎨 Building frontend for production..."
cd frontend && npm install && npm run build
@echo "📁 Copying dist files for embedding..."
rm -rf web/frontend
mkdir -p web/frontend
cp -r frontend/dist web/frontend/
@echo "✅ Frontend build completed"
# Start frontend development server
frontend-dev:
@echo "🎨 Starting frontend development server..."
cd frontend && npm install && npm run dev
# Build backend with dev flag (for development with frontend hot reload)
backend-dev:
@echo "🔨 Building backend in development mode..."
go build -tags dev -o mcpproxy-dev ./cmd/mcpproxy
@echo "✅ Development backend ready!"
@echo "🚀 Run: ./mcpproxy-dev serve"
@echo "🌐 In dev mode, make sure frontend dev server is running on port 3000"
# Clean build artifacts
clean:
@echo "🧹 Cleaning build artifacts..."
rm -f mcpproxy mcpproxy-dev mcpproxy-tray
rm -rf frontend/dist frontend/node_modules web/frontend
go clean
@echo "✅ Cleanup completed"
# Run tests
test:
@echo "🧪 Running Go tests..."
go test ./internal/... -v
@echo "🧪 Running frontend tests..."
cd frontend && npm install && npm run test
# Run tests with coverage
test-coverage:
@echo "🧪 Running tests with coverage..."
go test -coverprofile=coverage.out ./internal/...
go tool cover -html=coverage.out -o coverage.html
cd frontend && npm install && npm run coverage
# Run linter
lint:
@echo "🔍 Running Go linter..."
golangci-lint run ./...
@echo "🔍 Running frontend linter..."
cd frontend && npm install && npm run lint
# Install development dependencies
dev-setup:
@echo "🛠️ Setting up development environment..."
@echo "📦 Installing swag (OpenAPI generator)..."
go install github.com/swaggo/swag/v2/cmd/swag@v2.0.0-rc4
@echo "📦 Installing frontend dependencies..."
cd frontend && npm install
@echo "📦 Installing Playwright E2E test dependencies..."
cd e2e/playwright && npm install
@echo "📦 Installing Playwright browsers..."
cd e2e/playwright && npx playwright install chromium
@echo "✅ Development setup completed"
# Run OAuth E2E tests with Playwright
test-e2e-oauth:
@echo "🧪 Running OAuth E2E tests..."
./scripts/run-oauth-e2e.sh
# Run all E2E tests
test-e2e: test-e2e-oauth
@echo "🧪 Running E2E tests..."
./scripts/test-api-e2e.sh