新增能力:桌面端新增 macOS 打包支持,electron-builder 增加独立 mac 配置块, 产出 dmg,按 arm64、x64 分别单独构建、不产出 universal 包;Pandoc 运行时清单 新增 darwin/arm64、darwin/x64 两个官方发行项(含独立许可证文件来源),桌面 Pandoc 候选路径与 prepare-pandoc-runtime.mjs 均已泛化为按 --platform/--arch 参数选取目标,不再只认 Windows x64。AGENTS.md 不再硬编码 Windows 绝对路径与 强制 PowerShell 语法,改为按当前 Shell 与仓库实际位置自适应。 问题修复:修复解压内置 Pandoc 时未保留 Unix 可执行权限位的问题(unzipSync 不保留压缩包内权限,已补 chmod 0o755);修复根 package.json 中 build:web-runtime/dev/desktop:dev 三个脚本的构建顺序错误 (@md-to-pdf/application 被排在其依赖的 @md-to-pdf/preview-engine 之前,在 没有历史 dist 残留的全新环境中会导致类型解析失败);修正 packages/docx-engine/tests/pandoc-runtime.test.ts 与 apps/desktop/tests/markdown-file.test.ts 中依赖宿主 OS 或路径分隔符的测试 断言,避免这些用例只能在特定平台上通过。 验证结果:docx-engine 包 93 项测试、desktop 包 62 项测试(61 通过 + 1 项 Windows 专属用例按预期跳过)均通过;全项目类型检查、生产构建通过, git diff --check 无空白错误。跳过依赖 Git 忽略的真实客户文档语料(tmp/)的 test:docx-real-world-corpus 与 test:docx-release-gate-suites 后,其余全部 工作区测试均通过;这两步需要接入真实语料的机器上单独执行。本机 macOS (Apple Silicon)实测 npm run package:mac:arm64 全链路成功,内置 Pandoc 3.9.0.2 完成下载、哈希校验与真实 DOCX 冒烟转换;实际截图确认窗口、macOS 原生菜单栏、编辑器工具栏、中文字体与实时预览渲染正常。 兼容与部署:版本统一为 0.6.4。本版本仅完成开发基础设施与验证,未构建正式 发行文件:没有产出真实签名的 dmg、没有重新构建 Windows 安装包,也没有重新 构建 Docker 镜像;正式 macOS 发行产物与 Windows/Docker 同步验证留待 DOCX 发布门禁阶段完成后一并发布。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K5N6pcbjV4jVfXrcH3NcLP
76 lines
2.4 KiB
JavaScript
76 lines
2.4 KiB
JavaScript
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.4";
|
||
|
||
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`
|
||
);
|