From 3e5d17a4661d4c3b9dcba7a1fc6e414c762938c5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:09:57 +0000 Subject: [PATCH 1/5] =?UTF-8?q?fix(tools):=20check-catalog.js=20=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20CommonJS=20=E9=81=BF=E5=85=8D=20ESM=20import=20?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 仓库根 package.json 未设置 "type": "module",check-catalog.js 却使用 ESM import 语法,直接 node tools/check-catalog.js 运行会抛出 SyntaxError: Cannot use import statement outside a module。 改为与 tools/ 下其余脚本一致的 CommonJS 写法,并用 __dirname 替代 import.meta.url + fileURLToPath。 Co-authored-by: Shiroha --- tools/check-catalog.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/check-catalog.js b/tools/check-catalog.js index 26a3f4a..4cd259b 100644 --- a/tools/check-catalog.js +++ b/tools/check-catalog.js @@ -11,12 +11,13 @@ * - entry.init 仅在 sapi 类型可选 * - 不允许循环依赖(拓扑排序检测) */ -import { accessSync, constants, readFileSync } from "node:fs"; -import { resolve, join, dirname } from "node:path"; -import { fileURLToPath } from 'node:url'; -import path from "node:path"; +const { accessSync, constants, readFileSync } = require("node:fs"); +const { resolve, join } = require("node:path"); -const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +// 本文件以 CommonJS 方式运行(仓库根 package.json 未设置 "type": "module"), +// 直接使用 __dirname,避免 import.meta.url 触发 "Cannot use import statement +// outside a module" 语法错误。 +const ROOT = resolve(__dirname, ".."); const CATALOG = join(ROOT, "modules", "catalog.json"); const SERVICES_CATALOG = join(ROOT, "services", "catalog.json"); /* SAPI modules no longer register through a single static entry.ts — From 345037c9be9aede15392ee0d24b57e109b921412 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:10:03 +0000 Subject: [PATCH 2/5] =?UTF-8?q?fix(tools):=20check-ootb.js=20/=20sim-new-u?= =?UTF-8?q?ser.js=20=E6=8C=87=E5=90=91=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=20db-server/index.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 真实入口是 db-server/dist/index.js(由 tsc 构建产出),db-server/index.js 从未存在过。这导致 CI 中 'db-server 启动 + 模块接口' 与 'sim-new-user 全流程通过' 两项检查必然失败(进程启动失败 → 健康检查超时)。 改为指向 dist/index.js,并在未构建时给出明确报错提示运行 npm run build。 Co-authored-by: Shiroha --- tools/check-ootb.js | 4 +++- tools/sim-new-user.js | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/check-ootb.js b/tools/check-ootb.js index 970b038..19d6694 100644 --- a/tools/check-ootb.js +++ b/tools/check-ootb.js @@ -106,7 +106,9 @@ function fileContains(p, needle) { { let dbProc = null; try { - dbProc = spawn(process.execPath, [path.join(ROOT, "db-server", "index.js")], { + const dbEntry = path.join(ROOT, "db-server", "dist", "index.js"); + if (!exists(dbEntry)) throw new Error(`db-server 未构建: ${dbEntry} 不存在,请先运行 npm run build`); + dbProc = spawn(process.execPath, [dbEntry], { cwd: ROOT, env: { ...process.env }, stdio: ["ignore", "pipe", "pipe"], diff --git a/tools/sim-new-user.js b/tools/sim-new-user.js index 18990b9..cb7b752 100644 --- a/tools/sim-new-user.js +++ b/tools/sim-new-user.js @@ -29,8 +29,12 @@ function expect(cond, msg) { let dbProc = null; function startDb(simDir) { + const dbEntry = path.join(ROOT, "db-server", "dist", "index.js"); + if (!fs.existsSync(dbEntry)) { + fail(`db-server 未构建: ${dbEntry} 不存在,请先运行 npm run build (或 npm run build --workspace db-server)`); + } const env = { ...process.env, SFMC_ROOT: simDir, DB_PORT: String(DB_PORT) }; - dbProc = spawn(process.execPath, [path.join(ROOT, "db-server", "index.js")], { + dbProc = spawn(process.execPath, [dbEntry], { cwd: ROOT, env, stdio: ["ignore", "pipe", "pipe"], From ef22cdef0ab7a22b2b9a603382c32ee360a7e883 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:10:08 +0000 Subject: [PATCH 3/5] =?UTF-8?q?fix(config):=20db=5Fconfig.json=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=20modulesDir=20=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modulesDir 由 db-server/src/env.ts 通过 resolve(PROJECT_ROOT, modulesDir) 解析,PROJECT_ROOT 即仓库根(SFMC_ROOT)。旧值 "../modules" 会解析到仓库 外的父目录,导致模块 catalog 接口返回空列表(check-ootb 报 'modules 为 空')。改为 "modules",正确解析到 /modules。 Co-authored-by: Shiroha --- configs-default/db_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs-default/db_config.json b/configs-default/db_config.json index 0dff98e..c1380db 100644 --- a/configs-default/db_config.json +++ b/configs-default/db_config.json @@ -3,5 +3,5 @@ "db_port": 3001, "http_auth": "", "dbDir": "./data/sfmc_data.db", - "modulesDir": "../modules" + "modulesDir": "modules" } From 740a261c3d4f3eee9fffc1c8fd71b7de1a475764 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:10:13 +0000 Subject: [PATCH 4/5] =?UTF-8?q?fix(package):=20check-catalog=20npm=20scrip?= =?UTF-8?q?t=20=E8=B7=AF=E5=BE=84=E5=A4=9A=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=89=8D=E5=AF=BC=E6=96=9C=E6=9D=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "node /tools/check-catalog.js" 是从文件系统根解析的绝对路径,该文件从 未存在于 /tools/,脚本会直接报错。改为仓库相对路径 tools/check-catalog.js。 Co-authored-by: Shiroha --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f3d3e81..8f57faf 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "module-core:typecheck": "npm run sdk:typecheck", "module-core:test": "echo \"no sdk tests yet\"", "module-core:verify": "npm run sdk:verify", - "check-catalog": "node /tools/check-catalog.js", + "check-catalog": "node tools/check-catalog.js", "lint": "eslint . --ext .ts,.tsx", "bundle": "node build-sea.mjs", "sea": "node --build-sea sea-config.json" From 875959916c7c39e86bf01dc3c3bc1fcfa4966618 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:10:20 +0000 Subject: [PATCH 5/5] =?UTF-8?q?ci(ootb):=20=E5=9C=A8=20check-ootb=20?= =?UTF-8?q?=E5=89=8D=E4=BB=8E=20configs-default=20=E5=A1=AB=E5=85=85=20con?= =?UTF-8?q?figs/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit configs/ 已被 .gitignore 忽略,CI checkout 后该目录不存在, check-ootb.js 第 1 项 '必备仓库文件齐全' 检查 configs/{db_config,bds_updater,qq_config}.json 因此必然失败。 新增一步在构建之后、检查之前,把 configs-default/*.json 复制到 configs/(仅在目标文件不存在时才复制,不覆盖用户自定义配置)。 Co-authored-by: Shiroha --- .github/workflows/ootb.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ootb.yml b/.github/workflows/ootb.yml index c6ac97d..ca96f44 100644 --- a/.github/workflows/ootb.yml +++ b/.github/workflows/ootb.yml @@ -27,6 +27,15 @@ jobs: shell: pwsh run: npm run build --workspaces --if-present + - name: Populate configs from defaults + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path configs | Out-Null + Get-ChildItem -Path configs-default -Filter *.json | ForEach-Object { + $dest = Join-Path configs $_.Name + if (-not (Test-Path $dest)) { Copy-Item $_.FullName $dest } + } + - name: Run check-ootb shell: pwsh run: node tools/check-ootb.js