-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (94 loc) · 4.98 KB
/
Copy pathMakefile
File metadata and controls
122 lines (94 loc) · 4.98 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
.DEFAULT_GOAL := help
.PHONY: help dev dev-fast clean nuke build \
check test test-watch test-cov typecheck lint fix \
deploy logs secret secrets status \
docker-build docker-shell docker-logs docker-prune
# ──────────────────────────────────────────────
# Help
# ──────────────────────────────────────────────
help: ## Show all available commands
@echo "Usage: make <target>"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) \
| awk -F ':.*## ' '{ printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }'
# ──────────────────────────────────────────────
# Core Dev Workflow
# ──────────────────────────────────────────────
dev: clean ## Clean start: kill stale containers, clear state, run dev server
@npx wrangler dev
dev-fast: ## Skip cleanup, just run wrangler dev
@npx wrangler dev
clean: ## Kill sandbox containers and remove wrangler state
@echo "Stopping sandbox containers..."
@-docker ps -q --filter ancestor=cloudflare-dev/sandbox | xargs -r docker kill 2>/dev/null
@-docker ps -q --filter name=sandbox | xargs -r docker kill 2>/dev/null
@-docker ps -q | xargs -r -I{} sh -c 'docker inspect --format="{{.Id}} {{.Config.Image}}" {} | grep sandbox | cut -d" " -f1' | xargs -r docker kill 2>/dev/null
@echo "Removing wrangler state..."
@rm -rf .wrangler/state
@echo "Clean complete."
nuke: clean ## Full reset: clean + remove dist, node_modules, images, reinstall
@echo "Removing build artifacts..."
@rm -rf dist/
@echo "Removing node_modules..."
@rm -rf node_modules/
@echo "Removing sandbox docker images..."
@-docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' | grep sandbox | awk '{print $$2}' | xargs -r docker rmi -f 2>/dev/null
@echo "Reinstalling dependencies..."
@npm install
@echo "Nuke complete."
build: ## Build worker + client
@npx vite build
# ──────────────────────────────────────────────
# Quality & Testing
# ──────────────────────────────────────────────
check: typecheck lint fix-format-check test ## Run ALL checks: typecheck, lint, format-check, test (mirrors CI)
fix-format-check:
@npx oxfmt --check src/
test: ## Run tests
@npx vitest run
test-watch: ## Run tests in watch mode
@npx vitest
test-cov: ## Run tests with coverage
@npx vitest run --coverage
typecheck: ## TypeScript strict check
@npx tsc --noEmit
lint: ## Run linter
@npx oxlint src/
fix: ## Auto-fix: lint + format
@npx oxlint --fix src/
@npx oxfmt --write src/
# ──────────────────────────────────────────────
# Deployment & Ops
# ──────────────────────────────────────────────
deploy: build ## Build and deploy to Cloudflare
@npx wrangler deploy
logs: ## Tail production logs
@npx wrangler tail
secret: ## Set a secret (usage: make secret KEY=FOO VALUE=bar)
@echo "$(VALUE)" | npx wrangler secret put $(KEY)
secrets: ## List all secrets
@npx wrangler secret list
status: ## Show sandbox containers, images, and listening ports
@echo "=== Sandbox Containers ==="
@docker ps --filter name=sandbox --format 'table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null || true
@echo ""
@echo "=== Sandbox Images ==="
@docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.Size}}' | grep -E 'REPOSITORY|sandbox' || true
@echo ""
@echo "=== Listening Ports (8787, 5173, 18789) ==="
@lsof -iTCP:8787 -iTCP:5173 -iTCP:18789 -sTCP:LISTEN -P -n 2>/dev/null || echo " (none)"
# ──────────────────────────────────────────────
# Docker / Container Helpers
# ──────────────────────────────────────────────
docker-build: ## Force rebuild sandbox image (no cache)
@docker build --no-cache -t cloudflare-dev/sandbox:local .
docker-shell: ## Shell into running sandbox container
@docker exec -it $$(docker ps --filter name=sandbox -q | head -1) bash
docker-logs: ## Tail logs from running sandbox container
@docker logs -f $$(docker ps --filter name=sandbox -q | head -1)
docker-prune: ## Remove old/dangling sandbox images
@echo "Removing dangling images..."
@-docker image prune -f
@echo "Removing old sandbox images..."
@-docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' | grep sandbox | awk '{print $$2}' | xargs -r docker rmi -f 2>/dev/null
@echo "Prune complete."