-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (103 loc) · 4.36 KB
/
Copy pathMakefile
File metadata and controls
132 lines (103 loc) · 4.36 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
VERSION := $(shell cat VERSION)
IMAGE_NAME ?= wedding-server
IMAGE_TAG ?= $(VERSION)
.PHONY: all build build-frontend build-admin build-backend clean dev dev-frontend dev-admin dev-backend install install-admin help docker-build docker-run docker-up docker-down version sync-version test test-backend test-frontend test-admin coverage coverage-go coverage-frontend coverage-admin generate-og
all: build
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " all Build everything (default)"
@echo " install Install all frontend dependencies"
@echo " install-admin Install admin frontend dependencies"
@echo " build Build frontend, admin, and backend"
@echo " build-frontend Build Vue.js visitor frontend"
@echo " build-admin Build Vue.js admin frontend"
@echo " build-backend Build Go backend (includes both frontends)"
@echo " clean Remove build artifacts"
@echo " dev Run all dev servers in parallel (Ctrl+C to stop)"
@echo " dev-frontend Run visitor frontend dev server (port 5173)"
@echo " dev-admin Run admin frontend dev server (port 5174)"
@echo " dev-backend Run backend dev server"
@echo " docker-build Build Docker image (IMAGE_NAME=$(IMAGE_NAME), IMAGE_TAG=$(IMAGE_TAG))"
@echo " docker-run Run Docker container"
@echo " docker-up Build image, start compose, show admin password"
@echo " docker-down Stop compose and remove volumes"
@echo " generate-og Generate OG image from wedding config"
@echo " version Print current version"
@echo " test Run all tests (backend + frontend)"
@echo " test-backend Run Go backend unit tests"
@echo " test-frontend Run visitor frontend unit tests"
@echo " test-admin Run admin frontend unit tests (if available)"
@echo " coverage Run all coverage reports"
@echo " coverage-go Generate Go HTML coverage report"
@echo " coverage-frontend Show visitor frontend coverage"
@echo " coverage-admin Show admin frontend coverage"
@echo " sync-version Sync VERSION to frontend/package.json"
@echo " help Show this help message"
test: test-backend test-frontend test-admin
test-backend:
go test ./internal/... -v
test-frontend:
cd frontend && npm run test
test-admin:
cd admin-frontend && npm run test
coverage: coverage-go coverage-frontend coverage-admin
coverage-go:
@echo "── Go Backend Coverage ──"
go test ./internal/... -coverprofile=coverage.out
@go tool cover -func=coverage.out | tail -1
go tool cover -html=coverage.out -o coverage.html
@echo "HTML report: coverage.html"
coverage-frontend:
@echo "── Visitor Frontend Coverage ──"
cd frontend && npx vitest run --coverage 2>&1 || true
coverage-admin:
@echo "── Admin Frontend Coverage ──"
cd admin-frontend && npx vitest run --coverage 2>&1 || true
install:
cd frontend && npm install
cd admin-frontend && npm install
install-admin:
cd admin-frontend && npm install
build: build-frontend build-admin build-backend
sync-version:
cd frontend && npm version $(VERSION) --no-git-tag-version --allow-same-version
generate-og:
cd frontend && npx tsx scripts/generate-og.ts
build-frontend: sync-version generate-og
cd frontend && npm run build
build-admin:
cd admin-frontend && npm run build
build-backend: build-frontend build-admin
CGO_ENABLED=0 go build -tags timetzdata -ldflags "-s -w -X main.Version=$(VERSION)" -o wedding-server .
clean:
rm -f wedding-server
rm -rf web/dist/*
touch web/dist/.gitkeep
rm -rf web/admin/*
touch web/admin/.gitkeep
dev-frontend:
cd frontend && npm run dev -- --host
dev-admin:
cd admin-frontend && npm run dev -- --host
dev-backend:
go run main.go
dev:
@trap 'kill 0' INT TERM; \
(cd frontend && npm run dev) & \
(cd admin-frontend && npm run dev) & \
go run main.go & \
wait
version:
@echo $(VERSION)
docker-build:
docker build --build-arg VERSION=$(VERSION) -t $(IMAGE_NAME):$(IMAGE_TAG) -t $(IMAGE_NAME):latest .
docker-run: docker-build
docker run -d -p 8080:8080 -v wedding-data:/data $(IMAGE_NAME):$(IMAGE_TAG)
docker-up: docker-build
WEDDING_IMAGE=$(IMAGE_NAME):latest docker compose up -d
@sleep 2
@docker compose logs wedding-server 2>/dev/null | grep -A 1 "AUTO-GENERATED ADMIN PASSWORD" || echo "Password already changed or not available"
docker-down:
docker compose down -v