-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
368 lines (308 loc) · 9.95 KB
/
Makefile
File metadata and controls
368 lines (308 loc) · 9.95 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
# Laravel Homeschool Learning App - Makefile
# Common development and deployment commands
# Variables
PHP = php
COMPOSER = composer
NPM = npm
ARTISAN = $(PHP) artisan
PORT ?= 8000
# Colors for output
GREEN = \033[0;32m
YELLOW = \033[1;33m
RED = \033[0;31m
NC = \033[0m # No Color
# Default target
.DEFAULT_GOAL := help
## Help command
help: ## Show this help message
@echo "$(GREEN)Laravel Homeschool Learning App - Available Commands$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(GREEN)Usage:$(NC) make [command]"
## Development Environment
.PHONY: install
install: ## Install all dependencies (Composer + NPM)
@echo "$(GREEN)Installing Composer dependencies...$(NC)"
$(COMPOSER) install
@echo "$(GREEN)Installing NPM dependencies...$(NC)"
$(NPM) install
@echo "$(GREEN)Building frontend assets...$(NC)"
$(NPM) run build
@echo "$(GREEN)Dependencies installed successfully!$(NC)"
.PHONY: dev
dev: ## Start development server (Laravel + Vite)
@echo "$(GREEN)Starting development environment...$(NC)"
@echo "$(YELLOW)Laravel server: http://localhost:$(PORT)$(NC)"
@echo "$(YELLOW)Using .env.local configuration$(NC)"
@export $$(cat .env.local | grep -v '^#' | xargs) && php artisan serve --port=$(PORT)
.PHONY: dev-all
dev-all: ## Start all development services (Laravel + Vite + Queue + Logs)
@echo "$(GREEN)Starting all development services...$(NC)"
$(COMPOSER) run dev
.PHONY: vite
vite: ## Start Vite dev server for frontend assets
@echo "$(GREEN)Starting Vite development server...$(NC)"
$(NPM) run dev
.PHONY: build
build: ## Build frontend assets for production
@echo "$(GREEN)Building frontend assets for production...$(NC)"
$(NPM) run build
## Database Operations
.PHONY: db-fresh
db-fresh: ## Drop all tables and re-run migrations with seeders
@echo "$(YELLOW)⚠️ This will delete all data! Press Ctrl+C to cancel...$(NC)"
@sleep 3
@echo "$(GREEN)Refreshing database...$(NC)"
$(ARTISAN) migrate:fresh --seed
.PHONY: migrate
migrate: ## Run database migrations
@echo "$(GREEN)Running migrations...$(NC)"
$(ARTISAN) migrate
.PHONY: rollback
rollback: ## Rollback last database migration
@echo "$(YELLOW)Rolling back last migration...$(NC)"
$(ARTISAN) migrate:rollback
.PHONY: seed
seed: ## Seed the database
@echo "$(GREEN)Seeding database...$(NC)"
$(ARTISAN) db:seed
.PHONY: db-reset
db-reset: ## Reset database (rollback all migrations and re-run)
@echo "$(YELLOW)Resetting database...$(NC)"
$(ARTISAN) migrate:reset
$(ARTISAN) migrate
$(ARTISAN) db:seed
## Testing
.PHONY: test
test: ## Run all tests (PHPUnit + E2E)
@echo "$(GREEN)Running all tests...$(NC)"
@$(MAKE) test-unit
@$(MAKE) test-e2e
.PHONY: test-unit
test-unit: ## Run PHPUnit tests (SAFE - uses test database)
@echo "$(GREEN)Running PHPUnit tests on TEST database...$(NC)"
@echo "$(YELLOW)⚠️ Using safe test runner to protect development database$(NC)"
@export $$(cat .env.testing | grep -v '^#' | xargs) && ./scripts/safe-test.sh
.PHONY: test-unit-coverage
test-unit-coverage: ## Run PHPUnit tests with coverage (SAFE - uses test database)
@echo "$(GREEN)Running PHPUnit tests with coverage on TEST database...$(NC)"
@export $$(cat .env.testing | grep -v '^#' | xargs) && ./scripts/safe-test.sh --coverage
.PHONY: test-e2e
test-e2e: ## Run E2E tests with Playwright
@echo "$(GREEN)Running E2E tests...$(NC)"
$(NPM) run test:e2e
.PHONY: test-e2e-headed
test-e2e-headed: ## Run E2E tests with browser visible
@echo "$(GREEN)Running E2E tests with browser...$(NC)"
$(NPM) run test:e2e:headed
.PHONY: test-e2e-ui
test-e2e-ui: ## Open Playwright test UI
@echo "$(GREEN)Opening Playwright test UI...$(NC)"
$(NPM) run test:ui
.PHONY: test-specific
test-specific: ## Run specific test file (use TEST=path/to/test)
@echo "$(GREEN)Running specific test: $(TEST)$(NC)"
$(NPM) run test:e2e -- $(TEST)
## Code Quality
.PHONY: lint
lint: ## Run code linters (PHP + JS)
@echo "$(GREEN)Running linters...$(NC)"
@$(MAKE) lint-php
@$(MAKE) lint-js
.PHONY: lint-php
lint-php: ## Run PHP linter (Pint)
@echo "$(GREEN)Running PHP linter...$(NC)"
./vendor/bin/pint
.PHONY: lint-js
lint-js: ## Run JavaScript linter
@echo "$(GREEN)Running JavaScript linter...$(NC)"
$(NPM) run lint
.PHONY: lint-fix
lint-fix: ## Auto-fix linting issues
@echo "$(GREEN)Auto-fixing linting issues...$(NC)"
./vendor/bin/pint
$(NPM) run lint:fix
.PHONY: format
format: ## Format code with Prettier
@echo "$(GREEN)Formatting code...$(NC)"
$(NPM) run format
.PHONY: phpstan
phpstan: ## Run PHPStan static analysis
@echo "$(GREEN)Running PHPStan static analysis...$(NC)"
./vendor/bin/phpstan analyse --memory-limit=512M
.PHONY: type-check
type-check: ## Run TypeScript type checking
@echo "$(GREEN)Running TypeScript type checking...$(NC)"
$(NPM) run type-check
## Cache and Optimization
.PHONY: cache-clear
cache-clear: ## Clear all caches
@echo "$(GREEN)Clearing all caches...$(NC)"
$(ARTISAN) cache:clear
$(ARTISAN) config:clear
$(ARTISAN) route:clear
$(ARTISAN) view:clear
@echo "$(GREEN)All caches cleared!$(NC)"
.PHONY: optimize
optimize: ## Optimize application for production
@echo "$(GREEN)Optimizing application...$(NC)"
$(ARTISAN) config:cache
$(ARTISAN) route:cache
$(ARTISAN) view:cache
@echo "$(GREEN)Application optimized!$(NC)"
.PHONY: optimize-clear
optimize-clear: ## Clear optimization caches
@echo "$(YELLOW)Clearing optimization caches...$(NC)"
$(ARTISAN) optimize:clear
## Queue Management
.PHONY: queue
queue: ## Start queue worker
@echo "$(GREEN)Starting queue worker...$(NC)"
$(ARTISAN) queue:work
.PHONY: queue-listen
queue-listen: ## Start queue listener (auto-restart on code changes)
@echo "$(GREEN)Starting queue listener...$(NC)"
$(ARTISAN) queue:listen
.PHONY: queue-restart
queue-restart: ## Restart queue workers
@echo "$(YELLOW)Restarting queue workers...$(NC)"
$(ARTISAN) queue:restart
## Logs and Debugging
.PHONY: logs
logs: ## Tail Laravel logs
@echo "$(GREEN)Tailing Laravel logs...$(NC)"
tail -f storage/logs/laravel.log
.PHONY: logs-clear
logs-clear: ## Clear Laravel logs
@echo "$(YELLOW)Clearing Laravel logs...$(NC)"
rm -f storage/logs/*.log
@echo "$(GREEN)Logs cleared!$(NC)"
.PHONY: pail
pail: ## Start Laravel Pail log viewer
@echo "$(GREEN)Starting Laravel Pail...$(NC)"
$(ARTISAN) pail
## Artisan Commands
.PHONY: tinker
tinker: ## Start Laravel Tinker REPL
@echo "$(GREEN)Starting Laravel Tinker...$(NC)"
$(ARTISAN) tinker
.PHONY: routes
routes: ## List all routes
@echo "$(GREEN)Listing all routes...$(NC)"
$(ARTISAN) route:list
.PHONY: storage-link
storage-link: ## Create storage symlink
@echo "$(GREEN)Creating storage symlink...$(NC)"
$(ARTISAN) storage:link
## Git Hooks
.PHONY: hooks-install
hooks-install: ## Install git hooks (Husky)
@echo "$(GREEN)Installing git hooks...$(NC)"
npx husky install
.PHONY: pre-commit
pre-commit: ## Run pre-commit checks
@echo "$(GREEN)Running pre-commit checks...$(NC)"
@$(MAKE) lint-php
@$(MAKE) phpstan
@$(MAKE) test-unit
## Environment Setup
.PHONY: env-copy
env-copy: ## Copy .env.example to .env
@echo "$(GREEN)Copying .env.example to .env...$(NC)"
cp .env.example .env
@echo "$(GREEN)Environment file created!$(NC)"
.PHONY: key-generate
key-generate: ## Generate application key
@echo "$(GREEN)Generating application key...$(NC)"
$(ARTISAN) key:generate
.PHONY: setup
setup: ## Complete setup for new installation
@echo "$(GREEN)Setting up Laravel Homeschool Learning App...$(NC)"
@$(MAKE) env-copy
@$(MAKE) key-generate
@$(MAKE) install
@$(MAKE) migrate
@$(MAKE) seed
@$(MAKE) storage-link
@echo "$(GREEN)✅ Setup complete! Run 'make dev' to start development server.$(NC)"
## Supabase (Local Development)
.PHONY: supabase-start
supabase-start: ## Start local Supabase instance
@echo "$(GREEN)Starting local Supabase...$(NC)"
supabase start
.PHONY: supabase-stop
supabase-stop: ## Stop local Supabase instance
@echo "$(YELLOW)Stopping local Supabase...$(NC)"
supabase stop
.PHONY: supabase-status
supabase-status: ## Check Supabase status
@echo "$(GREEN)Checking Supabase status...$(NC)"
supabase status
.PHONY: supabase-reset
supabase-reset: ## Reset Supabase database
@echo "$(YELLOW)⚠️ This will reset the Supabase database! Press Ctrl+C to cancel...$(NC)"
@sleep 3
supabase db reset
## Quick Commands
.PHONY: fresh
fresh: ## Fresh install (reset everything and start clean)
@echo "$(YELLOW)⚠️ This will delete all data and reinstall! Press Ctrl+C to cancel...$(NC)"
@sleep 3
@$(MAKE) cache-clear
@$(MAKE) db-fresh
@$(MAKE) optimize
@echo "$(GREEN)✅ Fresh install complete!$(NC)"
.PHONY: update
update: ## Update dependencies (Composer + NPM)
@echo "$(GREEN)Updating dependencies...$(NC)"
$(COMPOSER) update
$(NPM) update
$(NPM) run build
@echo "$(GREEN)Dependencies updated!$(NC)"
.PHONY: check
check: ## Run all checks (lint, phpstan, tests)
@echo "$(GREEN)Running all checks...$(NC)"
@$(MAKE) lint
@$(MAKE) phpstan
@$(MAKE) type-check
@$(MAKE) test-unit
@echo "$(GREEN)✅ All checks passed!$(NC)"
.PHONY: clean
clean: ## Clean build artifacts and caches
@echo "$(YELLOW)Cleaning build artifacts and caches...$(NC)"
rm -rf node_modules
rm -rf vendor
rm -rf public/build
rm -rf public/hot
rm -rf storage/framework/cache/*
rm -rf storage/framework/sessions/*
rm -rf storage/framework/views/*
rm -rf bootstrap/cache/*
@echo "$(GREEN)Cleaned!$(NC)"
## Production Commands
.PHONY: deploy
deploy: ## Deploy to production (run build and optimization)
@echo "$(GREEN)Preparing for production deployment...$(NC)"
@$(MAKE) build
@$(MAKE) optimize
@echo "$(GREEN)✅ Ready for deployment!$(NC)"
.PHONY: maintenance-on
maintenance-on: ## Enable maintenance mode
@echo "$(YELLOW)Enabling maintenance mode...$(NC)"
$(ARTISAN) down
.PHONY: maintenance-off
maintenance-off: ## Disable maintenance mode
@echo "$(GREEN)Disabling maintenance mode...$(NC)"
$(ARTISAN) up
# Aliases for common commands
.PHONY: s serve start
s: dev
serve: dev
start: dev
.PHONY: t
t: test
.PHONY: m
m: migrate
.PHONY: f
f: fresh