- 新增 desktop 应用入口,将后端与前端打包为单一可执行文件 - 集成系统托盘功能(getlantern/systray) - 支持单实例锁和端口冲突检测 - 启动时自动打开浏览器显示管理界面 - 新增 embedfs 模块嵌入静态资源 - 新增跨平台构建脚本(macOS/Windows/Linux) - 新增 macOS .app 打包脚本 - 统一 Makefile,移除 backend/Makefile - 更新 README 添加桌面应用使用说明
116 lines
3.4 KiB
Makefile
116 lines
3.4 KiB
Makefile
.PHONY: all clean \
|
|
backend-build backend-run backend-test backend-test-unit backend-test-integration backend-test-coverage \
|
|
backend-lint backend-deps backend-generate \
|
|
backend-migrate-up backend-migrate-down backend-migrate-status backend-migrate-create \
|
|
frontend-build frontend-dev frontend-test frontend-test-watch frontend-test-coverage frontend-test-e2e frontend-lint \
|
|
desktop desktop-darwin desktop-windows desktop-linux package-macos
|
|
|
|
# ============================================
|
|
# 后端
|
|
# ============================================
|
|
|
|
all: backend-build
|
|
|
|
backend-build:
|
|
cd backend && go build -o bin/server ./cmd/server
|
|
|
|
backend-run:
|
|
cd backend && go run ./cmd/server
|
|
|
|
backend-test:
|
|
cd backend && go test ./... -v
|
|
|
|
backend-test-unit:
|
|
cd backend && go test ./internal/... ./pkg/... -v
|
|
|
|
backend-test-integration:
|
|
cd backend && go test ./tests/... -v
|
|
|
|
backend-test-coverage:
|
|
cd backend && go test ./... -coverprofile=coverage.out
|
|
cd backend && go tool cover -html=coverage.out -o coverage.html
|
|
@echo "Coverage report generated: backend/coverage.html"
|
|
|
|
backend-lint:
|
|
cd backend && go tool golangci-lint run ./...
|
|
|
|
backend-deps:
|
|
cd backend && go mod tidy
|
|
|
|
backend-generate:
|
|
cd backend && go generate ./...
|
|
|
|
backend-migrate-up:
|
|
cd backend && goose -dir migrations sqlite3 $(DB_PATH) up
|
|
|
|
backend-migrate-down:
|
|
cd backend && goose -dir migrations sqlite3 $(DB_PATH) down
|
|
|
|
backend-migrate-status:
|
|
cd backend && goose -dir migrations sqlite3 $(DB_PATH) status
|
|
|
|
backend-migrate-create:
|
|
@read -p "Migration name: " name; \
|
|
cd backend && goose -dir migrations create $$name sql
|
|
|
|
# ============================================
|
|
# 前端
|
|
# ============================================
|
|
|
|
frontend-build:
|
|
cd frontend && bun install && bun run build
|
|
|
|
frontend-dev:
|
|
cd frontend && bun dev
|
|
|
|
frontend-test:
|
|
cd frontend && bun run test
|
|
|
|
frontend-test-watch:
|
|
cd frontend && bun run test:watch
|
|
|
|
frontend-test-coverage:
|
|
cd frontend && bun run test:coverage
|
|
|
|
frontend-test-e2e:
|
|
cd frontend && bun run test:e2e
|
|
|
|
frontend-lint:
|
|
cd frontend && bun run lint
|
|
|
|
# ============================================
|
|
# 桌面应用
|
|
# ============================================
|
|
|
|
desktop: frontend-build-desktop embedfs-prepare
|
|
cd backend && CGO_ENABLED=1 go build -o ../build/nex ./cmd/desktop
|
|
|
|
frontend-build-desktop:
|
|
cd frontend && cp .env.desktop .env.production.local && bun install && bun run build && rm -f .env.production.local
|
|
|
|
embedfs-prepare:
|
|
rm -rf embedfs/assets embedfs/frontend-dist
|
|
cp -r assets embedfs/assets
|
|
cp -r frontend/dist embedfs/frontend-dist
|
|
|
|
desktop-darwin: frontend-build-desktop embedfs-prepare
|
|
cd backend && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o ../build/nex-darwin-arm64 ./cmd/desktop
|
|
cd backend && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o ../build/nex-darwin-amd64 ./cmd/desktop
|
|
|
|
desktop-windows: frontend-build-desktop embedfs-prepare
|
|
cd backend && CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags "-H=windowsgui" -o ../build/nex-windows-amd64.exe ./cmd/desktop
|
|
|
|
desktop-linux: frontend-build-desktop embedfs-prepare
|
|
cd backend && CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o ../build/nex-linux-amd64 ./cmd/desktop
|
|
|
|
package-macos:
|
|
./scripts/build/package-macos.sh
|
|
|
|
# ============================================
|
|
# 清理
|
|
# ============================================
|
|
|
|
clean:
|
|
rm -rf backend/bin/ backend/coverage.out backend/coverage.html
|
|
rm -rf build/
|