Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
267 lines (237 loc) · 8.41 KB
/
Copy pathTaskfile.yml
File metadata and controls
267 lines (237 loc) · 8.41 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
version: "3"
vars:
API_DIR: apps/api
WEB_DIR: apps/web
API_PORT: 8080
DOCKER_COMPOSE: infrastructure/docker/docker-compose.yml
INFRA_DIR: infrastructure/terraform
tasks:
check:
desc: Check prerequisites — detect missing tools with install instructions
silent: true
cmds:
- |
missing=0
check_tool() {
if command -v "$1" &> /dev/null; then
printf " ✓ %-10s %s\n" "$1" "$(eval "$3")"
else
printf " ✗ %-10s missing — install with: %s\n" "$1" "$2"
missing=$((missing + 1))
fi
}
echo "Checking prerequisites..."
echo ""
check_tool "docker" "brew install --cask docker" "docker --version | head -1"
check_tool "node" "nvm install 24" "node --version"
check_tool "pnpm" "npm install -g pnpm" "pnpm --version"
check_tool "java" "sdk install java 25-open" "java --version 2>&1 | head -1"
check_tool "lefthook" "brew install lefthook" "lefthook version"
echo ""
if [ "$missing" -gt 0 ]; then
echo "⚠ $missing tool(s) missing. Install them and re-run: task check"
exit 1
else
echo "All prerequisites installed."
fi
setup:
desc: Full-stack setup — copy env templates, install web dependencies, install git hooks
cmds:
- task: setup:api
- task: setup:infra
- task: setup:web
- task: setup:hooks
setup:hooks:
desc: Install git hooks via Lefthook
cmds:
- |
if command -v lefthook &> /dev/null; then
lefthook install
echo "Git hooks installed via Lefthook"
else
echo "Warning: lefthook is not installed. Install with: brew install lefthook"
fi
setup:api:
desc: API setup — copy env and config templates if missing
cmds:
- |
if [ ! -f {{.API_DIR}}/.env.local ]; then
cp {{.API_DIR}}/.env.local.example {{.API_DIR}}/.env.local
echo "Created {{.API_DIR}}/.env.local from template"
else
echo "{{.API_DIR}}/.env.local already exists, skipping"
fi
- |
if [ ! -f {{.API_DIR}}/src/main/resources/application-local.yml ]; then
cp {{.API_DIR}}/src/main/resources/application-local.yml.example {{.API_DIR}}/src/main/resources/application-local.yml
echo "Created {{.API_DIR}}/src/main/resources/application-local.yml from template"
else
echo "{{.API_DIR}}/src/main/resources/application-local.yml already exists, skipping"
fi
setup:infra:
desc: Infrastructure setup — copy Terraform tfvars template if missing
cmds:
- |
if [ ! -f {{.INFRA_DIR}}/terraform.tfvars ]; then
cp {{.INFRA_DIR}}/terraform.tfvars.example {{.INFRA_DIR}}/terraform.tfvars
echo "Created {{.INFRA_DIR}}/terraform.tfvars from template"
else
echo "{{.INFRA_DIR}}/terraform.tfvars already exists, skipping"
fi
setup:web:
desc: Web setup — copy .env.local template if missing, install dependencies
cmds:
- |
if [ ! -f {{.WEB_DIR}}/.env.local ]; then
cp {{.WEB_DIR}}/.env.local.example {{.WEB_DIR}}/.env.local
echo "Created {{.WEB_DIR}}/.env.local from template"
else
echo "{{.WEB_DIR}}/.env.local already exists, skipping"
fi
- cd {{.WEB_DIR}} && pnpm install
setup:mock:
desc: Mock-mode setup — copy mock env template, install dependencies
cmds:
- cp {{.WEB_DIR}}/.env.local.mock {{.WEB_DIR}}/.env.local
- echo "Created {{.WEB_DIR}}/.env.local for mock mode"
- cd {{.WEB_DIR}} && pnpm install
dev:
desc: Full-stack dev — start API (auto-starts postgres), then web once the API is healthy
deps:
- dev:api
- dev:web:after-api
dev:web:after-api:
# The web is ready in under a second and the API takes ~20s; a page opened in
# that gap renders the error page. Waiting on the health check avoids it.
internal: true
silent: true
cmds:
- |
echo "Waiting for the API on :{{.API_PORT}} before starting web..."
for i in $(seq 1 180); do
curl -sf http://localhost:{{.API_PORT}}/actuator/health > /dev/null && exit 0
sleep 1
done
echo "API not healthy after 180s; check the dev:api output above."
exit 1
- task: dev:web
dev:api:
desc: Start API server — auto-starts postgres via spring-boot-docker-compose
dir: "{{.API_DIR}}"
preconditions:
- sh: "! lsof -nP -iTCP:{{.API_PORT}} -sTCP:LISTEN > /dev/null"
msg: "Port {{.API_PORT}} is already in use, likely by an API left over from an earlier run. Run `task stop:all`, then retry."
cmds:
- ./gradlew bootRun --args='--spring.profiles.active=local'
dev:web:
desc: Start web dev server with Turbopack
dir: "{{.WEB_DIR}}"
env:
WATCHPACK_POLLING: "true"
CHOKIDAR_USEPOLLING: "true"
preconditions:
- sh: "! lsof -nP -iTCP:3000 -sTCP:LISTEN > /dev/null"
msg: "Port 3000 is already in use, likely by a web server left over from an earlier run. Run `task stop:all`, then retry."
cmds:
- pnpm run dev
dev:db:
desc: Start database only — useful when backend is not needed
cmds:
- docker compose -f {{.DOCKER_COMPOSE}} up -d
db:reset:
desc: Reset the database (WARNING — destroys all data)
cmds:
- docker compose -f {{.DOCKER_COMPOSE}} down -v
- docker compose -f {{.DOCKER_COMPOSE}} up -d db
test:
desc: Run all tests — API + web
cmds:
- task: test:api
- task: test:web
test:api:
desc: Run API tests (uses Testcontainers, not Docker Compose)
dir: "{{.API_DIR}}"
cmds:
- ./gradlew test
test:web:
desc: Run web lint, typecheck, and unit tests
dir: "{{.WEB_DIR}}"
cmds:
- pnpm run lint
- pnpm run typecheck
- pnpm run test:unit
lint:
desc: Run all linters — ktlint + ESLint
cmds:
- task: lint:api
- task: lint:web
lint:api:
desc: Run Kotlin linter (ktlint)
dir: "{{.API_DIR}}"
cmds:
- ./gradlew ktlintCheck
lint:web:
desc: Run ESLint
dir: "{{.WEB_DIR}}"
cmds:
- pnpm run lint
stop:
desc: Stop database container
cmds:
- docker compose -f {{.DOCKER_COMPOSE}} down
stop:all:
desc: Stop everything task dev starts — web, API, database — including servers left over from earlier runs
silent: true
cmds:
- |
# Task runs scripts with errexit, so commands that fail harmlessly end in `|| true`
pids=""
# Only stop port listeners started from this repo; report anything else
for pid in $(lsof -t -nP -iTCP:3000,3001,{{.API_PORT}} -sTCP:LISTEN 2>/dev/null || true); do
cwd=$(lsof -a -p "$pid" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p' || true)
case "$cwd" in
"{{.ROOT_DIR}}"*) pids="$pids $pid" ;;
*) echo "Skipping PID $pid: listens on a dev port but runs from $cwd" ;;
esac
done
# Processes without a port: the Gradle wrapper, next dev, and the Velite watcher
pids="$pids $(pgrep -f '{{.ROOT_DIR}}/{{.API_DIR}}/gradle/wrapper/gradle-wrapper.jar bootRun' || true)"
pids="$pids $(pgrep -f '{{.ROOT_DIR}}/{{.WEB_DIR}}/node_modules/.*(next dev|velite.*--watch)' || true)"
pids=$(printf '%s\n' $pids | sort -u | xargs)
if [ -z "$pids" ]; then
echo "No dev servers running"
exit 0
fi
echo "Stopping PIDs: $pids"
# Task's shell has no kill builtin; env runs the system binary
env kill $pids 2>/dev/null || true
alive=""
for i in $(seq 1 15); do
alive=""
for p in $pids; do
if env kill -0 "$p" 2>/dev/null; then alive="$alive $p"; fi
done
if [ -z "$alive" ]; then break; fi
sleep 1
done
if [ -n "$alive" ]; then
echo "Force-killing:$alive"
env kill -9 $alive 2>/dev/null || true
fi
echo "Dev servers stopped"
- task: stop
clean:
desc: Clean build artifacts
cmds:
- task: clean:api
- task: clean:web
clean:api:
desc: Clean API build artifacts
dir: "{{.API_DIR}}"
cmds:
- ./gradlew clean
clean:web:
desc: Clean web build artifacts
dir: "{{.WEB_DIR}}"
cmds:
- rm -rf .next .velite