feat: 内置 Desktop Pandoc 最小运行时
This commit is contained in:
@@ -17,6 +17,17 @@ interface ProductBrand {
|
||||
artifactPrefix: string;
|
||||
}
|
||||
|
||||
interface PandocRuntimeManifest {
|
||||
version: string;
|
||||
artifacts: Array<{
|
||||
platform: string;
|
||||
architecture: string;
|
||||
sha256: string;
|
||||
licenseFiles: string[];
|
||||
files?: Record<string, { bytes: number; sha256: string }>;
|
||||
}>;
|
||||
}
|
||||
|
||||
const desktopRoot = fileURLToPath(new URL("../", import.meta.url));
|
||||
const projectRoot = fileURLToPath(new URL("../../../", import.meta.url));
|
||||
|
||||
@@ -54,11 +65,62 @@ describe("桌面发行构建链", () => {
|
||||
expect(desktopManifest.scripts?.make).toMatch(
|
||||
/^npm run build:embedded-web && /
|
||||
);
|
||||
expect(desktopManifest.scripts?.package).toContain(
|
||||
"npm run prepare:pandoc"
|
||||
);
|
||||
expect(desktopManifest.scripts?.make).toContain(
|
||||
"npm run prepare:pandoc"
|
||||
);
|
||||
expect(rootManifest.scripts?.["desktop:package"]).toBe(
|
||||
"npm run package -w @md-to-pdf/desktop"
|
||||
);
|
||||
});
|
||||
|
||||
it("将固定 Pandoc 最小运行时作为 Desktop 独立资源打包", () => {
|
||||
const desktopManifest = readManifest(`${desktopRoot}/package.json`);
|
||||
const runtimeManifest = readManifest<PandocRuntimeManifest>(
|
||||
`${projectRoot}/packages/docx-engine/src/pandoc-runtime.json`
|
||||
);
|
||||
const builderConfig = readFileSync(
|
||||
`${desktopRoot}/electron-builder.config.cjs`,
|
||||
"utf8"
|
||||
);
|
||||
const prepareScript = readFileSync(
|
||||
`${desktopRoot}/scripts/prepare-pandoc-runtime.mjs`,
|
||||
"utf8"
|
||||
);
|
||||
const windowsArtifact = runtimeManifest.artifacts.find(
|
||||
(artifact) =>
|
||||
artifact.platform === "win32" && artifact.architecture === "x64"
|
||||
);
|
||||
|
||||
expect(runtimeManifest.version).toBe("3.9.0.2");
|
||||
expect(windowsArtifact).toMatchObject({
|
||||
sha256:
|
||||
"C97542F2800F446E788D9F74237856D995421AD1BB3CC8324286840C5F272D3A",
|
||||
licenseFiles: ["COPYING.rtf", "COPYRIGHT.txt"],
|
||||
files: {
|
||||
"pandoc.exe": {
|
||||
bytes: 231056136,
|
||||
sha256:
|
||||
"E83F8354C0F507222B5684797B9C5AE766F03889785995D14AAC27816EC456BA"
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(desktopManifest.scripts?.["prepare:pandoc"]).toBe(
|
||||
"node scripts/prepare-pandoc-runtime.mjs"
|
||||
);
|
||||
expect(builderConfig).toContain(
|
||||
"`.runtime/pandoc/${pandocRuntime.version}/windows-x86_64`"
|
||||
);
|
||||
expect(builderConfig).toContain('"pandoc.exe"');
|
||||
expect(builderConfig).toContain('"COPYING.rtf"');
|
||||
expect(builderConfig).toContain('"COPYRIGHT.txt"');
|
||||
expect(prepareScript).toContain("sha256(downloaded)");
|
||||
expect(prepareScript).toContain("smokeTestPandoc");
|
||||
expect(prepareScript).toContain('process.argv.includes("--check")');
|
||||
});
|
||||
|
||||
it("将内置主题示例作为独立资源复制到发行目录", () => {
|
||||
const builderConfig = readFileSync(
|
||||
`${desktopRoot}/electron-builder.config.cjs`,
|
||||
|
||||
Reference in New Issue
Block a user