新增通用 CSS 到 OOXML 翻译修复,统一字体、字距、精确行距、段落、列表、表格、引用、代码块与行内代码连续性,不引入按主题 ID 分支。 新增 MdTP Mono 并统一 Serif、Sans、Mono 三字体包的 Chromium 与 DOCX 使用链;字体声明、嵌入部件和 Word/WPS 实际采用均进入硬门禁。 重建封面整页及正文语义块视觉差分,14 套主题、纵横两个方向、五组页边距共 140 个真实场景全部通过,阻断失败和诊断失败均为零。 源码服务、Docker Web API 与实际安装 Desktop 的 red-briefing 导出均包含 5 个字体部件;Word/WPS 原生渲染和逐页复核通过。修复 Docker 构建上下文与运行层复用软链接,并完善 v0.6.1 版本、发行说明和发布归集。 验证:npm test(116 个文件、616 项测试)、npm run typecheck、npm run build、git diff --check 全部通过。Desktop 安装器与 ZIP、Docker v0.6.1 镜像已生成;Windows 产物仍为未签名内部发行。
102 lines
3.4 KiB
TypeScript
102 lines
3.4 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
interface PackageManifest {
|
|
scripts?: Record<string, string>;
|
|
}
|
|
|
|
const projectRoot = fileURLToPath(
|
|
new URL("../../../", import.meta.url)
|
|
);
|
|
|
|
function readProjectFile(relativePath: string) {
|
|
return readFileSync(`${projectRoot}/${relativePath}`, "utf8");
|
|
}
|
|
|
|
describe("Docker v0.6.1 部署契约", () => {
|
|
it("完整构建并复制 DOCX 运行时工作区和 Lua Filter", () => {
|
|
const dockerfile = readProjectFile("deploy/Dockerfile");
|
|
const workspaces = [
|
|
"semantic-document",
|
|
"docx-theme-engine",
|
|
"font-pack-registry",
|
|
"docx-engine"
|
|
];
|
|
|
|
for (const workspace of workspaces) {
|
|
expect(dockerfile).toContain(
|
|
`COPY packages/${workspace}/package.json packages/${workspace}/package.json`
|
|
);
|
|
expect(dockerfile).toContain(
|
|
`npm run build -w @md-to-pdf/${workspace}`
|
|
);
|
|
expect(dockerfile).toContain(
|
|
`/app/packages/${workspace}/dist ./packages/${workspace}/dist`
|
|
);
|
|
}
|
|
expect(dockerfile).toContain(
|
|
"/app/packages/docx-engine/assets ./packages/docx-engine/assets"
|
|
);
|
|
expect(dockerfile).toContain("COPY tsconfig.base.json product.json ./");
|
|
});
|
|
|
|
it("固定校验 Pandoc 二进制、许可证、版权和最终版本", () => {
|
|
const dockerfile = readProjectFile("deploy/Dockerfile");
|
|
|
|
expect(dockerfile).toContain("ARG PANDOC_VERSION=3.9.0.2");
|
|
expect(dockerfile).toContain(
|
|
"A69ABFABABDA8A56969A254B09F9553A7BE89DDEC00D4E0FE9FD585D71A67508"
|
|
);
|
|
expect(dockerfile).toContain(
|
|
"9D56CAC92294E206AF026A5502BEE0FED77200B08B51EC28AA63C9EFDA4DCFDD"
|
|
);
|
|
expect(dockerfile).toContain(
|
|
"842E33EF01625E93F85BEBB8BAC83AA570186B7AA77A09971257CC29F8F60740"
|
|
);
|
|
expect(dockerfile).toContain(
|
|
"COPY --from=pandoc-runtime /opt/pandoc/3.9.0.2 /opt/pandoc/3.9.0.2"
|
|
);
|
|
expect(dockerfile).toContain(
|
|
"ln -sfn /opt/pandoc/3.9.0.2/bin/pandoc /usr/local/bin/pandoc"
|
|
);
|
|
expect(dockerfile).toContain(
|
|
'test "$(pandoc --version | head -n 1)" = "pandoc 3.9.0.2"'
|
|
);
|
|
});
|
|
|
|
it("将受校验字体包内置到镜像并取消运行时字体挂载", () => {
|
|
const dockerfile = readProjectFile("deploy/Dockerfile");
|
|
const compose = readProjectFile("deploy/compose.yaml");
|
|
const dockerignore = readProjectFile(".dockerignore");
|
|
const dockerfileIgnore = readProjectFile(
|
|
"deploy/Dockerfile.dockerignore"
|
|
);
|
|
|
|
expect(compose).toContain(
|
|
"FONT_PACK_ROOT: /app/.local/font-packs"
|
|
);
|
|
expect(compose).not.toContain("MD_TO_PDF_FONT_PACK_DIR");
|
|
expect(dockerfile).toContain(
|
|
"COPY --chown=pwuser:pwuser output/font-packs/root /app/.local/font-packs"
|
|
);
|
|
expect(dockerfile).toContain("FONT_PACK_ROOT=/app/.local/font-packs");
|
|
expect(compose).toContain(
|
|
'APP_VERSION: "${MD_TO_PDF_APP_VERSION:-0.6.1}"'
|
|
);
|
|
expect(dockerignore.split(/\r?\n/u)).toContain(".local");
|
|
expect(dockerignore).toContain("!output/font-packs/root/**");
|
|
expect(dockerfileIgnore).toBe(dockerignore);
|
|
});
|
|
|
|
it("提供显式真实 Docker 字体包验收命令", () => {
|
|
const manifest = JSON.parse(
|
|
readProjectFile("package.json")
|
|
) as PackageManifest;
|
|
|
|
expect(manifest.scripts?.["verify:docker-font-pack"]).toContain(
|
|
"deploy/verify-font-pack-compose.mjs"
|
|
);
|
|
});
|
|
});
|