Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
370 lines (276 loc) Β· 13.9 KB
/
Copy pathMakefile
File metadata and controls
370 lines (276 loc) Β· 13.9 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
# Copyright (c) 2025 Affilibuster by Ronen Druker.
# Makefile for Affilibuster development
# Detect CPU cores (cross-platform)
NPROCS := $(shell sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)
MAKEFLAGS += --output-sync=target
.PHONY: help all all-fast dev build start stop restart logs lint lint-check lint-python lint-python-check lint-typescript lint-typescript-check lint-shell lint-shell-check format format-check format-python format-python-check format-typescript format-typescript-check format-shell format-shell-check format-makefile format-makefile-check test test-backend test-backend-unit test-backend-integration test-frontend-unit test-the-green-brother test-the-green-brother-unit test-gentle-hawk test-gentle-hawk-unit test-performance test-all-unit test-all-integration test-parallel test-fast test-all audit clean clean-coverage coverage-merge coverage-view playwright-report ci-test install install-backend install-frontend install-the-green-brother install-gentle-hawk install-cms setup upgrade upgrade-cms upgrade-backend upgrade-the-green-brother upgrade-gentle-hawk upgrade-frontend upgrade-pre-commit ps pre-commit export import export-docker import-docker generate-env-dev generate-env-prod backup-prod build-remote start-remote stop-remote logs-remote dev-remote
# Default target
.DEFAULT_GOAL := help
help: ## Show this help message
@echo "Affilibuster Development Commands:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
all: clean setup pre-commit start test ## Run complete workflow
all-fast: clean setup pre-commit start test-fast ## Run complete workflow with faster tests (backend + the-green-brother unit only)
# Linting & Formatting
pre-commit: ## Run pre-commit hooks on all files
@echo "π Running pre-commit on all files..."
@pre-commit run --all-files
@echo "β
Pre-commit checks complete"
# Individual linters - check only
lint-python-check: ## Check Python code linting (Ruff)
@bash scripts/lint.sh python check
lint-typescript-check: ## Check TypeScript/JavaScript linting (ESLint)
@bash scripts/lint.sh typescript check
lint-shell-check: ## Check shell script linting (shellcheck)
@bash scripts/lint.sh shell check
# Individual linters - auto-fix
lint-python: ## Lint and fix Python code (Ruff)
@bash scripts/lint.sh python
lint-typescript: ## Lint and fix TypeScript/JavaScript (ESLint)
@bash scripts/lint.sh typescript
lint-shell: ## Lint shell scripts (shellcheck - check only, no auto-fix)
@bash scripts/lint.sh shell
# All linters
lint-check: ## Check all linting without fixing
@bash scripts/lint.sh all check
lint: ## Lint and fix all code
@bash scripts/lint.sh all
format-python: ## Format Python code (Ruff)
@bash scripts/format.sh python
format-python-check: ## Check Python formatting without making changes
@bash scripts/format.sh python check
format-typescript: ## Format TypeScript/JavaScript (Prettier)
@bash scripts/format.sh typescript
format-typescript-check: ## Check TypeScript/JavaScript formatting without making changes
@bash scripts/format.sh typescript check
format-shell: ## Format shell scripts
@bash scripts/format.sh shell
format-shell-check: ## Check shell script formatting without making changes
@bash scripts/format.sh shell check
format-makefile: ## Format Makefile (checkmake validation)
@bash scripts/format.sh makefile
format-makefile-check: ## Check Makefile format without making changes
@bash scripts/format.sh makefile check
format: ## Format all code (Python, JS/TS, Shell, Makefile)
@bash scripts/format.sh all
format-check: ## Check all code formatting without making changes
@bash scripts/format.sh all check
dev: format lint ## Start all services
@echo "π Starting Affilibuster Development Environment..."
@./scripts/build.sh
@docker compose logs -f 2>&1 | "./scripts/log.sh"
build: format lint ## Build (with linting and formatting)
@./scripts/build.sh --build
start: ## Start Docker services only
@./scripts/build.sh
stop: ## Stop all Docker services
@echo "π Stopping Docker services..."
@docker compose down
@echo "β
Services stopped"
restart: ## Restart Docker services
@echo "π Restarting Docker services..."
@docker compose restart
@echo "β
Services restarted"
logs: ## View Docker logs (all services)
@docker compose logs -f
logs-backend: ## View backend logs only
@docker compose logs -f backend
logs-the-green-brother: ## View the-green-brother logs only
@docker compose logs -f the-green-brother
# Production
# Helper to pass arguments to docker compose (e.g. make start-prod strapi)
# Only capture extra args when running production commands to avoid conflicts with other targets
PROD_GOALS := dcp build-prod start-prod stop-prod logs-prod export-prod import-prod
ifneq ($(filter $(PROD_GOALS),$(firstword $(MAKECMDGOALS))),)
ifeq ($(origin PROD_ARGS),undefined)
PROD_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(PROD_ARGS):;@:)
endif
endif
# Production Docker Compose command
DCP_CMD := docker compose --env-file .env.prod -f docker-compose.prod.yaml
dcp: ## Run generic docker compose production command (e.g. make dcp logs -f)
@$(DCP_CMD) $(PROD_ARGS)
setup-vps: ## Setup VPS environment (install Docker, etc.)
@bash scripts/setup-vps.sh
generate-env-dev: ## Generate development .env file
@bash scripts/generate-env.sh development
generate-env-prod: ## Generate production .env.prod file
@bash scripts/generate-env.sh production
build-prod: ## Build production services
@$(DCP_CMD) build $(PROD_ARGS)
start-prod: ## Start production services
@$(DCP_CMD) up -d $(PROD_ARGS)
stop-prod: ## Stop production services
@$(DCP_CMD) down $(PROD_ARGS)
logs-prod: ## View production logs
@$(DCP_CMD) logs -f $(PROD_ARGS)
# Remote (local frontend against production backend & CMS)
# Docker Compose command for remote-backend development
DCR_CMD := docker compose --env-file .env.prod -f docker-compose.remote.yaml
build-remote: ## Build frontend for remote-backend development
@$(DCR_CMD) build
start-remote: ## Start frontend against production backend & CMS
@echo "π Starting frontend (remote backend mode)..."
@$(DCR_CMD) up -d
@echo "β
Frontend running at http://localhost:3000 β production backend"
stop-remote: ## Stop remote-backend frontend
@$(DCR_CMD) down
logs-remote: ## View remote-backend frontend logs
@$(DCR_CMD) logs -f
dev-remote: ## Start frontend against production backend & CMS (with logs)
@echo "π Starting frontend (remote backend mode)..."
@$(DCR_CMD) up -d
@$(DCR_CMD) logs -f
test-backend-unit: ## Run backend unit tests only
@bash scripts/test.sh backend-unit
test-backend-integration: ## Run backend integration tests only
@bash scripts/test.sh backend-integration
test-backend: ## Run all backend tests (unit + integration)
@bash scripts/test.sh backend
test-the-green-brother-unit: ## Run the-green-brother unit tests only (Jest)
@bash scripts/test.sh the-green-brother-unit
test-the-green-brother-integration: ## Run the-green-brother integration tests only (Playwright E2E)
@bash scripts/test.sh the-green-brother-integration $(BROWSER)
test-the-green-brother: ## Run all the-green-brother tests (unit + integration)
@bash scripts/test.sh the-green-brother
test-frontend-unit: ## Run shared frontend package unit tests (Jest)
@echo "π§ͺ Running frontend package unit tests..."
@cd frontend && npm test -- --coverage \
--coverageReporters=lcov \
--coverageReporters=json \
--coverageReporters=html \
--coverageReporters=text \
--coverageReporters=text-summary
@echo "β
Frontend package unit tests passed"
test-gentle-hawk-unit: ## Run gentle-hawk unit tests only (Jest)
@echo "π§ͺ Running gentle-hawk unit tests..."
@cd gentle-hawk && npm test -- --coverage \
--coverageReporters=lcov \
--coverageReporters=json \
--coverageReporters=html \
--coverageReporters=text \
--coverageReporters=text-summary
@echo "β
GentleHawk unit tests passed"
test-gentle-hawk: test-gentle-hawk-unit ## Run all gentle-hawk tests
test-performance: ## Run performance tests only
@bash scripts/test.sh performance $(BROWSER)
test-all-unit: ## Run all unit tests (backend + the-green-brother)
@bash scripts/test.sh all-unit
test-all-integration: ## Run all integration tests (backend + the-green-brother)
@bash scripts/test.sh all-integration
test: ## Run all tests with coverage (shows all errors)
@bash scripts/test.sh
test-parallel: ## Run all tests in parallel (FAST)
@bash scripts/test.sh parallel
test-fast: ## Run fast tests only (backend + frontend + the-green-brother + gentle-hawk unit)
@echo "π§ͺ Running fast tests (backend + frontend + the-green-brother + gentle-hawk unit)..."
@$(MAKE) test-backend
@$(MAKE) test-frontend-unit
@$(MAKE) test-the-green-brother-unit
@$(MAKE) test-gentle-hawk-unit
@echo "β
Fast tests complete"
test-all: ## Run all tests + merge coverage
@bash scripts/test.sh merge
coverage-merge: ## Merge coverage reports
@bash scripts/test.sh merge-only
coverage-view: ## Open merged coverage report in browser
@if [ -f "coverage-merged/html/index.html" ]; then \
open coverage-merged/html/index.html || xdg-open coverage-merged/html/index.html; \
else \
echo "β Run 'make test-all' first to generate merged coverage"; \
fi
clean-coverage: ## Clean all coverage reports
@bash scripts/clean.sh coverage
playwright-report: ## View Playwright E2E test report in browser
@if [ -d "the-green-brother/playwright-report" ]; then \
echo "π Starting Playwright report server..."; \
echo " Open http://localhost:$${PLAYWRIGHT_REPORT_PORT:-9323} in your browser"; \
echo " Press Ctrl+C to stop the server"; \
docker compose exec test-runner sh -c 'cd /app && npx playwright show-report --port $${PLAYWRIGHT_REPORT_PORT:-9323} --host 0.0.0.0'; \
else \
echo "β No Playwright report found"; \
echo " Run 'make test-the-green-brother' or 'make test' first to generate E2E test reports"; \
fi
audit: ## Run Lighthouse performance audits
@bash scripts/audit.sh
install-backend: ## Install backend dependencies
@echo "π¦ Installing backend dependencies..."
@cd backend && uv sync
install-frontend: ## Install shared frontend package dependencies
@echo "π¦ Installing frontend package dependencies..."
@cd frontend && npm install
install-the-green-brother: ## Install the-green-brother dependencies
@echo "π¦ Installing the-green-brother dependencies..."
@cd the-green-brother && npm install
install-gentle-hawk: ## Install gentle-hawk dependencies
@echo "π¦ Installing gentle-hawk dependencies..."
@cd gentle-hawk && npm install
install-cms: ## Install CMS dependencies
@echo "π¦ Installing CMS dependencies..."
@cd cms && npm install
install: install-backend install-frontend install-the-green-brother install-gentle-hawk install-cms ## Install all dependencies
@echo "β
All dependencies installed"
setup: ## Complete development environment setup (installs all tools and dependencies)
@bash scripts/setup.sh
upgrade-cms: ## Update CMS dependencies only
@cd cms && npm update --save
upgrade-frontend: ## Update shared frontend package dependencies only
@cd frontend && npm update --save
upgrade-the-green-brother: ## Update the-green-brother dependencies only
@cd the-green-brother && npm update --save
upgrade-gentle-hawk: ## Update gentle-hawk dependencies only
@cd gentle-hawk && npm update --save
upgrade-backend: ## Update backend dependencies only
@cd backend && uv sync --upgrade
upgrade-pre-commit: ## Update pre-commit hooks only
@pre-commit autoupdate
upgrade: upgrade-backend upgrade-frontend upgrade-the-green-brother upgrade-gentle-hawk upgrade-cms upgrade-pre-commit ## Update all dependencies to latest
@echo "β
All dependencies updated"
clean: ## Clean up containers, volumes, and all build artifacts (zero state)
@bash scripts/clean.sh
ps: ## Show running containers
@docker compose ps
export: ## Export strapi cms data (local)
@echo "π½ Exporting strapi cms data (local)..."
@cd cms && npm run data:export
@echo "β
Strapi cms data exported"
import: ## Import strapi cms data (local)
@echo "π½ Importing strapi cms data (local)..."
@tar -cf data/export.tar -C "data" assets entities schemas configuration links metadata.json
@cd cms && npm run data:import -- --force --file "../data/export.tar"
@rm data/export.tar
@echo "β
Strapi cms data imported"
export-docker: ## Export strapi cms data (via Docker)
@echo "π½ Exporting strapi cms data (Docker)..."
@docker compose exec strapi sh -c 'npm run data:export'
@echo "β
Strapi cms data exported"
import-docker: ## Import strapi cms data (via Docker)
@echo "π½ Importing strapi cms data (Docker)..."
@tar -cf data/export.tar -C "data" assets entities schemas configuration links metadata.json
@docker compose exec strapi sh -c 'npm run data:import -- --force --file "/data/export.tar"'
@rm data/export.tar
@echo "β
Strapi cms data imported"
export-prod: ## Export strapi cms data (production)
@echo "π½ Exporting strapi cms data (production)..."
@$(DCP_CMD) exec -u root strapi sh -c 'rm -rf /data && mkdir -p /data && chown strapi:strapi /data'
@$(DCP_CMD) exec strapi npm run data:export
@$(DCP_CMD) exec strapi tar -cf /tmp/export.tar -C /data .
@mkdir -p data
@$(DCP_CMD) cp strapi:/tmp/export.tar data/export.tar
@tar -xf data/export.tar -C data
@rm data/export.tar
@$(DCP_CMD) exec -u root strapi rm -rf /data /tmp/export.tar
@echo "β
Strapi cms data exported from production"
backup-prod: ## Run full production backup (Strapi + PostgreSQL + git push)
@bash scripts/backup.sh
import-prod: ## Import strapi cms data (production)
@echo "π½ Importing strapi cms data (production)..."
@tar -cf data/export.tar -C "data" assets entities schemas configuration links metadata.json
@$(DCP_CMD) cp data/export.tar strapi:/tmp/export.tar
@$(DCP_CMD) exec strapi npm run data:import -- --force --file "/tmp/export.tar"
@$(DCP_CMD) exec -u root strapi rm -f /tmp/export.tar
@rm -f data/export.tar
@echo "β
Strapi cms data imported to production"