From 03934f70af1bf35b66c74b23d2ba8f2b48252e31 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:29:49 +0000 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=20ootb=20workflow?= =?UTF-8?q?=20=E9=95=BF=E6=9C=9F=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=9B=9B?= =?UTF-8?q?=E5=A4=84=E6=A0=B9=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. tools/check-catalog.js 用了 ESM import 语法,但该文件以 .js 结尾且仓库 根 package.json 没有 "type": "module",Node 按 CJS 解析导致 SyntaxError。改为 require() 风格,与 tools/ 目录其余脚本保持一致。 2. tools/check-ootb.js 和 tools/sim-new-user.js 都 spawn 了 db-server/index.js,但该文件不存在——真实产物入口是 tsc 编译后的 db-server/dist/index.js。两处均修正路径。 3. configs-default/db_config.json 的 modulesDir 默认值是 "../modules", 但 db-server 是相对仓库根解析该路径,会指向仓库外的 /modules 导致模块 API 返回空列表。改为 "modules",与 wizard 生成值和文档一致。 4. .github/workflows/ootb.yml 里 configs/ 从未被创建(已 gitignore), 导致 check-ootb 恒定报缺失 db_config.json/bds_updater.json/ qq_config.json。在 build 之后、check-ootb 之前新增一步,从 configs-default/*.json 复制到 configs/(仅当目标文件不存在时复制)。 本地复现验证:npm run build --workspaces --if-present 后 node tools/check-ootb.js 从 2/6 变为 6/6 全部通过,node tools/smoke-modules.js 也全部通过。 Co-authored-by: Shiroha --- .github/workflows/ootb.yml | 11 +++++++++++ configs-default/db_config.json | 2 +- tools/check-catalog.js | 9 ++++----- tools/check-ootb.js | 2 +- tools/sim-new-user.js | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ootb.yml b/.github/workflows/ootb.yml index c6ac97d..9f6b621 100644 --- a/.github/workflows/ootb.yml +++ b/.github/workflows/ootb.yml @@ -27,6 +27,17 @@ jobs: shell: pwsh run: npm run build --workspaces --if-present + - name: Seed configs/ from configs-default/ + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path configs | Out-Null + Get-ChildItem configs-default/*.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 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" } diff --git a/tools/check-catalog.js b/tools/check-catalog.js index 26a3f4a..35440ff 100644 --- a/tools/check-catalog.js +++ b/tools/check-catalog.js @@ -11,12 +11,11 @@ * - 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, dirname } = require("node:path"); +const path = require("node:path"); -const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +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 — diff --git a/tools/check-ootb.js b/tools/check-ootb.js index 970b038..240bb13 100644 --- a/tools/check-ootb.js +++ b/tools/check-ootb.js @@ -106,7 +106,7 @@ function fileContains(p, needle) { { let dbProc = null; try { - dbProc = spawn(process.execPath, [path.join(ROOT, "db-server", "index.js")], { + dbProc = spawn(process.execPath, [path.join(ROOT, "db-server", "dist", "index.js")], { 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..8206073 100644 --- a/tools/sim-new-user.js +++ b/tools/sim-new-user.js @@ -30,7 +30,7 @@ let dbProc = null; function startDb(simDir) { 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, [path.join(ROOT, "db-server", "dist", "index.js")], { cwd: ROOT, env, stdio: ["ignore", "pipe", "pipe"],