-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (118 loc) · 5.17 KB
/
Copy pathMakefile
File metadata and controls
148 lines (118 loc) · 5.17 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
UID ?= $(shell id -u 2>/dev/null || echo 1000)
GID ?= $(shell id -g 2>/dev/null || echo 1000)
export UID GID
.PHONY: help up down restart logs build build-api build-web build-app check fix format lint seed test test-watch test-cov test-e2e sh-api sh-web install install-api install-web add-api add-web sync-modules sync_modules fix-perms
help:
@echo "NIddle Development Makefile"
@echo ""
@echo "Container Management:"
@echo " make up - Start development environment (auto-builds, renews volumes & syncs modules)"
@echo " make down - Stop development environment"
@echo " make restart - Restart all containers"
@echo " make logs - Follow container logs"
@echo " make build - Rebuild container images"
@echo ""
@echo "Dependency Management:"
@echo " make install - Install/sync dependencies in all containers & sync to host"
@echo " make install-api - Install/sync dependencies in API container & sync to host"
@echo " make install-web - Install/sync dependencies in Web container & sync to host"
@echo " make add-api pkg=<name> - Add dependency to API container (e.g. make add-api pkg=axios)"
@echo " make add-web pkg=<name> - Add dependency to Web container (e.g. make add-web pkg=lucide-react)"
@echo " make sync-modules - Sync node_modules from containers to host"
@echo " make fix-perms - Ensure node_modules on host has proper user permissions"
@echo ""
@echo "Application Build:"
@echo " make build-api - Build the API application (npm run build:api)"
@echo " make build-web - Build the Web application (npm run build:web)"
@echo " make build-app - Build both API and Web applications"
@echo ""
@echo "Code Quality:"
@echo " make check - Run linting and formatting checks"
@echo " make fix - Automatically fix linting and formatting issues"
@echo " make format - Format codebase with Biome"
@echo " make lint - Lint codebase with Biome"
@echo ""
@echo "Database & Testing:"
@echo " make seed - Seed database with initial sample data"
@echo " make test - Run unit tests"
@echo " make test-watch - Run unit tests in watch mode"
@echo " make test-cov - Run unit tests and generate coverage report"
@echo " make test-e2e - Run end-to-end tests"
@echo ""
@echo "Shell Access:"
@echo " make sh-api - Open a shell inside the API container"
@echo " make sh-web - Open a shell inside the Web container"
fix-perms:
@mkdir -p node_modules apps/api/node_modules apps/web/node_modules
@if { [ -d node_modules ] && [ ! -w node_modules ]; } || \
{ [ -d apps/api/node_modules ] && [ ! -w apps/api/node_modules ]; } || \
{ [ -d apps/web/node_modules ] && [ ! -w apps/web/node_modules ]; }; then \
echo "Fixing node_modules permissions via Docker..."; \
docker run --rm -v "$$(pwd):/host" alpine chown -R $(UID):$(GID) /host/node_modules /host/apps/api/node_modules /host/apps/web/node_modules 2>/dev/null || true; \
fi
up: fix-perms
docker compose up -d --build -V
@$(MAKE) sync-modules
down:
docker compose down
restart:
docker compose restart
logs:
docker compose logs -f
build:
docker compose build
sync-modules: fix-perms
@echo "Waiting for containers to be ready..."
@sh -c 'count=0; until docker compose exec -T api true 2>/dev/null || [ $$count -ge 30 ]; do sleep 1; count=$$((count + 1)); done'
@echo "Syncing node_modules to host..."
@docker compose cp api:/app/node_modules ./
@docker compose cp web:/app/node_modules ./ 2>/dev/null || true
@docker compose cp api:/app/apps/api/node_modules ./apps/api/ 2>/dev/null || true
@docker compose cp web:/app/apps/web/node_modules ./apps/web/ 2>/dev/null || true
@echo "Sync complete!"
sync_modules: sync-modules
build-api:
docker compose exec api npm run build:api
build-web:
docker compose exec web npm run build:web
build-app: build-api build-web
check:
docker compose exec api npm run check
fix:
docker compose exec api npm run check:fix
format:
docker compose exec api npm run format
lint:
docker compose exec api npm run lint
seed:
docker compose exec api npm run seed
test:
docker compose exec api npm test
test-watch:
docker compose exec api npm run test:watch
test-cov:
docker compose exec api npm run test:cov
test-e2e:
docker compose exec api npm run test:e2e
sh-api:
docker compose exec api sh
sh-web:
docker compose exec web sh
install:
docker compose exec api npm install
docker compose exec web npm install
@$(MAKE) sync-modules
install-api:
docker compose exec api npm install
@$(MAKE) sync-modules
install-web:
docker compose exec web npm install
@$(MAKE) sync-modules
add-api:
@if [ -z "$(pkg)" ]; then echo "Usage: make add-api pkg=<package_name>"; exit 1; fi
docker compose exec api npm install $(pkg) -w apps/api
@$(MAKE) sync-modules
add-web:
@if [ -z "$(pkg)" ]; then echo "Usage: make add-web pkg=<package_name>"; exit 1; fi
docker compose exec web npm install $(pkg) -w apps/web
@$(MAKE) sync-modules