fix(ci): 修复 ootb workflow 连续失败——db-server 入口路径、check-catalog ESM 语法、缺失 configs#8
Closed
cursor[bot] wants to merge 4 commits into
Closed
fix(ci): 修复 ootb workflow 连续失败——db-server 入口路径、check-catalog ESM 语法、缺失 configs#8cursor[bot] wants to merge 4 commits into
cursor[bot] wants to merge 4 commits into
Conversation
… 上的 ESM SyntaxError check-catalog.js 此前用 import/import.meta.url 编写,但仓库根 package.json 未 声明 "type": "module",且与其余 tools/*.js(均为 CommonJS)风格不一致。 本地较新的 Node(22.14+)具备自动模块语法探测所以能跑通,但 ootb.yml 固定 的 node-version: '22.5' 解析出的 22.5.1 不支持该探测,直接抛出 'Cannot use import statement outside a module',导致 check-ootb 第 3 项 必然失败。改为 require + __dirname 后不再依赖 Node 版本的探测行为。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
db-server 只在 package.json#main 指向 dist/index.js(编译产物),仓库里 从没有 db-server/index.js 这个文件(历史上曾存在,后作为死代码被删除, 但引用它的三处调用点没有同步更新)。这导致: - check-ootb.js 第 6 项 'db-server 启动 + 模块接口' 必然报 'db-server 不可达' - check-ootb.js 第 7 项内部调用的 sim-new-user.js 必然超时 - tools/test-db-api.js 手测脚本同样起不来 db-server 统一改为 db-server/dist/index.js。顺带修正 test-db-api.js 里写入的 临时 db_config.json,其 modulesDir 沿用了同一处 '../modules' 笔误 (见下一条 commit 对 configs-default 的修正),改为与新建的 workspace/modules 目录匹配的 'modules'。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
db-server/src/env.ts 用 resolve(PROJECT_ROOT, dbconfig.modulesDir) 解析 modulesDir,PROJECT_ROOT 就是仓库根(SFMC_ROOT)。默认模板写的 '../modules' 会解析到仓库根的上一级目录(即仓库外部),导致 GET /api/sfmc/modules/catalog 读到空目录、模块列表永远为空, 命中 AGENTS.md 里记录的已知坑。改为 'modules',与 'configs/ 缺失时回退到 join(PROJECT_ROOT, "modules")' 的默认行为保持一致。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
configs/ 在 .gitignore 中被忽略,全新 checkout(包括 CI runner)不会带上 db_config.json / bds_updater.json / qq_config.json。本地开发时靠 'sfmc init' 交互式向导写入,但 CI 里没有 TTY 跑不了向导,而 check-ootb.js 的第 1 项检查又要求这些文件必须存在于仓库工作区中,于是每次 push 到 main/refactor/** 都必然失败。新增一步,在 build 之后、check-ootb 之前, 从 configs-default/*.json 补全 configs/(已存在的文件不覆盖,保留人工 写入的真实配置)。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
This was referenced Jul 21, 2026
Member
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.
背景
本次 push(
docs(platform): update HANDOFF.md)本身只改了文档,但触发的ootbworkflow 依旧失败——事实上main分支最近多次 push 的ootb检查全部是红的。逐个排查后确认是三处独立的、真实存在的 bug,而不是环境问题:根因与修复
db-server/index.js不存在 —db-server的可执行入口只有dist/index.js(编译产物,package.json#main),仓库里从未有过顶层index.js这个 shim 文件(历史上存在过,后作为死代码被删除,但三处调用点没有同步更新):tools/check-ootb.js第 6 项「db-server 启动 + 模块接口」→ 报错db-server 不可达tools/check-ootb.js第 7 项内部调用的tools/sim-new-user.js→ 超时tools/test-db-api.js(手测脚本)同样起不来统一改为
db-server/dist/index.js。tools/check-catalog.js用 ESMimport,其余tools/*.js全是 CommonJS — 仓库根package.json没有"type": "module"。本地较新 Node(22.14+)有自动模块语法探测所以能跑,但ootb.yml固定的node-version: '22.5'(解析为 22.5.1)不支持该探测,直接报SyntaxError: Cannot use import statement outside a module。改为require+__dirname,和其余工具脚本风格一致,不再依赖 Node 版本行为。CI 里
configs/从未被填充 —configs/在.gitignore中,全新 checkout(含 CI runner)不会带上db_config.json等文件;本地靠sfmc init交互式向导写入,CI 没有 TTY 跑不了向导。而check-ootb.js第 1 项检查要求这些文件必须存在,于是每次 push 必然报「必备仓库文件齐全」失败。新增一步,在 build 之后、check-ootb 之前,从configs-default/*.json补全configs/(已存在的文件不覆盖)。顺带修正:
configs-default/db_config.json里modulesDir默认值是"../modules",但db-server/src/env.ts用resolve(PROJECT_ROOT, modulesDir)解析(PROJECT_ROOT即仓库根),会解析到仓库外部,导致模块目录 API 永远为空。改为"modules"。tools/test-db-api.js里手写的临时 config 有同样的笔误,一并修正。验证
在本地(Linux)完整复现了 CI 步骤:
npm install→npm run build --workspaces --if-present→ 补configs/→node tools/check-ootb.js:修复前:
通过 2 / 失败 4(必备仓库文件齐全 / check-catalog / db-server 启动 / sim-new-user 均失败)修复后:
通过 6 / 失败 0,并额外验证node tools/smoke-modules.js(针对真实 db-server 起服务)全部通过。所有改动均为最小侵入的路径/配置修正,未触碰任何模块业务逻辑。