示例工程 54-packaging-targets-and-artifacts
54-packaging-targets-and-artifacts/app/shared/targets.ts
export type Layer = {
id: "package" | "make" | "distribute" | "update";
title: string;
output: string;
note: string;
};
export type ArtifactRow = {
id: string;
platform: "macOS" | "Windows" | "Linux" | "跨平台";
installer: string;
updateSource: boolean;
tool: "Forge" | "electron-builder" | "packager";
note: string;
};
export type ToolRow = {
name: string;
configLines: string;
targets: string;
update: string;
note: string;
};
export const LAYERS: Layer[] = [
{
id: "package",
title: "package",
output: ".app / 目录",
note: "生成可运行的应用目录;Forge 的 `package` 到这一步为止。",
},
{
id: "make",
title: "make",
output: "zip / dmg / nupkg / deb …",
note: "在 package 之上生成安装器或归档;不是所有产物都是安装器。",
},
{
id: "distribute",
title: "distribute",
output: "官网 / GitHub Releases / 商店",
note: "决定用户从哪里下载,以及谁负责签名、审核与更新。",
},
{
id: "update",
title: "update",
output: "更新 feed / 元数据",
note: "自动更新只认特定产物:macOS 用 zip,Windows 用 nupkg + RELEASES。",
},
];
export const ARTIFACTS: ArtifactRow[] = [
{
id: "dir",
platform: "macOS",
installer: "无(目录)",
updateSource: false,
tool: "packager",
note: "调试与本地验证用;不能直接分发给用户。",
},
{
id: "zip",
platform: "macOS",
installer: "无(归档)",
updateSource: true,
tool: "Forge",
note: "Squirrel.Mac 的更新源;也可以作为绿色版分发。",
},
{
id: "dmg",
platform: "macOS",
installer: "有(磁盘映像)",
updateSource: false,
tool: "Forge",
note: "最常见的拖拽安装体验;不是自动更新源。",
},
{
id: "pkg",
platform: "macOS",
installer: "有(安装包)",
updateSource: false,
tool: "Forge",
note: "适合企业分发与 MAS;安装行为更重。",
},
{
id: "squirrel",
platform: "Windows",
installer: "有(Squirrel)",
updateSource: true,
tool: "Forge",
note: "产出 .nupkg 与 RELEASES;Windows 自动更新的前提。",
},
{
id: "nsis",
platform: "Windows",
installer: "有(NSIS)",
updateSource: false,
tool: "electron-builder",
note: "安装路径与卸载行为可定制;Forge 主线不覆盖。",
},
{
id: "msi",
platform: "Windows",
installer: "有(MSI)",
updateSource: false,
tool: "Forge",
note: "WiX 生成;适合企业软件分发。",
},
{
id: "appx",
platform: "Windows",
installer: "有(MSIX)",
updateSource: true,
tool: "Forge",
note: "商店与应用身份;Electron 41+ 可通过 :format 走 MSIX 更新。",
},
{
id: "portable",
platform: "Windows",
installer: "无(单文件)",
updateSource: false,
tool: "electron-builder",
note: "免安装;无法写安装目录,数据仍走 userData。",
},
{
id: "deb",
platform: "Linux",
installer: "有(deb)",
updateSource: false,
tool: "Forge",
note: "Debian/Ubuntu 系;依赖与仓库由发行版管理。",
},
{
id: "rpm",
platform: "Linux",
installer: "有(rpm)",
updateSource: false,
tool: "Forge",
note: "Fedora/RHEL 系;与 deb 相同,更新由仓库负责。",
},
{
id: "appimage",
platform: "Linux",
installer: "无(单文件)",
updateSource: false,
tool: "electron-builder",
note: "免安装;没有系统级签名,用户需手动校验。",
},
{
id: "snap",
platform: "Linux",
installer: "有(snap)",
updateSource: true,
tool: "Forge",
note: "Snap Store 负责更新;应用内不要再自更新。",
},
{
id: "flatpak",
platform: "Linux",
installer: "有(flatpak)",
updateSource: true,
tool: "Forge",
note: "Flathub 负责更新;沙箱权限由 manifest 声明。",
},
];
export const TOOLS: ToolRow[] = [
{
name: "Electron Forge",
configLines: "约 20–60 行",
targets:
"dmg / pkg / zip / squirrel / wix / appx / deb / rpm / snap / flatpak",
update: "Squirrel 元数据、zip(macOS)",
note: "与 Vite、签名、发布钩子集成;本教程主线。",
},
{
name: "electron-builder",
configLines: "约 40–120 行",
targets:
"dmg / pkg / mas / nsis / nsis-web / portable / appx / msi / squirrel / appimage / snap / deb / rpm / pacman",
update: "electron-updater(差分、灰度)",
note: "单配置打全平台,社区大;本教程只在第 54 章对照。",
},
{
name: "@electron/packager",
configLines: "约 5–20 行",
targets: "dir / zip",
update: "无",
note: "只负责打包目录,没有 maker 与更新概念。",
},
];
export type Measurements = {
appName: string;
arch: string;
appBytes: number;
asarBytes: number;
zipBytes: number;
dmgBytes: number;
measuredAt: string;
note: string;
};