-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (158 loc) · 5.77 KB
/
Makefile
File metadata and controls
190 lines (158 loc) · 5.77 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
DOCKER_COMPOSE = docker compose -f docker-compose.local.yml
APP_CONTAINER = issue-api-app-1
DB_CONTAINER = issue-api-mysqldb-1
NODE_IMAGE = node:22-alpine
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help message
@echo "Issue API - Available Commands"
@echo "================================"
@echo "install Install npm dependencies"
@echo "dev Start development server with hot reload"
@echo "build Build the TypeScript application"
@echo "clean Clean build artifacts"
@echo "start Start the production application locally"
@echo "t Run tests"
@echo "tw Run tests in watch mode"
@echo "tc Run tests with coverage report"
@echo "lint Run ESLint"
@echo "lint-fix Run ESLint with auto-fix"
@echo "up Start all services with Docker Compose"
@echo "down Stop all services and remove containers"
@echo "rst Restart all services"
@echo "logs Show logs for all services"
@echo "logs-app Show logs for app service only"
@echo "logs-db Show logs for database service only"
@echo "shell-app Open shell in app container"
@echo "shell-db Open MySQL shell in database container"
@echo "ps Show running containers"
@echo "prune Remove containers, networks, volumes, and images"
@echo "m-up Run database migrations"
@echo "m-down Undo last database migration"
@echo "drop Drop all database tables (WARNING: destroys all data)"
@echo "db-create Create database if it doesn't exist"
@echo "db-seed Seed database with initial data"
@echo "setup Complete project setup (start services, migrate, seed)"
@echo "dev-setup Setup for local development (no Docker)"
@echo "full-reset Full project reset (clean Docker, restart)"
@echo "test Run tests"
@echo "check Run all code quality checks"
.PHONY: install
install: ## Install npm dependencies
@echo "Installing dependencies..."
npm ci
.PHONY: dev
dev: ## Start development server with hot reload
@echo "Starting development server..."
npm run dev:watch
.PHONY: build
build: ## Build the TypeScript application
@echo "Building application..."
npm run build
.PHONY: clean
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
npm run clean
.PHONY: start
start: ## Start the production application locally
@echo "Starting production server..."
npm start
.PHONY: t
t: ## Run tests
@echo "Running tests..."
npm test
.PHONY: tw
tw: ## Run tests in watch mode
@echo "Running tests in watch mode..."
npm run test:watch
.PHONY: tc
tc: ## Run tests with coverage report
@echo "Running tests with coverage..."
npm run test:coverage
.PHONY: lint
lint: ## Run ESLint
@echo "Running linter..."
npm run lint
.PHONY: lint-fix
lint-fix: ## Run ESLint with auto-fix
@echo "Running linter with auto-fix..."
npm run lint:fix
.PHONY: up
up: ## Start all services with Docker Compose
@echo "Starting services with Docker Compose..."
$(DOCKER_COMPOSE) up --build -d
.PHONY: down
down: ## Stop all services and remove containers
@echo "Stopping services..."
$(DOCKER_COMPOSE) down
.PHONY: rst
rst: down up ## Restart all services
.PHONY: logs
logs: ## Show logs for all services
@echo "Showing logs..."
$(DOCKER_COMPOSE) logs -f
.PHONY: logs-app
logs-app: ## Show logs for app service only
@echo "Showing app logs..."
$(DOCKER_COMPOSE) logs -f app
.PHONY: logs-db
logs-db: ## Show logs for database service only
@echo "Showing database logs..."
$(DOCKER_COMPOSE) logs -f mysqldb
.PHONY: shell-app
shell-app: ## Open shell in app container
@echo "Opening shell in app container..."
$(DOCKER_COMPOSE) exec app sh
.PHONY: shell-db
shell-db: ## Open MySQL shell in database container
@echo "Opening MySQL shell..."
$(DOCKER_COMPOSE) exec mysqldb mysql -u root -p
.PHONY: ps
ps: ## Show running containers
@echo "Running containers:"
$(DOCKER_COMPOSE) ps
.PHONY: prune
prune: ## Remove containers, networks, volumes, and images
@echo "Cleaning up Docker resources..."
$(DOCKER_COMPOSE) down -v --rmi all --remove-orphans
docker system prune -f
.PHONY: m-up
m-up: ## Run database migrations
@echo "Running database migrations..."
$(DOCKER_COMPOSE) exec app npm run migrate
.PHONY: m-down
m-down: ## Undo last database migration
@echo "Undoing last migration..."
$(DOCKER_COMPOSE) exec app npm run migrate:undo
.PHONY: drop
drop: ## Drop all database tables (WARNING: destroys all data)
@echo "Dropping all database tables - all data will be lost!"
$(DOCKER_COMPOSE) exec app npm run db:drop:tables
@echo "All tables dropped successfully"
.PHONY: db-create
db-create: ## Create database if it doesn't exist
@echo "Creating database if it doesn't exist..."
$(DOCKER_COMPOSE) exec app npm run db:create
@echo "Database created or already exists"
.PHONY: db-seed
db-seed: ## Seed database with initial data
@echo "Seeding database..."
$(DOCKER_COMPOSE) exec app npm run db:seed
.PHONY: setup
setup: up m-up db-seed ## Complete project setup (start services, migrate, seed)
@echo "Project setup complete!"
@echo "Your API should be available at: http://localhost:8080"
.PHONY: dev-setup
dev-setup: install build ## Setup for local development (no Docker)
@echo "Development setup complete!"
@echo "Run 'make dev' to start development server"
.PHONY: full-reset
full-reset: drop prune up m-up db-seed ## Full project reset (clean Docker, restart)
@echo "Full reset complete!"
.PHONY: test
test: ## Run tests
@echo "Running tests..."
npm test
.PHONY: check
check: lint test ## Run all code quality checks
@echo "All checks passed!"