diff --git a/.github/workflows/ootb.yml b/.github/workflows/ootb.yml index c6ac97d..2b0b99b 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 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/.gitignore b/.gitignore index 8337848..08108d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ bds-tools/dist/ db-server/dist/ panel/dist/ +qq-bridge/dist/ +sfmc/dist/ +remote-controller/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/db-server/src/index.ts b/db-server/src/index.ts index b4a149f..746455c 100644 --- a/db-server/src/index.ts +++ b/db-server/src/index.ts @@ -78,7 +78,7 @@ log.success( ); // ── enabled 集合(从 lock file)───────────────────────────── -const lockFile = loadModuleLock(env.MODULE_LOCK_PATH); +let lockFile = loadModuleLock(env.MODULE_LOCK_PATH); const moduleCatalog = readJsonFile<{ modules?: unknown[] }>(env.MODULE_CATALOG_PATH, { modules: [], }); @@ -194,6 +194,8 @@ function setModuleEnabled(mod: { id: string; canDisable: boolean }, enabled: boo const lock = loadModuleLock(env.MODULE_LOCK_PATH); updateModuleState(lock, mod.id, { enabled: !!enabled }); writeJsonFile(env.MODULE_LOCK_PATH, lock); + // 同步内存缓存,避免写入后立即读取(如 enable/disable 接口的返回值)仍是旧状态 + lockFile = lock; } // ── 路由工厂实例 (旧业务路径 — 保留直到各模块迁 v2) ──────────────── diff --git a/tools/check-catalog.js b/tools/check-catalog.js index 26a3f4a..c40ef52 100644 --- a/tools/check-catalog.js +++ b/tools/check-catalog.js @@ -11,12 +11,10 @@ * - 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)), ".."); +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"],