feat: 完成 Docker DOCX 与可选字体包部署链
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
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.0 部署契约", () => {
|
||||
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"
|
||||
);
|
||||
});
|
||||
|
||||
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(
|
||||
'test "$(pandoc --version | head -n 1)" = "pandoc 3.9.0.2"'
|
||||
);
|
||||
});
|
||||
|
||||
it("只读挂载字体包并排除本地字体资产构建上下文", () => {
|
||||
const compose = readProjectFile("deploy/compose.yaml");
|
||||
const dockerignore = readProjectFile(
|
||||
"deploy/Dockerfile.dockerignore"
|
||||
);
|
||||
|
||||
expect(compose).toContain(
|
||||
"FONT_PACK_ROOT: /app/.local/font-packs"
|
||||
);
|
||||
expect(compose).toContain(
|
||||
"${MD_TO_PDF_FONT_PACK_DIR:-../.local/font-packs}:/app/.local/font-packs:ro"
|
||||
);
|
||||
expect(compose).toContain(
|
||||
'APP_VERSION: "${MD_TO_PDF_APP_VERSION:-0.6.0}"'
|
||||
);
|
||||
expect(dockerignore.split(/\r?\n/u)).toContain(".local");
|
||||
expect(dockerignore.split(/\r?\n/u)).toContain("output");
|
||||
});
|
||||
|
||||
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"
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user