Files
pure-note/Makefile
T

54 lines
1.6 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Pure Note 构建与运维入口
#
# 常用目标:
# make web 构建前端(npm ci + vite build → web/dist)
# make sync-assets 拷贝 web/dist → internal/webui/dist(go:embed 约束,§8.3-1)
# make build 全量构建(前端 + 单二进制 pn)
# make linux 交叉编译 linux/amd64
# make test Go 测试 + 前端测试
# make smoke 真实构建冒烟测试(§8.3-6)
# make dev 双进程热重载(air + vite dev)
# make vulncheck govulncheck
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(DATE)
.PHONY: web sync-assets build linux test smoke dev vulncheck clean
web:
cd web && npm ci && npm run build
# go:embed 只能引用本包目录树内文件:产物必须拷进 internal/webui/dist
sync-assets:
rm -rf internal/webui/dist
cp -r web/dist internal/webui/dist
touch internal/webui/dist/.gitkeep
build: web sync-assets
CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o pn ./cmd/pn
linux: web sync-assets
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="$(LDFLAGS)" \
-o pn-linux-amd64 ./cmd/pn
test:
go vet ./...
go test ./...
cd web && npm test
# 构建冒烟(§8.3-6):真实构建 → 起服务 → 断言公开页与 script/link 资源 200 + 正确 MIME
smoke: build
./scripts/smoke.sh
dev:
air &
cd web && npm run dev
vulncheck:
govulncheck ./...
clean:
rm -f pn pn-linux-amd64