app-builder-lib 27.0.0-alpha.13 → 27.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/configuration.d.ts +47 -1
  2. package/dist/configuration.d.ts.map +1 -1
  3. package/dist/configuration.js.map +1 -1
  4. package/dist/options/PlatformSpecificBuildOptions.d.ts +4 -1
  5. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  6. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  7. package/dist/packager.d.ts +6 -0
  8. package/dist/packager.d.ts.map +1 -1
  9. package/dist/packager.js +14 -3
  10. package/dist/packager.js.map +1 -1
  11. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  12. package/dist/publish/updateInfoBuilder.js +7 -5
  13. package/dist/publish/updateInfoBuilder.js.map +1 -1
  14. package/dist/targets/blockmap/blockmap.d.ts +30 -0
  15. package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
  16. package/dist/targets/blockmap/blockmap.js +99 -31
  17. package/dist/targets/blockmap/blockmap.js.map +1 -1
  18. package/dist/targets/blockmap/blockmapV3.d.ts +36 -0
  19. package/dist/targets/blockmap/blockmapV3.d.ts.map +1 -0
  20. package/dist/targets/blockmap/blockmapV3.js +41 -0
  21. package/dist/targets/blockmap/blockmapV3.js.map +1 -0
  22. package/dist/targets/blockmap/verbatimRange.d.ts +6 -0
  23. package/dist/targets/blockmap/verbatimRange.d.ts.map +1 -1
  24. package/dist/targets/blockmap/verbatimRange.js +11 -0
  25. package/dist/targets/blockmap/verbatimRange.js.map +1 -1
  26. package/dist/targets/differentialUpdateInfoBuilder.d.ts +92 -4
  27. package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
  28. package/dist/targets/differentialUpdateInfoBuilder.js +266 -10
  29. package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
  30. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  31. package/dist/targets/linux/FpmTarget.js +15 -1
  32. package/dist/targets/linux/FpmTarget.js.map +1 -1
  33. package/dist/targets/targetFactory.d.ts +1 -1
  34. package/dist/targets/targetFactory.d.ts.map +1 -1
  35. package/dist/targets/targetFactory.js +22 -0
  36. package/dist/targets/targetFactory.js.map +1 -1
  37. package/dist/targets/win/MsiTarget.d.ts +7 -0
  38. package/dist/targets/win/MsiTarget.d.ts.map +1 -1
  39. package/dist/targets/win/MsiTarget.js +140 -21
  40. package/dist/targets/win/MsiTarget.js.map +1 -1
  41. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  42. package/dist/targets/win/nsis/NsisTarget.js +14 -6
  43. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  44. package/dist/toolsets/appimage.d.ts +3 -0
  45. package/dist/toolsets/appimage.d.ts.map +1 -1
  46. package/dist/toolsets/appimage.js +4 -1
  47. package/dist/toolsets/appimage.js.map +1 -1
  48. package/dist/toolsets/wix.d.ts +44 -0
  49. package/dist/toolsets/wix.d.ts.map +1 -0
  50. package/dist/toolsets/wix.js +91 -0
  51. package/dist/toolsets/wix.js.map +1 -0
  52. package/dist/util/electronUpdaterCompatibility.d.ts +43 -0
  53. package/dist/util/electronUpdaterCompatibility.d.ts.map +1 -0
  54. package/dist/util/electronUpdaterCompatibility.js +53 -0
  55. package/dist/util/electronUpdaterCompatibility.js.map +1 -0
  56. package/dist/util/packageMetadata.js +115 -51
  57. package/dist/util/packageMetadata.js.map +1 -1
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/dist/version.js.map +1 -1
  61. package/package.json +8 -8
  62. package/scheme.json +45 -6
  63. package/templates/msi/template.xml +5 -5
  64. package/templates/msiWrapped/template.xml +1 -1
  65. package/templates/nsis/assistedInstaller.nsh +32 -1
@@ -0,0 +1,91 @@
1
+ import { Arch, InvalidConfigurationError } from "builder-util";
2
+ import { BUILD_CHANGES_URL } from "../util/config/legacyOptions.js";
3
+ import { downloadBuilderToolset } from "../util/electronGet.js";
4
+ import { getCustomToolsetPath } from "./custom.js";
5
+ import { resolveToolsetVersion } from "./version.js";
6
+ // Newest WiX bundle — selected when the config is unset or "latest".
7
+ const WIX_LATEST = "2.0.0";
8
+ export const wixChecksums = {
9
+ "0.0.0": {
10
+ "wix-4.0.0.5512.2.7z": "fe677fcd837b18c9b912985d91636bbd8a1e800c3b3a6a841b6f96e89624e839",
11
+ },
12
+ "2.0.0": {
13
+ // WiX Toolset v3.14.1 (candle/light)
14
+ "wix-3.14.1.tar.gz": "8f1a5a017042cb287b11b8056ed8e29f86ebe456b09086c4f510b56659e014d5",
15
+ },
16
+ };
17
+ /** The `xmlns` of a `.wxs` document in `schema`. */
18
+ export function getWixNamespace(schema) {
19
+ return schema === "v3" ? "http://schemas.microsoft.com/wix/2006/wi" : "http://wixtoolset.org/schemas/v4/wxs";
20
+ }
21
+ const WIX4_NAMESPACE_PATTERN = /\bxmlns(?::[\w.-]+)?\s*=\s*(["'])(http:\/\/wixtoolset\.org\/schemas\/v4\/[^"']*)\1/g;
22
+ /** The WiX 4 namespaces (`http://wixtoolset.org/schemas/v4/...`) that a `.wxs` project declares, each once. */
23
+ export function findWix4Namespaces(project) {
24
+ return [...new Set(Array.from(project.matchAll(WIX4_NAMESPACE_PATTERN), it => it[2]))];
25
+ }
26
+ /**
27
+ * Fails a WiX 3 build whose project declares a WiX 4 namespace, which only an `msiProjectCreated` hook can add (the
28
+ * generated project uses the WiX 3 ones). candle would reject it with an "unhandled extension element" error that
29
+ * doesn't say the bundle is the cause.
30
+ */
31
+ export function assertNoWix4Namespaces(project, schema) {
32
+ if (schema !== "v3") {
33
+ return;
34
+ }
35
+ const namespaces = findWix4Namespaces(project);
36
+ if (namespaces.length === 0) {
37
+ return;
38
+ }
39
+ throw new InvalidConfigurationError(`The MSI project declares the WiX 4 namespace ${namespaces.map(it => `"${it}"`).join(", ")}, most likely from an msiProjectCreated hook, ` +
40
+ `but the WiX 3 toolset reads WiX 3 namespaces only (electron-builder v27 builds MSIs with WiX 3.14.1 by default, toolsets.wix "latest"). ` +
41
+ `Use the WiX 3 namespace (for example "http://schemas.microsoft.com/wix/UtilExtension" instead of "http://wixtoolset.org/schemas/v4/wxs/util"), ` +
42
+ `or set toolsets.wix to "0.0.0" to keep the legacy WiX 4 preview bundle. ` +
43
+ `See ${BUILD_CHANGES_URL}#toolset-defaults-resolve-to-latest-newest-bundle`);
44
+ }
45
+ /** Resolves a `toolsets.wix` version: unset or `"latest"` is the newest bundle, `"0.0.0"` the legacy one. */
46
+ export function resolveWixVersion(wix) {
47
+ return resolveToolsetVersion(wix, WIX_LATEST);
48
+ }
49
+ export async function getWixToolset(wix, resourcesDir) {
50
+ if (typeof wix === "object" && wix != null) {
51
+ // a custom bundle must mirror the WiX v3 layout (candle.exe, light.exe and the extensions at its root)
52
+ return { path: await getCustomToolsetPath(wix, resourcesDir), schema: "v3" };
53
+ }
54
+ const resolved = resolveWixVersion(wix);
55
+ if (resolved === "0.0.0") {
56
+ const file = "wix-4.0.0.5512.2.7z";
57
+ // noinspection SpellCheckingInspection
58
+ const toolsetPath = await downloadBuilderToolset({
59
+ releaseName: "wix-4.0.0.5512.2",
60
+ filenameWithExt: file,
61
+ checksums: { [file]: wixChecksums["0.0.0"][file] },
62
+ });
63
+ return { path: toolsetPath, schema: "v4-preview" };
64
+ }
65
+ const file = "wix-3.14.1.tar.gz";
66
+ const toolsetPath = await downloadBuilderToolset({
67
+ releaseName: `wix@${resolved}`,
68
+ filenameWithExt: file,
69
+ checksums: { [file]: wixChecksums[resolved][file] },
70
+ });
71
+ return { path: toolsetPath, schema: "v3" };
72
+ }
73
+ /**
74
+ * The architecture an MSI is built for: arm64 needs a toolset that supports it, otherwise it falls back to x64 (the
75
+ * x64 package then runs on Windows on Arm under emulation).
76
+ */
77
+ export function getWixArch(arch, schema) {
78
+ return arch === Arch.arm64 && schema !== "v3" ? Arch.x64 : arch;
79
+ }
80
+ /** The value of `candle -arch` for `wixArch`. */
81
+ export function getCandleArch(wixArch) {
82
+ switch (wixArch) {
83
+ case Arch.ia32:
84
+ return "x86";
85
+ case Arch.arm64:
86
+ return "arm64";
87
+ default:
88
+ return "x64";
89
+ }
90
+ }
91
+ //# sourceMappingURL=wix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wix.js","sourceRoot":"","sources":["../../src/toolsets/wix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD,qEAAqE;AACrE,MAAM,UAAU,GAAG,OAAO,CAAA;AAE1B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE;QACP,qBAAqB,EAAE,kEAAkE;KAC1F;IACD,OAAO,EAAE;QACP,qCAAqC;QACrC,mBAAmB,EAAE,kEAAkE;KACxF;CACO,CAAA;AAgBV,oDAAoD;AACpD,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,sCAAsC,CAAA;AAC9G,CAAC;AAED,MAAM,sBAAsB,GAAG,qFAAqF,CAAA;AAEpH,+GAA+G;AAC/G,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe,EAA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AO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,CAAA;IACpD,CAAC;IACD,MAAM,IAAI,GAAG,mBAAmB,CAAA;IAChC,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC;QAC/C,WAAW,EAAE,OAAO,QAAQ,EAAE;QAC9B,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE;KACpD,CAAC,CAAA;IACF,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,MAAiB;IACtD,OAAO,IAAI,KAAK,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AACjE,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,aAAa,CAAC,OAAa;IACzC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,IAAI;YACZ,OAAO,KAAK,CAAA;QACd,KAAK,IAAI,CAAC,KAAK;YACb,OAAO,OAAO,CAAA;QAChB;YACE,OAAO,KAAK,CAAA;IAChB,CAAC;AACH,CAAC","sourcesContent":["import { Arch, InvalidConfigurationError } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { BUILD_CHANGES_URL } from \"../util/config/legacyOptions.js\"\nimport { downloadBuilderToolset } from \"../util/electronGet.js\"\nimport { getCustomToolsetPath } from \"./custom.js\"\nimport { resolveToolsetVersion } from \"./version.js\"\n\n// Newest WiX bundle — selected when the config is unset or \"latest\".\nconst WIX_LATEST = \"2.0.0\"\n\nexport const wixChecksums = {\n \"0.0.0\": {\n \"wix-4.0.0.5512.2.7z\": \"fe677fcd837b18c9b912985d91636bbd8a1e800c3b3a6a841b6f96e89624e839\",\n },\n \"2.0.0\": {\n // WiX Toolset v3.14.1 (candle/light)\n \"wix-3.14.1.tar.gz\": \"8f1a5a017042cb287b11b8056ed8e29f86ebe456b09086c4f510b56659e014d5\",\n },\n} as const\n\n/**\n * The `.wxs` dialect a WiX bundle compiles. The legacy bundle is a WiX 4 preview (4.0.0.5512) that still ships `candle` /\n * `light`: it reads the v4 namespace and accepts v4 conveniences (the inline directory syntax `Name=\"APPLICATIONFOLDER:\\sub\\\"`,\n * `Component/@Directory` inside a `ComponentGroup` that sets one) but has no `arm64`. WiX 3 needs every directory as a nested\n * `Directory` element and every component in its own directory, and supports `-arch arm64`.\n */\nexport type WixSchema = \"v3\" | \"v4-preview\"\n\n/** A WiX bundle on disk and the `.wxs` dialect it compiles. */\nexport interface WixToolset {\n readonly path: string\n readonly schema: WixSchema\n}\n\n/** The `xmlns` of a `.wxs` document in `schema`. */\nexport function getWixNamespace(schema: WixSchema): string {\n return schema === \"v3\" ? \"http://schemas.microsoft.com/wix/2006/wi\" : \"http://wixtoolset.org/schemas/v4/wxs\"\n}\n\nconst WIX4_NAMESPACE_PATTERN = /\\bxmlns(?::[\\w.-]+)?\\s*=\\s*([\"'])(http:\\/\\/wixtoolset\\.org\\/schemas\\/v4\\/[^\"']*)\\1/g\n\n/** The WiX 4 namespaces (`http://wixtoolset.org/schemas/v4/...`) that a `.wxs` project declares, each once. */\nexport function findWix4Namespaces(project: string): Array<string> {\n return [...new Set(Array.from(project.matchAll(WIX4_NAMESPACE_PATTERN), it => it[2]))]\n}\n\n/**\n * Fails a WiX 3 build whose project declares a WiX 4 namespace, which only an `msiProjectCreated` hook can add (the\n * generated project uses the WiX 3 ones). candle would reject it with an \"unhandled extension element\" error that\n * doesn't say the bundle is the cause.\n */\nexport function assertNoWix4Namespaces(project: string, schema: WixSchema): void {\n if (schema !== \"v3\") {\n return\n }\n const namespaces = findWix4Namespaces(project)\n if (namespaces.length === 0) {\n return\n }\n throw new InvalidConfigurationError(\n `The MSI project declares the WiX 4 namespace ${namespaces.map(it => `\"${it}\"`).join(\", \")}, most likely from an msiProjectCreated hook, ` +\n `but the WiX 3 toolset reads WiX 3 namespaces only (electron-builder v27 builds MSIs with WiX 3.14.1 by default, toolsets.wix \"latest\"). ` +\n `Use the WiX 3 namespace (for example \"http://schemas.microsoft.com/wix/UtilExtension\" instead of \"http://wixtoolset.org/schemas/v4/wxs/util\"), ` +\n `or set toolsets.wix to \"0.0.0\" to keep the legacy WiX 4 preview bundle. ` +\n `See ${BUILD_CHANGES_URL}#toolset-defaults-resolve-to-latest-newest-bundle`\n )\n}\n\n/** Resolves a `toolsets.wix` version: unset or `\"latest\"` is the newest bundle, `\"0.0.0\"` the legacy one. */\nexport function resolveWixVersion(wix: Exclude<ToolsetConfig[\"wix\"], object> | Nullish): \"0.0.0\" | \"2.0.0\" {\n return resolveToolsetVersion(wix, WIX_LATEST)\n}\n\nexport async function getWixToolset(wix: ToolsetConfig[\"wix\"] | Nullish, resourcesDir: string): Promise<WixToolset> {\n if (typeof wix === \"object\" && wix != null) {\n // a custom bundle must mirror the WiX v3 layout (candle.exe, light.exe and the extensions at its root)\n return { path: await getCustomToolsetPath(wix, resourcesDir), schema: \"v3\" }\n }\n const resolved = resolveWixVersion(wix)\n if (resolved === \"0.0.0\") {\n const file = \"wix-4.0.0.5512.2.7z\"\n // noinspection SpellCheckingInspection\n const toolsetPath = await downloadBuilderToolset({\n releaseName: \"wix-4.0.0.5512.2\",\n filenameWithExt: file,\n checksums: { [file]: wixChecksums[\"0.0.0\"][file] },\n })\n return { path: toolsetPath, schema: \"v4-preview\" }\n }\n const file = \"wix-3.14.1.tar.gz\"\n const toolsetPath = await downloadBuilderToolset({\n releaseName: `wix@${resolved}`,\n filenameWithExt: file,\n checksums: { [file]: wixChecksums[resolved][file] },\n })\n return { path: toolsetPath, schema: \"v3\" }\n}\n\n/**\n * The architecture an MSI is built for: arm64 needs a toolset that supports it, otherwise it falls back to x64 (the\n * x64 package then runs on Windows on Arm under emulation).\n */\nexport function getWixArch(arch: Arch, schema: WixSchema): Arch {\n return arch === Arch.arm64 && schema !== \"v3\" ? Arch.x64 : arch\n}\n\n/** The value of `candle -arch` for `wixArch`. */\nexport function getCandleArch(wixArch: Arch): \"x86\" | \"x64\" | \"arm64\" {\n switch (wixArch) {\n case Arch.ia32:\n return \"x86\"\n case Arch.arm64:\n return \"arm64\"\n default:\n return \"x64\"\n }\n}\n"]}
@@ -0,0 +1,43 @@
1
+ import { type Platform } from "../core.js";
2
+ import type { PlatformSpecificBuildOptions } from "../options/PlatformSpecificBuildOptions.js";
3
+ /** Default `electronUpdaterCompatibility`: the electron-updater versions the installed apps are assumed to ship. */
4
+ export declare const DEFAULT_ELECTRON_UPDATER_COMPATIBILITY = ">=7";
5
+ /** v27 breaking-changes entry on the block map format following `electronUpdaterCompatibility`, linked from the build warning and error. */
6
+ export declare const BLOCK_MAP_FORMAT_DOCS_URL = "https://www.electron.build/docs/migration/v27-build-changes#block-map-format-follows-electronupdatercompatibility";
7
+ /** electron-updater versions before this one cannot read the binary block map; for ranges (`electronUpdaterCompatibility`). */
8
+ export declare const BINARY_BLOCK_MAP_MIN_UPDATER = "7.0.0";
9
+ /**
10
+ * The first electron-updater release that reads the binary block map: the 7.0.0 prereleases up to 7.0.0-alpha.12 (npm `next`)
11
+ * cannot, though a range such as `>=7` reads as electron-updater 7.
12
+ */
13
+ export declare const BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE = "7.0.0-alpha.13";
14
+ /** Whether the `electronUpdaterCompatibility` range includes only electron-updater versions that read the binary block map. */
15
+ export declare function isBinaryBlockMapSupported(range: string): boolean;
16
+ /**
17
+ * Whether a build with the `blockmap` option `value` writes binary `.blockmap` files for `range`, without the validation and
18
+ * warning of `resolveBlockMapFormat`.
19
+ */
20
+ export declare function writesBinaryBlockMap(value: unknown, range: string): boolean;
21
+ /** The `electronUpdaterCompatibility` range that applies to a platform: the platform option, then the root option, then the default. */
22
+ export declare function resolveElectronUpdaterCompatibility(platformOptions: Pick<PlatformSpecificBuildOptions, "electronUpdaterCompatibility"> | null | undefined, config: Pick<PlatformSpecificBuildOptions, "electronUpdaterCompatibility">): string;
23
+ type CompatibilityOptions = Pick<PlatformSpecificBuildOptions, "electronUpdaterCompatibility">;
24
+ type PlatformKey = "mac" | "win" | "linux";
25
+ /** What the app's own electron-updater has to read on one platform of a build. */
26
+ export interface ElectronUpdaterRequirement {
27
+ readonly platform: string;
28
+ /** the `electronUpdaterCompatibility` of the platform */
29
+ readonly range: string;
30
+ /** whether the platform publishes binary `.blockmap` files that electron-updater reads */
31
+ readonly binaryBlockMap: boolean;
32
+ }
33
+ /**
34
+ * The requirement of each platform a build targets, resolved as the targets resolve them (`platformOptions`, then the root option,
35
+ * then the default). `builtTargets`: the target names each platform builds (see `resolveTargetNames`).
36
+ */
37
+ export declare function electronUpdaterRequirements(config: CompatibilityOptions & {
38
+ readonly blockmap?: unknown;
39
+ } & {
40
+ readonly [platform in PlatformKey]?: CompatibilityOptions | null;
41
+ }, builtTargets: Iterable<readonly [Pick<Platform, "name" | "buildConfigurationKey">, Iterable<string>]>): Array<ElectronUpdaterRequirement>;
42
+ export {};
43
+ //# sourceMappingURL=electronUpdaterCompatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronUpdaterCompatibility.d.ts","sourceRoot":"","sources":["../../src/util/electronUpdaterCompatibility.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAA;AAE9F,oHAAoH;AACpH,eAAO,MAAM,sCAAsC,QAAQ,CAAA;AAE3D,4IAA4I;AAC5I,eAAO,MAAM,yBAAyB,sHAAsH,CAAA;AAE5J,+HAA+H;AAC/H,eAAO,MAAM,4BAA4B,UAAU,CAAA;AAEnD;;;GAGG;AACH,eAAO,MAAM,o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: the electron-updater versions the installed apps are assumed to ship. */
4
+ export const DEFAULT_ELECTRON_UPDATER_COMPATIBILITY = ">=7";
5
+ /** v27 breaking-changes entry on the block map format following `electronUpdaterCompatibility`, linked from the build warning and error. */
6
+ export const BLOCK_MAP_FORMAT_DOCS_URL = "https://www.electron.build/docs/migration/v27-build-changes#block-map-format-follows-electronupdatercompatibility";
7
+ /** electron-updater versions before this one cannot read the binary block map; for ranges (`electronUpdaterCompatibility`). */
8
+ export const BINARY_BLOCK_MAP_MIN_UPDATER = "7.0.0";
9
+ /**
10
+ * The first electron-updater release that reads the binary block map: the 7.0.0 prereleases up to 7.0.0-alpha.12 (npm `next`)
11
+ * cannot, though a range such as `>=7` reads as electron-updater 7.
12
+ */
13
+ export const BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE = "7.0.0-alpha.13";
14
+ /** Whether the `electronUpdaterCompatibility` range includes only electron-updater versions that read the binary block map. */
15
+ export function isBinaryBlockMapSupported(range) {
16
+ // no includePrerelease: it would make ">=7" intersect "<7.0.0" at the 7.0.0-0 prerelease point
17
+ return !semver.intersects(range, `<${BINARY_BLOCK_MAP_MIN_UPDATER}`);
18
+ }
19
+ /**
20
+ * Whether a build with the `blockmap` option `value` writes binary `.blockmap` files for `range`, without the validation and
21
+ * warning of `resolveBlockMapFormat`.
22
+ */
23
+ export function writesBinaryBlockMap(value, range) {
24
+ return value !== "v2" && isBinaryBlockMapSupported(range);
25
+ }
26
+ /** The `electronUpdaterCompatibility` range that applies to a platform: the platform option, then the root option, then the default. */
27
+ export function resolveElectronUpdaterCompatibility(platformOptions, config) {
28
+ return platformOptions?.electronUpdaterCompatibility || config.electronUpdaterCompatibility || DEFAULT_ELECTRON_UPDATER_COMPATIBILITY;
29
+ }
30
+ /** The targets whose `.blockmap` file electron-updater reads, by platform; `DEFAULT_TARGET` (an NSIS installer, a zip and a dmg) among them. */
31
+ const BLOCK_MAP_FILE_TARGETS = {
32
+ // not the portable executable, nor nsis-web, whose package embeds its map
33
+ win: [DEFAULT_TARGET, "nsis"],
34
+ // MacUpdater downloads only the zip, so a dmg's map is never read
35
+ mac: [DEFAULT_TARGET, "zip"],
36
+ // an AppImage embeds its map
37
+ linux: [],
38
+ };
39
+ /**
40
+ * The requirement of each platform a build targets, resolved as the targets resolve them (`platformOptions`, then the root option,
41
+ * then the default). `builtTargets`: the target names each platform builds (see `resolveTargetNames`).
42
+ */
43
+ export function electronUpdaterRequirements(config, builtTargets) {
44
+ const requirements = [];
45
+ for (const [{ name, buildConfigurationKey: key }, targetNames] of builtTargets) {
46
+ const isKnown = key === "mac" || key === "win" || key === "linux";
47
+ const range = resolveElectronUpdaterCompatibility(isKnown ? config[key] : null, config);
48
+ const writesBlockMapFile = isKnown && [...targetNames].some(it => BLOCK_MAP_FILE_TARGETS[key].includes(it));
49
+ requirements.push({ platform: name, range, binaryBlockMap: writesBlockMapFile && writesBinaryBlockMap(config.blockmap, range) });
50
+ }
51
+ return requirements;
52
+ }
53
+ //# sourceMappingURL=electronUpdaterCompatibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronUpdaterCompatibility.js","sourceRoot":"","sources":["../../src/util/electronUpdaterCompatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAA;AAG1D,oHAAoH;AACpH,MAAM,CAAC,MAAM,sCAAsC,GAAG,KAAK,CAAA;AAE3D,4IAA4I;AAC5I,MAAM,CAAC,MAAM,yBAAyB,GAAG,mHAAmH,CAAA;AAE5J,+HAA+H;AAC/H,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAA;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,gBAAgB,CAAA;AAEpE,+HAA+H;AAC/H,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACrD,+FAA+F;IAC/F,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,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AAQ,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,kBAAkB,IAAI,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IAClI,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC","sourcesContent":["import * as semver from \"semver\"\nimport { DEFAULT_TARGET, type Platform } from \"../core.js\"\nimport type { PlatformSpecificBuildOptions } from \"../options/PlatformSpecificBuildOptions.js\"\n\n/** Default `electronUpdaterCompatibility`: the electron-updater versions the installed apps are assumed to ship. */\nexport const DEFAULT_ELECTRON_UPDATER_COMPATIBILITY = \">=7\"\n\n/** v27 breaking-changes entry on the block map format following `electronUpdaterCompatibility`, linked from the build warning and error. */\nexport const BLOCK_MAP_FORMAT_DOCS_URL = \"https://www.electron.build/docs/migration/v27-build-changes#block-map-format-follows-electronupdatercompatibility\"\n\n/** electron-updater versions before this one cannot read the binary block map; for ranges (`electronUpdaterCompatibility`). */\nexport const BINARY_BLOCK_MAP_MIN_UPDATER = \"7.0.0\"\n\n/**\n * The first electron-updater release that reads the binary block map: the 7.0.0 prereleases up to 7.0.0-alpha.12 (npm `next`)\n * cannot, though a range such as `>=7` reads as electron-updater 7.\n */\nexport const BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE = \"7.0.0-alpha.13\"\n\n/** Whether the `electronUpdaterCompatibility` range includes only electron-updater versions that read the binary block map. */\nexport function isBinaryBlockMapSupported(range: string): boolean {\n // no includePrerelease: it would make \">=7\" intersect \"<7.0.0\" at the 7.0.0-0 prerelease point\n return !semver.intersects(range, `<${BINARY_BLOCK_MAP_MIN_UPDATER}`)\n}\n\n/**\n * Whether a build with the `blockmap` option `value` writes binary `.blockmap` files for `range`, without the validation and\n * warning of `resolveBlockMapFormat`.\n */\nexport function writesBinaryBlockMap(value: unknown, range: string): boolean {\n return value !== \"v2\" && isBinaryBlockMapSupported(range)\n}\n\n/** The `electronUpdaterCompatibility` range that applies to a platform: the platform option, then the root option, then the default. */\nexport function resolveElectronUpdaterCompatibility(\n platformOptions: Pick<PlatformSpecificBuildOptions, \"electronUpdaterCompatibility\"> | null | undefined,\n config: Pick<PlatformSpecificBuildOptions, \"electronUpdaterCompatibility\">\n): string {\n return platformOptions?.electronUpdaterCompatibility || config.electronUpdaterCompatibility || DEFAULT_ELECTRON_UPDATER_COMPATIBILITY\n}\n\ntype CompatibilityOptions = Pick<PlatformSpecificBuildOptions, \"electronUpdaterCompatibility\">\ntype PlatformKey = \"mac\" | \"win\" | \"linux\"\n\n/** The targets whose `.blockmap` file electron-updater reads, by platform; `DEFAULT_TARGET` (an NSIS installer, a zip and a dmg) among them. */\nconst BLOCK_MAP_FILE_TARGETS: Readonly<Record<PlatformKey, ReadonlyArray<string>>> = {\n // not the portable executable, nor nsis-web, whose package embeds its map\n win: [DEFAULT_TARGET, \"nsis\"],\n // MacUpdater downloads only the zip, so a dmg's map is never read\n mac: [DEFAULT_TARGET, \"zip\"],\n // an AppImage embeds its map\n linux: [],\n}\n\n/** What the app's own electron-updater has to read on one platform of a build. */\nexport interface ElectronUpdaterRequirement {\n readonly platform: string\n /** the `electronUpdaterCompatibility` of the platform */\n readonly range: string\n /** whether the platform publishes binary `.blockmap` files that electron-updater reads */\n readonly binaryBlockMap: boolean\n}\n\n/**\n * The requirement of each platform a build targets, resolved as the targets resolve them (`platformOptions`, then the root option,\n * then the default). `builtTargets`: the target names each platform builds (see `resolveTargetNames`).\n */\nexport function electronUpdaterRequirements(\n config: CompatibilityOptions & { readonly blockmap?: unknown } & { readonly [platform in PlatformKey]?: CompatibilityOptions | null },\n builtTargets: Iterable<readonly [Pick<Platform, \"name\" | \"buildConfigurationKey\">, Iterable<string>]>\n): Array<ElectronUpdaterRequirement> {\n const requirements: Array<ElectronUpdaterRequirement> = []\n for (const [{ name, buildConfigurationKey: key }, targetNames] of builtTargets) {\n const isKnown = key === \"mac\" || key === \"win\" || key === \"linux\"\n const range = resolveElectronUpdaterCompatibility(isKnown ? config[key] : null, config)\n const writesBlockMapFile = isKnown && [...targetNames].some(it => BLOCK_MAP_FILE_TARGETS[key].includes(it))\n requirements.push({ platform: name, range, binaryBlockMap: writesBlockMapFile && writesBinaryBlockMap(config.blockmap, range) })\n }\n return requirements\n}\n"]}
@@ -3,6 +3,7 @@ import fsExtra from "fs-extra";
3
3
  import { createRequire } from "node:module";
4
4
  import * as path from "path";
5
5
  import * as semver from "semver";
6
+ import { BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE, BLOCK_MAP_FORMAT_DOCS_URL, DEFAULT_ELECTRON_UPDATER_COMPATIBILITY, } from "./electronUpdaterCompatibility.js";
6
7
  import { normalizePackageData } from "./normalizePackageData.js";
7
8
  const require = createRequire(import.meta.url);
8
9
  /** @internal */
@@ -28,8 +29,11 @@ async function authors(file, data) {
28
29
  }
29
30
  data.contributors = authorData.split(/\r?\n/g).map(it => it.replace(/^\s*#.*$/, "").trim());
30
31
  }
31
- /** @internal */
32
- export function checkMetadata(metadata, devMetadata, appPackageFile, devAppPackageFile, projectDir) {
32
+ /**
33
+ * `electronUpdaterRequirements`: what the app's electron-updater has to read on each platform the build targets.
34
+ * @internal
35
+ */
36
+ export function checkMetadata(metadata, devMetadata, appPackageFile, devAppPackageFile, projectDir, electronUpdaterRequirements) {
33
37
  const errors = [];
34
38
  const reportError = (missedFieldName) => {
35
39
  errors.push(`Please specify '${missedFieldName}' in the package.json (${appPackageFile})`);
@@ -47,7 +51,8 @@ export function checkMetadata(metadata, devMetadata, appPackageFile, devAppPacka
47
51
  log.warn({ appPackageFile }, `author is missed in the package.json`);
48
52
  }
49
53
  checkNotEmpty("version", metadata.version);
50
- checkDependencies(metadata.dependencies, errors, projectDir);
54
+ checkElectronUpdater(metadata, devMetadata, errors, projectDir, electronUpdaterRequirements);
55
+ checkDependencies(metadata.dependencies, errors);
51
56
  if (metadata !== devMetadata) {
52
57
  if (metadata.build != null) {
53
58
  errors.push(`'build' in the application package.json (${appPackageFile}) is not supported since 3.0 anymore. Please move 'build' into the development package.json (${devAppPackageFile})`);
@@ -82,60 +87,119 @@ function versionSatisfies(version, range, loose) {
82
87
  }
83
88
  return semver.satisfies(coerced, range, loose);
84
89
  }
85
- function checkDependencies(dependencies, errors, projectDir) {
86
- if (dependencies == null) {
87
- return;
90
+ /** The lowest version `versionOrRange` (an installed version, or a declared specifier such as `^7.0.0-alpha.5`) allows. */
91
+ function lowestVersion(versionOrRange) {
92
+ const version = semver.parse(versionOrRange);
93
+ if (version != null) {
94
+ return version;
88
95
  }
89
- let updaterVersion = dependencies["electron-updater"];
90
- if (updaterVersion != null) {
91
- let skipValidation = false;
92
- // prefer the version of the actually-installed electron-updater over the declared specifier,
93
- // so that specifiers like pnpm `catalog:`/`workspace:` are validated against the real version
94
- let resolvedPackageJson = null;
95
- try {
96
- resolvedPackageJson = require.resolve("electron-updater/package.json", { paths: [projectDir] });
97
- }
98
- catch (_ignored) {
99
- // electron-updater is not installed (MODULE_NOT_FOUND), or the installed version's `exports` map
100
- // does not expose "./package.json" (ERR_PACKAGE_PATH_NOT_EXPORTED) — fall back to the declared specifier below
101
- }
102
- if (resolvedPackageJson != null) {
103
- updaterVersion = fsExtra.readJsonSync(resolvedPackageJson).version;
96
+ try {
97
+ return semver.validRange(versionOrRange) == null ? null : semver.minVersion(versionOrRange);
98
+ }
99
+ catch (_ignored) {
100
+ return null;
101
+ }
102
+ }
103
+ /**
104
+ * The electron-updater the app ships: from the app's `dependencies`, else bundled (by webpack, vite, ...) from its `devDependencies`,
105
+ * or from the `dependencies` or `devDependencies` of the development package.json (two package.json layout).
106
+ */
107
+ function findAppElectronUpdater(metadata, devMetadata, projectDir) {
108
+ let declared = null;
109
+ const dev = devMetadata === metadata ? null : devMetadata;
110
+ const candidates = [
111
+ [metadata.dependencies, null],
112
+ [metadata.devDependencies, "devDependencies"],
113
+ [dev?.dependencies, "dependencies of the development package.json"],
114
+ [dev?.devDependencies, "devDependencies"],
115
+ ];
116
+ for (const [dependencies, bundledFrom] of candidates) {
117
+ const specifier = dependencies == null ? undefined : dependencies["electron-updater"];
118
+ if (typeof specifier === "string") {
119
+ declared = { specifier, bundledFrom };
120
+ break;
104
121
  }
105
- else {
106
- // Pick the version out of yarn berry patch syntax
107
- // "patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch"
108
- if (updaterVersion.startsWith("patch:")) {
109
- const npmMarker = "@npm%3A";
110
- const markerIndex = updaterVersion.indexOf(npmMarker);
111
- if (markerIndex !== -1) {
112
- const versionStart = markerIndex + npmMarker.length;
113
- const hashIndex = updaterVersion.indexOf("#", versionStart);
114
- if (hashIndex > versionStart) {
115
- updaterVersion = updaterVersion.slice(versionStart, hashIndex);
116
- }
117
- }
118
- }
119
- // for testing auto-update using workspace electron-updater
120
- const prefixes = ["link:", "file:"];
121
- for (const prefix of prefixes) {
122
- if (updaterVersion.startsWith(prefix)) {
123
- const normalized = path.normalize(updaterVersion.substring(prefix.length));
124
- const packageJsonPath = path.isAbsolute(normalized) ? normalized : path.resolve(process.cwd(), normalized);
125
- const json = fsExtra.readJsonSync(path.join(packageJsonPath, "package.json"));
126
- updaterVersion = json.version;
127
- break;
128
- }
122
+ }
123
+ if (declared == null) {
124
+ return null;
125
+ }
126
+ const { bundledFrom } = declared;
127
+ let updaterVersion = declared.specifier;
128
+ // prefer the version of the actually-installed electron-updater over the declared specifier,
129
+ // so that specifiers like pnpm `catalog:`/`workspace:` are validated against the real version
130
+ let resolvedPackageJson = null;
131
+ try {
132
+ resolvedPackageJson = require.resolve("electron-updater/package.json", { paths: [projectDir] });
133
+ }
134
+ catch (_ignored) {
135
+ // electron-updater is not installed (MODULE_NOT_FOUND), or the installed version's `exports` map
136
+ // does not expose "./package.json" (ERR_PACKAGE_PATH_NOT_EXPORTED) — fall back to the declared specifier below
137
+ }
138
+ if (resolvedPackageJson != null) {
139
+ return { version: fsExtra.readJsonSync(resolvedPackageJson).version, bundledFrom, isUnresolvable: false };
140
+ }
141
+ // Pick the version out of yarn berry patch syntax
142
+ // "patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch"
143
+ if (updaterVersion.startsWith("patch:")) {
144
+ const npmMarker = "@npm%3A";
145
+ const markerIndex = updaterVersion.indexOf(npmMarker);
146
+ if (markerIndex !== -1) {
147
+ const versionStart = markerIndex + npmMarker.length;
148
+ const hashIndex = updaterVersion.indexOf("#", versionStart);
149
+ if (hashIndex > versionStart) {
150
+ updaterVersion = updaterVersion.slice(versionStart, hashIndex);
129
151
  }
130
- // pnpm `catalog:` and `workspace:` specifiers cannot be resolved to a concrete version from the package.json alone, so skip validation
131
- const unresolvableProtocols = ["catalog:", "workspace:"];
132
- skipValidation = unresolvableProtocols.some(protocol => updaterVersion.startsWith(protocol));
133
152
  }
134
- const requiredElectronUpdaterVersion = "4.0.0";
135
- if (!skipValidation && !versionSatisfies(updaterVersion, `>=${requiredElectronUpdaterVersion}`)) {
136
- errors.push(`At least electron-updater ${requiredElectronUpdaterVersion} is recommended by current electron-builder version. Please set electron-updater version to "^${requiredElectronUpdaterVersion}". Received "${updaterVersion}"`);
153
+ }
154
+ // for testing auto-update using workspace electron-updater
155
+ for (const prefix of ["link:", "file:"]) {
156
+ if (updaterVersion.startsWith(prefix)) {
157
+ const normalized = path.normalize(updaterVersion.substring(prefix.length));
158
+ const packageJsonPath = path.isAbsolute(normalized) ? normalized : path.resolve(process.cwd(), normalized);
159
+ const json = fsExtra.readJsonSync(path.join(packageJsonPath, "package.json"));
160
+ return { version: json.version, bundledFrom, isUnresolvable: false };
137
161
  }
138
162
  }
163
+ // pnpm `catalog:` and `workspace:` specifiers cannot be resolved to a concrete version from the package.json alone, so skip validation
164
+ const isUnresolvable = ["catalog:", "workspace:"].some(protocol => updaterVersion.startsWith(protocol));
165
+ return { version: updaterVersion, bundledFrom, isUnresolvable };
166
+ }
167
+ function checkElectronUpdater(metadata, devMetadata, errors, projectDir, requirements) {
168
+ const updater = findAppElectronUpdater(metadata, devMetadata, projectDir);
169
+ if (updater == null || updater.isUnresolvable) {
170
+ return;
171
+ }
172
+ const { version, bundledFrom } = updater;
173
+ const source = bundledFrom == null ? "" : ` (bundled from ${bundledFrom})`;
174
+ const requiredElectronUpdaterVersion = "4.0.0";
175
+ if (!versionSatisfies(version, `>=${requiredElectronUpdaterVersion}`)) {
176
+ errors.push(`At least electron-updater ${requiredElectronUpdaterVersion} is recommended by current electron-builder version. Please set electron-updater version to "^${requiredElectronUpdaterVersion}". Received "${version}"${source}`);
177
+ return;
178
+ }
179
+ // the build writes update files (the block map format among them) for each platform's range: an app outside it cannot read them.
180
+ // Coerced, so that ">=7" admits the 7.0.0 prereleases; the binary block map floor below tells those apart.
181
+ const unsatisfied = requirements.filter(it => !versionSatisfies(version, it.range));
182
+ if (unsatisfied.length > 0) {
183
+ const ranges = [...new Set(unsatisfied.map(it => `"${it.range}"`))].join(", ");
184
+ const platforms = unsatisfied.map(it => it.platform).join(", ");
185
+ errors.push(`electron-updater ${version}${source} does not satisfy electronUpdaterCompatibility ${ranges} of ${platforms} (the default is "${DEFAULT_ELECTRON_UPDATER_COMPATIBILITY}" since electron-builder 27). ` +
186
+ `Upgrade electron-updater to 7, or set electronUpdaterCompatibility to a range that includes "<7" (e.g. ">=6"), which switches the build to the JSON block map. ` +
187
+ `See ${BLOCK_MAP_FORMAT_DOCS_URL}`);
188
+ return;
189
+ }
190
+ const lowest = lowestVersion(version);
191
+ const binary = requirements.filter(it => it.binaryBlockMap);
192
+ if (lowest == null || binary.length === 0 || semver.gte(lowest, BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE)) {
193
+ return;
194
+ }
195
+ errors.push(`electron-updater ${version}${source} cannot read the binary block map the build writes for ${binary.map(it => it.platform).join(", ")}: ` +
196
+ `electron-updater reads it from ${BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE}. Upgrade electron-updater, or set "blockmap" to "v2" to write the JSON block map. ` +
197
+ `See ${BLOCK_MAP_FORMAT_DOCS_URL}`);
198
+ }
199
+ function checkDependencies(dependencies, errors) {
200
+ if (dependencies == null) {
201
+ return;
202
+ }
139
203
  const swVersion = dependencies["electron-builder-squirrel-windows"];
140
204
  if (swVersion != null && !versionSatisfies(swVersion, ">=20.32.0")) {
141
205
  errors.push(`At least electron-builder-squirrel-windows 20.32.0 is required by current electron-builder version. Please set electron-builder-squirrel-windows to "^20.32.0"`);
@@ -1 +1 @@
1
- {"version":3,"file":"packageMetadata.js","sourceRoot":"","sources":["../../src/util/packageMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAE9E,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzC,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACzB,kEAAkE;IAClE,OAAO,IAAI,CAAC,OAAO,CAAA;IACnB,OAAO,IAAI,CAAC,MAAM,CAAA;IAClB,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,IAAI,CAAA;AACb,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,IAAS;IAC5C,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAM;IACR,CAAC;IAED,IAAI,UAAU,CAAA;IACd,IAAI,CAA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T,6BAA6B,8BAA8B,iGAAiG,8BAA8B,gBAAgB,cAAc,GAAG,CAC5N,CAAA;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,mCAAmC,CAAC,CAAA;IACnE,IAAI,SAAS,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,gKAAgK,CAAC,CAAA;IAC/K,CAAC;AACH,CAAC","sourcesContent":["import { InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport fsExtra from \"fs-extra\"\nimport { createRequire } from \"node:module\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Metadata } from \"../options/metadata.js\"\nimport { normalizePackageData } from \"./normalizePackageData.js\"\n\nconst require = createRequire(import.meta.url)\n\n/** @internal */\nexport async function readPackageJson(file: string): Promise<any> {\n const data = await fsExtra.readJson(file)\n await authors(file, data)\n // remove not required fields because can be used for remote build\n delete data.scripts\n delete data.readme\n normalizePackageData(data)\n return data\n}\n\nasync function authors(file: string, data: any) {\n if (data.contributors != null) {\n return\n }\n\n let authorData\n try {\n authorData = await fsExtra.readFile(path.resolve(path.dirname(file), \"AUTHORS\"), \"utf8\")\n } catch (_ignored) {\n return\n }\n\n data.contributors = authorData.split(/\\r?\\n/g).map(it => it.replace(/^\\s*#.*$/, \"\").trim())\n}\n\n/** @internal */\nexport function checkMetadata(metadata: Metadata, devMetadata: any | null, appPackageFile: string, devAppPackageFile: string, projectDir: string): void {\n const errors: Array<string> = []\n const reportError = (missedFieldName: string) => {\n errors.push(`Please specify '${missedFieldName}' in the package.json (${appPackageFile})`)\n }\n\n const checkNotEmpty = (name: string, value: string | Nullish) => {\n if (isEmptyOrSpaces(value)) {\n reportError(name)\n }\n }\n\n checkNotEmpty(\"name\", metadata.name)\n\n if (isEmptyOrSpaces(metadata.description)) {\n log.warn({ appPackageFile }, `description is missed in the package.json`)\n }\n if (metadata.author == null) {\n log.warn({ appPackageFile }, `author is missed in the package.json`)\n }\n checkNotEmpty(\"version\", metadata.version)\n\n checkDependencies(metadata.dependencies, errors, projectDir)\n if (metadata !== devMetadata) {\n if (metadata.build != null) {\n errors.push(\n `'build' in the application package.json (${appPackageFile}) is not supported since 3.0 anymore. Please move 'build' into the development package.json (${devAppPackageFile})`\n )\n }\n }\n\n // Root-level `directories` was read by v26 and is ignored by v27. It lives outside the validated\n // Configuration object, so nothing else catches it: the build silently writes to the default `dist`\n // instead of the configured output directory, and a release pipeline copies from an empty path.\n const rootDirectories = (devMetadata ?? metadata)?.directories\n if (rootDirectories != null) {\n errors.push(\n `'directories' at the root of the package.json (${devAppPackageFile}) is no longer read by electron-builder v27 — move it under the 'build' key:\\n` +\n ` { \"build\": { \"directories\": ${JSON.stringify(rootDirectories)} } }\\n` +\n \" Left where it is, it is ignored and your build output goes to the default 'dist' directory.\\n\" +\n \" Run `electron-builder migrate-schema` to move it automatically.\\n\" +\n \" https://www.electron.build/docs/migration/v27-config-changes#root-level-directories-in-packagejson\"\n )\n }\n\n const devDependencies = (metadata as any).devDependencies\n if (devDependencies != null && (\"electron-rebuild\" in devDependencies || \"@electron/rebuild\" in devDependencies)) {\n log.info(\n '@electron/rebuild already used by electron-builder, please consider to remove excess dependency from devDependencies\\n\\nTo ensure your native dependencies are always matched electron version, simply add script `\"postinstall\": \"electron-builder install-app-deps\" to your `package.json`'\n )\n }\n\n if (errors.length > 0) {\n throw new InvalidConfigurationError(errors.join(\"\\n\"))\n }\n}\n\nfunction versionSatisfies(version: string | semver.SemVer | null, range: string | semver.Range, loose?: boolean): boolean {\n if (version == null) {\n return false\n }\n\n const coerced = semver.coerce(version)\n if (coerced == null) {\n return false\n }\n\n return semver.satisfies(coerced, range, loose)\n}\n\nfunction checkDependencies(dependencies: Record<string, string> | Nullish, errors: Array<string>, projectDir: string) {\n if (dependencies == null) {\n return\n }\n\n let updaterVersion = dependencies[\"electron-updater\"]\n if (updaterVersion != null) {\n let skipValidation = false\n\n // prefer the version of the actually-installed electron-updater over the declared specifier,\n // so that specifiers like pnpm `catalog:`/`workspace:` are validated against the real version\n let resolvedPackageJson: string | null = null\n try {\n resolvedPackageJson = require.resolve(\"electron-updater/package.json\", { paths: [projectDir] })\n } catch (_ignored) {\n // electron-updater is not installed (MODULE_NOT_FOUND), or the installed version's `exports` map\n // does not expose \"./package.json\" (ERR_PACKAGE_PATH_NOT_EXPORTED) — fall back to the declared specifier below\n }\n\n if (resolvedPackageJson != null) {\n updaterVersion = fsExtra.readJsonSync(resolvedPackageJson).version\n } else {\n // Pick the version out of yarn berry patch syntax\n // \"patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch\"\n if (updaterVersion.startsWith(\"patch:\")) {\n const npmMarker = \"@npm%3A\"\n const markerIndex = updaterVersion.indexOf(npmMarker)\n if (markerIndex !== -1) {\n const versionStart = markerIndex + npmMarker.length\n const hashIndex = updaterVersion.indexOf(\"#\", versionStart)\n if (hashIndex > versionStart) {\n updaterVersion = updaterVersion.slice(versionStart, hashIndex)\n }\n }\n }\n\n // for testing auto-update using workspace electron-updater\n const prefixes = [\"link:\", \"file:\"]\n for (const prefix of prefixes) {\n if (updaterVersion.startsWith(prefix)) {\n const normalized = path.normalize(updaterVersion.substring(prefix.length))\n const packageJsonPath = path.isAbsolute(normalized) ? normalized : path.resolve(process.cwd(), normalized)\n const json = fsExtra.readJsonSync(path.join(packageJsonPath, \"package.json\"))\n updaterVersion = json.version\n break\n }\n }\n\n // pnpm `catalog:` and `workspace:` specifiers cannot be resolved to a concrete version from the package.json alone, so skip validation\n const unresolvableProtocols = [\"catalog:\", \"workspace:\"]\n skipValidation = unresolvableProtocols.some(protocol => updaterVersion.startsWith(protocol))\n }\n\n const requiredElectronUpdaterVersion = \"4.0.0\"\n if (!skipValidation && !versionSatisfies(updaterVersion, `>=${requiredElectronUpdaterVersion}`)) {\n errors.push(\n `At least electron-updater ${requiredElectronUpdaterVersion} is recommended by current electron-builder version. Please set electron-updater version to \"^${requiredElectronUpdaterVersion}\". Received \"${updaterVersion}\"`\n )\n }\n }\n\n const swVersion = dependencies[\"electron-builder-squirrel-windows\"]\n if (swVersion != null && !versionSatisfies(swVersion, \">=20.32.0\")) {\n errors.push(`At least electron-builder-squirrel-windows 20.32.0 is required by current electron-builder version. Please set electron-builder-squirrel-windows to \"^20.32.0\"`)\n }\n}\n"]}
1
+ {"version":3,"file":"packageMetadata.js","sourceRoot":"","sources":["../../src/util/packageMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAE9E,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,EACL,oCAAoC,EACpC,yBAAyB,EACzB,sCAAsC,GAEvC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzC,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACzB,kEAAkE;IAClE,OAAO,IAAI,CAAC,OAAO,CAAA;IACnB,OAAO,IAAI,CAAC,MAAM,CAAA;IAClB,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,IAAI,CAAA;AACb,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,IAA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CAAC,IAAI,CAAC,CAAA;QAC/D,MAAM,CAAC,IAAI,CACT,oBAAoB,OAAO,GAAG,MAAM,kDAAkD,MAAM,OAAO,SAAS,qBAAqB,sCAAsC,gCAAgC;YACrM,iKAAiK;YACjK,OAAO,yBAAyB,EAAE,CACrC,CAAA;QACD,OAAM;IACR,CAAC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IACrC,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,CAAA;IAC3D,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,oCAAoC,CAAC,EAAE,CAAC;QACtG,OAAM;IACR,CAAC;IACD,MAAM,CAAC,IAAI,CACT,oBAAoB,OAAO,GAAG,MAAM,0DAA0D,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QACxI,kCAAkC,oCAAoC,qFAAqF;QAC3J,OAAO,yBAAyB,EAAE,CACrC,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,YAA8C,EAAE,MAAqB;IAC9F,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,OAAM;IACR,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,mCAAmC,CAAC,CAAA;IACnE,IAAI,SAAS,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,gKAAgK,CAAC,CAAA;IAC/K,CAAC;AACH,CAAC","sourcesContent":["import { InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport fsExtra from \"fs-extra\"\nimport { createRequire } from \"node:module\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Metadata } from \"../options/metadata.js\"\nimport {\n BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE,\n BLOCK_MAP_FORMAT_DOCS_URL,\n DEFAULT_ELECTRON_UPDATER_COMPATIBILITY,\n ElectronUpdaterRequirement,\n} from \"./electronUpdaterCompatibility.js\"\nimport { normalizePackageData } from \"./normalizePackageData.js\"\n\nconst require = createRequire(import.meta.url)\n\n/** @internal */\nexport async function readPackageJson(file: string): Promise<any> {\n const data = await fsExtra.readJson(file)\n await authors(file, data)\n // remove not required fields because can be used for remote build\n delete data.scripts\n delete data.readme\n normalizePackageData(data)\n return data\n}\n\nasync function authors(file: string, data: any) {\n if (data.contributors != null) {\n return\n }\n\n let authorData\n try {\n authorData = await fsExtra.readFile(path.resolve(path.dirname(file), \"AUTHORS\"), \"utf8\")\n } catch (_ignored) {\n return\n }\n\n data.contributors = authorData.split(/\\r?\\n/g).map(it => it.replace(/^\\s*#.*$/, \"\").trim())\n}\n\n/**\n * `electronUpdaterRequirements`: what the app's electron-updater has to read on each platform the build targets.\n * @internal\n */\nexport function checkMetadata(\n metadata: Metadata,\n devMetadata: any | null,\n appPackageFile: string,\n devAppPackageFile: string,\n projectDir: string,\n electronUpdaterRequirements: Array<ElectronUpdaterRequirement>\n): void {\n const errors: Array<string> = []\n const reportError = (missedFieldName: string) => {\n errors.push(`Please specify '${missedFieldName}' in the package.json (${appPackageFile})`)\n }\n\n const checkNotEmpty = (name: string, value: string | Nullish) => {\n if (isEmptyOrSpaces(value)) {\n reportError(name)\n }\n }\n\n checkNotEmpty(\"name\", metadata.name)\n\n if (isEmptyOrSpaces(metadata.description)) {\n log.warn({ appPackageFile }, `description is missed in the package.json`)\n }\n if (metadata.author == null) {\n log.warn({ appPackageFile }, `author is missed in the package.json`)\n }\n checkNotEmpty(\"version\", metadata.version)\n\n checkElectronUpdater(metadata, devMetadata, errors, projectDir, electronUpdaterRequirements)\n checkDependencies(metadata.dependencies, errors)\n if (metadata !== devMetadata) {\n if (metadata.build != null) {\n errors.push(\n `'build' in the application package.json (${appPackageFile}) is not supported since 3.0 anymore. Please move 'build' into the development package.json (${devAppPackageFile})`\n )\n }\n }\n\n // Root-level `directories` was read by v26 and is ignored by v27. It lives outside the validated\n // Configuration object, so nothing else catches it: the build silently writes to the default `dist`\n // instead of the configured output directory, and a release pipeline copies from an empty path.\n const rootDirectories = (devMetadata ?? metadata)?.directories\n if (rootDirectories != null) {\n errors.push(\n `'directories' at the root of the package.json (${devAppPackageFile}) is no longer read by electron-builder v27 — move it under the 'build' key:\\n` +\n ` { \"build\": { \"directories\": ${JSON.stringify(rootDirectories)} } }\\n` +\n \" Left where it is, it is ignored and your build output goes to the default 'dist' directory.\\n\" +\n \" Run `electron-builder migrate-schema` to move it automatically.\\n\" +\n \" https://www.electron.build/docs/migration/v27-config-changes#root-level-directories-in-packagejson\"\n )\n }\n\n const devDependencies = (metadata as any).devDependencies\n if (devDependencies != null && (\"electron-rebuild\" in devDependencies || \"@electron/rebuild\" in devDependencies)) {\n log.info(\n '@electron/rebuild already used by electron-builder, please consider to remove excess dependency from devDependencies\\n\\nTo ensure your native dependencies are always matched electron version, simply add script `\"postinstall\": \"electron-builder install-app-deps\" to your `package.json`'\n )\n }\n\n if (errors.length > 0) {\n throw new InvalidConfigurationError(errors.join(\"\\n\"))\n }\n}\n\nfunction versionSatisfies(version: string | semver.SemVer | null, range: string | semver.Range, loose?: boolean): boolean {\n if (version == null) {\n return false\n }\n\n const coerced = semver.coerce(version)\n if (coerced == null) {\n return false\n }\n\n return semver.satisfies(coerced, range, loose)\n}\n\n/** The lowest version `versionOrRange` (an installed version, or a declared specifier such as `^7.0.0-alpha.5`) allows. */\nfunction lowestVersion(versionOrRange: string): semver.SemVer | null {\n const version = semver.parse(versionOrRange)\n if (version != null) {\n return version\n }\n try {\n return semver.validRange(versionOrRange) == null ? null : semver.minVersion(versionOrRange)\n } catch (_ignored) {\n return null\n }\n}\n\ninterface AppElectronUpdater {\n /** the installed version, or the declared specifier when electron-updater is not installed */\n readonly version: string\n /** where a bundler takes it from (null: the app's `dependencies`, which are packaged) */\n readonly bundledFrom: string | null\n /** `catalog:` / `workspace:` specifier of an electron-updater that is not installed */\n readonly isUnresolvable: boolean\n}\n\n/**\n * The electron-updater the app ships: from the app's `dependencies`, else bundled (by webpack, vite, ...) from its `devDependencies`,\n * or from the `dependencies` or `devDependencies` of the development package.json (two package.json layout).\n */\nfunction findAppElectronUpdater(metadata: Metadata, devMetadata: any | null, projectDir: string): AppElectronUpdater | null {\n let declared: { specifier: string; bundledFrom: string | null } | null = null\n const dev = devMetadata === metadata ? null : devMetadata\n const candidates: Array<[unknown, string | null]> = [\n [metadata.dependencies, null],\n [(metadata as any).devDependencies, \"devDependencies\"],\n [dev?.dependencies, \"dependencies of the development package.json\"],\n [dev?.devDependencies, \"devDependencies\"],\n ]\n for (const [dependencies, bundledFrom] of candidates) {\n const specifier = dependencies == null ? undefined : (dependencies as Record<string, unknown>)[\"electron-updater\"]\n if (typeof specifier === \"string\") {\n declared = { specifier, bundledFrom }\n break\n }\n }\n if (declared == null) {\n return null\n }\n const { bundledFrom } = declared\n let updaterVersion = declared.specifier\n\n // prefer the version of the actually-installed electron-updater over the declared specifier,\n // so that specifiers like pnpm `catalog:`/`workspace:` are validated against the real version\n let resolvedPackageJson: string | null = null\n try {\n resolvedPackageJson = require.resolve(\"electron-updater/package.json\", { paths: [projectDir] })\n } catch (_ignored) {\n // electron-updater is not installed (MODULE_NOT_FOUND), or the installed version's `exports` map\n // does not expose \"./package.json\" (ERR_PACKAGE_PATH_NOT_EXPORTED) — fall back to the declared specifier below\n }\n\n if (resolvedPackageJson != null) {\n return { version: fsExtra.readJsonSync(resolvedPackageJson).version, bundledFrom, isUnresolvable: false }\n }\n\n // Pick the version out of yarn berry patch syntax\n // \"patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch\"\n if (updaterVersion.startsWith(\"patch:\")) {\n const npmMarker = \"@npm%3A\"\n const markerIndex = updaterVersion.indexOf(npmMarker)\n if (markerIndex !== -1) {\n const versionStart = markerIndex + npmMarker.length\n const hashIndex = updaterVersion.indexOf(\"#\", versionStart)\n if (hashIndex > versionStart) {\n updaterVersion = updaterVersion.slice(versionStart, hashIndex)\n }\n }\n }\n\n // for testing auto-update using workspace electron-updater\n for (const prefix of [\"link:\", \"file:\"]) {\n if (updaterVersion.startsWith(prefix)) {\n const normalized = path.normalize(updaterVersion.substring(prefix.length))\n const packageJsonPath = path.isAbsolute(normalized) ? normalized : path.resolve(process.cwd(), normalized)\n const json = fsExtra.readJsonSync(path.join(packageJsonPath, \"package.json\"))\n return { version: json.version, bundledFrom, isUnresolvable: false }\n }\n }\n\n // pnpm `catalog:` and `workspace:` specifiers cannot be resolved to a concrete version from the package.json alone, so skip validation\n const isUnresolvable = [\"catalog:\", \"workspace:\"].some(protocol => updaterVersion.startsWith(protocol))\n return { version: updaterVersion, bundledFrom, isUnresolvable }\n}\n\nfunction checkElectronUpdater(metadata: Metadata, devMetadata: any | null, errors: Array<string>, projectDir: string, requirements: Array<ElectronUpdaterRequirement>) {\n const updater = findAppElectronUpdater(metadata, devMetadata, projectDir)\n if (updater == null || updater.isUnresolvable) {\n return\n }\n const { version, bundledFrom } = updater\n const source = bundledFrom == null ? \"\" : ` (bundled from ${bundledFrom})`\n\n const requiredElectronUpdaterVersion = \"4.0.0\"\n if (!versionSatisfies(version, `>=${requiredElectronUpdaterVersion}`)) {\n errors.push(\n `At least electron-updater ${requiredElectronUpdaterVersion} is recommended by current electron-builder version. Please set electron-updater version to \"^${requiredElectronUpdaterVersion}\". Received \"${version}\"${source}`\n )\n return\n }\n\n // the build writes update files (the block map format among them) for each platform's range: an app outside it cannot read them.\n // Coerced, so that \">=7\" admits the 7.0.0 prereleases; the binary block map floor below tells those apart.\n const unsatisfied = requirements.filter(it => !versionSatisfies(version, it.range))\n if (unsatisfied.length > 0) {\n const ranges = [...new Set(unsatisfied.map(it => `\"${it.range}\"`))].join(\", \")\n const platforms = unsatisfied.map(it => it.platform).join(\", \")\n errors.push(\n `electron-updater ${version}${source} does not satisfy electronUpdaterCompatibility ${ranges} of ${platforms} (the default is \"${DEFAULT_ELECTRON_UPDATER_COMPATIBILITY}\" since electron-builder 27). ` +\n `Upgrade electron-updater to 7, or set electronUpdaterCompatibility to a range that includes \"<7\" (e.g. \">=6\"), which switches the build to the JSON block map. ` +\n `See ${BLOCK_MAP_FORMAT_DOCS_URL}`\n )\n return\n }\n\n const lowest = lowestVersion(version)\n const binary = requirements.filter(it => it.binaryBlockMap)\n if (lowest == null || binary.length === 0 || semver.gte(lowest, BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE)) {\n return\n }\n errors.push(\n `electron-updater ${version}${source} cannot read the binary block map the build writes for ${binary.map(it => it.platform).join(\", \")}: ` +\n `electron-updater reads it from ${BINARY_BLOCK_MAP_MIN_UPDATER_RELEASE}. Upgrade electron-updater, or set \"blockmap\" to \"v2\" to write the JSON block map. ` +\n `See ${BLOCK_MAP_FORMAT_DOCS_URL}`\n )\n}\n\nfunction checkDependencies(dependencies: Record<string, string> | Nullish, errors: Array<string>) {\n if (dependencies == null) {\n return\n }\n\n const swVersion = dependencies[\"electron-builder-squirrel-windows\"]\n if (swVersion != null && !versionSatisfies(swVersion, \">=20.32.0\")) {\n errors.push(`At least electron-builder-squirrel-windows 20.32.0 is required by current electron-builder version. Please set electron-builder-squirrel-windows to \"^20.32.0\"`)\n }\n}\n"]}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PACKAGE_VERSION = "27.0.0-alpha.13";
1
+ export declare const PACKAGE_VERSION = "27.0.0-alpha.14";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const PACKAGE_VERSION = "27.0.0-alpha.13";
1
+ export const PACKAGE_VERSION = "27.0.0-alpha.14";
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"27.0.0-alpha.13\"\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"27.0.0-alpha.14\"\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "app-builder-lib",
3
3
  "description": "electron-builder lib",
4
- "version": "27.0.0-alpha.13",
4
+ "version": "27.0.0-alpha.14",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "exports": {
@@ -97,9 +97,9 @@
97
97
  "undici": "^7.30.1",
98
98
  "unzipper": "^0.12.3",
99
99
  "which": "^5.0.0",
100
- "builder-util": "27.0.0-alpha.13",
101
- "builder-util-runtime": "10.0.0-alpha.12",
102
- "electron-publish": "27.0.0-alpha.13"
100
+ "electron-publish": "27.0.0-alpha.14",
101
+ "builder-util": "27.0.0-alpha.14",
102
+ "builder-util-runtime": "10.0.0-alpha.13"
103
103
  },
104
104
  "///": "babel in devDependencies for proton tests",
105
105
  "devDependencies": {
@@ -116,12 +116,12 @@
116
116
  "@types/unzipper": "^0.10.11",
117
117
  "@types/which": "^3.0.4",
118
118
  "toml": "^5.0.1",
119
- "electron-builder-squirrel-windows": "27.0.0-alpha.13",
120
- "dmg-builder": "27.0.0-alpha.13"
119
+ "electron-builder-squirrel-windows": "27.0.0-alpha.14",
120
+ "dmg-builder": "27.0.0-alpha.14"
121
121
  },
122
122
  "peerDependencies": {
123
- "dmg-builder": "27.0.0-alpha.13",
124
- "electron-builder-squirrel-windows": "27.0.0-alpha.13"
123
+ "dmg-builder": "27.0.0-alpha.14",
124
+ "electron-builder-squirrel-windows": "27.0.0-alpha.14"
125
125
  },
126
126
  "//": "electron-builder-squirrel-windows and dmg-builder added as dev dep for tests (as otherwise `require` doesn't work using Yarn 2)",
127
127
  "types": "./dist/index.d.ts",