From 75332263669105ea6fae167fb7457c6a9c3d5231 Mon Sep 17 00:00:00 2001 From: SkyJourney Date: Wed, 26 Aug 2026 20:05:00 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=A7=84=E8=8C=83=E5=8C=96=20DOCX=20?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=A8=E7=A6=81=E4=BA=A7=E5=87=BA=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=B9=B6=E6=96=B0=E5=A2=9E=E6=B8=85=E7=90=86=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题修复:verify-docx-release-gate-suite.mjs 默认输出目录此前写死为 output/docx-release-gate-v0.6.2,版本升级后需要手工改字符串。改为从根 package.json 动态读取版本号,生成 output/docx-release-gate/v/, 环境变量 MD_TO_PDF_RELEASE_GATE_OUTPUT_DIR 覆盖行为不变。 新增能力:新增 npm run clean:docx-gate-output,清理新目录结构及历史遗留的 output/docx-release-gate-v* 旧命名目录。 验证结果:test:docx-release-gate-suites、test:docx-real-world-corpus 通过; 本机手工构造新旧两种命名目录验证清理脚本均能正确删除且不误删其他 output 子目录。 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01K5N6pcbjV4jVfXrcH3NcLP --- package.json | 1 + scripts/clean-docx-gate-output.mjs | 28 ++++++++++++++++++++++ scripts/verify-docx-release-gate-suite.mjs | 5 +++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 scripts/clean-docx-gate-output.mjs diff --git a/package.json b/package.json index 293bde5..5035453 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "verify:docx-layout-visual-matrix": "npm run test:docx-layout-visual-matrix-cases && npm run verify:font-pack && npm run build:web-runtime && npm run build -w @md-to-pdf/document-visual-diff && npm run build -w @md-to-pdf/server && node scripts/verify-docx-layout-visual-matrix.mjs", "verify:docx-release-gate-suite": "npm run test:docx-layout-visual-matrix-cases && npm run test:docx-real-world-corpus && npm run test:docx-release-gate-suites && npm run verify:font-pack && npm run build:web-runtime && npm run build -w @md-to-pdf/document-visual-diff && npm run build -w @md-to-pdf/server && node scripts/verify-docx-release-gate-suite.mjs", "verify:docx-release-gate-560": "npm run verify:docx-release-gate-suite", + "clean:docx-gate-output": "node scripts/clean-docx-gate-output.mjs", "test": "npm run test:release-stage && npm run test:docx-layout-visual-matrix-cases && npm run test:docx-real-world-corpus && npm run test:docx-release-gate-suites && npm run test -w @md-to-pdf/markdown-echarts && npm run test -w @md-to-pdf/core && npm run build -w @md-to-pdf/core && npm run test -w @md-to-pdf/semantic-document && npm run build -w @md-to-pdf/semantic-document && npm run test -w @md-to-pdf/docx-theme-engine && npm run test -w @md-to-pdf/document-visual-diff && npm run test -w @md-to-pdf/font-pack-registry && npm run build -w @md-to-pdf/font-pack-registry && npm run test -w @md-to-pdf/docx-engine && npm run build -w @md-to-pdf/docx-engine && npm run test -w @md-to-pdf/font-pack-builder && npm run test -w @md-to-pdf/renderer && npm run test -w @md-to-pdf/application && npm run build -w @md-to-pdf/application && npm run test -w @md-to-pdf/preview-engine && npm run build -w @md-to-pdf/preview-engine && npm run test -w @md-to-pdf/web && npm run test -w @md-to-pdf/server && npm run test -w @md-to-pdf/desktop", "typecheck": "npm run typecheck -w @md-to-pdf/markdown-echarts && npm run build -w @md-to-pdf/markdown-echarts && npm run typecheck -w @md-to-pdf/core && npm run build -w @md-to-pdf/core && npm run typecheck -w @md-to-pdf/semantic-document && npm run build -w @md-to-pdf/semantic-document && npm run typecheck -w @md-to-pdf/docx-theme-engine && npm run build -w @md-to-pdf/docx-theme-engine && npm run typecheck -w @md-to-pdf/document-visual-diff && npm run typecheck -w @md-to-pdf/font-pack-registry && npm run typecheck -w @md-to-pdf/docx-engine && npm run build -w @md-to-pdf/docx-engine && npm run typecheck -w @md-to-pdf/font-pack-builder && npm run typecheck -w @md-to-pdf/renderer && npm run build -w @md-to-pdf/renderer && npm run typecheck -w @md-to-pdf/application && npm run build -w @md-to-pdf/application && npm run typecheck -w @md-to-pdf/preview-engine && npm run build -w @md-to-pdf/preview-engine && npm run typecheck -w @md-to-pdf/web && npm run typecheck -w @md-to-pdf/server && npm run typecheck -w @md-to-pdf/desktop" }, diff --git a/scripts/clean-docx-gate-output.mjs b/scripts/clean-docx-gate-output.mjs new file mode 100644 index 0000000..33d6d45 --- /dev/null +++ b/scripts/clean-docx-gate-output.mjs @@ -0,0 +1,28 @@ +import fs from "node:fs"; +import path from "node:path"; + +const repositoryDirectory = path.resolve(import.meta.dirname, ".."); +const outputDirectory = path.join(repositoryDirectory, "output"); + +const targets = [path.join(outputDirectory, "docx-release-gate")]; + +if (fs.existsSync(outputDirectory)) { + for (const entry of fs.readdirSync(outputDirectory, { withFileTypes: true })) { + if (entry.isDirectory() && /^docx-release-gate-v/u.test(entry.name)) { + targets.push(path.join(outputDirectory, entry.name)); + } + } +} + +let removedCount = 0; +for (const target of targets) { + if (fs.existsSync(target)) { + fs.rmSync(target, { recursive: true, force: true }); + process.stdout.write(`已删除:${path.relative(repositoryDirectory, target)}\n`); + removedCount += 1; + } +} + +if (removedCount === 0) { + process.stdout.write("没有找到需要清理的门禁产出目录。\n"); +} diff --git a/scripts/verify-docx-release-gate-suite.mjs b/scripts/verify-docx-release-gate-suite.mjs index 0f9f9e6..ead541e 100644 --- a/scripts/verify-docx-release-gate-suite.mjs +++ b/scripts/verify-docx-release-gate-suite.mjs @@ -16,10 +16,13 @@ import { const execFileAsync = promisify(execFile); const repositoryDirectory = path.resolve(import.meta.dirname, ".."); const matrixScript = path.join(repositoryDirectory, "scripts", "verify-docx-layout-visual-matrix.mjs"); +const repositoryVersion = JSON.parse( + fs.readFileSync(path.join(repositoryDirectory, "package.json"), "utf8") +).version; const outputRoot = path.resolve( repositoryDirectory, process.env.MD_TO_PDF_RELEASE_GATE_OUTPUT_DIR?.trim() || - "output/docx-release-gate-v0.6.2" + path.join("output", "docx-release-gate", `v${repositoryVersion}`) ); const requestedSuiteId = process.env.MD_TO_PDF_RELEASE_GATE_SUITE?.trim() || "next"; const selectedCaseId = process.env.MD_TO_PDF_RELEASE_GATE_CASE?.trim() || undefined;