-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (58 loc) · 2.34 KB
/
Copy pathMakefile
File metadata and controls
77 lines (58 loc) · 2.34 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
BINARY := solid-mind
APP := solid-mind
# Ports used by the dev servers (frontend, backend, and PocketBase-style API)
PORTS := 3000 3001
# ─────────────────────────────────────────
# Default: build & start server
# ─────────────────────────────────────────
.PHONY: all
all: kill-ports frontend## (*) Build frontend assets and start the server
go run cmd/$(BINARY)/main.go superuser upsert admin@mail.internal password --dir=pb_data
go run cmd/$(BINARY)/main.go serve
# ─────────────────────────────────────────
# Frontend (Vite build -> internal/handler/dist, embedded via go:embed)
# ─────────────────────────────────────────
.PHONY: frontend
frontend: frontend/node_modules
cd frontend && pnpm run build
frontend/node_modules: frontend/package.json frontend/pnpm-lock.yaml
cd frontend && pnpm install --frozen-lockfile
touch $@
# ─────────────────────────────────────────
# Misc
# ─────────────────────────────────────────
.PHONY: clean
clean: ## Remove build artifacts
rm -rf internal/assets/dist
.PHONY: kill-ports
kill-ports:
@for port in $(PORTS); do \
pid=$$(lsof -ti tcp:$$port); \
if [ -n "$$pid" ]; then \
echo "Killing process on port $$port (pid $$pid)"; \
kill -9 $$pid; \
fi \
done
.PHONY: clean
rm -fr ./tmp/ # air
# -------------------------
# port: 3001
.PHONY: dev-front
dev-front:
npx concurrently -n "frontend,backend" -c "blue,green" "cd frontend && pnpm dev" "go run cmd/$(BINARY)/main.go serve"
# port: 3000
.PHONY: dev-back
dev-back:
npx concurrently -n "frontend,backend" -c "blue,green" "cd frontend && pnpm watch" "air"
.PHONY: test
test:
cd frontend && pnpm test
go test ./...
format:
cd frontend && pnpm exec prettier --write "src/**/*.{js,jsx,css}"
migrate-collections:
yes | go run ./cmd/solid-mind migrate collections
build: frontend
go build -o $(BINARY) ./cmd/$(BINARY)
lint:
golangci-lint run; cd frontend && pnpm run lint