Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (58 loc) · 2.83 KB
/
Copy pathMakefile
File metadata and controls
70 lines (58 loc) · 2.83 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
# ============================================================================
# SPU Backend — Development Makefile
# ============================================================================
# One-command shortcuts for common development workflows.
# Usage: make <target>
# ============================================================================
.PHONY: help setup db-up db-down db-test-up dev prod test lint clean
# Default target
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
setup: ## Install dependencies and create .env from template
@echo "📦 Installing Node.js dependencies..."
npm install
@if [ ! -f .env ]; then \
echo "⚠️ .env not found — copying from .env.example"; \
cp .env.example .env; \
echo "✏️ Edit .env with your database credentials before proceeding."; \
else \
echo "✅ .env already exists, skipping copy."; \
fi
# ---------------------------------------------------------------------------
# Database
# ---------------------------------------------------------------------------
db-up: ## Start PostgreSQL (development) via Docker Compose
docker compose up -d postgres
@echo "⏳ Waiting for PostgreSQL to accept connections..."
@until docker compose exec postgres pg_isready -U postgres > /dev/null 2>&1; do sleep 1; done
@echo "✅ PostgreSQL is ready on port $${PGPORT_DEV:-5432}"
db-down: ## Stop and remove database containers (preserves data volume)
docker compose down
db-test-up: ## Start PostgreSQL (test) via Docker Compose test profile
docker compose --profile test up -d postgres-test
@echo "✅ Test PostgreSQL is ready on port 5433"
# ---------------------------------------------------------------------------
# Application
# ---------------------------------------------------------------------------
dev: ## Start the development server (Nodemon + auto-reload)
npm run start:dev
prod: ## Start the production server
npm run start:prod
# ---------------------------------------------------------------------------
# Testing & Quality
# ---------------------------------------------------------------------------
test: ## Run the full Mocha test suite
npm run start:test
lint: ## Run ESLint (if configured)
npx eslint . --fix 2>/dev/null || echo "ℹ️ ESLint not configured — skipping."
# ---------------------------------------------------------------------------
# Cleanup
# ---------------------------------------------------------------------------
clean: db-down ## Stop containers, remove node_modules and Docker volumes
rm -rf node_modules
docker compose down -v
@echo "🗑️ Cleanup complete."