chore: directory migration - gateway→server, web→client/electron

This commit is contained in:
2026-09-08 19:16:35 +08:00
parent fd9f99a3f9
commit f9d757b5e5
243 changed files with 5095 additions and 228 deletions

View File

@ -64,7 +64,7 @@ run() {
eval "$@"
}
[ -d "$REPO/gateway" ] || { bad "找不到 $REPO/gateway"; exit 2; }
[ -d "$REPO/server" ] || { bad "找不到 $REPO/server"; exit 2; }
command -v sqlite3 >/dev/null 2>&1 || { bad "缺少 sqlite3无法安全备份数据库"; exit 2; }
say "0. 计划"
@ -75,17 +75,17 @@ printf ' 服务 : %s\n' "$SERVICE"
[ "$DRY_RUN" = 1 ] && printf ' 模式 : DRY-RUN不落地\n' || printf ' 模式 : 真实执行\n'
# ---------------------------------------------------------------- 1 前端产物
if [ "$SYNC_WEB" = 1 ] && [ -d "$REPO/web/dist/assets" ]; then
if [ "$SYNC_WEB" = 1 ] && [ -d "$REPO/client/electron/dist/assets" ]; then
say "1. 同步前端产物进 go:embed 目录"
# 只清构建产物placeholder.html 在版本库里(让 go:embed 在新克隆里能编译),
# 删掉它会让 git 看到一个本地删除,下一次 commit -a 就把它从仓库带走。
run "rm -rf '$REPO/gateway/internal/static/static/assets'"
run "rm -f '$REPO/gateway/internal/static/static/index.html'"
run "cp -r '$REPO/web/dist/.' '$REPO/gateway/internal/static/static/'"
run "rm -rf '$REPO/server/internal/static/static/assets'"
run "rm -f '$REPO/server/internal/static/static/index.html'"
run "cp -r '$REPO/client/electron/dist/.' '$REPO/server/internal/static/static/'"
ok "前端产物已同步"
else
say "1. 跳过前端同步"
[ "$SYNC_WEB" = 0 ] && ok "--skip-web" || warn "web/dist 不存在,先跑 cd web && npm run build"
[ "$SYNC_WEB" = 0 ] && ok "--skip-web" || warn "client/electron/dist 不存在,先跑 cd client/electron && npm run build"
fi
# ---------------------------------------------------------------- 2 静态检查与测试
@ -93,12 +93,12 @@ say "2. 构建前检查"
if [ "$DRY_RUN" = 1 ]; then
printf ' [dry-run] go vet ./... && go test ./...\n'
else
( cd "$REPO/gateway" && go vet ./... ) || { bad "go vet 不过,终止"; exit 1; }
( cd "$REPO/server" && go vet ./... ) || { bad "go vet 不过,终止"; exit 1; }
ok "go vet 通过"
if [ "$SKIP_TESTS" = 1 ]; then
warn "--skip-tests跳过测试急救模式事后必须补跑"
else
( cd "$REPO/gateway" && timeout 280 go test ./... -timeout 250s ) \
( cd "$REPO/server" && timeout 280 go test ./... -timeout 250s ) \
|| { bad "测试不过,终止部署"; exit 1; }
ok "go test 全包通过"
fi
@ -110,9 +110,9 @@ STAGE="/tmp/agentmail-gateway-build-$TS"
# 先删再建go build -o 到已存在的路径时可能拿到 stale 二进制(此坑中过多次)
run "rm -f '$STAGE'"
if [ "$DRY_RUN" = 1 ]; then
printf ' [dry-run] (cd gateway && go build -o %s ./cmd/server)\n' "$STAGE"
printf ' [dry-run] (cd server && go build -o %s ./cmd/server)\n' "$STAGE"
else
( cd "$REPO/gateway" && go build -o "$STAGE" ./cmd/server ) \
( cd "$REPO/server" && go build -o "$STAGE" ./cmd/server ) \
|| { bad "构建失败"; exit 1; }
ok "构建完成 $(du -h "$STAGE" | cut -f1)"
fi