fix(deploy): 未选模块重部署后删除其 zone 路由 /m/<id>/*(#77) - #78
Merged
Conversation
- steps:步骤④′ 对 config.modules 未列出的已存在模块删除 zone 路由 /m/<id>/*, 幂等(不存在不报错)、只删路由(不删 Worker、不动 D1,数据保留);步骤日志记录删除动作 - dns:新增 removeModuleRoutes(CF API GET/DELETE /zones/<id>/workers/routes, 精确匹配 pattern,查询/删除失败只记日志不中断,风格同 removeLegacyCustomDomains) - config:modules 允许空数组(移除唯一模块可表达;§6.5 全停用空态) - test:dns 5 用例 + steps 2 用例(未选模块删除动作 + 注册表 disable 并存、无 domain 跳过)+ config 空列表 Signed-off-by: HandyWote <huangyinghui01@corp.netease.com>
This was referenced Sep 9, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Closes #77
#16 七步剧本第 7 步验收条款(
docs/requirements.mdL207 /docs/PRODUCT_SPEC.md§M0 L472):「移除模块重部署后路由消失」。真机实测当前部署器只把未选中模块翻转注册表enabled=0(not_deployed),zone 路由/m/<id>/*原样保留(/m/hello/仍 200 命中模块 Worker)——验收条款未达标。主会话与用户 2026-09-09 拍板:补实现(不改验收条款;§5.4 卸载三选一属 M1,本 PR 只做 M0 要求的「路由消失」,数据保留不动 D1)。
改动
deploy/cloudflare/src/dns.tsremoveModuleRoutes:CF APIGET /zones/<zoneId>/workers/routes→ 对未选模块精确匹配pattern === "<domain>/m/<id>/*"→DELETE /zones/<zoneId>/workers/routes/<routeId>。幂等:路由不存在不报错、零 DELETE 只记日志;查询/删除失败只记日志不中断(风格同removeLegacyCustomDomains)deploy/cloudflare/src/steps.tsconfig.modules未列出的已存在模块调用删除;未配置 domain(无 zone 路由)时记日志跳过;删除动作经 reporter 记入步骤日志;测试注入口cleanupModuleRoutes(默认真实实现)deploy/cloudflare/src/config.tsmodules去掉.min(1)——允许[](移除唯一模块可表达;§6.5 App.vue 已有全停用空态)deploy/cloudflare/test/dns.test.tsdeploy/cloudflare/test/steps.test.tsenabled = 0照旧 + 删除先于步骤⑤ + 未选模块不重新部署;无 domain 时跳过删除deploy/cloudflare/test/config.test.ts边界(按 issue 明确):只删 zone 路由。不删模块 Worker、不动模块 D1(数据保留;完整卸载剧本属 M1)。注册表
enabled=0(not_deployed)行为保持现状。破坏性回验(红 → 绿)
if (false) await cleanupRoutes(...))steps.test.ts > 未选模块(modules: [])…→AssertionError: expected [] to have a length of 1 but got +0for (const id of [] as string[]))dns.test.tsremoveModuleRoutes 3 用例失败(expected [] to have a length of 1/expected false to be true)两处独立守卫(编排接线 / CF API 删除)分别回验,均已还原,
git diff无破坏性残留。验收对照表(issue #77)
m0/dev;不合并m0/dev;本 PR 不合并(rebase 合并,线性)/m/hello/*路由已消失 → 恢复 hello 重部署 → 路由回来三件套验证(issue #77 · m0/issue-77)
typecheck ✅
pnpm -r typecheckEXIT=0 —— 7 个项目全过(contracts / ui / shell / cloudflare / module-sdk / core-api / hello)。test ✅
pnpm -r testEXIT=0 —— 7 包 32 文件 275 用例全绿:deploy/cloudflare69 → 77(#77 新增 8 用例)。build ✅
pnpm -r buildEXIT=0 —— 7 包全过(shell dist:index.html+index-HAX6bGJC.css+index-D_KFHRjM.js)。工作区卫生:
git status --short仅 #77 的 6 个文件;.deploy/、dist/均在 gitignore 内。