-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
378 lines (309 loc) · 15.1 KB
/
Makefile
File metadata and controls
378 lines (309 loc) · 15.1 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# Aether Shield - Comprehensive Makefile
# Enterprise-Grade Network Security Platform
.PHONY: help install clean reset dev build start test lint format typecheck
.PHONY: quick-start status health docker db db-migrate db-studio db-seed
.PHONY: go-server go-build go-test go-clean go-install-deps go-secrets
.PHONY: packages packages-dev packages-build packages-test
.PHONY: github-app golang-sdk nodejs-sdk python-sdk
.PHONY: docker-build docker-build-dev docker-run docker-run-dev docker-stop
.PHONY: docker-logs docker-shell docker-clean docker-clean-all docker-version
.PHONY: docker-up docker-down docker-rebuild
.PHONY: version-packages changeset monitoring monitoring-stop security-scan docs-serve ci
# Default target
.DEFAULT_GOAL := help
# Variables
PNPM := pnpm
NODE_VERSION := 18.0.0
GO_VERSION := 1.21
PORT_FRONTEND := 3000
PORT_BACKEND := 8080
DOCKERFILE := infrastructure/docker/Dockerfile
DOCKER_COMPOSE := docker-compose
DOCKER := docker
# Colors for output
BLUE := \033[36m
GREEN := \033[32m
YELLOW := \033[33m
RED := \033[31m
RESET := \033[0m
## 🚀 Quick Start & Development
help: ## Show all available commands
@echo "$(BLUE)🛡️ Aether Shield - Enterprise Network Security$(RESET)"
@echo ""
@echo "$(GREEN)🚀 Quick Start:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Quick Start/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🔧 Development:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Development/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🏗️ Build & Production:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Build/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)📦 Package Ecosystem:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Package/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🗄️ Database:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Database/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🐹 Go Backend:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Go/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🐳 Docker & Deployment:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Docker/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🔧 Code Quality:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Code/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(GREEN)🛠️ Utilities:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && /Utilities/ {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
quick-start: ## Quick Start - Install, migrate, and start dev servers
@echo "$(BLUE)🚀 Quick Start - Aether Shield$(RESET)"
@echo "$(YELLOW)Installing dependencies...$(RESET)"
@$(MAKE) install
@echo "$(YELLOW)Setting up environment...$(RESET)"
@$(MAKE) env-dev
@echo "$(YELLOW)Running database migrations...$(RESET)"
@$(MAKE) db-migrate
@echo "$(YELLOW)Starting development servers...$(RESET)"
@$(MAKE) dev
## 🏗️ Development Commands
dev: ## Development - Start all services (frontend + backend)
@echo "$(BLUE)🔧 Starting all development services...$(RESET)"
@$(PNPM) dev
dev-frontend: ## Development - Start frontend only (port 3000)
@echo "$(BLUE)🎨 Starting frontend development server...$(RESET)"
@$(PNPM) dev:frontend
dev-backend: ## Development - Start backend only (port 8080)
@echo "$(BLUE)⚙️ Starting backend development server...$(RESET)"
@$(PNPM) dev:backend
dev-github: ## Development - Start GitHub App development
@echo "$(BLUE)🚀 Starting GitHub App development server...$(RESET)"
@cd package/github && $(PNPM) dev
## 🔧 Installation & Setup
install: ## Install - Install all dependencies
@echo "$(BLUE)📦 Installing all dependencies...$(RESET)"
@$(PNPM) install
env-dev: ## Environment - Setup development environment
@echo "$(BLUE)🔧 Setting up development environment...$(RESET)"
@if [ ! -f .env.local ]; then cp .env.example .env.local; echo "$(GREEN)✅ Created .env.local$(RESET)"; fi
reset: ## Reset - Clean and reinstall everything
@echo "$(BLUE)🔄 Resetting project...$(RESET)"
@$(MAKE) clean
@$(MAKE) install
## 🏗️ Build & Production
build: ## Build - Build all packages
@echo "$(BLUE)🏗️ Building all packages...$(RESET)"
@$(PNPM) build
build-frontend: ## Build - Build frontend only
@echo "$(BLUE)🎨 Building frontend...$(RESET)"
@$(PNPM) build:frontend
build-backend: ## Build - Build backend only
@echo "$(BLUE)⚙️ Building backend...$(RESET)"
@$(PNPM) build:backend
build-cli: ## Build - Build CLI only
@echo "$(BLUE)🛠️ Building CLI...$(RESET)"
@$(PNPM) build:cli
start: ## Start - Start production servers
@echo "$(BLUE)🚀 Starting production servers...$(RESET)"
@$(PNPM) start
## 📦 Package Ecosystem
packages: ## Package - Build all packages
@echo "$(BLUE)📦 Building all packages...$(RESET)"
@cd package/github && $(PNPM) build
@cd package/golang && go build
@cd package/node && $(PNPM) build
@cd package/python && python -m build
packages-dev: ## Package - Start all packages in development mode
@echo "$(BLUE)📦 Starting all packages in development...$(RESET)"
@concurrently "cd package/github && pnpm dev" "cd package/golang && go run main.go" "cd package/node && pnpm dev"
packages-test: ## Package - Test all packages
@echo "$(BLUE)📧 Testing all packages...$(RESET)"
@cd package/github && $(PNPM) test
@cd package/golang && go test
@cd package/node && $(PNPM) test
@cd package/python && python -m pytest
github-app: ## Package - Start GitHub App development
@echo "$(BLUE)🚀 Starting GitHub App...$(RESET)"
@cd package/github && $(PNPM) dev
golang-sdk: ## Package - Build Go SDK
@echo "$(BLUE)🐹 Building Go SDK...$(RESET)"
@cd package/golang && go build
nodejs-sdk: ## Package - Build Node.js SDK
@echo "$(BLUE)📦 Building Node.js SDK...$(RESET)"
@cd package/node && $(PNPM) build
python-sdk: ## Package - Build Python SDK
@echo "$(BLUE)🐍 Building Python SDK...$(RESET)"
@cd package/python && python -m build
## 🗄️ Database Commands
db-migrate: ## Database - Run migrations
@echo "$(BLUE)🗄️ Running database migrations...$(RESET)"
@$(PNPM) db:migrate
db-studio: ## Database - Open database studio
@echo "$(BLUE)🔍 Opening Prisma Studio...$(RESET)"
@$(PNPM) db:studio
db-seed: ## Database - Seed development data
@echo "$(BLUE)🌱 Seeding development data...$(RESET)"
@$(PNPM) db:seed
db-generate: ## Database - Generate Prisma client
@echo "$(BLUE)⚙️ Generating Prisma client...$(RESET)"
@$(PNPM) db:generate
## 🐹 Go Backend Commands
go-server: ## Go - Start Go server directly
@echo "$(BLUE)🐹 Starting Go server...$(RESET)"
@cd server && go run main.go
go-build: ## Go - Build Go binary
@echo "$(BLUE)🐹 Building Go binary...$(RESET)"
@cd server && go build -o bin/server main.go
go-test: ## Go - Run Go tests
@echo "$(BLUE)🧪 Running Go tests...$(RESET)"
@cd server && go test ./...
go-clean: ## Go - Clean Go build artifacts
@echo "$(BLUE)🧹 Cleaning Go artifacts...$(RESET)"
@cd server && rm -rf bin/
go-install-deps: ## Go - Install Go dependencies
@echo "$(BLUE)📦 Installing Go dependencies...$(RESET)"
@cd server && go mod download
go-secrets: ## Go - Generate JWT and encryption secrets for .env.example
@echo "$(BLUE)🔐 Generating new secrets for server/.env.example...$(RESET)"
@echo "$(YELLOW)Generating JWT secret...$(RESET)"
@JWT_SECRET=$$(openssl rand -base64 32 | tr -d '\n'); \
ENCRYPTION_KEY=$$(openssl rand -base64 24 | tr -d '\n'); \
sed -i.tmp "s/VAULT_JWT_SECRET=.*/VAULT_JWT_SECRET=$$JWT_SECRET/" server/.env.example; \
sed -i.tmp "s/VAULT_SECURITY_ENCRYPTION_KEY=.*/VAULT_SECURITY_ENCRYPTION_KEY=$$ENCRYPTION_KEY/" server/.env.example; \
rm -f server/.env.example.tmp
@echo "$(GREEN)✅ Secrets generated and updated in server/.env.example$(RESET)"
@echo "$(YELLOW)JWT Secret: $$(grep VAULT_JWT_SECRET server/.env.example | cut -d'=' -f2)$(RESET)"
@echo "$(YELLOW)Encryption Key: $$(grep VAULT_SECURITY_ENCRYPTION_KEY server/.env.example | cut -d'=' -f2)$(RESET)"
## 🐳 Docker Commands
docker-build: ## Docker - Build development image with hot-reload
@echo "$(BLUE)🏗️ Building Aether Shield development image...$(RESET)"
@$(DOCKER) build -t aether-shield-dev -f $(DOCKERFILE) .
@echo "$(GREEN)✅ Development image built: aether-shield-dev$(RESET)"
docker-run: ## Docker - Run development container with hot-reload
@echo "$(BLUE)🐳 Starting Aether Shield development container...$(RESET)"
@$(DOCKER) run -it --rm -p 3000:3000 -p 8080:8080 -v $(PWD):/app -v /app/node_modules aether-shield-dev
@echo "$(GREEN)✅ Aether Shield running in development mode with hot-reload$(RESET)"
@echo "$(GREEN)✅ Frontend: http://localhost:3000$(RESET)"
@echo "$(GREEN)✅ Backend API: http://localhost:8080$(RESET)"
docker-run-detached: ## Docker - Run development container in detached mode
@echo "$(BLUE)🐳 Starting Aether Shield development container in detached mode...$(RESET)"
@$(DOCKER) run -d --name aether-shield-dev -p 3000:3000 -p 8080:8080 -v $(PWD):/app -v /app/node_modules aether-shield-dev
@echo "$(GREEN)✅ Aether Shield running in detached mode$(RESET)"
docker-stop: ## Docker - Stop development container
@echo "$(BLUE)🛑 Stopping Aether Shield development container...$(RESET)"
@$(DOCKER) stop aether-shield-dev
@$(DOCKER) rm aether-shield-dev
@echo "$(GREEN)✅ Container stopped and removed$(RESET)"
docker-logs: ## Docker - Show development container logs
@echo "$(BLUE)📝 Showing Aether Shield development container logs...$(RESET)"
@$(DOCKER) logs -f aether-shield-dev
docker-shell: ## Docker - Get shell in running container
@echo "$(BLUE)🐚 Opening shell in Aether Shield container...$(RESET)"
@$(DOCKER) exec -it aether-shield-dev sh
docker-up: ## Docker - Start development environment with Docker Compose
@echo "$(BLUE)🐳 Starting Aether Shield development environment with Docker Compose...$(RESET)"
@cd infrastructure/docker && $(DOCKER_COMPOSE) -f docker-compose.dev.yml up --build
docker-down: ## Docker - Stop development environment
@echo "$(BLUE)🛑 Stopping Aether Shield development environment...$(RESET)"
@cd infrastructure/docker && $(DOCKER_COMPOSE) -f docker-compose.dev.yml down
docker-rebuild: ## Docker - Rebuild and restart development environment
@echo "$(BLUE)🔄 Rebuilding Aether Shield development environment...$(RESET)"
@cd infrastructure/docker && $(DOCKER_COMPOSE) -f docker-compose.dev.yml down -v
@cd infrastructure/docker && $(DOCKER_COMPOSE) -f docker-compose.dev.yml up --build --force-recreate
docker-clean: ## Docker - Clean all Docker artifacts
@echo "$(BLUE)🧹 Cleaning Docker artifacts...$(RESET)"
@$(DOCKER) system prune -f
@echo "$(GREEN)✅ Cleanup completed$(RESET)"
docker-clean-all: ## Docker - Remove all Aether Shield development resources
@echo "$(BLUE)🧹 Removing all Aether Shield development Docker resources...$(RESET)"
@$(DOCKER) rm -f aether-shield-dev 2>/dev/null || true
@$(DOCKER) rmi -f aether-shield-dev 2>/dev/null || true
@echo "$(GREEN)✅ All resources removed$(RESET)"
docker-version: ## Docker - Show version information
@echo "$(BLUE)📋 Aether Shield Infrastructure - Version Information$(RESET)"
@echo "$(GREEN)Docker version:$(RESET) $(shell docker --version)"
@echo "$(GREEN)Docker Compose version:$(RESET) $(shell docker-compose --version)"
@echo "$(GREEN)Available images:$(RESET)"
@$(DOCKER) images | grep aether-shield || echo " No Aether Shield images found"
## 🔧 Code Quality
lint: ## Code - Lint all packages
@echo "$(BLUE)🔍 Linting all packages...$(RESET)"
@$(PNPM) lint
lint-fix: ## Code - Fix linting issues
@echo "$(BLUE)🔧 Fixing linting issues...$(RESET)"
@$(PNPM) lint:fix
typecheck: ## Code - Type check all packages
@echo "$(BLUE)🔍 Type checking all packages...$(RESET)"
@$(PNPM) typecheck
format: ## Code - Format code with Prettier
@echo "$(BLUE)💅 Formatting code...$(RESET)"
@$(PNPM) format
test: ## Code - Run all tests
@echo "$(BLUE)🧪 Running all tests...$(RESET)"
@$(PNPM) test
## 🛠️ Utilities
clean: ## Utilities - Clean build artifacts and dependencies
@echo "$(BLUE)🧹 Cleaning project...$(RESET)"
@$(PNPM) clean
clean-build: ## Utilities - Clean build directories
@echo "$(BLUE)🧹 Cleaning build directories...$(RESET)"
@$(PNPM) clean:build
clean-deps: ## Utilities - Clean node_modules
@echo "$(BLUE)🧹 Cleaning dependencies...$(RESET)"
@$(PNPM) clean:deps
status: ## Utilities - Show project status
@echo "$(BLUE)📊 Project Status:$(RESET)"
@echo "$(GREEN)Node.js version:$(RESET) $(shell node --version)"
@echo "$(GREEN)pnpm version:$(RESET) $(shell pnpm --version)"
@echo "$(GREEN)Go version:$(RESET) $(shell go version)"
@echo "$(GREEN)Git branch:$(RESET) $(shell git branch --show-current)"
@echo "$(GREEN)Git status:$(RESET) $(shell git status --porcelain | wc -l) modified files"
health: ## Utilities - Check service health
@echo "$(BLUE)🏥 Checking service health...$(RESET)"
@if curl -s http://localhost:$(PORT_BACKEND)/health > /dev/null; then echo "$(GREEN)✅ Backend is healthy$(RESET)"; else echo "$(RED)❌ Backend is down$(RESET)"; fi
@if curl -s http://localhost:$(PORT_FRONTEND) > /dev/null; then echo "$(GREEN)✅ Frontend is running$(RESET)"; else echo "$(RED)❌ Frontend is down$(RESET)"; fi
cli: ## Utilities - Run CLI
@echo "$(BLUE)🛠️ Running Aether Shield CLI...$(RESET)"
@$(PNPM) cli
logs: ## Utilities - Show development logs
@echo "$(BLUE)📝 Showing development logs...$(RESET)"
@docker-compose logs -f
update: ## Utilities - Update all dependencies
@echo "$(BLUE)⬆️ Updating dependencies...$(RESET)"
@$(PNPM) update:all
install-deps: ## Utilities - Install all dependencies
@echo "$(BLUE)📦 Installing all dependencies...$(RESET)"
@$(PNPM) install:all
## 🚀 Release & Publishing
release: ## Release - Build and publish packages
@echo "$(BLUE)🚀 Building and releasing packages...$(RESET)"
@$(PNPM) release
version-packages: ## Release - Version packages
@echo "$(BLUE)📋 Versioning packages...$(RESET)"
@$(PNPM) version-packages
changeset: ## Release - Create changeset
@echo "$(BLUE)📝 Creating changeset...$(RESET)"
@$(PNPM) changeset
## 📊 Monitoring
monitoring: ## Monitoring - Start monitoring stack
@echo "$(BLUE)📊 Starting monitoring stack...$(RESET)"
@cd monitoring && docker-compose up -d
monitoring-stop: ## Monitoring - Stop monitoring stack
@echo "$(BLUE)🛑 Stopping monitoring stack...$(RESET)"
@cd monitoring && docker-compose down
## 🔐 Security
security-scan: ## Security - Run security scan
@echo "$(BLUE)🔒 Running security scan...$(RESET)"
@npm audit
@cd server && go mod audit
## 📚 Documentation
docs-serve: ## Documentation - Serve documentation locally
@echo "$(BLUE)📚 Serving documentation...$(RESET)"
@cd docs && $(PNPM) dev
## 🌐 CI/CD
ci: ## CI - Run CI pipeline locally
@echo "$(BLUE)🔄 Running CI pipeline...$(RESET)"
@$(MAKE) lint
@$(MAKE) typecheck
@$(MAKE) test
@$(MAKE) build