From b6a63c9eab52086b106dc515214b0ebb3766de60 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 21 Jul 2026 17:21:41 +0000 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=20ootb=20workflow?= =?UTF-8?q?=20=E8=BF=9E=E7=BB=AD=E5=A4=B1=E8=B4=A5=E2=80=94=E2=80=94check-?= =?UTF-8?q?catalog=20ESM=20=E8=AF=AD=E6=B3=95=E3=80=81db-server=20?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E8=B7=AF=E5=BE=84=E3=80=81=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tools/check-catalog.js: 改回 CommonJS require(仓库根 package.json 未 声明 type:module,ESM import 语法在固定 Node 22.5.x 的 CI 上直接抛 SyntaxError) - tools/check-ootb.js、tools/sim-new-user.js、tools/test-db-api.js: spawn 的 db-server 入口从不存在的 db-server/index.js 改为构建产物 db-server/dist/index.js(导致 db-server 不可达 / sim-new-user 超时) - configs-default/db_config.json: modulesDir 从 "../modules"(相对 PROJECT_ROOT 解析到仓库外)改为 "modules" - .github/workflows/ootb.yml: build 之后新增 Seed configs/ 步骤,从 configs-default/ 拷贝缺失的 json(configs/ 被 gitignore,CI checkout 后为空) - .gitignore: 补充 qq-bridge/dist/、sfmc/dist/(build 产物,此前未忽略) 本地验证: npm install && npm run build --workspaces --if-present 后 node tools/check-ootb.js 从 2 PASS / 4 FAIL 变为 6 PASS / 0 FAIL。 Co-authored-by: Shiroha --- .github/workflows/ootb.yml | 9 +++++++++ .gitignore | 2 ++ configs-default/db_config.json | 2 +- tools/check-catalog.js | 11 ++++++----- tools/check-ootb.js | 2 +- tools/sim-new-user.js | 2 +- tools/test-db-api.js | 4 ++-- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ootb.yml b/.github/workflows/ootb.yml index c6ac97d..71a4844 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: Seed configs/ from configs-default/ + 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 diff --git a/.gitignore b/.gitignore index 8337848..f949c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ bds-tools/dist/ db-server/dist/ panel/dist/ +qq-bridge/dist/ +sfmc/dist/ modules/sdk/@sfmc-sdk/dist/ modules/sdk/@sfmc-sdk/node_modules/ shared/**/dist/ 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..cf9e449 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"; +// 与其余 tools/*.js 保持一致的 CommonJS 写法:仓库根 package.json 未设置 +// "type": "module",若沿用 import 语法,在未启用模块语法自动探测的 Node 版本 +// (例如 CI 固定的 22.5.x)上会直接抛出 SyntaxError。 +const { accessSync, constants, readFileSync } = require("node:fs"); +const { resolve, join } = 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"], diff --git a/tools/test-db-api.js b/tools/test-db-api.js index b82892d..cee487a 100644 --- a/tools/test-db-api.js +++ b/tools/test-db-api.js @@ -62,11 +62,11 @@ async function main() { copy(path.join(ROOT, 'modules', 'module-lock.json'), path.join(workspace, 'modules', 'module-lock.json')); fs.mkdirSync(path.join(workspace, 'data'), { recursive: true }); fs.mkdirSync(path.join(workspace, 'configs'), { recursive: true }); - fs.writeFileSync(path.join(workspace, 'configs', 'db_config.json'), JSON.stringify({ db_port: PORT, dbDir: './data/sfmc_data.db', modulesDir: '../modules' }) + '\n'); + fs.writeFileSync(path.join(workspace, 'configs', 'db_config.json'), JSON.stringify({ db_port: PORT, dbDir: './data/sfmc_data.db', modulesDir: 'modules' }) + '\n'); copy(path.join(ROOT, 'configs', 'qq_config.json'), path.join(workspace, 'configs', 'qq_config.json')); copy(path.join(ROOT, 'configs', 'settings.json'), path.join(workspace, 'configs', 'settings.json')); - const child = spawn(process.execPath, [path.join(ROOT, 'db-server', 'index.js')], { + const child = spawn(process.execPath, [path.join(ROOT, 'db-server', 'dist', 'index.js')], { cwd: ROOT, env: { ...process.env, SFMC_ROOT: workspace, SFMC_DB_PATH: dbPath, SFMC_MODULES_DIR: path.join(workspace, 'modules'), DB_PORT: String(PORT) }, stdio: ['ignore', 'pipe', 'pipe'],