-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
784 lines (668 loc) · 27.3 KB
/
Copy pathmakefile
File metadata and controls
784 lines (668 loc) · 27.3 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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
#!make
.DEFAULT_GOAL := search
.PHONY: help
# Colors
COLOR_RESET = \033[0m
COLOR_GREEN = \033[32m
COLOR_BLUE = \033[34m
COLOR_CYAN = \033[36m
COLOR_YELLOW = \033[33m
# Check if php container exists in compose stack and set ENTRYPOINT
PHP_CONTAINER := $(shell docker compose ps -q php 2>/dev/null)
ENTRYPOINT =
ifneq ($(PHP_CONTAINER),)
ENTRYPOINT = docker compose exec php
else
$(info Compose stack is not running, running commands directly on host)
endif
# Common variables
DOCKER_COMPOSE = docker compose
PHP_ARTISAN = $(DOCKER_COMPOSE) run --rm php ${ENTRYPOINT} php artisan
PHP_COMPOSER = $(DOCKER_COMPOSE) run --rm -it php composer
PHP_NPM = $(DOCKER_COMPOSE) run --rm php npm
PHP_PINT = $(DOCKER_COMPOSE) run -T --rm php ./vendor/bin/pint
PHP_VERSION=php8.4
# --------------------------------------------------------------------------
# OS Detection
# --------------------------------------------------------------------------
UNAME_S := $(shell uname -s)
# Set OS-specific variables
ifeq ($(UNAME_S),Linux)
OS = linux
NEXTJS_PATH = /var/www/adhub-next
CD_CMD = cd
EXEC_CMD =
else ifeq ($(UNAME_S),Darwin)
OS = macos
NEXTJS_PATH = /Users/mohammadreza/Documents/GitHub/adhub-next
CD_CMD = cd
EXEC_CMD =
else
OS = windows
# Windows paths - adjust based on your setup
ifneq (,$(findstring Microsoft,$(shell uname -r)))
# WSL2
NEXTJS_PATH = /var/www/adhub-next
CD_CMD = cd
EXEC_CMD =
else ifneq (,$(findstring MINGW,$(UNAME_S)))
# Git Bash / MinGW
NEXTJS_PATH = /c/var/www/adhub-next
CD_CMD = cd
EXEC_CMD =
else
# Native Windows CMD
NEXTJS_PATH = C:\var\www\adhub-next
CD_CMD = cd /d
EXEC_CMD = cmd /C
endif
endif
os-info: ## Show OS detection info
@echo "OS: $(OS)"
@echo "UNAME_S: $(UNAME_S)"
@echo "Next.js Path: $(NEXTJS_PATH)"
@echo "CD Command: $(CD_CMD)"
@echo "Exec Command: $(EXEC_CMD)"
# --------------------------------------------------------------------------
# Make menus
# --------------------------------------------------------------------------
search: ## Search for a command
${ENTRYPOINT} php artisan make:run
help: ## Show this help menu
@printf "${COLOR_CYAN}Usage:${COLOR_RESET}\n make [command]\n\n${COLOR_CYAN}Available commands:${COLOR_RESET}\n"
@awk -F ':.*##' '/^[a-zA-Z0-9_%-]+:.*##/ {printf " ${COLOR_GREEN}%-25s${COLOR_RESET}%s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
# --------------------------------------------------------------------------
# Docker
# --------------------------------------------------------------------------
build: ## Run docker compose build
$(DOCKER_COMPOSE) build
ps: ## Show running containers
$(DOCKER_COMPOSE) ps
up: ## Start containers in detached mode
$(DOCKER_COMPOSE) up -d
down: ## Stop containers
$(DOCKER_COMPOSE) down
down-volumes: ## Stop containers and remove volumes
$(DOCKER_COMPOSE) down --volumes
restart: ## Restart containers
$(DOCKER_COMPOSE) restart
composer: ## Run composer commands
$(PHP_COMPOSER) $(filter-out $@,$(MAKECMDGOALS))
%:
tinker: ## Start Artisan tinker
$(PHP_ARTISAN) tinker
artisan: ## Run Artisan commands
$(PHP_ARTISAN) $(filter-out $@,$(MAKECMDGOALS))
%:
npm: ## Run npm commands
$(PHP_NPM) $(filter-out $@,$(MAKECMDGOALS))
%:
migration: ## Create new migration
$(PHP_ARTISAN) make:migration $(filter-out $@,$(MAKECMDGOALS))
%:
migrate: ## Run migrations
$(PHP_ARTISAN) migrate
horizon: ## Start Horizon queue
$(PHP_ARTISAN) horizon
## Development
install-laravel: ## Download Laravel and update .env
@if [ -d "./app" ]; then \
printf "${COLOR_YELLOW}ℹ Project already exists.${COLOR_RESET}\n"; \
else \
chmod +x ./docker-repo/install_laravel.sh; \
./docker-repo/install_laravel.sh; \
chown -R $(USER):$(GROUP) .; \
rm -rf src; \
fi
format: ## Format changed files with pint
$(PHP_PINT) --dirty
format-all: ## Format all files with pint
$(PHP_PINT)
test: ## Run tests
$(PHP_ARTISAN) test
# --------------------------------------------------------------------------
# Next js
# --------------------------------------------------------------------------
next-init: ## Initialize Next.js project
@echo "Running on $(OS)"
$(CD_CMD) "$(NEXTJS_PATH)" && $(EXEC_CMD) npm run init
next-reload: ## pull, install and run Next.js dev server
@echo "Running on $(OS)"
$(CD_CMD) "$(NEXTJS_PATH)" && $(EXEC_CMD) npm run reload
next-dev: ## Run Next.js dev server
@echo "Running on $(OS)"
$(CD_CMD) "$(NEXTJS_PATH)" && $(EXEC_CMD) npm run dev
# --------------------------------------------------------------------------
# Database
# --------------------------------------------------------------------------
db-grate: ## migrate databases
${ENTRYPOINT} php artisan migrate --force
${ENTRYPOINT} php artisan migrate --force --env=testing
db-back: ## migrate:rollback databases
${ENTRYPOINT} php artisan migrate:rollback --force
${ENTRYPOINT} php artisan migrate:rollback --force --env=testing
db-fresh: ## Recreate databases
${ENTRYPOINT} php artisan migrate:fresh --force --seed
${ENTRYPOINT} php artisan migrate:fresh --force --env=testing
db-telescope: ## Run Telescope DB migrations
${ENTRYPOINT} php artisan migrate --database=telescope --path=vendor/laravel/telescope/database/migrations --force
# --------------------------------------------------------------------------
# Tests
# --------------------------------------------------------------------------
test-r: ## Run tests in random order
${ENTRYPOINT} php artisan config:clear --ansi
${ENTRYPOINT} php artisan test --profile --compact --order-by random
test-rf: ## Recreate test db and run tests in random order
${ENTRYPOINT} php artisan config:clear --ansi
${ENTRYPOINT} php artisan test --profile --compact --order-by random
test-p: ## Run tests in parallel
${ENTRYPOINT} php artisan config:clear --ansi
${ENTRYPOINT} php artisan test --parallel
test-pf: ## Recreate test DB and run parallel tests
${ENTRYPOINT} php artisan config:clear --ansi
${ENTRYPOINT} php artisan test --parallel --recreate-databases
test-cov: ## Generate code coverage report
${ENTRYPOINT} php artisan config:clear --ansi
${ENTRYPOINT} php artisan test --coverage --compact --min=30 --coverage-clover=build/coverage@tests.xml
test-type-cov: ## Generate type coverage report
${ENTRYPOINT} php artisan config:clear --ansi
${ENTRYPOINT} php artisan test --type-coverage --compact --min=94 --type-coverage-json=build/type-coverage@tests.json
test-ls: ## list tests
${ENTRYPOINT} php artisan test --list-tests
# --------------------------------------------------------------------------
# Clear
# --------------------------------------------------------------------------
clean: ## Clear all caches
${ENTRYPOINT} php artisan clear-compiled
${ENTRYPOINT} php artisan optimize:clear
${ENTRYPOINT} php artisan modules:clear
${ENTRYPOINT} php artisan filament:optimize-clear
${ENTRYPOINT} php artisan schedule:clear-cache
${ENTRYPOINT} php artisan permission:cache-reset
${ENTRYPOINT} php artisan debugbar:clear
deep-clean: ## Deep clean application
${ENTRYPOINT} php artisan activitylog:clean
${ENTRYPOINT} php artisan mail:prune
${ENTRYPOINT} php artisan telescope:clear
${ENTRYPOINT} php artisan telescope:prune
${ENTRYPOINT} php artisan horizon:clear
${ENTRYPOINT} php artisan horizon:clear-metrics
${ENTRYPOINT} php artisan pulse:clear
${ENTRYPOINT} php artisan queue:clear
${ENTRYPOINT} php artisan settings:clear-cache
${ENTRYPOINT} php artisan settings:clear-discovered
${ENTRYPOINT} php artisan auth:clear-resets
${ENTRYPOINT} php artisan backup:clean
${ENTRYPOINT} php artisan cache:prune-stale-tags
${ENTRYPOINT} php artisan filament-excel:prune
${ENTRYPOINT} php artisan sanctum:prune-expired
cache: ## Cache system files
${ENTRYPOINT} php artisan optimize
${ENTRYPOINT} php artisan modules:cache
${ENTRYPOINT} php artisan filament:optimize
${ENTRYPOINT} php artisan settings:discover
# --------------------------------------------------------------------------
# Pint
# --------------------------------------------------------------------------
pint-dirty: ## Run PHP code style fixer to only modify the files that have uncommitted changes
vendor/bin/pint --dirty --parallel
pint-test: ## Run PHP code style fixer to simply inspect your code for style errors
vendor/bin/pint --test --parallel
pint: ## Run PHP code style fixer
vendor/bin/pint --repair --parallel
# --------------------------------------------------------------------------
# Serve
# --------------------------------------------------------------------------
start: ## Start all development servers
@npx concurrently -k -n "QUEUE,HORIZON,REVERB,OCTANE,VITE,SCHEDULE,PULSE,NEXT,LOGGING,NIGHTWATCH" \
-c "green,blue,magenta,cyan,yellow,red,gray,black,white,green" \
"${ENTRYPOINT} php artisan queue:listen" \
"${ENTRYPOINT} php artisan horizon" \
"${ENTRYPOINT} php artisan reverb:start --debug" \
"${ENTRYPOINT} php artisan octane:start --watch --port=9000" \
"npm run dev" \
"${ENTRYPOINT} php artisan schedule:work" \
"${ENTRYPOINT} php artisan pulse:work" \
"make next-dev" \
"${ENTRYPOINT} php artisan pail --timeout=86400" \
"${ENTRYPOINT} php artisan nightwatch:agent"
serve: ## Start basic servers
@npx concurrently -k -n "QUEUE,HORIZON,REVERB,SERVER,VITE,SCHEDULE,PULSE,NEXT,LOGGING,NIGHTWATCH" \
-c "green,blue,magenta,cyan,yellow,red,gray,black,white,green" \
"${ENTRYPOINT} php artisan queue:listen" \
"${ENTRYPOINT} php artisan horizon" \
"${ENTRYPOINT} php artisan reverb:start --debug" \
"${ENTRYPOINT} php artisan serve --port=9000" \
"npm run dev" \
"${ENTRYPOINT} php artisan schedule:run-cronless" \
"${ENTRYPOINT} php artisan pulse:work" \
"make next-dev" \
"${ENTRYPOINT} php artisan pail --timeout=86400" \
"${ENTRYPOINT} php artisan nightwatch:agent"
# --------------------------------------------------------------------------
# Setup
# --------------------------------------------------------------------------
install: ## Initialize project
make fix-permissions
make setup
sudo cp .env.example .env
sudo cp .env.testing.example .env.testing
make git-hooks
make dev
ide: ## Generate IDE helper files
${ENTRYPOINT} php artisan ide-helper:generate
${ENTRYPOINT} php artisan ide-helper:models --nowrite
${ENTRYPOINT} php artisan ide-helper:meta
${ENTRYPOINT} php artisan ide-helper:eloquent
reload: ## Update and refresh application
git pull
composer install
${ENTRYPOINT} php artisan down --refresh=15
${ENTRYPOINT} php artisan reload
make clean
${ENTRYPOINT} php artisan responsecache:clear
${ENTRYPOINT} php artisan modules:sync
${ENTRYPOINT} php artisan filament:upgrade
${ENTRYPOINT} php artisan themes:upgrade
${ENTRYPOINT} php artisan migrate --force --seed
${ENTRYPOINT} php artisan schedule-monitor:sync
npm install && npm run build
${ENTRYPOINT} php artisan schedule:run
${ENTRYPOINT} php artisan backup:list
${ENTRYPOINT} php artisan scramble:analyze
make notes
make ide
${ENTRYPOINT} php artisan up
reload-quick: ## Update and refresh application
git pull
composer install
${ENTRYPOINT} php artisan down --refresh=15
${ENTRYPOINT} php artisan reload
${ENTRYPOINT} php artisan responsecache:clear
${ENTRYPOINT} php artisan modules:sync
${ENTRYPOINT} php artisan migrate --force
${ENTRYPOINT} php artisan schedule-monitor:sync
${ENTRYPOINT} php artisan scramble:analyze
make notes
make ide
${ENTRYPOINT} php artisan up
dev: ## Full development setup
make reload
make checkup
make test-r
make next-reload
make start
prod: ## Production deployment
git pull
composer install --optimize-autoloader --no-dev
make clean
${ENTRYPOINT} php artisan migrate --graceful --ansi --force
make cache
npm install && npm run build
make start
# --------------------------------------------------------------------------
# Git
# --------------------------------------------------------------------------
git-clean: ## prune unused files and compress files to reduce repo size
git gc --prune=now --aggressive
git-hooks: ## set git hooks path to custom .githooks dir
sudo chmod +x .githooks
git config core.hooksPath .githooks
git-alias: ## add aliases to git
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lg "log --oneline --graph --all --decorate"
git-user:
git config --global user.name "Mohamadreza Rezaei"
git config --global user.email "me.moham6dreza@gmail.com"
git config --list
git-blame-ignore:
git config blame.ignoreRevsFile .git-blame-ignore-revs
# --------------------------------------------------------------------------
# Health
# --------------------------------------------------------------------------
microscope: ## Run fearless refactoring, it does a lot of smart checks to find certain errors.
${ENTRYPOINT} php artisan check:views
${ENTRYPOINT} php artisan check:routes
#${ENTRYPOINT} php artisan check:psr4
#${ENTRYPOINT} php artisan check:imports
${ENTRYPOINT} php artisan check:stringy_classes
${ENTRYPOINT} php artisan check:dd
${ENTRYPOINT} php artisan check:bad_practices
${ENTRYPOINT} php artisan check:compact
${ENTRYPOINT} php artisan check:blade_queries
#${ENTRYPOINT} php artisan check:action_comments
#${ENTRYPOINT} php artisan check:extract_blades
${ENTRYPOINT} php artisan pp:route
${ENTRYPOINT} php artisan check:generate
#${ENTRYPOINT} php artisan check:endif
${ENTRYPOINT} php artisan check:events
#${ENTRYPOINT} php artisan check:gates
${ENTRYPOINT} php artisan check:dynamic_where
${ENTRYPOINT} php artisan check:aliases
${ENTRYPOINT} php artisan check:dead_controllers
#${ENTRYPOINT} php artisan check:generic_docblocks
${ENTRYPOINT} php artisan enforce:helper_functions
#${ENTRYPOINT} php artisan list:models
app-checkup: ## Run necessary tools to check code and code style
make rector-test
make pint-test
# make phpstan
make migrate-lint
make test-p
app-fix:
make microscope
make rector
make pint
make test-p
app-quick-fix:
make rector
make pint
app-health:
composer du
${ENTRYPOINT} php artisan route:list
make test-r
migrate-lint:
${ENTRYPOINT} php artisan migrate:lint
migrate-lint-baseline:
${ENTRYPOINT} php artisan migrate:lint --generate-baseline
# --------------------------------------------------------------------------
# Phpstan
# --------------------------------------------------------------------------
phpstan: ## Run phpstan analysis
vendor/bin/phpstan analyse --memory-limit=2G
phpstan-baseline: ## Run phpstan analysis and generate baseline
vendor/bin/phpstan analyse --memory-limit=2G --generate-baseline
rector-test: ## Run rector analysis
@echo "Starting Rector at $$(date)"
@start=$$(date +%s); \
vendor/bin/rector --dry-run; \
end=$$(date +%s); \
duration=$$((end - start)); \
echo "Rector completed in $$duration seconds"
rector: ## Run rector analysis and change files
@echo "Starting Rector at $$(date)"
@start=$$(date +%s); \
vendor/bin/rector; \
end=$$(date +%s); \
duration=$$((end - start)); \
echo "Rector completed in $$duration seconds"
rector-rules:
vendor/bin/rector list-rules
# --------------------------------------------------------------------------
# Boost
# --------------------------------------------------------------------------
boost-install:
${ENTRYPOINT} php artisan boost:mcp
boost-update:
${ENTRYPOINT} php artisan boost:update --ansi
# --------------------------------------------------------------------------
# Wayfinder
# --------------------------------------------------------------------------
wayfinder:
${ENTRYPOINT} php artisan wayfinder:generate
# --------------------------------------------------------------------------
# Others
# --------------------------------------------------------------------------
notes:
${ENTRYPOINT} php artisan ghost:write
upgrade:
composer update
npm update
vendor-routes: ## Show list of routes that are registered by packages
${ENTRYPOINT} php artisan route:list --only-vendor
filament-up:
vendor/bin/filament-v4
toon:
${ENTRYPOINT} php artisan toon:convert $(filter-out $@,$(MAKECMDGOALS)) --decode --pretty
%:
post-update-cmd:
${ENTRYPOINT} php artisan vendor:publish --tag=laravel-assets --ansi --force
${ENTRYPOINT} php artisan filament:assets
${ENTRYPOINT} php artisan boost:update --ansi
# --------------------------------------------------------------------------
# Linux
# --------------------------------------------------------------------------
php-extensions:
sudo apt install ${PHP_VERSION}-{dev,pcov,xdebug,sqlite3,cli,soap,fpm,xml,curl,cgi,mysql,mysqlnd,gd,bz2,ldap,pgsql,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache,mongodb}
php-reload:
sudo systemctl reload nginx
sudo systemctl reload ${PHP_VERSION}-fpm
permissions:
sudo chmod -R 777 storage
ports:
sudo fuser -k 3000/tcp && fuser -k 9000/tcp && fuser -k 2407/tcp
fix-permissions: ## Fix project directory permissions
@printf "${COLOR_BLUE}▶ Fixing file and directory permissions...${COLOR_RESET}\n"
@sudo chown -R $(USER):$(USER) .
@sudo find . -type d \( -name "vendor" -o -name "node_modules" \) -prune -o -type f -exec chmod 664 {} \;
@sudo find . -type d \( -name "vendor" -o -name "node_modules" \) -prune -o -type d -exec chmod 775 {} \;
@sudo chgrp -R $(USER) storage bootstrap/cache
@sudo chmod -R ug+rwx storage bootstrap/cache
@printf "${COLOR_GREEN}✓ All permissions fixed successfully!${COLOR_RESET}\n"
setup: ## Configure Nginx for adhub.local
@printf "${COLOR_BLUE}▶ Starting adhub.local setup...${COLOR_RESET}\n"
@printf '%s\n' 'map $$http_upgrade $$connection_upgrade {' \
' default upgrade;' \
' "" close;' \
'}' \
'' \
'server {' \
' listen 80;' \
' listen [::]:80;' \
' server_name adhub.local;' \
' server_tokens off;' \
' root /var/www/adhub-laravel/public;' \
'' \
' index index.php;' \
'' \
' charset utf-8;' \
'' \
' location /index.php {' \
' try_files /not_exists @octane;' \
' }' \
'' \
' location / {' \
' try_files $$uri $$uri/ @octane;' \
' }' \
'' \
' location = /favicon.ico { access_log off; log_not_found off; }' \
' location = /robots.txt { access_log off; log_not_found off; }' \
'' \
' access_log off;' \
' error_log /var/log/nginx/adhub-error.log error;' \
'' \
' error_page 404 /index.php;' \
'' \
' location @octane {' \
' set $$suffix "";' \
'' \
' if ($$uri = /index.php) {' \
' set $$suffix ?$$query_string;' \
' }' \
'' \
' proxy_http_version 1.1;' \
' proxy_set_header Host $$http_host;' \
' proxy_set_header Scheme $$scheme;' \
' proxy_set_header SERVER_PORT $$server_port;' \
' proxy_set_header REMOTE_ADDR $$remote_addr;' \
' proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for;' \
' proxy_set_header Upgrade $$http_upgrade;' \
' proxy_set_header Connection $$connection_upgrade;' \
'' \
' proxy_pass http://127.0.0.1:9000$$suffix;' \
' }' \
'}' | sudo tee /etc/nginx/sites-available/adhub >/dev/null
@sudo ln -sf /etc/nginx/sites-available/adhub /etc/nginx/sites-enabled/
@sudo nginx -t
@sudo systemctl reload nginx
@sudo systemctl reload ${PHP_VERSION}-fpm
@if ! grep -q "adhub.local" /etc/hosts; then \
sudo sed -i '1s/^/127.0.0.1 adhub.local\n/' /etc/hosts; \
printf "${COLOR_GREEN}✓ Added adhub.local to /etc/hosts${COLOR_RESET}\n"; \
else \
printf "${COLOR_YELLOW}ℹ adhub.local already exists in /etc/hosts${COLOR_RESET}\n"; \
fi
@printf "${COLOR_GREEN}✓ adhub.local setup completed!${COLOR_RESET}\n"
setup-worker: ## Configure Supervisor for Laravel queue worker
@printf "${COLOR_BLUE}▶ Starting Laravel worker setup...${COLOR_RESET}\n"
@printf '%s\n' '[program:laravel-worker]' \
'process_name=%(program_name)s_%(process_num)02d' \
'command=php /var/www/adhub-laravel/artisan queue:work redis --sleep=3 --tries=3 --max-time=86400' \
'autostart=true' \
'autorestart=true' \
'stopasgroup=true' \
'killasgroup=true' \
'user=www-data' \
'numprocs=8' \
'redirect_stderr=true' \
'stdout_logfile=/var/www/adhub-laravel/storage/logs/worker.log' \
'stopwaitsecs=3600' | sudo tee /etc/supervisor/conf.d/laravel-worker.conf >/dev/null
@sudo supervisorctl reread >/dev/null
@sudo supervisorctl update >/dev/null
@if sudo supervisorctl status laravel-worker:* | grep -q RUNNING; then \
printf "${COLOR_YELLOW}✓ Laravel worker is already running${COLOR_RESET}\n"; \
sudo supervisorctl restart laravel-worker:* >/dev/null; \
printf "${COLOR_GREEN}✓ Laravel worker restarted${COLOR_RESET}\n"; \
else \
sudo supervisorctl start laravel-worker:* >/dev/null; \
printf "${COLOR_GREEN}✓ Laravel worker started${COLOR_RESET}\n"; \
fi
@printf "${COLOR_GREEN}✓ Laravel worker setup completed!${COLOR_RESET}\n"
setup-horizon: ## Configure Supervisor for Laravel horizon
@printf "${COLOR_BLUE}▶ Starting Laravel horizon setup...${COLOR_RESET}\n"
@printf '%s\n' '[program:horizon]' \
'process_name=%(program_name)s_%(process_num)02d' \
'command=php /var/www/adhub-laravel/artisan horizon' \
'autostart=true' \
'autorestart=true' \
'user=www-data' \
'redirect_stderr=true' \
'stdout_logfile=/var/www/adhub-laravel/storage/logs/horizon.log' \
'stopwaitsecs=3600' | sudo tee /etc/supervisor/conf.d/horizon.conf >/dev/null
@sudo supervisorctl reread >/dev/null
@sudo supervisorctl update >/dev/null
@if sudo supervisorctl status horizon | grep -q RUNNING; then \
printf "${COLOR_YELLOW}✓ Laravel horizon is already running${COLOR_RESET}\n"; \
sudo supervisorctl restart horizon >/dev/null; \
printf "${COLOR_GREEN}✓ Laravel horizon restarted${COLOR_RESET}\n"; \
else \
sudo supervisorctl start horizon >/dev/null; \
printf "${COLOR_GREEN}✓ Laravel horizon started${COLOR_RESET}\n"; \
fi
@printf "${COLOR_GREEN}✓ Laravel horizon setup completed!${COLOR_RESET}\n"
serve-ip: find-ip ## serve project in local network
@echo "Starting Laravel development server on http://$(IP):8080"
@php -S $(IP):8080 -t public
find-ip: ## Find local IP address
$(eval IP := $(shell \
if command -v ip >/dev/null; then \
ip route get 1 | awk '{print $$7}' | head -1; \
elif command -v ifconfig >/dev/null; then \
ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -1; \
else \
echo "127.0.0.1"; \
fi \
))
@if [ -z "$(IP)" ]; then \
echo "Could not detect IP address, falling back to 127.0.0.1"; \
$(eval IP := 127.0.0.1) \
fi
# --------------------------------------------------------------------------
# MCP Configuration
# --------------------------------------------------------------------------
# MCP configuration paths
MCP_SOURCE = mcp.json
MCP_INTELLIJ_DIR = $(HOME)/.config/github-copilot/intellij
MCP_INTELLIJ_TARGET = $(MCP_INTELLIJ_DIR)/mcp.json
MCP_VSCODE_DIR = $(HOME)/.config/Code/User/globalStorage/github.copilot-chat
MCP_VSCODE_TARGET = $(MCP_VSCODE_DIR)/mcp.json
mcp-copy: ## Copy mcp.json to IntelliJ Copilot configuration directory
@printf "${COLOR_BLUE}▶ Copying MCP configuration to IntelliJ...${COLOR_RESET}\n"
@if [ ! -f "$(MCP_SOURCE)" ]; then \
printf "${COLOR_YELLOW}⚠ Warning: $(MCP_SOURCE) not found in project root${COLOR_RESET}\n"; \
exit 1; \
fi
@mkdir -p "$(MCP_INTELLIJ_DIR)"
@cp -v "$(MCP_SOURCE)" "$(MCP_INTELLIJ_TARGET)"
@printf "${COLOR_GREEN}✓ MCP configuration copied to IntelliJ successfully!${COLOR_RESET}\n"
@printf "${COLOR_CYAN} Target: $(MCP_INTELLIJ_TARGET)${COLOR_RESET}\n"
mcp-copy-vscode: ## Copy mcp.json to VSCode Copilot configuration directory
@printf "${COLOR_BLUE}▶ Copying MCP configuration to VSCode...${COLOR_RESET}\n"
@if [ ! -f "$(MCP_SOURCE)" ]; then \
printf "${COLOR_YELLOW}⚠ Warning: $(MCP_SOURCE) not found in project root${COLOR_RESET}\n"; \
exit 1; \
fi
@mkdir -p "$(MCP_VSCODE_DIR)"
@cp -v "$(MCP_SOURCE)" "$(MCP_VSCODE_TARGET)"
@printf "${COLOR_GREEN}✓ MCP configuration copied to VSCode successfully!${COLOR_RESET}\n"
@printf "${COLOR_CYAN} Target: $(MCP_VSCODE_TARGET)${COLOR_RESET}\n"
mcp-copy-all: ## Copy mcp.json to all supported IDEs
@make mcp-copy
@make mcp-copy-vscode
mcp-sync: ## Sync mcp.json from IntelliJ back to project root
@printf "${COLOR_BLUE}▶ Syncing MCP configuration from IntelliJ to project...${COLOR_RESET}\n"
@if [ ! -f "$(MCP_INTELLIJ_TARGET)" ]; then \
printf "${COLOR_YELLOW}⚠ Warning: $(MCP_INTELLIJ_TARGET) not found${COLOR_RESET}\n"; \
exit 1; \
fi
@cp -v "$(MCP_INTELLIJ_TARGET)" "$(MCP_SOURCE)"
@printf "${COLOR_GREEN}✓ MCP configuration synced from IntelliJ successfully!${COLOR_RESET}\n"
mcp-diff: ## Show differences between project and IntelliJ mcp.json
@printf "${COLOR_BLUE}▶ Comparing MCP configurations...${COLOR_RESET}\n"
@if [ ! -f "$(MCP_SOURCE)" ]; then \
printf "${COLOR_YELLOW}⚠ Project mcp.json not found${COLOR_RESET}\n"; \
elif [ ! -f "$(MCP_INTELLIJ_TARGET)" ]; then \
printf "${COLOR_YELLOW}⚠ IntelliJ mcp.json not found${COLOR_RESET}\n"; \
else \
diff -u "$(MCP_INTELLIJ_TARGET)" "$(MCP_SOURCE)" || true; \
fi
mcp-edit: ## Open project mcp.json in default editor
@${EDITOR:-nano} "$(MCP_SOURCE)"
mcp-validate: ## Validate mcp.json syntax
@printf "${COLOR_BLUE}▶ Validating MCP configuration...${COLOR_RESET}\n"
@if [ ! -f "$(MCP_SOURCE)" ]; then \
printf "${COLOR_YELLOW}⚠ Warning: $(MCP_SOURCE) not found${COLOR_RESET}\n"; \
exit 1; \
fi
@if command -v jq >/dev/null 2>&1; then \
jq empty "$(MCP_SOURCE)" && \
printf "${COLOR_GREEN}✓ MCP configuration is valid JSON${COLOR_RESET}\n"; \
else \
printf "${COLOR_YELLOW}⚠ jq not installed, skipping validation${COLOR_RESET}\n"; \
printf "${COLOR_CYAN} Install with: sudo apt install jq${COLOR_RESET}\n"; \
fi
mcp-show: ## Display current mcp.json configuration
@printf "${COLOR_BLUE}▶ Current MCP Configuration:${COLOR_RESET}\n"
@if [ -f "$(MCP_SOURCE)" ]; then \
if command -v jq >/dev/null 2>&1; then \
jq . "$(MCP_SOURCE)"; \
else \
cat "$(MCP_SOURCE)"; \
fi \
else \
printf "${COLOR_YELLOW}⚠ $(MCP_SOURCE) not found${COLOR_RESET}\n"; \
fi
mcp-backup: ## Backup IntelliJ mcp.json configuration
@printf "${COLOR_BLUE}▶ Backing up IntelliJ MCP configuration...${COLOR_RESET}\n"
@if [ -f "$(MCP_INTELLIJ_TARGET)" ]; then \
cp "$(MCP_INTELLIJ_TARGET)" "$(MCP_INTELLIJ_TARGET).backup.$$(date +%Y%m%d_%H%M%S)"; \
printf "${COLOR_GREEN}✓ Backup created successfully${COLOR_RESET}\n"; \
else \
printf "${COLOR_YELLOW}⚠ No IntelliJ mcp.json found to backup${COLOR_RESET}\n"; \
fi
mcp-help: ## Show MCP commands help
@printf "${COLOR_CYAN}MCP Configuration Management Commands:${COLOR_RESET}\n"
@printf " ${COLOR_GREEN}make mcp-copy${COLOR_RESET} Copy mcp.json to IntelliJ\n"
@printf " ${COLOR_GREEN}make mcp-copy-vscode${COLOR_RESET} Copy mcp.json to VSCode\n"
@printf " ${COLOR_GREEN}make mcp-copy-all${COLOR_RESET} Copy mcp.json to all IDEs\n"
@printf " ${COLOR_GREEN}make mcp-sync${COLOR_RESET} Sync from IntelliJ to project\n"
@printf " ${COLOR_GREEN}make mcp-diff${COLOR_RESET} Compare configurations\n"
@printf " ${COLOR_GREEN}make mcp-edit${COLOR_RESET} Edit project mcp.json\n"
@printf " ${COLOR_GREEN}make mcp-validate${COLOR_RESET} Validate JSON syntax\n"
@printf " ${COLOR_GREEN}make mcp-show${COLOR_RESET} Display configuration\n"
@printf " ${COLOR_GREEN}make mcp-backup${COLOR_RESET} Backup IntelliJ config\n"
# --------------------------------------------------------------------------
# End
# --------------------------------------------------------------------------