-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
245 lines (203 loc) · 9.6 KB
/
Copy pathMakefile
File metadata and controls
245 lines (203 loc) · 9.6 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
.PHONY: help install install-python install-frontend dev dev-services dev-web \
test test-python test-frontend test-coverage \
lint lint-python lint-frontend \
format format-python format-frontend \
type-check type-check-python type-check-frontend \
check clean docker-up docker-down migrate \
deploy-all
# Default target
.DEFAULT_GOAL := help
# Colors for output
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m # No Color
help: ## Show this help message
@echo "$(BLUE)ASDEFCON Platform - Available Commands$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
# Installation targets
install: install-python install-frontend ## Install all dependencies
install-python: ## Install Python dependencies for all services
@echo "$(BLUE)Installing Python dependencies...$(NC)"
@cd services/document-service && uv sync
@cd services/clause-service && uv sync
@cd services/compliance-service && uv sync
@cd services/collaboration-service && uv sync
@cd services/export-service && uv sync
@echo "$(GREEN)✓ Python dependencies installed$(NC)"
install-frontend: ## Install frontend dependencies
@echo "$(BLUE)Installing frontend dependencies...$(NC)"
@cd apps/web && npm install
@cd packages/shared && npm install
@cd packages/api-contracts && npm install
@echo "$(GREEN)✓ Frontend dependencies installed$(NC)"
# Development targets
dev: ## Start all services in development mode
@echo "$(BLUE)Starting all services...$(NC)"
@make -j6 dev-document-service dev-clause-service dev-compliance-service dev-collaboration-service dev-export-service dev-web
dev-services: ## Start all backend services
@make -j5 dev-document-service dev-clause-service dev-compliance-service dev-collaboration-service dev-export-service
dev-document-service: ## Start document service
@cd services/document-service && make dev
dev-clause-service: ## Start clause service
@cd services/clause-service && make dev
dev-compliance-service: ## Start compliance service
@cd services/compliance-service && make dev
dev-collaboration-service: ## Start collaboration service
@cd services/collaboration-service && make dev
dev-export-service: ## Start export service
@cd services/export-service && make dev
dev-web: ## Start frontend application
@cd apps/web && npm run dev
# Testing targets
test: test-python test-frontend ## Run all tests
test-python: ## Run Python tests for all services
@echo "$(BLUE)Running Python tests...$(NC)"
@cd services/document-service && make test
@cd services/clause-service && make test
@cd services/compliance-service && make test
@cd services/collaboration-service && make test
@cd services/export-service && make test
@echo "$(GREEN)✓ All Python tests passed$(NC)"
test-frontend: ## Run frontend tests
@echo "$(BLUE)Running frontend tests...$(NC)"
@cd apps/web && npm test
@echo "$(GREEN)✓ Frontend tests passed$(NC)"
test-coverage: ## Run tests with coverage report
@echo "$(BLUE)Running tests with coverage...$(NC)"
@cd services/document-service && make test-coverage
@cd services/clause-service && make test-coverage
@cd services/compliance-service && make test-coverage
@cd services/collaboration-service && make test-coverage
@cd services/export-service && make test-coverage
@cd apps/web && npm run test:coverage
test-integration: ## Run integration tests
@echo "$(BLUE)Running integration tests...$(NC)"
@cd services/document-service && make test-integration
@cd services/clause-service && make test-integration
@cd services/compliance-service && make test-integration
@cd services/collaboration-service && make test-integration
@cd services/export-service && make test-integration
test-e2e: ## Run end-to-end tests
@echo "$(BLUE)Running E2E tests...$(NC)"
@cd apps/web && npm run test:e2e
# Linting targets
lint: lint-python lint-frontend ## Run all linters
lint-python: ## Lint Python code
@echo "$(BLUE)Linting Python code...$(NC)"
@cd services/document-service && make lint
@cd services/clause-service && make lint
@cd services/compliance-service && make lint
@cd services/collaboration-service && make lint
@cd services/export-service && make lint
@echo "$(GREEN)✓ Python linting passed$(NC)"
lint-frontend: ## Lint frontend code
@echo "$(BLUE)Linting frontend code...$(NC)"
@cd apps/web && npm run lint
@echo "$(GREEN)✓ Frontend linting passed$(NC)"
# Formatting targets
format: format-python format-frontend ## Format all code
format-python: ## Format Python code
@echo "$(BLUE)Formatting Python code...$(NC)"
@cd services/document-service && make format
@cd services/clause-service && make format
@cd services/compliance-service && make format
@cd services/collaboration-service && make format
@cd services/export-service && make format
@echo "$(GREEN)✓ Python code formatted$(NC)"
format-frontend: ## Format frontend code
@echo "$(BLUE)Formatting frontend code...$(NC)"
@cd apps/web && npm run format
@echo "$(GREEN)✓ Frontend code formatted$(NC)"
# Type checking targets
type-check: type-check-python type-check-frontend ## Run all type checkers
type-check-python: ## Type check Python code
@echo "$(BLUE)Type checking Python code...$(NC)"
@cd services/document-service && make type-check
@cd services/clause-service && make type-check
@cd services/compliance-service && make type-check
@cd services/collaboration-service && make type-check
@cd services/export-service && make type-check
@echo "$(GREEN)✓ Python type checking passed$(NC)"
type-check-frontend: ## Type check frontend code
@echo "$(BLUE)Type checking frontend code...$(NC)"
@cd apps/web && npm run type-check
@echo "$(GREEN)✓ Frontend type checking passed$(NC)"
# Combined check target
check: lint type-check test ## Run all quality checks (lint, type-check, test)
@echo "$(GREEN)✓ All checks passed!$(NC)"
# Database targets
migrate: ## Run database migrations for all services
@echo "$(BLUE)Running database migrations...$(NC)"
@cd services/document-service && make migrate
@cd services/clause-service && make migrate
@cd services/compliance-service && make migrate
@cd services/collaboration-service && make migrate
@cd services/export-service && make migrate
@echo "$(GREEN)✓ Migrations completed$(NC)"
migrate-create: ## Create new migration (use SERVICE=service-name NAME=migration_name)
@if [ -z "$(SERVICE)" ] || [ -z "$(NAME)" ]; then \
echo "$(RED)Error: SERVICE and NAME required$(NC)"; \
echo "Usage: make migrate-create SERVICE=document-service NAME=add_user_table"; \
exit 1; \
fi
@cd services/$(SERVICE) && make migrate-create NAME=$(NAME)
# Docker targets
docker-up: ## Start Docker Compose services (PostgreSQL, Redis, etc.)
@echo "$(BLUE)Starting Docker services...$(NC)"
@docker-compose up -d
@echo "$(GREEN)✓ Docker services started$(NC)"
docker-down: ## Stop Docker Compose services
@echo "$(BLUE)Stopping Docker services...$(NC)"
@docker-compose down
@echo "$(GREEN)✓ Docker services stopped$(NC)"
docker-logs: ## Show Docker Compose logs
@docker-compose logs -f
docker-ps: ## Show running Docker containers
@docker-compose ps
# Deployment targets
deploy-all: ## Deploy all services to Railway
@echo "$(BLUE)Deploying all services to Railway...$(NC)"
@cd services/document-service && railway up
@cd services/clause-service && railway up
@cd services/compliance-service && railway up
@cd services/collaboration-service && railway up
@cd services/export-service && railway up
@cd apps/web && railway up
@echo "$(GREEN)✓ All services deployed$(NC)"
# Clean targets
clean: ## Remove build artifacts and caches
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".next" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "dist" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "build" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@find . -type f -name ".coverage" -delete 2>/dev/null || true
@echo "$(GREEN)✓ Cleaned$(NC)"
clean-all: clean ## Remove all dependencies and build artifacts
@echo "$(BLUE)Removing all dependencies...$(NC)"
@find . -type d -name "node_modules" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".venv" -exec rm -rf {} + 2>/dev/null || true
@echo "$(GREEN)✓ All cleaned$(NC)"
# Utility targets
setup: docker-up install migrate ## Complete setup (Docker + install + migrate)
@echo "$(GREEN)✓ Setup complete! Run 'make dev' to start development$(NC)"
health: ## Check health of all services
@echo "$(BLUE)Checking service health...$(NC)"
@curl -f http://localhost:8001/health || echo "$(RED)Document service not running$(NC)"
@curl -f http://localhost:8002/health || echo "$(RED)Clause service not running$(NC)"
@curl -f http://localhost:8003/health || echo "$(RED)Compliance service not running$(NC)"
@curl -f http://localhost:8004/health || echo "$(RED)Collaboration service not running$(NC)"
@curl -f http://localhost:8005/health || echo "$(RED)Export service not running$(NC)"
@curl -f http://localhost:3000 || echo "$(RED)Web app not running$(NC)"
logs: ## Show logs from all services
@echo "$(BLUE)Showing service logs...$(NC)"
@tail -f services/*/logs/*.log apps/web/logs/*.log 2>/dev/null || echo "No log files found"