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

@ -15,8 +15,8 @@ ETC=/etc/agentmail
[[ $EUID -eq 0 ]] || { echo "需要 rootsudo $0" >&2; exit 1; }
echo "==> 构建前端"
( cd "$REPO/web" && npm ci --no-audit --no-fund 2>/dev/null || npm install --no-audit --no-fund )
( cd "$REPO/web" && npm run typecheck && npm test && npm run build )
( cd "$REPO/client/electron" && npm ci --no-audit --no-fund 2>/dev/null || npm install --no-audit --no-fund )
( cd "$REPO/client/electron" && npm run typecheck && npm test && npm run build )
echo "==> 校验插件共用模块同源"
# lib/ 下的纯函数模块在三个插件里逐字节相同(见 docs/PLUGIN-CONTRACT.md 第六节)。
@ -34,7 +34,7 @@ fi
# DSH 插件:先构建再跑测试。
#
# 它是 TypeScript 写的package.json 的 main 指向 dist/index.js而 dist/ 不进版本库
# (与 web/dist 同理)—— 新克隆里不先 tscDSH 加载插件时会直接找不到入口。
# (与 client/electron/dist 同理)—— 新克隆里不先 tscDSH 加载插件时会直接找不到入口。
# 测试本身只碰 lib/ 下的纯函数(不依赖 dist但先构建能把类型错误也当成门禁。
#
# 盖住的三类约定都是「错了不当场报错、只在深处炸一个无关错误」:
@ -64,18 +64,18 @@ echo "==> 前端产物嵌入 Gateway"
# 只清构建产物,不能 rm -rf 整个目录:
# placeholder.html 在版本库里(让 go:embed 在新克隆里能编译),
# 删掉它会让 git 看到一个本地删除,下一次 commit -a 就把它从仓库里带走了。
rm -rf "$REPO/gateway/internal/static/static/assets"
rm -f "$REPO/gateway/internal/static/static/index.html"
cp -r "$REPO/web/dist/." "$REPO/gateway/internal/static/static/"
rm -rf "$REPO/server/internal/static/static/assets"
rm -f "$REPO/server/internal/static/static/index.html"
cp -r "$REPO/client/electron/dist/." "$REPO/server/internal/static/static/"
echo "==> 构建 Gateway单二进制内含前端 + SQLite"
# 先删再建go build -o 到已存在的路径时可能拿到 stale 二进制(此坑中过多次)
rm -f "$REPO/gateway/agentmail-gateway"
( cd "$REPO/gateway" && go vet ./... && go test ./... && go build -o "$REPO/gateway/agentmail-gateway" ./cmd/server )
rm -f "$REPO/server/agentmail-gateway"
( cd "$REPO/server" && go vet ./... && go test ./... && go build -o "$REPO/server/agentmail-gateway" ./cmd/server )
echo "==> 安装到 $PREFIX"
install -d "$PREFIX" "$PREFIX/data" "$ETC"
install -m 0755 "$REPO/gateway/agentmail-gateway" "$PREFIX/agentmail-gateway"
install -m 0755 "$REPO/server/agentmail-gateway" "$PREFIX/agentmail-gateway"
# ---- env 文件:仅在缺失时生成,密码随机 ----
if [[ ! -f "$ETC/gateway.env" ]]; then