-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
200 lines (168 loc) · 7.35 KB
/
Copy pathMakefile
File metadata and controls
200 lines (168 loc) · 7.35 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
# TaskTime Pro Makefile
# Shorthand commands for common Docker operations
APP_RUN_ENV ?=
APP_RUN = docker compose run --rm $(APP_RUN_ENV) app
.PHONY: help dev dev-push-local preview-push-local preview-push-cloud preview-cloud stop build preview preview-build install lint typecheck clean logs shell test test-run test-coverage test-e2e test-e2e-smoke test-e2e-drive-browsers test-e2e-pwa-smoke release-gate blog-install blog-dev blog-build
PREVIEW_PORT ?= 3101
# Default target - show help
help:
@echo "TaskTime Pro Development Commands"
@echo "=============================="
@echo ""
@echo " make dev - Start development server (docker compose up)"
@echo " make dev-push-local - Start app dev server using local Worker at http://localhost:8787"
@echo " make preview-push-local - Build production preview using local Worker at http://localhost:8787"
@echo " make preview-push-cloud - Build production preview using deployed Worker at https://sync.tasktime.pro"
@echo " make preview-cloud - Build production preview using the deployed production Worker"
@echo " make stop - Stop development server"
@echo " make build - Build for production"
@echo " make preview - Stop current dev containers, build merged app+blog output, and serve it locally on PREVIEW_PORT ($(PREVIEW_PORT))"
@echo " make preview-build - Build merged app+blog output and serve it locally on PREVIEW_PORT ($(PREVIEW_PORT)); stop make dev first if needed"
@echo " make blog-install - Install blog dependencies"
@echo " make blog-dev - Start Astro blog dev server (http://localhost:4321/blog)"
@echo " make blog-build - Build the Astro blog"
@echo " make install - Install all dependencies"
@echo " make add PKG=<package> - Add a new npm package"
@echo " make lint - Run ESLint"
@echo " make typecheck - Run the repository-wide TypeScript check"
@echo " make logs - View container logs"
@echo " make shell - Open shell in container"
@echo " make clean - Remove containers and rebuild"
@echo " make test - Run vitest in watch mode"
@echo " make test-run - Run vitest once"
@echo " make test-coverage - Run vitest with coverage"
@echo " make test-e2e - Run Playwright E2E tests"
@echo " make test-e2e-smoke - Run critical Playwright smoke tests in Chromium"
@echo " make test-e2e-drive-browsers - Run direct Drive smoke in Chromium, Firefox, and WebKit"
@echo " make test-e2e-pwa-smoke - Run production-preview PWA offline boot smoke test"
@echo " make release-gate - Run lint, typecheck, coverage, browser/PWA smoke, and build"
@echo ""
# Start development server
dev:
docker compose up -d
@echo "Development server running at http://localhost:3101"
@echo "Blog dev server is available through the same origin at http://localhost:3101/blog"
# Start local app dev server wired to local Wrangler Worker
dev-push-local:
docker compose run --rm -p 3101:3101 \
-e VITE_SYNC_WORKER_URL=http://localhost:8787 \
-e VITE_PUSH_NOTIFICATIONS_ENABLED=true \
app sh -lc 'sh ./scripts/start-dev-servers.sh'
# Build and preview production app wired to local Wrangler Worker.
# Use this for service-worker/Web Push testing; Vite dev mode unregisters service workers.
preview-push-local:
docker compose run --rm -p 3101:3101 \
-e VITE_SYNC_WORKER_URL=http://localhost:8787 \
-e VITE_PUSH_NOTIFICATIONS_ENABLED=true \
app sh -lc 'npm run build && npm run preview -- --host 0.0.0.0 --port 3101'
# Build and preview production app wired to the deployed Cloudflare Worker.
# This verifies the real edge route and browser CORS path before release.
preview-push-cloud:
-docker compose down --remove-orphans
@leftovers=$$(docker ps -aq --filter "name=tasktime-app-run-"); \
if [ -n "$$leftovers" ]; then docker rm -f $$leftovers; fi
docker compose run --rm -p $(PREVIEW_PORT):$(PREVIEW_PORT) \
-e VITE_SYNC_WORKER_URL=https://sync.tasktime.pro \
-e VITE_PUSH_NOTIFICATIONS_ENABLED=true \
app sh -lc 'npm run build && npm run preview -- --host 0.0.0.0 --port $(PREVIEW_PORT)'
# Production-equivalent local browser check. Keep preview-push-cloud as the
# backwards-compatible target used by existing Web Push documentation.
preview-cloud: preview-push-cloud
# Stop development server
stop:
docker compose down
# Build for production
build:
docker compose run --rm app npm run build
# Stop current dev services, build merged app+blog output, and serve it locally
preview:
-docker compose down --remove-orphans
@leftovers=$$(docker ps -aq --filter "name=tasktime-app-run-"); \
if [ -n "$$leftovers" ]; then docker rm -f $$leftovers; fi
$(MAKE) preview-build
# Build merged app+blog output and serve it locally
preview-build:
docker compose run --rm -p $(PREVIEW_PORT):$(PREVIEW_PORT) app sh -lc 'npm run build && npm run preview -- --host 0.0.0.0 --port $(PREVIEW_PORT)'
# Install blog dependencies
blog-install:
docker compose run --rm app sh -lc 'cd blog && npm ci'
# Start Astro blog dev server
blog-dev:
docker compose run --rm -p 4321:4321 app sh -lc 'cd blog && if [ ! -d node_modules ]; then npm ci; fi && npm run dev -- --host 0.0.0.0 --port 4321'
# Build the Astro blog
blog-build:
docker compose run --rm app sh -lc 'cd blog && if [ ! -d node_modules ]; then npm ci; fi && npm run build'
# Install dependencies (useful after pulling changes)
install:
docker compose run --rm app npm install
# Add a new package (usage: make add PKG=package-name)
add:
@if [ -z "$(PKG)" ]; then \
echo "Usage: make add PKG=<package-name>"; \
exit 1; \
fi
docker compose run --rm app npm install $(PKG)
@echo "Remember to rebuild: make clean"
# Run linter
lint:
@attempt=1; \
while [ $$attempt -le 3 ]; do \
output_file=$$(mktemp); \
if $(APP_RUN) sh -lc 'find src -maxdepth 4 -type d >/dev/null && npm run lint' >"$$output_file" 2>&1; then \
cat "$$output_file"; \
rm -f "$$output_file"; \
exit 0; \
fi; \
cat "$$output_file"; \
if grep -q "ENOENT: no such file or directory, scandir '/app/src/" "$$output_file" && [ $$attempt -lt 3 ]; then \
rm -f "$$output_file"; \
echo "Retrying lint after Docker bind mount settles..."; \
attempt=$$((attempt + 1)); \
continue; \
fi; \
rm -f "$$output_file"; \
exit 1; \
done
# Run tests
typecheck:
docker compose run --rm app npm run typecheck
test:
docker compose run --rm app npm test
test-run:
docker compose run --rm app npm run test:run
test-coverage:
docker compose run --rm app npm run test:coverage
test-e2e:
docker compose run --rm app npm run test:e2e
test-e2e-smoke:
docker compose run --rm app npm run test:e2e:smoke
test-e2e-drive-browsers:
docker compose run --rm app npm run test:e2e:drive-browsers
test-e2e-pwa-smoke:
docker compose run --rm app npm run test:e2e:pwa:smoke
# Release gate checks (lint + typecheck + coverage + browser/PWA smoke + build)
release-gate:
$(MAKE) lint
$(APP_RUN) npm run typecheck
$(APP_RUN) npm run test:coverage
$(APP_RUN) npm run test:e2e:smoke
$(APP_RUN) npm run test:e2e:pwa:smoke
$(APP_RUN) npm run build
# View logs
logs:
docker compose logs -f
# Open shell in container
shell:
docker compose exec app sh
# Clean rebuild (removes containers and rebuilds image)
clean:
docker compose down
docker compose build --no-cache
@echo "Clean rebuild complete. Run 'make dev' to start."
# Run arbitrary npm command (usage: make npm CMD="run test")
npm:
@if [ -z "$(CMD)" ]; then \
echo "Usage: make npm CMD=\"<npm command>\""; \
exit 1; \
fi
docker compose run --rm app npm $(CMD)