fix: 内置DOCX双中文字体包
This commit is contained in:
@@ -1,45 +1,13 @@
|
||||
import { copyFile, mkdir, readFile } from "node:fs/promises";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { spawn } from "node:child_process";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createDesktopCompanionInclude } from "../packages/font-pack-builder/dist/index.js";
|
||||
|
||||
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const desktopRoot = join(repositoryRoot, "apps", "desktop");
|
||||
const desktopManifest = JSON.parse(
|
||||
await readFile(join(desktopRoot, "package.json"), "utf8")
|
||||
);
|
||||
const fontInstallerName =
|
||||
"MorphDoc-FontPack-mdtp-serif-sc-1.0.0-x86_64-Setup.exe";
|
||||
const fontArchiveName = "MorphDoc-FontPack-mdtp-serif-sc-1.0.0.zip";
|
||||
const fontInstallerPath = join(
|
||||
repositoryRoot,
|
||||
"output",
|
||||
"font-packs",
|
||||
"windows",
|
||||
fontInstallerName
|
||||
);
|
||||
const generatedInclude = join(
|
||||
repositoryRoot,
|
||||
"output",
|
||||
"font-packs",
|
||||
"desktop-companion.nsh"
|
||||
);
|
||||
const fontArchivePath = join(
|
||||
repositoryRoot,
|
||||
"output",
|
||||
"font-packs",
|
||||
"release",
|
||||
fontArchiveName
|
||||
);
|
||||
|
||||
await createDesktopCompanionInclude({
|
||||
installerPath: fontInstallerPath,
|
||||
baseIncludePath: join(desktopRoot, "build", "installer.nsh"),
|
||||
outputPath: generatedInclude,
|
||||
displayName: "MdTP 中文宋体兼容包 1.0.0"
|
||||
});
|
||||
|
||||
const npmCli =
|
||||
process.env.npm_execpath ||
|
||||
join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
|
||||
@@ -49,10 +17,7 @@ await new Promise((resolvePromise, reject) => {
|
||||
[npmCli, "run", "make", "-w", "@md-to-pdf/desktop"],
|
||||
{
|
||||
cwd: repositoryRoot,
|
||||
env: {
|
||||
...process.env,
|
||||
MD_TO_PDF_NSIS_INCLUDE: generatedInclude
|
||||
},
|
||||
env: process.env,
|
||||
stdio: "inherit",
|
||||
windowsHide: true
|
||||
}
|
||||
@@ -71,10 +36,6 @@ await new Promise((resolvePromise, reject) => {
|
||||
});
|
||||
});
|
||||
|
||||
const desktopOutput = join(desktopRoot, "out", `v${desktopManifest.version}`);
|
||||
await mkdir(desktopOutput, { recursive: true });
|
||||
await copyFile(fontInstallerPath, join(desktopOutput, fontInstallerName));
|
||||
await copyFile(fontArchivePath, join(desktopOutput, fontArchiveName));
|
||||
process.stdout.write(
|
||||
`主安装器、字体包伴随安装器与 ZIP 附件已生成:${desktopOutput}\n`
|
||||
`已生成内置字体包的主安装器与便携 ZIP:${join(desktopRoot, "out", `v${desktopManifest.version}`)}\n`
|
||||
);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import {
|
||||
buildFontPack,
|
||||
verifyFontPack
|
||||
} from "../packages/font-pack-builder/dist/index.js";
|
||||
import { discoverFontPacks } from "../packages/font-pack-registry/dist/index.js";
|
||||
|
||||
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const bundlePath = join(repositoryRoot, "font-packs", "bundle.json");
|
||||
const bundle = JSON.parse(await readFile(bundlePath, "utf8"));
|
||||
const outputRoot = join(repositoryRoot, "output", "font-packs", "root");
|
||||
const appVersion = process.env.npm_package_version || "0.6.0";
|
||||
|
||||
if (
|
||||
bundle.schemaVersion !== 1 ||
|
||||
!Array.isArray(bundle.packs) ||
|
||||
bundle.packs.length === 0
|
||||
) {
|
||||
throw new Error("字体包集合清单无效");
|
||||
}
|
||||
|
||||
const identities = new Set();
|
||||
const reports = [];
|
||||
for (const pack of bundle.packs) {
|
||||
const identity = `${pack.id}@${pack.version}`;
|
||||
if (identities.has(identity)) {
|
||||
throw new Error(`字体包集合存在重复项:${identity}`);
|
||||
}
|
||||
identities.add(identity);
|
||||
const reportPath = join(
|
||||
repositoryRoot,
|
||||
"output",
|
||||
"font-packs",
|
||||
`${pack.id}-build-report.json`
|
||||
);
|
||||
const built = await buildFontPack({
|
||||
recipePath: resolve(repositoryRoot, pack.recipe),
|
||||
sourceRoot: resolve(repositoryRoot, pack.sourceRoot),
|
||||
outputRoot,
|
||||
reportPath
|
||||
});
|
||||
const verified = await verifyFontPack({
|
||||
root: outputRoot,
|
||||
appVersion,
|
||||
packId: pack.id,
|
||||
packVersion: pack.version
|
||||
});
|
||||
reports.push({ identity, built, verified });
|
||||
}
|
||||
|
||||
const registry = await discoverFontPacks({
|
||||
roots: [outputRoot],
|
||||
appVersion
|
||||
});
|
||||
const errors = registry.diagnostics.filter((item) => item.severity === "error");
|
||||
if (errors.length > 0) {
|
||||
throw new Error(
|
||||
`字体包集合注册失败:${errors.map((item) => `${item.code} ${item.message}`).join(";")}`
|
||||
);
|
||||
}
|
||||
const actualIdentities = registry.packs
|
||||
.map((pack) => `${pack.id}@${pack.version}`)
|
||||
.sort();
|
||||
const expectedIdentities = [...identities].sort();
|
||||
if (JSON.stringify(actualIdentities) !== JSON.stringify(expectedIdentities)) {
|
||||
throw new Error(
|
||||
`字体包输出根目录包含清单外内容:期望 ${expectedIdentities.join(", ")},实际 ${actualIdentities.join(", ")}`
|
||||
);
|
||||
}
|
||||
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({ appVersion, outputRoot, registryFingerprint: registry.fingerprint, reports }, null, 2)}\n`
|
||||
);
|
||||
@@ -184,9 +184,7 @@ export async function stageRelease(options = {}) {
|
||||
);
|
||||
const desktopNames = [
|
||||
`MorphDoc-${version}-x86_64-Setup.exe`,
|
||||
`MorphDoc-${version}-x86_64.zip`,
|
||||
"MorphDoc-FontPack-mdtp-serif-sc-1.0.0-x86_64-Setup.exe",
|
||||
"MorphDoc-FontPack-mdtp-serif-sc-1.0.0.zip"
|
||||
`MorphDoc-${version}-x86_64.zip`
|
||||
];
|
||||
const releaseNotesSource = join(
|
||||
repositoryRoot,
|
||||
|
||||
Reference in New Issue
Block a user