app-builder-lib 27.0.0-alpha.11 → 27.0.0-alpha.13
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.
- package/dist/asar/asarUtil.js +1 -1
- package/dist/asar/asarUtil.js.map +1 -1
- package/dist/codeSign/certInfo.d.ts +4 -1
- package/dist/codeSign/certInfo.d.ts.map +1 -1
- package/dist/codeSign/certInfo.js +5 -3
- package/dist/codeSign/certInfo.js.map +1 -1
- package/dist/codeSign/forceCodeSigning.d.ts +22 -0
- package/dist/codeSign/forceCodeSigning.d.ts.map +1 -0
- package/dist/codeSign/forceCodeSigning.js +18 -0
- package/dist/codeSign/forceCodeSigning.js.map +1 -0
- package/dist/codeSign/mac/macCodeSign.d.ts +13 -1
- package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
- package/dist/codeSign/mac/macCodeSign.js +29 -2
- package/dist/codeSign/mac/macCodeSign.js.map +1 -1
- package/dist/codeSign/mac/macSignatureVerifier.d.ts +23 -0
- package/dist/codeSign/mac/macSignatureVerifier.d.ts.map +1 -0
- package/dist/codeSign/mac/macSignatureVerifier.js +96 -0
- package/dist/codeSign/mac/macSignatureVerifier.js.map +1 -0
- package/dist/codeSign/win/authenticodeSignature.d.ts +83 -0
- package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -0
- package/dist/codeSign/win/authenticodeSignature.js +289 -0
- package/dist/codeSign/win/authenticodeSignature.js.map +1 -0
- package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.js +4 -3
- package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
- package/dist/codeSign/win/publisherName.d.ts +31 -0
- package/dist/codeSign/win/publisherName.d.ts.map +1 -0
- package/dist/codeSign/win/publisherName.js +78 -0
- package/dist/codeSign/win/publisherName.js.map +1 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts +27 -9
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.js +80 -49
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
- package/dist/codeSign/win/verifyUpdatePublisher.d.ts +25 -0
- package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -0
- package/dist/codeSign/win/verifyUpdatePublisher.js +101 -0
- package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -0
- package/dist/codeSign/win/windowsSignAzureManager.d.ts +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.js +24 -6
- package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
- package/dist/configuration.d.ts +56 -12
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/electron/ElectronFramework.d.ts +15 -0
- package/dist/electron/ElectronFramework.d.ts.map +1 -1
- package/dist/electron/ElectronFramework.js +33 -2
- package/dist/electron/ElectronFramework.js.map +1 -1
- package/dist/electron/mac/asarIntegrityDigest.d.ts +10 -0
- package/dist/electron/mac/asarIntegrityDigest.d.ts.map +1 -0
- package/dist/electron/mac/asarIntegrityDigest.js +122 -0
- package/dist/electron/mac/asarIntegrityDigest.js.map +1 -0
- package/dist/electron/mac/electronMac.js +1 -28
- package/dist/electron/mac/electronMac.js.map +1 -1
- package/dist/electron/mac/electronMacUtils.d.ts +9 -0
- package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
- package/dist/electron/mac/electronMacUtils.js +37 -0
- package/dist/electron/mac/electronMacUtils.js.map +1 -1
- package/dist/fileMatcher.d.ts +34 -11
- package/dist/fileMatcher.d.ts.map +1 -1
- package/dist/fileMatcher.js +125 -36
- package/dist/fileMatcher.js.map +1 -1
- package/dist/forge-maker.d.ts +64 -0
- package/dist/forge-maker.d.ts.map +1 -1
- package/dist/forge-maker.js +104 -2
- package/dist/forge-maker.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +9 -3
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +8 -3
- package/dist/indexInternal.js.map +1 -1
- package/dist/linuxPackager.js +1 -1
- package/dist/linuxPackager.js.map +1 -1
- package/dist/macPackager.d.ts +32 -0
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +215 -13
- package/dist/macPackager.js.map +1 -1
- package/dist/options/FuseOptionsV1.d.ts +4 -0
- package/dist/options/FuseOptionsV1.d.ts.map +1 -1
- package/dist/options/FuseOptionsV1.js.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.d.ts +93 -21
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/SquirrelWindowsOptions.d.ts +3 -0
- package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
- package/dist/options/SquirrelWindowsOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +22 -3
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +68 -19
- package/dist/options/winOptions.d.ts.map +1 -1
- package/dist/options/winOptions.js +20 -0
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +3 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +11 -2
- package/dist/packager.js.map +1 -1
- package/dist/platformPackager.d.ts +18 -7
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +56 -15
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +4 -0
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +106 -28
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/manifestUploadCheck.d.ts +10 -0
- package/dist/publish/manifestUploadCheck.d.ts.map +1 -0
- package/dist/publish/manifestUploadCheck.js +75 -0
- package/dist/publish/manifestUploadCheck.js.map +1 -0
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +51 -17
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/publish/updateManifestVerifier.d.ts +22 -0
- package/dist/publish/updateManifestVerifier.d.ts.map +1 -0
- package/dist/publish/updateManifestVerifier.js +65 -0
- package/dist/publish/updateManifestVerifier.js.map +1 -0
- package/dist/targets/ArchiveTarget.d.ts.map +1 -1
- package/dist/targets/ArchiveTarget.js +6 -2
- package/dist/targets/ArchiveTarget.js.map +1 -1
- package/dist/targets/archive.d.ts +6 -0
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +15 -5
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.js +4 -0
- package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/dist/targets/linux/FlatpakTarget.js +5 -5
- package/dist/targets/linux/FlatpakTarget.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +12 -17
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.js +6 -1
- package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
- package/dist/targets/linux/appimage/appImageUtil.js +9 -9
- package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
- package/dist/targets/linux/flatpakBundle.d.ts.map +1 -1
- package/dist/targets/linux/flatpakBundle.js +25 -20
- package/dist/targets/linux/flatpakBundle.js.map +1 -1
- package/dist/targets/linux/snap/core24.d.ts.map +1 -1
- package/dist/targets/linux/snap/core24.js +2 -9
- package/dist/targets/linux/snap/core24.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +22 -6
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/linux/snap/snapPlugs.d.ts +2 -2
- package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapPlugs.js +1 -1
- package/dist/targets/linux/snap/snapPlugs.js.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.js +19 -17
- package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +21 -3
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +140 -13
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +8 -5
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +15 -3
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.d.ts +1 -1
- package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
- package/dist/toolsets/nsis.js +1 -1
- package/dist/toolsets/nsis.js.map +1 -1
- package/dist/toolsets/winCodeSign.d.ts +14 -1
- package/dist/toolsets/winCodeSign.d.ts.map +1 -1
- package/dist/toolsets/winCodeSign.js +14 -1
- package/dist/toolsets/winCodeSign.js.map +1 -1
- package/dist/toolsets/wine.d.ts +3 -0
- package/dist/toolsets/wine.d.ts.map +1 -1
- package/dist/toolsets/wine.js +14 -5
- package/dist/toolsets/wine.js.map +1 -1
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +15 -11
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/buildOutputVerifier.d.ts +40 -0
- package/dist/util/buildOutputVerifier.d.ts.map +1 -0
- package/dist/util/buildOutputVerifier.js +420 -0
- package/dist/util/buildOutputVerifier.js.map +1 -0
- package/dist/util/config/config.d.ts.map +1 -1
- package/dist/util/config/config.js +9 -1
- package/dist/util/config/config.js.map +1 -1
- package/dist/util/config/fileOptions.d.ts +22 -0
- package/dist/util/config/fileOptions.d.ts.map +1 -1
- package/dist/util/config/fileOptions.js +92 -2
- package/dist/util/config/fileOptions.js.map +1 -1
- package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
- package/dist/util/config/legacyConfigGuard.js +2 -2
- package/dist/util/config/legacyConfigGuard.js.map +1 -1
- package/dist/util/config/legacyOptions.d.ts +9 -2
- package/dist/util/config/legacyOptions.d.ts.map +1 -1
- package/dist/util/config/legacyOptions.js +20 -2
- package/dist/util/config/legacyOptions.js.map +1 -1
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +3 -1
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +3 -9
- package/dist/util/flags.js.map +1 -1
- package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
- package/dist/util/mac/macosIconComposer.js +6 -5
- package/dist/util/mac/macosIconComposer.js.map +1 -1
- package/dist/util/macroExpander.js +1 -1
- package/dist/util/macroExpander.js.map +1 -1
- package/dist/util/nativeBinaryVerifier.d.ts.map +1 -1
- package/dist/util/nativeBinaryVerifier.js +3 -1
- package/dist/util/nativeBinaryVerifier.js.map +1 -1
- package/dist/util/packageMetadata.js +1 -1
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/util/removedEnvVars.d.ts +2 -0
- package/dist/util/removedEnvVars.d.ts.map +1 -1
- package/dist/util/removedEnvVars.js +15 -1
- package/dist/util/removedEnvVars.js.map +1 -1
- package/dist/util/streamSpawnToFile.d.ts +3 -1
- package/dist/util/streamSpawnToFile.d.ts.map +1 -1
- package/dist/util/streamSpawnToFile.js +6 -2
- package/dist/util/streamSpawnToFile.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/vm/ParallelsVm.d.ts +10 -0
- package/dist/vm/ParallelsVm.d.ts.map +1 -1
- package/dist/vm/ParallelsVm.js +22 -8
- package/dist/vm/ParallelsVm.js.map +1 -1
- package/dist/vm/PwshVm.d.ts +0 -1
- package/dist/vm/PwshVm.d.ts.map +1 -1
- package/dist/vm/PwshVm.js +10 -15
- package/dist/vm/PwshVm.js.map +1 -1
- package/dist/vm/WineVm.d.ts.map +1 -1
- package/dist/vm/WineVm.js +4 -4
- package/dist/vm/WineVm.js.map +1 -1
- package/dist/vm/vm.d.ts +9 -3
- package/dist/vm/vm.d.ts.map +1 -1
- package/dist/vm/vm.js +40 -32
- package/dist/vm/vm.js.map +1 -1
- package/dist/winPackager.d.ts +16 -1
- package/dist/winPackager.d.ts.map +1 -1
- package/dist/winPackager.js +77 -19
- package/dist/winPackager.js.map +1 -1
- package/package.json +12 -10
- package/scheme.json +662 -50
- package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +14 -9
- package/templates/nsis/installSection.nsh +5 -0
- package/dist/vm/MonoVm.d.ts +0 -9
- package/dist/vm/MonoVm.d.ts.map +0 -1
- package/dist/vm/MonoVm.js +0 -16
- package/dist/vm/MonoVm.js.map +0 -1
package/dist/util/flags.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InvalidConfigurationError, isEnvTrue } from "builder-util";
|
|
2
|
+
import { removedEnvVarDocsUrl } from "./removedEnvVars.js";
|
|
2
3
|
// ─── Code signing ─────────────────────────────────────────────────────────────
|
|
3
4
|
export function isAutoDiscoveryCodeSignIdentity() {
|
|
4
5
|
return process.env.CSC_IDENTITY_AUTO_DISCOVERY !== "false";
|
|
@@ -77,7 +78,7 @@ const REMOVED_ENV_VARS = {
|
|
|
77
78
|
},
|
|
78
79
|
USE_SYSTEM_WINE: {
|
|
79
80
|
controlled: "forcing the host-installed Wine instead of the downloaded bundle",
|
|
80
|
-
replacement: 'toolsets.wine: "system" (the host `wine`
|
|
81
|
+
replacement: 'toolsets.wine: "system" (the host `wine` is already the default on macOS and Linux, so you can simply drop this variable)',
|
|
81
82
|
},
|
|
82
83
|
USE_SYSTEM_SIGNCODE: {
|
|
83
84
|
controlled: "forcing the host signtool/signcode instead of the bundled winCodeSign toolset",
|
|
@@ -131,14 +132,7 @@ export function checkRemovedEnvVars(env = process.env) {
|
|
|
131
132
|
const { controlled, replacement } = REMOVED_ENV_VARS[name];
|
|
132
133
|
return `• ${name} controlled ${controlled}.\n Use ${replacement} instead.`;
|
|
133
134
|
});
|
|
134
|
-
return [
|
|
135
|
-
header,
|
|
136
|
-
"",
|
|
137
|
-
...entries,
|
|
138
|
-
"",
|
|
139
|
-
"Unset the variable once you have moved the setting into your configuration.",
|
|
140
|
-
"https://www.electron.build/docs/migration/v27-breaking-changes#toolset-env-var-overrides-removed",
|
|
141
|
-
].join("\n");
|
|
135
|
+
return [header, "", ...entries, "", "Unset the variable once you have moved the setting into your configuration.", ...new Set(found.map(removedEnvVarDocsUrl))].join("\n");
|
|
142
136
|
}
|
|
143
137
|
/**
|
|
144
138
|
* Throws when a removed environment variable is set. Called once per process from `Packager.build()`
|
package/dist/util/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/util/flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEnE,iFAAiF;AAEjF,MAAM,UAAU,+BAA+B;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,OAAO,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACpD,CAAC;AAED,iFAAiF;AAEjF,MAAM,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AA;IACT,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,MAAM,GACV,KAAK,CAAC,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,4BAA4B,KAAK,CAAC,CAAC,CAAC,0DAA0D;QAChG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,2FAA2F,CAAA;IAChH,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC/B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAC1D,OAAO,KAAK,IAAI,eAAe,UAAU,YAAY,WAAW,WAAW,CAAA;IAC7E,CAAC,CAAC,CAAA;IACF,OAAO;QACL,MAAM;QACN,EAAE;QACF,GAAG,OAAO;QACV,EAAE;QACF,6EAA6E;QAC7E,kGAAkG;KACnG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,qBAAqB,EAAE,CAAC;QAC1B,OAAM;IACR,CAAC;IACD,qBAAqB,GAAG,IAAI,CAAA;IAC5B,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,wBAAwB;IACtC,qBAAqB,GAAG,KAAK,CAAA;AAC/B,CAAC","sourcesContent":["import { InvalidConfigurationError, isEnvTrue } from \"builder-util\"\n\n// ─── Code signing ─────────────────────────────────────────────────────────────\n\nexport function isAutoDiscoveryCodeSignIdentity() {\n return process.env.CSC_IDENTITY_AUTO_DISCOVERY !== \"false\"\n}\n\nexport function isCscForPullRequest() {\n return isEnvTrue(process.env.CSC_FOR_PULL_REQUEST)\n}\n\n// ─── Build behaviour ──────────────────────────────────────────────────────────\n\nexport function isBuildCacheEnabled() {\n return !isEnvTrue(process.env.ELECTRON_BUILDER_DISABLE_BUILD_CACHE)\n}\n\nexport function isRemoveStageDirEvenIfDebug() {\n return isEnvTrue(process.env.ELECTRON_BUILDER_REMOVE_STAGE_EVEN_IF_DEBUG)\n}\n\nexport function isOfflineModeEnabled() {\n return isEnvTrue(process.env.ELECTRON_BUILDER_OFFLINE)\n}\n\n// ─── Publishing ───────────────────────────────────────────────────────────────\n\nexport function isPublishForPullRequest() {\n return isEnvTrue(process.env.PUBLISH_FOR_PULL_REQUEST)\n}\n\n// ─── Package metadata / dependencies ─────────────────────────────────────────\n\nexport function isNpmNoBinLinks() {\n return isEnvTrue(process.env.NPM_NO_BIN_LINKS)\n}\n\n// ─── CI environment detection ─────────────────────────────────────────────────\n\nexport function isTravis() {\n return isEnvTrue(process.env.TRAVIS)\n}\n\n// ─── Platform toolset overrides ───────────────────────────────────────────────\n\nexport function isFpmDebug() {\n return isEnvTrue(process.env.FPM_DEBUG)\n}\n\nexport function isSnapDestructiveMode() {\n return isEnvTrue(process.env.SNAP_DESTRUCTIVE_MODE)\n}\n\n// ─── Removed environment variables (v26 → v27) ───────────────────────────────\n\ninterface RemovedEnvVar {\n /** How to achieve the same thing in v27. */\n readonly replacement: string\n /** What the variable used to control, so the user can tell whether they still need it. */\n readonly controlled: string\n}\n\n/**\n * Environment variables that v26 honored and v27 ignores.\n *\n * These are the most silent of all the v27 breaking changes: unlike a removed config key, nothing\n * validates `process.env`, so a CI image exporting `USE_SYSTEM_WINE` or `ELECTRON_BUILDER_NSIS_DIR`\n * silently switches toolchain with a green build. `CI_BUILD_TAG` is worse still — combined with the\n * removal of implicit publishing, a tagged release simply stops uploading.\n *\n * Toolsets are now configured through the `toolsets` build option, which accepts an `https://` URL\n * (downloaded and cached) or a `file://` path (used as-is).\n */\nconst REMOVED_ENV_VARS: Record<string, RemovedEnvVar> = {\n APPIMAGE_TOOLS_PATH: {\n controlled: \"the AppImage build tools (mksquashfs, runtime)\",\n replacement: 'toolsets.appimage: { url: \"file:///path/to/appimage-tools-dir\" }',\n },\n LINUX_TOOLS_MAC_PATH: {\n controlled: \"the linux-tools-mac bundle (ar, lzip, gtar) used when building Linux targets on macOS\",\n replacement: 'toolsets.linuxToolsMac: { url: \"file:///path/to/linux-tools-mac-dir\" }',\n },\n CUSTOM_FPM_PATH: {\n controlled: \"the FPM executable\",\n replacement: 'toolsets.fpm: { url: \"file:///path/to/fpm-dir\" }',\n },\n USE_SYSTEM_FPM: {\n controlled: \"forcing the host-installed fpm instead of the bundled one\",\n replacement: 'toolsets.fpm: { url: \"file:///path/to/fpm-dir\" }',\n },\n ELECTRON_BUILDER_NSIS_DIR: {\n controlled: \"the NSIS compiler bundle directory\",\n replacement: 'toolsets.nsis: { url: \"file:///path/to/nsis-bundle-dir\" }',\n },\n ELECTRON_BUILDER_NSIS_RESOURCES_DIR: {\n controlled: \"the NSIS resources/plugins directory\",\n replacement: 'toolsets.nsis: { url: \"file:///path/to/nsis-bundle-dir\" } (the v27 nsis bundle carries compiler and resources together)',\n },\n ELECTRON_BUILDER_WINE_TOOLSET_DIR: {\n controlled: \"the Wine bundle directory\",\n replacement: 'toolsets.wine: { url: \"file:///path/to/wine-dir\" }',\n },\n USE_SYSTEM_WINE: {\n controlled: \"forcing the host-installed Wine instead of the downloaded bundle\",\n replacement: 'toolsets.wine: \"system\" (the host `wine` on PATH is already the default on macOS and Linux, so you can simply drop this variable)',\n },\n USE_SYSTEM_SIGNCODE: {\n controlled: \"forcing the host signtool/signcode instead of the bundled winCodeSign toolset\",\n replacement: 'win.sign (e.g. { \"win\": { \"sign\": { \"type\": \"signtool\", … } } }) together with toolsets.winCodeSign: { url: \"file:///path/to/bundle-dir\" }',\n },\n USE_SYSTEM_OSSLSIGNCODE: {\n controlled: \"forcing the host osslsigncode instead of the bundled one\",\n replacement: 'win.sign together with toolsets.winCodeSign: { url: \"file:///path/to/bundle-dir\" }',\n },\n SIGNTOOL_PATH: {\n controlled: \"the path to signtool.exe\",\n replacement: 'toolsets.winCodeSign: { url: \"file:///path/to/bundle-dir\" }',\n },\n ELECTRON_BUILDER_7ZIP_PATH: {\n controlled: \"the 7-Zip executable\",\n replacement: 'toolsets.sevenZip: { url: \"file:///path/to/dir\" } (a custom sevenZip bundle must be a .tar.gz, .zip, or bare file:// directory)',\n },\n ELECTRON_BUILDER_ICONS_TOOLSET_DIR: {\n controlled: \"the icons toolset bundle directory\",\n replacement: 'toolsets.icons: { url: \"file:///path/to/icons-bundle-dir\" }',\n },\n CI_BUILD_TAG: {\n controlled: \"the release tag used by the publisher\",\n replacement: \"the CI_COMMIT_TAG environment variable (the standard GitLab CI variable)\",\n },\n ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY: {\n controlled: \"bundling electron-builder itself when it was listed under production dependencies\",\n replacement: 'the ignoredProductionDependencies build option — drop \"electron-builder\" from the list to ship it inside your app',\n },\n}\n\n/** Emitted once per process; a build can invoke the packager more than once. */\nlet removedEnvVarsChecked = false\n\n/**\n * Fails the build when a removed environment variable is set, naming the `toolsets` (or other)\n * replacement. Without this the variable is simply ignored and the build silently uses a different\n * toolchain than the one CI asked for.\n *\n * @internal exported for tests\n */\nexport function checkRemovedEnvVars(env: NodeJS.ProcessEnv = process.env): string | null {\n const found = Object.keys(REMOVED_ENV_VARS)\n .filter(name => env[name] != null && env[name] !== \"\")\n .sort()\n if (found.length === 0) {\n return null\n }\n\n const header =\n found.length === 1\n ? `The environment variable ${found[0]} was removed in electron-builder v27 and is now ignored:`\n : `${found.length} environment variables set here were removed in electron-builder v27 and are now ignored:`\n const entries = found.map(name => {\n const { controlled, replacement } = REMOVED_ENV_VARS[name]\n return `• ${name} controlled ${controlled}.\\n Use ${replacement} instead.`\n })\n return [\n header,\n \"\",\n ...entries,\n \"\",\n \"Unset the variable once you have moved the setting into your configuration.\",\n \"https://www.electron.build/docs/migration/v27-breaking-changes#toolset-env-var-overrides-removed\",\n ].join(\"\\n\")\n}\n\n/**\n * Throws when a removed environment variable is set. Called once per process from `Packager.build()`\n * so it runs for every entrypoint (CLI, programmatic `build()`, and a directly constructed Packager).\n */\nexport function assertNoRemovedEnvVars(): void {\n if (removedEnvVarsChecked) {\n return\n }\n removedEnvVarsChecked = true\n const message = checkRemovedEnvVars()\n if (message != null) {\n throw new InvalidConfigurationError(message)\n }\n}\n\n/** @internal exported for tests — lets a test re-arm the once-per-process guard. */\nexport function resetRemovedEnvVarsCheck(): void {\n removedEnvVarsChecked = false\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/util/flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,iFAAiF;AAEjF,MAAM,UAAU,+BAA+B;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,OAAO,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACpD,CAAC;AAED,iFAAiF;AAEjF,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;AAC3E,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AACxD,CAAC;AAED,iFAAiF;AAEjF,MAAM,UAAU,uBAAuB;IACrC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AACxD,CA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AAe,UAAU,YAAY,WAAW,WAAW,CAAA;IAC7E,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,6EAA6E,EAAE,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC5K,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,qBAAqB,EAAE,CAAC;QAC1B,OAAM;IACR,CAAC;IACD,qBAAqB,GAAG,IAAI,CAAA;IAC5B,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,wBAAwB;IACtC,qBAAqB,GAAG,KAAK,CAAA;AAC/B,CAAC","sourcesContent":["import { InvalidConfigurationError, isEnvTrue } from \"builder-util\"\nimport { removedEnvVarDocsUrl } from \"./removedEnvVars.js\"\n\n// ─── Code signing ─────────────────────────────────────────────────────────────\n\nexport function isAutoDiscoveryCodeSignIdentity() {\n return process.env.CSC_IDENTITY_AUTO_DISCOVERY !== \"false\"\n}\n\nexport function isCscForPullRequest() {\n return isEnvTrue(process.env.CSC_FOR_PULL_REQUEST)\n}\n\n// ─── Build behaviour ──────────────────────────────────────────────────────────\n\nexport function isBuildCacheEnabled() {\n return !isEnvTrue(process.env.ELECTRON_BUILDER_DISABLE_BUILD_CACHE)\n}\n\nexport function isRemoveStageDirEvenIfDebug() {\n return isEnvTrue(process.env.ELECTRON_BUILDER_REMOVE_STAGE_EVEN_IF_DEBUG)\n}\n\nexport function isOfflineModeEnabled() {\n return isEnvTrue(process.env.ELECTRON_BUILDER_OFFLINE)\n}\n\n// ─── Publishing ───────────────────────────────────────────────────────────────\n\nexport function isPublishForPullRequest() {\n return isEnvTrue(process.env.PUBLISH_FOR_PULL_REQUEST)\n}\n\n// ─── Package metadata / dependencies ─────────────────────────────────────────\n\nexport function isNpmNoBinLinks() {\n return isEnvTrue(process.env.NPM_NO_BIN_LINKS)\n}\n\n// ─── CI environment detection ─────────────────────────────────────────────────\n\nexport function isTravis() {\n return isEnvTrue(process.env.TRAVIS)\n}\n\n// ─── Platform toolset overrides ───────────────────────────────────────────────\n\nexport function isFpmDebug() {\n return isEnvTrue(process.env.FPM_DEBUG)\n}\n\nexport function isSnapDestructiveMode() {\n return isEnvTrue(process.env.SNAP_DESTRUCTIVE_MODE)\n}\n\n// ─── Removed environment variables (v26 → v27) ───────────────────────────────\n\ninterface RemovedEnvVar {\n /** How to achieve the same thing in v27. */\n readonly replacement: string\n /** What the variable used to control, so the user can tell whether they still need it. */\n readonly controlled: string\n}\n\n/**\n * Environment variables that v26 honored and v27 ignores.\n *\n * These are the most silent of all the v27 breaking changes: unlike a removed config key, nothing\n * validates `process.env`, so a CI image exporting `USE_SYSTEM_WINE` or `ELECTRON_BUILDER_NSIS_DIR`\n * silently switches toolchain with a green build. `CI_BUILD_TAG` is worse still — combined with the\n * removal of implicit publishing, a tagged release simply stops uploading.\n *\n * Toolsets are now configured through the `toolsets` build option, which accepts an `https://` URL\n * (downloaded and cached) or a `file://` path (used as-is).\n */\nconst REMOVED_ENV_VARS: Record<string, RemovedEnvVar> = {\n APPIMAGE_TOOLS_PATH: {\n controlled: \"the AppImage build tools (mksquashfs, runtime)\",\n replacement: 'toolsets.appimage: { url: \"file:///path/to/appimage-tools-dir\" }',\n },\n LINUX_TOOLS_MAC_PATH: {\n controlled: \"the linux-tools-mac bundle (ar, lzip, gtar) used when building Linux targets on macOS\",\n replacement: 'toolsets.linuxToolsMac: { url: \"file:///path/to/linux-tools-mac-dir\" }',\n },\n CUSTOM_FPM_PATH: {\n controlled: \"the FPM executable\",\n replacement: 'toolsets.fpm: { url: \"file:///path/to/fpm-dir\" }',\n },\n USE_SYSTEM_FPM: {\n controlled: \"forcing the host-installed fpm instead of the bundled one\",\n replacement: 'toolsets.fpm: { url: \"file:///path/to/fpm-dir\" }',\n },\n ELECTRON_BUILDER_NSIS_DIR: {\n controlled: \"the NSIS compiler bundle directory\",\n replacement: 'toolsets.nsis: { url: \"file:///path/to/nsis-bundle-dir\" }',\n },\n ELECTRON_BUILDER_NSIS_RESOURCES_DIR: {\n controlled: \"the NSIS resources/plugins directory\",\n replacement: 'toolsets.nsis: { url: \"file:///path/to/nsis-bundle-dir\" } (the v27 nsis bundle carries compiler and resources together)',\n },\n ELECTRON_BUILDER_WINE_TOOLSET_DIR: {\n controlled: \"the Wine bundle directory\",\n replacement: 'toolsets.wine: { url: \"file:///path/to/wine-dir\" }',\n },\n USE_SYSTEM_WINE: {\n controlled: \"forcing the host-installed Wine instead of the downloaded bundle\",\n replacement: 'toolsets.wine: \"system\" (the host `wine` is already the default on macOS and Linux, so you can simply drop this variable)',\n },\n USE_SYSTEM_SIGNCODE: {\n controlled: \"forcing the host signtool/signcode instead of the bundled winCodeSign toolset\",\n replacement: 'win.sign (e.g. { \"win\": { \"sign\": { \"type\": \"signtool\", … } } }) together with toolsets.winCodeSign: { url: \"file:///path/to/bundle-dir\" }',\n },\n USE_SYSTEM_OSSLSIGNCODE: {\n controlled: \"forcing the host osslsigncode instead of the bundled one\",\n replacement: 'win.sign together with toolsets.winCodeSign: { url: \"file:///path/to/bundle-dir\" }',\n },\n SIGNTOOL_PATH: {\n controlled: \"the path to signtool.exe\",\n replacement: 'toolsets.winCodeSign: { url: \"file:///path/to/bundle-dir\" }',\n },\n ELECTRON_BUILDER_7ZIP_PATH: {\n controlled: \"the 7-Zip executable\",\n replacement: 'toolsets.sevenZip: { url: \"file:///path/to/dir\" } (a custom sevenZip bundle must be a .tar.gz, .zip, or bare file:// directory)',\n },\n ELECTRON_BUILDER_ICONS_TOOLSET_DIR: {\n controlled: \"the icons toolset bundle directory\",\n replacement: 'toolsets.icons: { url: \"file:///path/to/icons-bundle-dir\" }',\n },\n CI_BUILD_TAG: {\n controlled: \"the release tag used by the publisher\",\n replacement: \"the CI_COMMIT_TAG environment variable (the standard GitLab CI variable)\",\n },\n ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY: {\n controlled: \"bundling electron-builder itself when it was listed under production dependencies\",\n replacement: 'the ignoredProductionDependencies build option — drop \"electron-builder\" from the list to ship it inside your app',\n },\n}\n\n/** Emitted once per process; a build can invoke the packager more than once. */\nlet removedEnvVarsChecked = false\n\n/**\n * Fails the build when a removed environment variable is set, naming the `toolsets` (or other)\n * replacement. Without this the variable is simply ignored and the build silently uses a different\n * toolchain than the one CI asked for.\n *\n * @internal exported for tests\n */\nexport function checkRemovedEnvVars(env: NodeJS.ProcessEnv = process.env): string | null {\n const found = Object.keys(REMOVED_ENV_VARS)\n .filter(name => env[name] != null && env[name] !== \"\")\n .sort()\n if (found.length === 0) {\n return null\n }\n\n const header =\n found.length === 1\n ? `The environment variable ${found[0]} was removed in electron-builder v27 and is now ignored:`\n : `${found.length} environment variables set here were removed in electron-builder v27 and are now ignored:`\n const entries = found.map(name => {\n const { controlled, replacement } = REMOVED_ENV_VARS[name]\n return `• ${name} controlled ${controlled}.\\n Use ${replacement} instead.`\n })\n return [header, \"\", ...entries, \"\", \"Unset the variable once you have moved the setting into your configuration.\", ...new Set(found.map(removedEnvVarDocsUrl))].join(\"\\n\")\n}\n\n/**\n * Throws when a removed environment variable is set. Called once per process from `Packager.build()`\n * so it runs for every entrypoint (CLI, programmatic `build()`, and a directly constructed Packager).\n */\nexport function assertNoRemovedEnvVars(): void {\n if (removedEnvVarsChecked) {\n return\n }\n removedEnvVarsChecked = true\n const message = checkRemovedEnvVars()\n if (message != null) {\n throw new InvalidConfigurationError(message)\n }\n}\n\n/** @internal exported for tests — lets a test re-arm the once-per-process guard. */\nexport function resetRemovedEnvVarsCheck(): void {\n removedEnvVarsChecked = false\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macosIconComposer.d.ts","sourceRoot":"","sources":["../../../src/util/mac/macosIconComposer.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"macosIconComposer.d.ts","sourceRoot":"","sources":["../../../src/util/mac/macosIconComposer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,MAAM,EAAE,MAAM,cAAc,CAAA;AAMzD,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAoCD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgDhH"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// Adapted from https://github.com/electron/packager/pull/1806
|
|
2
|
-
import { spawn } from "builder-util";
|
|
2
|
+
import { Executables, spawn } from "builder-util";
|
|
3
3
|
import * as fs from "fs/promises";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import plist from "plist";
|
|
6
6
|
import * as semver from "semver";
|
|
7
7
|
const INVALID_ACTOOL_VERSION_ERROR = new Error("Failed to check actool version. Is Xcode 26 or higher installed? See output of the `actool --version` CLI command for more details.");
|
|
8
|
-
async function checkActoolVersion(tmpDir) {
|
|
8
|
+
async function checkActoolVersion(actool, tmpDir) {
|
|
9
9
|
const acToolOutputFileName = path.resolve(tmpDir, "actool.log");
|
|
10
10
|
let versionInfo = undefined;
|
|
11
11
|
let acToolOutputFile = null;
|
|
12
12
|
let errorQueued = null;
|
|
13
13
|
try {
|
|
14
14
|
acToolOutputFile = await fs.open(acToolOutputFileName, "w");
|
|
15
|
-
await spawn(
|
|
15
|
+
await spawn(actool, ["--version"], { stdio: ["ignore", acToolOutputFile.fd, acToolOutputFile.fd] });
|
|
16
16
|
const acToolVersionOutput = await fs.readFile(acToolOutputFileName, "utf8");
|
|
17
17
|
versionInfo = plist.parse(acToolVersionOutput);
|
|
18
18
|
}
|
|
@@ -38,8 +38,9 @@ async function checkActoolVersion(tmpDir) {
|
|
|
38
38
|
* @returns The asset catalog and extra assets
|
|
39
39
|
*/
|
|
40
40
|
export async function generateAssetCatalogForIcon(tmpDir, inputPath) {
|
|
41
|
+
const actool = Executables.resolve("actool");
|
|
41
42
|
const tmpDirPath = await tmpDir.createTempDir({ prefix: "macos-icon-composer" });
|
|
42
|
-
await checkActoolVersion(tmpDirPath);
|
|
43
|
+
await checkActoolVersion(actool, tmpDirPath);
|
|
43
44
|
const iconPath = path.resolve(tmpDirPath, "Icon.icon");
|
|
44
45
|
const outputPath = path.resolve(tmpDirPath, "out");
|
|
45
46
|
await fs.cp(inputPath, iconPath, {
|
|
@@ -48,7 +49,7 @@ export async function generateAssetCatalogForIcon(tmpDir, inputPath) {
|
|
|
48
49
|
await fs.mkdir(outputPath, {
|
|
49
50
|
recursive: true,
|
|
50
51
|
});
|
|
51
|
-
await spawn(
|
|
52
|
+
await spawn(actool, [
|
|
52
53
|
iconPath,
|
|
53
54
|
"--compile",
|
|
54
55
|
outputPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macosIconComposer.js","sourceRoot":"","sources":["../../../src/util/mac/macosIconComposer.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,KAAK,EAAU,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"macosIconComposer.js","sourceRoot":"","sources":["../../../src/util/mac/macosIconComposer.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,WAAW,EAAE,KAAK,EAAU,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAOhC,MAAM,4B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AAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAA;IAC9E,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAA;IAEzE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA;AACnC,CAAC","sourcesContent":["// Adapted from https://github.com/electron/packager/pull/1806\n\nimport { Executables, spawn, TmpDir } from \"builder-util\"\nimport * as fs from \"fs/promises\"\nimport * as path from \"node:path\"\nimport plist from \"plist\"\nimport * as semver from \"semver\"\n\nexport interface AssetCatalogResult {\n assetCatalog: Buffer\n icnsFile: Buffer\n}\n\nconst INVALID_ACTOOL_VERSION_ERROR = new Error(\n \"Failed to check actool version. Is Xcode 26 or higher installed? See output of the `actool --version` CLI command for more details.\"\n)\n\nasync function checkActoolVersion(actool: string, tmpDir: string) {\n const acToolOutputFileName = path.resolve(tmpDir, \"actool.log\")\n\n let versionInfo: Record<string, Record<string, string>> | undefined = undefined\n\n let acToolOutputFile: fs.FileHandle | null = null\n let errorQueued: Error | null = null\n try {\n acToolOutputFile = await fs.open(acToolOutputFileName, \"w\")\n await spawn(actool, [\"--version\"], { stdio: [\"ignore\", acToolOutputFile.fd, acToolOutputFile.fd] })\n const acToolVersionOutput = await fs.readFile(acToolOutputFileName, \"utf8\")\n versionInfo = plist.parse(acToolVersionOutput) as Record<string, Record<string, string>>\n } catch (e: any) {\n errorQueued = e\n } finally {\n if (acToolOutputFile) {\n await acToolOutputFile.close()\n }\n }\n\n if (errorQueued || !versionInfo || !versionInfo[\"com.apple.actool.version\"] || !versionInfo[\"com.apple.actool.version\"][\"short-bundle-version\"]) {\n throw INVALID_ACTOOL_VERSION_ERROR\n }\n\n const acToolVersion = versionInfo[\"com.apple.actool.version\"][\"short-bundle-version\"]\n if (!semver.gte(semver.coerce(acToolVersion)!, \"26.0.0\")) {\n throw new Error(`Unsupported actool version. Must be on actool 26.0.0 or higher but found ${acToolVersion}. Install Xcode 26 or higher to get a supported version of actool.`)\n }\n}\n\n/**\n * Generates an asset catalog and extra assets that are useful for packaging the app.\n * @param inputPath The path to the `.icon` file\n * @returns The asset catalog and extra assets\n */\nexport async function generateAssetCatalogForIcon(tmpDir: TmpDir, inputPath: string): Promise<AssetCatalogResult> {\n const actool = Executables.resolve(\"actool\")\n const tmpDirPath = await tmpDir.createTempDir({ prefix: \"macos-icon-composer\" })\n\n await checkActoolVersion(actool, tmpDirPath)\n\n const iconPath = path.resolve(tmpDirPath, \"Icon.icon\")\n const outputPath = path.resolve(tmpDirPath, \"out\")\n\n await fs.cp(inputPath, iconPath, {\n recursive: true,\n })\n\n await fs.mkdir(outputPath, {\n recursive: true,\n })\n\n await spawn(actool, [\n iconPath,\n \"--compile\",\n outputPath,\n \"--output-format\",\n \"human-readable-text\",\n \"--notices\",\n \"--warnings\",\n \"--output-partial-info-plist\",\n path.resolve(outputPath, \"assetcatalog_generated_info.plist\"),\n \"--app-icon\",\n \"Icon\",\n \"--include-all-app-icons\",\n \"--accent-color\",\n \"AccentColor\",\n \"--enable-on-demand-resources\",\n \"NO\",\n \"--development-region\",\n \"en\",\n \"--target-device\",\n \"mac\",\n \"--minimum-deployment-target\",\n \"26.0\",\n \"--platform\",\n \"macosx\",\n ])\n\n const assetCatalog = await fs.readFile(path.resolve(outputPath, \"Assets.car\"))\n const icnsFile = await fs.readFile(path.resolve(outputPath, \"Icon.icns\"))\n\n return { assetCatalog, icnsFile }\n}\n"]}
|
|
@@ -11,7 +11,7 @@ export function expandMacro(pattern, arch, appInfo, extra = {}, isProductNameSan
|
|
|
11
11
|
// tslint:disable-next-line:no-invalid-template-strings
|
|
12
12
|
.replace("/${arch}", "");
|
|
13
13
|
}
|
|
14
|
-
return pattern.replace(/\${([_a-zA-
|
|
14
|
+
return pattern.replace(/\${([_a-zA-Z0-9./*+]+)}/g, (match, p1) => {
|
|
15
15
|
switch (p1) {
|
|
16
16
|
case "productName":
|
|
17
17
|
return isProductNameSanitized ? appInfo.sanitizedProductName : appInfo.productName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macroExpander.js","sourceRoot":"","sources":["../../src/util/macroExpander.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAI7D,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,IAAsB,EAAE,OAAgB,EAAE,QAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI;IACnI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO;YACf,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"macroExpander.js","sourceRoot":"","sources":["../../src/util/macroExpander.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAI7D,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,IAAsB,EAAE,OAAgB,EAAE,QAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI;IACnI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO;YACf,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uDAAuD;aACtD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uDAAuD;aACtD,OAAO,CAAC,UAA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AO,UAAU,OAAO,iBAAiB,EAAE,sCAAsC,CAAC,CAAA;oBAClJ,CAAC;oBACD,IAAI,uCAAuC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC1D,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,4FAA4F,CAAC,CAAA;oBAC9H,CAAC;oBACD,OAAO,QAAQ,CAAA;gBACjB,CAAC;gBAED,MAAM,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,CAAA;gBACvB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;oBAClB,MAAM,IAAI,yBAAyB,CAAC,0BAA0B,OAAO,YAAY,EAAE,iBAAiB,EAAE,wCAAwC,CAAC,CAAA;gBACjJ,CAAC;qBAAM,CAAC;oBACN,OAAO,KAAK,CAAA;gBACd,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { InvalidConfigurationError, log } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { AppInfo } from \"../appInfo.js\"\n\nexport function expandMacro(pattern: string, arch: string | Nullish, appInfo: AppInfo, extra: any = {}, isProductNameSanitized = true): string {\n if (arch == null) {\n pattern = pattern\n // tslint:disable-next-line:no-invalid-template-strings\n .replace(\"-${arch}\", \"\")\n // tslint:disable-next-line:no-invalid-template-strings\n .replace(\" ${arch}\", \"\")\n // tslint:disable-next-line:no-invalid-template-strings\n .replace(\"_${arch}\", \"\")\n // tslint:disable-next-line:no-invalid-template-strings\n .replace(\"/${arch}\", \"\")\n }\n\n return pattern.replace(/\\${([_a-zA-Z0-9./*+]+)}/g, (match, p1): string => {\n switch (p1) {\n case \"productName\":\n return isProductNameSanitized ? appInfo.sanitizedProductName : appInfo.productName\n\n case \"arch\":\n if (arch == null) {\n // see above, we remove macro if no arch\n return \"\"\n }\n return arch\n\n case \"author\": {\n const companyName = appInfo.companyName\n if (companyName == null) {\n throw new InvalidConfigurationError(`cannot expand pattern \"${pattern}\": author is not specified`, \"ERR_ELECTRON_BUILDER_AUTHOR_UNSPECIFIED\")\n }\n return companyName\n }\n\n case \"platform\":\n return process.platform\n\n case \"channel\":\n return appInfo.channel || \"latest\"\n\n default: {\n if (p1 in appInfo) {\n return (appInfo as any)[p1]\n }\n\n if (p1.startsWith(\"env.\")) {\n const envName = p1.substring(\"env.\".length)\n const envValue = process.env[envName]\n if (envValue == null) {\n throw new InvalidConfigurationError(`cannot expand pattern \"${pattern}\": env ${envName} is not defined`, \"ERR_ELECTRON_BUILDER_ENV_NOT_DEFINED\")\n }\n if (/TOKEN|SECRET|KEY|PASSWORD|CREDENTIAL/i.test(envName)) {\n log.warn({ envName, pattern }, \"macro expansion includes an env var that may contain a secret — verify this is intentional\")\n }\n return envValue\n }\n\n const value = extra[p1]\n if (value == null) {\n throw new InvalidConfigurationError(`cannot expand pattern \"${pattern}\": macro ${p1} is not defined`, \"ERR_ELECTRON_BUILDER_MACRO_NOT_DEFINED\")\n } else {\n return value\n }\n }\n }\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeBinaryVerifier.d.ts","sourceRoot":"","sources":["../../src/util/nativeBinaryVerifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAO,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"nativeBinaryVerifier.d.ts","sourceRoot":"","sources":["../../src/util/nativeBinaryVerifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAO,MAAM,cAAc,CAAA;AAOxC,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,CAAA;AAEvD,0JAA0J;AAC1J,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,mGAAmG;IACnG,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACvC;AA4BD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAkD7E;AAKD,uHAAuH;AACvH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhH;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAEnE;AAyFD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAA;AAElD,MAAM,WAAW,oBAAoB;IACnC,sGAAsG;IACtG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAA;CACpC;AA4LD,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CACnD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C7H"}
|
|
@@ -3,6 +3,7 @@ import { open, readdir, readFile } from "fs/promises";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { readAsar } from "../asar/asar.js";
|
|
5
5
|
import { archToNodeCpu, isPackageCompatible } from "./archCompatibility.js";
|
|
6
|
+
import { BUILD_CHANGES_URL } from "./config/legacyOptions.js";
|
|
6
7
|
/** Enough to cover the ELF/Mach-O headers, every `fat_arch` entry and the PE header of any real-world binary. */
|
|
7
8
|
const HEAD_READ_LENGTH = 4096;
|
|
8
9
|
// ELF: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
|
|
@@ -375,7 +376,8 @@ export async function verifyNativeBinaries({ resourcesDir, platform, arch, mode
|
|
|
375
376
|
fatal.map(it => ` ${formatMismatch(it, platform, cpu)}`).join("\n") +
|
|
376
377
|
"\nThe app would fail to load them at runtime. This usually means a binary built for another target (often the build host) was left in node_modules " +
|
|
377
378
|
"because the native rebuild was skipped or reused a cached result. Rebuild native dependencies for the target, " +
|
|
378
|
-
'or set `nativeModules.verifyNativeBinaries` to "warn" (or false) to package anyway.'
|
|
379
|
+
'or set `nativeModules.verifyNativeBinaries` to "warn" (or false) to package anyway. ' +
|
|
380
|
+
`See ${BUILD_CHANGES_URL}#native-binaries-are-verified-against-the-target`);
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
//# sourceMappingURL=nativeBinaryVerifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeBinaryVerifier.js","sourceRoot":"","sources":["../../src/util/nativeBinaryVerifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,GAAG,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAwB,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAyB,MAAM,wBAAwB,CAAA;AAYlG,iHAAiH;AACjH,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAE7B,wEAAwE;AACxE,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,MAAM,YAAY,GAA2B,EAAE,CAAC,EAAE,MAAM,EAAE,EA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\nimport * as path from \"path\"\nimport { AsarFilesystem, Node, readAsar } from \"../asar/asar.js\"\nimport { archToNodeCpu, isPackageCompatible, PackagePlatformFields } from \"./archCompatibility.js\"\n\n/** Container format of a native binary, as identified by its magic bytes. */\nexport type NativeBinaryFormat = \"elf\" | \"macho\" | \"pe\"\n\n/** What a native binary's header says it was built for. `arches` holds Node.js `process.arch` names (`x64`, `arm64`, `ia32`, `arm`) or `unknown(0x…)`. */\nexport interface NativeBinaryInfo {\n readonly format: NativeBinaryFormat\n /** Every architecture the file contains — more than one only for a Mach-O fat/universal binary. */\n readonly arches: ReadonlyArray<string>\n}\n\n/** Enough to cover the ELF/Mach-O headers, every `fat_arch` entry and the PE header of any real-world binary. */\nconst HEAD_READ_LENGTH = 4096\n\n// ELF: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html\nconst ELF_EI_DATA = 5\nconst ELF_E_MACHINE = 18\nconst ELF_MACHINES: Record<number, string> = { 3: \"ia32\", 40: \"arm\", 62: \"x64\", 183: \"arm64\" }\n\n// Mach-O: <mach-o/loader.h>, <mach-o/fat.h>, <mach/machine.h>\nconst MACHO_THIN_MAGIC_BE = new Set([0xfeedface, 0xfeedfacf])\nconst MACHO_THIN_MAGIC_LE = new Set([0xcefaedfe, 0xcffaedfe])\nconst MACHO_FAT_MAGIC = 0xcafebabe\nconst MACHO_FAT_MAGIC_64 = 0xcafebabf\n/** A fat header has fewer than 30 slices, whereas a Java class file (same `0xcafebabe` magic) has a `major_version` of at least 45 there. */\nconst MACHO_FAT_MAX_ARCH_COUNT = 30\nconst MACHO_CPU_TYPES: Record<number, string> = { 7: \"ia32\", 0x01000007: \"x64\", 12: \"arm\", 0x0100000c: \"arm64\" }\n\n// PE: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format\nconst PE_E_LFANEW = 0x3c\nconst PE_SIGNATURE = 0x00004550 // \"PE\\0\\0\" read little-endian\nconst PE_MACHINES: Record<number, string> = { 0x14c: \"ia32\", 0x8664: \"x64\", 0x1c4: \"arm\", 0xaa64: \"arm64\" }\n\nfunction machineName(table: Record<number, string>, value: number): string {\n return table[value] ?? `unknown(0x${value.toString(16)})`\n}\n\n/**\n * Identifies an ELF, Mach-O (thin or fat) or PE binary from the first bytes of a file and reports the\n * architecture(s) it was built for. Returns `null` for anything else — including a truncated header — so\n * callers treat unrecognized files as \"not a native binary\".\n */\nexport function parseNativeBinaryHeader(head: Buffer): NativeBinaryInfo | null {\n if (head.length < 4) {\n return null\n }\n\n if (head[0] === 0x7f && head[1] === 0x45 && head[2] === 0x4c && head[3] === 0x46) {\n if (head.length < ELF_E_MACHINE + 2) {\n return null\n }\n const littleEndian = head[ELF_EI_DATA] !== 2\n const machine = littleEndian ? head.readUInt16LE(ELF_E_MACHINE) : head.readUInt16BE(ELF_E_MACHINE)\n return { format: \"elf\", arches: [machineName(ELF_MACHINES, machine)] }\n }\n\n const magic = head.readUInt32BE(0)\n if (MACHO_THIN_MAGIC_BE.has(magic) || MACHO_THIN_MAGIC_LE.has(magic)) {\n if (head.length < 8) {\n return null\n }\n const cpuType = MACHO_THIN_MAGIC_BE.has(magic) ? head.readUInt32BE(4) : head.readUInt32LE(4)\n return { format: \"macho\", arches: [machineName(MACHO_CPU_TYPES, cpuType)] }\n }\n if (magic === MACHO_FAT_MAGIC || magic === MACHO_FAT_MAGIC_64) {\n if (head.length < 8) {\n return null\n }\n const count = head.readUInt32BE(4)\n const entrySize = magic === MACHO_FAT_MAGIC_64 ? 32 : 20\n if (count === 0 || count >= MACHO_FAT_MAX_ARCH_COUNT || head.length < 8 + count * entrySize) {\n return null\n }\n const arches: string[] = []\n for (let i = 0; i < count; i++) {\n arches.push(machineName(MACHO_CPU_TYPES, head.readUInt32BE(8 + i * entrySize)))\n }\n return { format: \"macho\", arches }\n }\n\n if (head[0] === 0x4d && head[1] === 0x5a) {\n if (head.length < PE_E_LFANEW + 4) {\n return null\n }\n const peOffset = head.readUInt32LE(PE_E_LFANEW)\n if (peOffset + 6 > head.length || head.readUInt32LE(peOffset) !== PE_SIGNATURE) {\n return null\n }\n return { format: \"pe\", arches: [machineName(PE_MACHINES, head.readUInt16LE(peOffset + 4))] }\n }\n\n return null\n}\n\nconst PLATFORM_FORMAT: Partial<Record<NodeJS.Platform, NativeBinaryFormat>> = { darwin: \"macho\", linux: \"elf\", win32: \"pe\" }\nconst FORMAT_LABEL: Record<NativeBinaryFormat, string> = { elf: \"ELF\", macho: \"Mach-O\", pe: \"PE\" }\n\n/** Whether the binary can be loaded by an app for the given platform (`process.platform`) and cpu (`process.arch`). */\nexport function isNativeBinaryCompatible(info: NativeBinaryInfo, platform: NodeJS.Platform, cpu: string): boolean {\n return PLATFORM_FORMAT[platform] === info.format && info.arches.includes(cpu)\n}\n\nexport function describeNativeBinary(info: NativeBinaryInfo): string {\n return `${FORMAT_LABEL[info.format]} ${info.arches.join(\"+\")}`\n}\n\n// Path segments that say which platform/arch a file is for: prebuildify `prebuilds/linux-arm64/`, node-pre-gyp\n// `napi-v6-linux-glibc-x64/`, platform packages such as `@img/sharp-darwin-arm64`, or `win/x64/` tool layouts.\nconst PLATFORM_TOKENS: Record<string, string> = {\n darwin: \"darwin\",\n mac: \"darwin\",\n macos: \"darwin\",\n osx: \"darwin\",\n linux: \"linux\",\n win32: \"win32\",\n win: \"win32\",\n windows: \"win32\",\n freebsd: \"freebsd\",\n openbsd: \"openbsd\",\n android: \"android\",\n sunos: \"sunos\",\n aix: \"aix\",\n}\nconst ARCH_TOKENS: Record<string, string> = {\n x64: \"x64\",\n amd64: \"x64\",\n arm64: \"arm64\",\n aarch64: \"arm64\",\n ia32: \"ia32\",\n x86: \"ia32\",\n i386: \"ia32\",\n i686: \"ia32\",\n arm: \"arm\",\n armv6: \"arm\",\n armv6l: \"arm\",\n armv7: \"arm\",\n armv7l: \"arm\",\n armhf: \"arm\",\n universal: \"universal\",\n}\n\n/**\n * The platform/arch a relative path declares through its directory or package names, if any. A segment only\n * counts when it pairs a platform with an arch (`linux-x64`, `sharp-darwin-arm64`) or is exactly one token\n * (`win`, `x64`), so package names such as `node-mac-permissions` are not mistaken for a platform variant.\n *\n * @internal Exported for tests only.\n */\nexport function platformDeclaredByPath(relativePath: string): { platform?: string; cpu?: string } {\n const result: { platform?: string; cpu?: string } = {}\n const segments = relativePath.split(/[\\\\/]/)\n segments.pop() // the file name itself (e.g. `node.napi.armv7.node`) is not a directory layout\n for (const segment of segments) {\n const tokens = segment\n .toLowerCase()\n .replace(/x86[-_]64/g, \"x64\")\n .replace(/x64\\+arm64|arm64\\+x64/g, \"universal\") // prebuildify's name for a fat macOS prebuild\n .split(/[-_.]/)\n const platform = tokens.map(t => PLATFORM_TOKENS[t]).find(it => it != null)\n const cpu = tokens.map(t => ARCH_TOKENS[t]).find(it => it != null)\n if (tokens.length === 1 || (platform != null && cpu != null)) {\n result.platform = platform ?? result.platform\n result.cpu = cpu ?? result.cpu\n }\n }\n return result\n}\n\n/**\n * The package directory (relative, `node_modules/<name>` or `node_modules/@scope/<name>`) owning a file, or `null`\n * when the file is not inside `node_modules`.\n */\nfunction packageRootOf(relativePath: string): string | null {\n const segments = relativePath.split(/[\\\\/]/)\n const index = segments.lastIndexOf(\"node_modules\")\n if (index < 0 || index + 2 >= segments.length) {\n return null\n }\n const nameLength = segments[index + 1].startsWith(\"@\") ? 2 : 1\n if (index + 1 + nameLength >= segments.length) {\n return null\n }\n return segments.slice(0, index + 1 + nameLength).join(\"/\")\n}\n\n/** Where a candidate file lives, and how to read its header and its package's `package.json`. */\ninterface NativeBinarySource {\n readonly label: string\n list(): Promise<Array<string>>\n readHead(relativePath: string): Promise<Buffer | null>\n readPackageJson(packageRoot: string): Promise<PackagePlatformFields | null>\n}\n\nexport type NativeBinaryKind = \"addon\" | \"library\"\n\nexport interface NativeBinaryMismatch {\n /** Path inside the packaged app, e.g. `app.asar.unpacked/node_modules/foo/build/Release/foo.node`. */\n readonly file: string\n readonly kind: NativeBinaryKind\n readonly detected: NativeBinaryInfo\n}\n\nconst LIBRARY_EXTENSIONS = new Set([\".dll\", \".exe\", \".dylib\", \".so\"])\n\n/** `.node` addons are what `require()` loads; other native files are classified as libraries/executables, or skipped. */\nfunction classify(file: string, allowExtensionless: boolean): NativeBinaryKind | null {\n const base = path.basename(file)\n const ext = path.extname(base).toLowerCase()\n if (ext === \".node\") {\n return \"addon\"\n }\n if (LIBRARY_EXTENSIONS.has(ext) || /\\.so(\\.\\d+)+$/.test(base)) {\n return \"library\"\n }\n // extensionless files are checked by magic bytes (bundled CLI tools such as esbuild's binary); only on disk,\n // where reading the head of a file is cheap — smart unpack moves such executables out of the asar anyway\n return allowExtensionless && ext === \"\" && !base.startsWith(\".\") ? \"library\" : null\n}\n\nasync function readFileHead(file: string): Promise<Buffer | null> {\n let handle\n try {\n handle = await open(file, \"r\")\n const head = Buffer.alloc(HEAD_READ_LENGTH)\n const { bytesRead } = await handle.read(head, 0, HEAD_READ_LENGTH, 0)\n return head.subarray(0, bytesRead)\n } catch {\n return null\n } finally {\n await handle?.close()\n }\n}\n\nasync function readJsonOrNull(file: string): Promise<any> {\n try {\n return JSON.parse(await readFile(file, \"utf8\"))\n } catch {\n return null\n }\n}\n\nasync function listFiles(dir: string, prefix = \"\"): Promise<Array<string>> {\n let entries\n try {\n entries = await readdir(path.join(dir, prefix), { withFileTypes: true })\n } catch {\n return []\n }\n const result: string[] = []\n for (const entry of entries) {\n const rel = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`\n if (entry.isDirectory()) {\n result.push(...(await listFiles(dir, rel)))\n } else if (entry.isFile()) {\n result.push(rel)\n }\n }\n return result\n}\n\n/** @internal Exported for tests only. */\nexport function directorySource(dir: string, label: string): NativeBinarySource {\n return {\n label,\n list: () => listFiles(dir),\n readHead: rel => readFileHead(path.join(dir, rel)),\n readPackageJson: root => readJsonOrNull(path.join(dir, root, \"package.json\")),\n }\n}\n\nfunction collectAsarFiles(node: Node, prefix: string, out: Array<string>) {\n for (const [name, child] of Object.entries(node.files ?? {})) {\n const rel = prefix === \"\" ? name : `${prefix}/${name}`\n if (child.files != null) {\n collectAsarFiles(child, rel, out)\n } else if (child.link == null && !child.unpacked) {\n out.push(rel) // unpacked files are covered by the `app.asar.unpacked` directory source\n }\n }\n}\n\nasync function readAsarFileHead(archive: AsarFilesystem, rel: string): Promise<Buffer | null> {\n const node = archive.getNode(rel.split(\"/\").join(path.sep))\n if (node == null || node.offset == null || !node.size) {\n return null\n }\n let handle\n try {\n handle = await open(archive.src, \"r\")\n const head = Buffer.alloc(Math.min(HEAD_READ_LENGTH, node.size))\n const { bytesRead } = await handle.read(head, 0, head.length, 8 + archive.headerSize + parseInt(node.offset, 10))\n return head.subarray(0, bytesRead)\n } catch {\n return null\n } finally {\n await handle?.close()\n }\n}\n\nasync function asarSource(archivePath: string, label: string): Promise<NativeBinarySource | null> {\n let archive: AsarFilesystem\n try {\n archive = await readAsar(archivePath)\n } catch {\n return null\n }\n return {\n label,\n list: () => {\n const files: string[] = []\n collectAsarFiles(archive.header, \"\", files)\n return Promise.resolve(files)\n },\n readHead: rel => readAsarFileHead(archive, rel),\n readPackageJson: async root => {\n const onDisk = await readJsonOrNull(path.join(`${archivePath}.unpacked`, root, \"package.json\"))\n if (onDisk != null) {\n return onDisk\n }\n try {\n return await archive.readJson(path.join(...root.split(\"/\"), \"package.json\"))\n } catch {\n return null\n }\n },\n }\n}\n\n/**\n * Scans the given sources for native binaries that were not built for `platform`/`cpu`. Files whose package declares\n * another platform (`package.json` `os`/`cpu`) or whose path names another platform/arch are skipped: they are\n * shipped on purpose (multi-platform prebuilds, a universal build's single-arch packages) and never loaded here.\n *\n * @internal Exported for tests only.\n */\nexport async function findNativeBinaryMismatches(\n sources: ReadonlyArray<NativeBinarySource>,\n platform: NodeJS.Platform,\n cpu: string,\n options: { extensionless: boolean[] } = { extensionless: sources.map(() => true) }\n): Promise<Array<NativeBinaryMismatch>> {\n const mismatches: NativeBinaryMismatch[] = []\n for (let i = 0; i < sources.length; i++) {\n const source = sources[i]\n const packageCompatibility = new Map<string, Promise<boolean>>()\n for (const rel of await source.list()) {\n const kind = classify(rel, options.extensionless[i] ?? true)\n if (kind == null) {\n continue\n }\n const head = await source.readHead(rel)\n const info = head == null ? null : parseNativeBinaryHeader(head)\n if (info == null || isNativeBinaryCompatible(info, platform, cpu)) {\n continue\n }\n\n const declared = platformDeclaredByPath(rel)\n if ((declared.platform != null && declared.platform !== platform) || (declared.cpu != null && declared.cpu !== cpu && declared.cpu !== \"universal\")) {\n log.debug({ file: rel, detected: describeNativeBinary(info), reason: \"path names another platform/arch\" }, \"skipped native binary check\")\n continue\n }\n const root = packageRootOf(rel)\n if (root != null) {\n if (!packageCompatibility.has(root)) {\n packageCompatibility.set(\n root,\n source.readPackageJson(root).then(pkg => pkg == null || isPackageCompatible(pkg, cpu, platform))\n )\n }\n if (!(await packageCompatibility.get(root))) {\n log.debug({ file: rel, detected: describeNativeBinary(info), reason: \"package.json os/cpu names another platform/arch\" }, \"skipped native binary check\")\n continue\n }\n }\n\n mismatches.push({ file: `${source.label}/${rel}`, kind, detected: info })\n }\n }\n return mismatches\n}\n\n/** @internal Exported for tests only. */\nexport function formatMismatch(mismatch: NativeBinaryMismatch, platform: NodeJS.Platform, cpu: string): string {\n const expectedFormat = PLATFORM_FORMAT[platform]\n const expected = expectedFormat == null ? `${platform} ${cpu}` : `${FORMAT_LABEL[expectedFormat]} ${cpu}`\n return `${mismatch.file}: ${describeNativeBinary(mismatch.detected)}, expected ${expected}`\n}\n\nexport interface VerifyNativeBinariesOptions {\n /** `Contents/Resources` (macOS) or `resources` directory of the packed app. */\n readonly resourcesDir: string\n readonly platform: NodeJS.Platform\n readonly arch: Arch\n /** `nativeModules.verifyNativeBinaries` */\n readonly mode: boolean | \"warn\" | null | undefined\n}\n\n/**\n * Checks that the native binaries shipped in the packed app (`app.asar`, `app.asar.unpacked`, or the `app` directory)\n * match the target platform and arch. A mismatched `.node` addon fails the build (unless `mode` is `\"warn\"`); any other\n * mismatched native file is a warning, since packages legitimately bundle helper binaries for several platforms.\n */\nexport async function verifyNativeBinaries({ resourcesDir, platform, arch, mode }: VerifyNativeBinariesOptions): Promise<void> {\n if (mode === false) {\n log.debug({ reason: \"nativeModules.verifyNativeBinaries is set to false\" }, \"skipped native binary check\")\n return\n }\n const cpu = archToNodeCpu(arch)\n if (cpu == null || PLATFORM_FORMAT[platform] == null) {\n return // e.g. `universal`: each slice is checked before the merge\n }\n\n const sources: NativeBinarySource[] = []\n const extensionless: boolean[] = []\n const archive = await asarSource(path.join(resourcesDir, \"app.asar\"), \"app.asar\")\n if (archive != null) {\n sources.push(archive)\n extensionless.push(false)\n }\n sources.push(directorySource(path.join(resourcesDir, \"app.asar.unpacked\"), \"app.asar.unpacked\"), directorySource(path.join(resourcesDir, \"app\"), \"app\"))\n extensionless.push(true, true)\n\n const mismatches = await findNativeBinaryMismatches(sources, platform, cpu, { extensionless })\n if (mismatches.length === 0) {\n return\n }\n\n const target = `${platform} ${cpu}`\n const fatal = mode === \"warn\" ? [] : mismatches.filter(it => it.kind === \"addon\")\n for (const mismatch of mismatches) {\n if (!fatal.includes(mismatch)) {\n log.warn({ file: mismatch.file, detected: describeNativeBinary(mismatch.detected), target }, \"native binary does not match the target platform/arch\")\n }\n }\n if (fatal.length > 0) {\n throw new Error(\n `Native module(s) built for the wrong platform/architecture were found in the packaged app (target: ${target}):\\n` +\n fatal.map(it => ` ${formatMismatch(it, platform, cpu)}`).join(\"\\n\") +\n \"\\nThe app would fail to load them at runtime. This usually means a binary built for another target (often the build host) was left in node_modules \" +\n \"because the native rebuild was skipped or reused a cached result. Rebuild native dependencies for the target, \" +\n 'or set `nativeModules.verifyNativeBinaries` to \"warn\" (or false) to package anyway.'\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nativeBinaryVerifier.js","sourceRoot":"","sources":["../../src/util/nativeBinaryVerifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,GAAG,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,OAAO,E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,EAAE,EAAE,uDAAuD,CAAC,CAAA;QACvJ,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,sGAAsG,MAAM,MAAM;YAChH,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,qJAAqJ;YACrJ,gHAAgH;YAChH,sFAAsF;YACtF,OAAO,iBAAiB,kDAAkD,CAC7E,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import { Arch, log } from \"builder-util\"\nimport { open, readdir, readFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport { AsarFilesystem, Node, readAsar } from \"../asar/asar.js\"\nimport { archToNodeCpu, isPackageCompatible, PackagePlatformFields } from \"./archCompatibility.js\"\nimport { BUILD_CHANGES_URL } from \"./config/legacyOptions.js\"\n\n/** Container format of a native binary, as identified by its magic bytes. */\nexport type NativeBinaryFormat = \"elf\" | \"macho\" | \"pe\"\n\n/** What a native binary's header says it was built for. `arches` holds Node.js `process.arch` names (`x64`, `arm64`, `ia32`, `arm`) or `unknown(0x…)`. */\nexport interface NativeBinaryInfo {\n readonly format: NativeBinaryFormat\n /** Every architecture the file contains — more than one only for a Mach-O fat/universal binary. */\n readonly arches: ReadonlyArray<string>\n}\n\n/** Enough to cover the ELF/Mach-O headers, every `fat_arch` entry and the PE header of any real-world binary. */\nconst HEAD_READ_LENGTH = 4096\n\n// ELF: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html\nconst ELF_EI_DATA = 5\nconst ELF_E_MACHINE = 18\nconst ELF_MACHINES: Record<number, string> = { 3: \"ia32\", 40: \"arm\", 62: \"x64\", 183: \"arm64\" }\n\n// Mach-O: <mach-o/loader.h>, <mach-o/fat.h>, <mach/machine.h>\nconst MACHO_THIN_MAGIC_BE = new Set([0xfeedface, 0xfeedfacf])\nconst MACHO_THIN_MAGIC_LE = new Set([0xcefaedfe, 0xcffaedfe])\nconst MACHO_FAT_MAGIC = 0xcafebabe\nconst MACHO_FAT_MAGIC_64 = 0xcafebabf\n/** A fat header has fewer than 30 slices, whereas a Java class file (same `0xcafebabe` magic) has a `major_version` of at least 45 there. */\nconst MACHO_FAT_MAX_ARCH_COUNT = 30\nconst MACHO_CPU_TYPES: Record<number, string> = { 7: \"ia32\", 0x01000007: \"x64\", 12: \"arm\", 0x0100000c: \"arm64\" }\n\n// PE: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format\nconst PE_E_LFANEW = 0x3c\nconst PE_SIGNATURE = 0x00004550 // \"PE\\0\\0\" read little-endian\nconst PE_MACHINES: Record<number, string> = { 0x14c: \"ia32\", 0x8664: \"x64\", 0x1c4: \"arm\", 0xaa64: \"arm64\" }\n\nfunction machineName(table: Record<number, string>, value: number): string {\n return table[value] ?? `unknown(0x${value.toString(16)})`\n}\n\n/**\n * Identifies an ELF, Mach-O (thin or fat) or PE binary from the first bytes of a file and reports the\n * architecture(s) it was built for. Returns `null` for anything else — including a truncated header — so\n * callers treat unrecognized files as \"not a native binary\".\n */\nexport function parseNativeBinaryHeader(head: Buffer): NativeBinaryInfo | null {\n if (head.length < 4) {\n return null\n }\n\n if (head[0] === 0x7f && head[1] === 0x45 && head[2] === 0x4c && head[3] === 0x46) {\n if (head.length < ELF_E_MACHINE + 2) {\n return null\n }\n const littleEndian = head[ELF_EI_DATA] !== 2\n const machine = littleEndian ? head.readUInt16LE(ELF_E_MACHINE) : head.readUInt16BE(ELF_E_MACHINE)\n return { format: \"elf\", arches: [machineName(ELF_MACHINES, machine)] }\n }\n\n const magic = head.readUInt32BE(0)\n if (MACHO_THIN_MAGIC_BE.has(magic) || MACHO_THIN_MAGIC_LE.has(magic)) {\n if (head.length < 8) {\n return null\n }\n const cpuType = MACHO_THIN_MAGIC_BE.has(magic) ? head.readUInt32BE(4) : head.readUInt32LE(4)\n return { format: \"macho\", arches: [machineName(MACHO_CPU_TYPES, cpuType)] }\n }\n if (magic === MACHO_FAT_MAGIC || magic === MACHO_FAT_MAGIC_64) {\n if (head.length < 8) {\n return null\n }\n const count = head.readUInt32BE(4)\n const entrySize = magic === MACHO_FAT_MAGIC_64 ? 32 : 20\n if (count === 0 || count >= MACHO_FAT_MAX_ARCH_COUNT || head.length < 8 + count * entrySize) {\n return null\n }\n const arches: string[] = []\n for (let i = 0; i < count; i++) {\n arches.push(machineName(MACHO_CPU_TYPES, head.readUInt32BE(8 + i * entrySize)))\n }\n return { format: \"macho\", arches }\n }\n\n if (head[0] === 0x4d && head[1] === 0x5a) {\n if (head.length < PE_E_LFANEW + 4) {\n return null\n }\n const peOffset = head.readUInt32LE(PE_E_LFANEW)\n if (peOffset + 6 > head.length || head.readUInt32LE(peOffset) !== PE_SIGNATURE) {\n return null\n }\n return { format: \"pe\", arches: [machineName(PE_MACHINES, head.readUInt16LE(peOffset + 4))] }\n }\n\n return null\n}\n\nconst PLATFORM_FORMAT: Partial<Record<NodeJS.Platform, NativeBinaryFormat>> = { darwin: \"macho\", linux: \"elf\", win32: \"pe\" }\nconst FORMAT_LABEL: Record<NativeBinaryFormat, string> = { elf: \"ELF\", macho: \"Mach-O\", pe: \"PE\" }\n\n/** Whether the binary can be loaded by an app for the given platform (`process.platform`) and cpu (`process.arch`). */\nexport function isNativeBinaryCompatible(info: NativeBinaryInfo, platform: NodeJS.Platform, cpu: string): boolean {\n return PLATFORM_FORMAT[platform] === info.format && info.arches.includes(cpu)\n}\n\nexport function describeNativeBinary(info: NativeBinaryInfo): string {\n return `${FORMAT_LABEL[info.format]} ${info.arches.join(\"+\")}`\n}\n\n// Path segments that say which platform/arch a file is for: prebuildify `prebuilds/linux-arm64/`, node-pre-gyp\n// `napi-v6-linux-glibc-x64/`, platform packages such as `@img/sharp-darwin-arm64`, or `win/x64/` tool layouts.\nconst PLATFORM_TOKENS: Record<string, string> = {\n darwin: \"darwin\",\n mac: \"darwin\",\n macos: \"darwin\",\n osx: \"darwin\",\n linux: \"linux\",\n win32: \"win32\",\n win: \"win32\",\n windows: \"win32\",\n freebsd: \"freebsd\",\n openbsd: \"openbsd\",\n android: \"android\",\n sunos: \"sunos\",\n aix: \"aix\",\n}\nconst ARCH_TOKENS: Record<string, string> = {\n x64: \"x64\",\n amd64: \"x64\",\n arm64: \"arm64\",\n aarch64: \"arm64\",\n ia32: \"ia32\",\n x86: \"ia32\",\n i386: \"ia32\",\n i686: \"ia32\",\n arm: \"arm\",\n armv6: \"arm\",\n armv6l: \"arm\",\n armv7: \"arm\",\n armv7l: \"arm\",\n armhf: \"arm\",\n universal: \"universal\",\n}\n\n/**\n * The platform/arch a relative path declares through its directory or package names, if any. A segment only\n * counts when it pairs a platform with an arch (`linux-x64`, `sharp-darwin-arm64`) or is exactly one token\n * (`win`, `x64`), so package names such as `node-mac-permissions` are not mistaken for a platform variant.\n *\n * @internal Exported for tests only.\n */\nexport function platformDeclaredByPath(relativePath: string): { platform?: string; cpu?: string } {\n const result: { platform?: string; cpu?: string } = {}\n const segments = relativePath.split(/[\\\\/]/)\n segments.pop() // the file name itself (e.g. `node.napi.armv7.node`) is not a directory layout\n for (const segment of segments) {\n const tokens = segment\n .toLowerCase()\n .replace(/x86[-_]64/g, \"x64\")\n .replace(/x64\\+arm64|arm64\\+x64/g, \"universal\") // prebuildify's name for a fat macOS prebuild\n .split(/[-_.]/)\n const platform = tokens.map(t => PLATFORM_TOKENS[t]).find(it => it != null)\n const cpu = tokens.map(t => ARCH_TOKENS[t]).find(it => it != null)\n if (tokens.length === 1 || (platform != null && cpu != null)) {\n result.platform = platform ?? result.platform\n result.cpu = cpu ?? result.cpu\n }\n }\n return result\n}\n\n/**\n * The package directory (relative, `node_modules/<name>` or `node_modules/@scope/<name>`) owning a file, or `null`\n * when the file is not inside `node_modules`.\n */\nfunction packageRootOf(relativePath: string): string | null {\n const segments = relativePath.split(/[\\\\/]/)\n const index = segments.lastIndexOf(\"node_modules\")\n if (index < 0 || index + 2 >= segments.length) {\n return null\n }\n const nameLength = segments[index + 1].startsWith(\"@\") ? 2 : 1\n if (index + 1 + nameLength >= segments.length) {\n return null\n }\n return segments.slice(0, index + 1 + nameLength).join(\"/\")\n}\n\n/** Where a candidate file lives, and how to read its header and its package's `package.json`. */\ninterface NativeBinarySource {\n readonly label: string\n list(): Promise<Array<string>>\n readHead(relativePath: string): Promise<Buffer | null>\n readPackageJson(packageRoot: string): Promise<PackagePlatformFields | null>\n}\n\nexport type NativeBinaryKind = \"addon\" | \"library\"\n\nexport interface NativeBinaryMismatch {\n /** Path inside the packaged app, e.g. `app.asar.unpacked/node_modules/foo/build/Release/foo.node`. */\n readonly file: string\n readonly kind: NativeBinaryKind\n readonly detected: NativeBinaryInfo\n}\n\nconst LIBRARY_EXTENSIONS = new Set([\".dll\", \".exe\", \".dylib\", \".so\"])\n\n/** `.node` addons are what `require()` loads; other native files are classified as libraries/executables, or skipped. */\nfunction classify(file: string, allowExtensionless: boolean): NativeBinaryKind | null {\n const base = path.basename(file)\n const ext = path.extname(base).toLowerCase()\n if (ext === \".node\") {\n return \"addon\"\n }\n if (LIBRARY_EXTENSIONS.has(ext) || /\\.so(\\.\\d+)+$/.test(base)) {\n return \"library\"\n }\n // extensionless files are checked by magic bytes (bundled CLI tools such as esbuild's binary); only on disk,\n // where reading the head of a file is cheap — smart unpack moves such executables out of the asar anyway\n return allowExtensionless && ext === \"\" && !base.startsWith(\".\") ? \"library\" : null\n}\n\nasync function readFileHead(file: string): Promise<Buffer | null> {\n let handle\n try {\n handle = await open(file, \"r\")\n const head = Buffer.alloc(HEAD_READ_LENGTH)\n const { bytesRead } = await handle.read(head, 0, HEAD_READ_LENGTH, 0)\n return head.subarray(0, bytesRead)\n } catch {\n return null\n } finally {\n await handle?.close()\n }\n}\n\nasync function readJsonOrNull(file: string): Promise<any> {\n try {\n return JSON.parse(await readFile(file, \"utf8\"))\n } catch {\n return null\n }\n}\n\nasync function listFiles(dir: string, prefix = \"\"): Promise<Array<string>> {\n let entries\n try {\n entries = await readdir(path.join(dir, prefix), { withFileTypes: true })\n } catch {\n return []\n }\n const result: string[] = []\n for (const entry of entries) {\n const rel = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`\n if (entry.isDirectory()) {\n result.push(...(await listFiles(dir, rel)))\n } else if (entry.isFile()) {\n result.push(rel)\n }\n }\n return result\n}\n\n/** @internal Exported for tests only. */\nexport function directorySource(dir: string, label: string): NativeBinarySource {\n return {\n label,\n list: () => listFiles(dir),\n readHead: rel => readFileHead(path.join(dir, rel)),\n readPackageJson: root => readJsonOrNull(path.join(dir, root, \"package.json\")),\n }\n}\n\nfunction collectAsarFiles(node: Node, prefix: string, out: Array<string>) {\n for (const [name, child] of Object.entries(node.files ?? {})) {\n const rel = prefix === \"\" ? name : `${prefix}/${name}`\n if (child.files != null) {\n collectAsarFiles(child, rel, out)\n } else if (child.link == null && !child.unpacked) {\n out.push(rel) // unpacked files are covered by the `app.asar.unpacked` directory source\n }\n }\n}\n\nasync function readAsarFileHead(archive: AsarFilesystem, rel: string): Promise<Buffer | null> {\n const node = archive.getNode(rel.split(\"/\").join(path.sep))\n if (node == null || node.offset == null || !node.size) {\n return null\n }\n let handle\n try {\n handle = await open(archive.src, \"r\")\n const head = Buffer.alloc(Math.min(HEAD_READ_LENGTH, node.size))\n const { bytesRead } = await handle.read(head, 0, head.length, 8 + archive.headerSize + parseInt(node.offset, 10))\n return head.subarray(0, bytesRead)\n } catch {\n return null\n } finally {\n await handle?.close()\n }\n}\n\nasync function asarSource(archivePath: string, label: string): Promise<NativeBinarySource | null> {\n let archive: AsarFilesystem\n try {\n archive = await readAsar(archivePath)\n } catch {\n return null\n }\n return {\n label,\n list: () => {\n const files: string[] = []\n collectAsarFiles(archive.header, \"\", files)\n return Promise.resolve(files)\n },\n readHead: rel => readAsarFileHead(archive, rel),\n readPackageJson: async root => {\n const onDisk = await readJsonOrNull(path.join(`${archivePath}.unpacked`, root, \"package.json\"))\n if (onDisk != null) {\n return onDisk\n }\n try {\n return await archive.readJson(path.join(...root.split(\"/\"), \"package.json\"))\n } catch {\n return null\n }\n },\n }\n}\n\n/**\n * Scans the given sources for native binaries that were not built for `platform`/`cpu`. Files whose package declares\n * another platform (`package.json` `os`/`cpu`) or whose path names another platform/arch are skipped: they are\n * shipped on purpose (multi-platform prebuilds, a universal build's single-arch packages) and never loaded here.\n *\n * @internal Exported for tests only.\n */\nexport async function findNativeBinaryMismatches(\n sources: ReadonlyArray<NativeBinarySource>,\n platform: NodeJS.Platform,\n cpu: string,\n options: { extensionless: boolean[] } = { extensionless: sources.map(() => true) }\n): Promise<Array<NativeBinaryMismatch>> {\n const mismatches: NativeBinaryMismatch[] = []\n for (let i = 0; i < sources.length; i++) {\n const source = sources[i]\n const packageCompatibility = new Map<string, Promise<boolean>>()\n for (const rel of await source.list()) {\n const kind = classify(rel, options.extensionless[i] ?? true)\n if (kind == null) {\n continue\n }\n const head = await source.readHead(rel)\n const info = head == null ? null : parseNativeBinaryHeader(head)\n if (info == null || isNativeBinaryCompatible(info, platform, cpu)) {\n continue\n }\n\n const declared = platformDeclaredByPath(rel)\n if ((declared.platform != null && declared.platform !== platform) || (declared.cpu != null && declared.cpu !== cpu && declared.cpu !== \"universal\")) {\n log.debug({ file: rel, detected: describeNativeBinary(info), reason: \"path names another platform/arch\" }, \"skipped native binary check\")\n continue\n }\n const root = packageRootOf(rel)\n if (root != null) {\n if (!packageCompatibility.has(root)) {\n packageCompatibility.set(\n root,\n source.readPackageJson(root).then(pkg => pkg == null || isPackageCompatible(pkg, cpu, platform))\n )\n }\n if (!(await packageCompatibility.get(root))) {\n log.debug({ file: rel, detected: describeNativeBinary(info), reason: \"package.json os/cpu names another platform/arch\" }, \"skipped native binary check\")\n continue\n }\n }\n\n mismatches.push({ file: `${source.label}/${rel}`, kind, detected: info })\n }\n }\n return mismatches\n}\n\n/** @internal Exported for tests only. */\nexport function formatMismatch(mismatch: NativeBinaryMismatch, platform: NodeJS.Platform, cpu: string): string {\n const expectedFormat = PLATFORM_FORMAT[platform]\n const expected = expectedFormat == null ? `${platform} ${cpu}` : `${FORMAT_LABEL[expectedFormat]} ${cpu}`\n return `${mismatch.file}: ${describeNativeBinary(mismatch.detected)}, expected ${expected}`\n}\n\nexport interface VerifyNativeBinariesOptions {\n /** `Contents/Resources` (macOS) or `resources` directory of the packed app. */\n readonly resourcesDir: string\n readonly platform: NodeJS.Platform\n readonly arch: Arch\n /** `nativeModules.verifyNativeBinaries` */\n readonly mode: boolean | \"warn\" | null | undefined\n}\n\n/**\n * Checks that the native binaries shipped in the packed app (`app.asar`, `app.asar.unpacked`, or the `app` directory)\n * match the target platform and arch. A mismatched `.node` addon fails the build (unless `mode` is `\"warn\"`); any other\n * mismatched native file is a warning, since packages legitimately bundle helper binaries for several platforms.\n */\nexport async function verifyNativeBinaries({ resourcesDir, platform, arch, mode }: VerifyNativeBinariesOptions): Promise<void> {\n if (mode === false) {\n log.debug({ reason: \"nativeModules.verifyNativeBinaries is set to false\" }, \"skipped native binary check\")\n return\n }\n const cpu = archToNodeCpu(arch)\n if (cpu == null || PLATFORM_FORMAT[platform] == null) {\n return // e.g. `universal`: each slice is checked before the merge\n }\n\n const sources: NativeBinarySource[] = []\n const extensionless: boolean[] = []\n const archive = await asarSource(path.join(resourcesDir, \"app.asar\"), \"app.asar\")\n if (archive != null) {\n sources.push(archive)\n extensionless.push(false)\n }\n sources.push(directorySource(path.join(resourcesDir, \"app.asar.unpacked\"), \"app.asar.unpacked\"), directorySource(path.join(resourcesDir, \"app\"), \"app\"))\n extensionless.push(true, true)\n\n const mismatches = await findNativeBinaryMismatches(sources, platform, cpu, { extensionless })\n if (mismatches.length === 0) {\n return\n }\n\n const target = `${platform} ${cpu}`\n const fatal = mode === \"warn\" ? [] : mismatches.filter(it => it.kind === \"addon\")\n for (const mismatch of mismatches) {\n if (!fatal.includes(mismatch)) {\n log.warn({ file: mismatch.file, detected: describeNativeBinary(mismatch.detected), target }, \"native binary does not match the target platform/arch\")\n }\n }\n if (fatal.length > 0) {\n throw new Error(\n `Native module(s) built for the wrong platform/architecture were found in the packaged app (target: ${target}):\\n` +\n fatal.map(it => ` ${formatMismatch(it, platform, cpu)}`).join(\"\\n\") +\n \"\\nThe app would fail to load them at runtime. This usually means a binary built for another target (often the build host) was left in node_modules \" +\n \"because the native rebuild was skipped or reused a cached result. Rebuild native dependencies for the target, \" +\n 'or set `nativeModules.verifyNativeBinaries` to \"warn\" (or false) to package anyway. ' +\n `See ${BUILD_CHANGES_URL}#native-binaries-are-verified-against-the-target`\n )\n }\n}\n"]}
|
|
@@ -62,7 +62,7 @@ export function checkMetadata(metadata, devMetadata, appPackageFile, devAppPacka
|
|
|
62
62
|
` { "build": { "directories": ${JSON.stringify(rootDirectories)} } }\n` +
|
|
63
63
|
" Left where it is, it is ignored and your build output goes to the default 'dist' directory.\n" +
|
|
64
64
|
" Run `electron-builder migrate-schema` to move it automatically.\n" +
|
|
65
|
-
" https://www.electron.build/docs/migration/v27-
|
|
65
|
+
" https://www.electron.build/docs/migration/v27-config-changes#root-level-directories-in-packagejson");
|
|
66
66
|
}
|
|
67
67
|
const devDependencies = metadata.devDependencies;
|
|
68
68
|
if (devDependencies != null && ("electron-rebuild" in devDependencies || "@electron/rebuild" in devDependencies)) {
|
|
@@ -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;AAE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E,EAAE,UAAU,CAAC,CAAA;oBAC1G,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAA;oBAC7E,cAAc,GAAG,IAAI,CAAC,OAAO,CAAA;oBAC7B,MAAK;gBACP,CAAC;YACH,CAAC;YAED,uIAAuI;YACvI,MAAM,qBAAqB,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;YACxD,cAAc,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC9F,CAAC;QAED,MAAM,8BAA8B,GAAG,OAAO,CAAA;QAC9C,IAAI,CAAC,cAAc,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,KAAK,8BAA8B,EAAE,CAAC,EAAE,CAAC;YAChG,MAAM,CAAC,IAAI,CACT,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-breaking-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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CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;oBAC1G,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAA;oBAC7E,cAAc,GAAG,IAAI,CAAC,OAAO,CAAA;oBAC7B,MAAK;gBACP,CAAC;YACH,CAAC;YAED,uIAAuI;YACvI,MAAM,qBAAqB,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;YACxD,cAAc,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC9F,CAAC;QAED,MAAM,8BAA8B,GAAG,OAAO,CAAA;QAC9C,IAAI,CAAC,cAAc,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,KAAK,8BAA8B,EAAE,CAAC,EAAE,CAAC;YAChG,MAAM,CAAC,IAAI,CACT,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"]}
|
|
@@ -15,6 +15,8 @@ interface RemovedEnvVar {
|
|
|
15
15
|
* not a signal — the removed `"release"` auto-publish behavior is covered in the migration docs).
|
|
16
16
|
*/
|
|
17
17
|
export declare const REMOVED_ENV_VARS: ReadonlyArray<RemovedEnvVar>;
|
|
18
|
+
/** The section of the v27 build-changes page that documents a removed environment variable. */
|
|
19
|
+
export declare function removedEnvVarDocsUrl(name: string): string;
|
|
18
20
|
/**
|
|
19
21
|
* Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the
|
|
20
22
|
* environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removedEnvVars.d.ts","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"removedEnvVars.d.ts","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACrB,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,aAAa,CAgCzD,CAAA;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWzD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,IAAI,CAM/E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { log } from "builder-util";
|
|
2
|
+
import { BUILD_CHANGES_URL } from "./config/legacyOptions.js";
|
|
2
3
|
/**
|
|
3
4
|
* Environment variables that were honored in electron-builder v26 but were removed in v27. When a
|
|
4
5
|
* project upgrades from v26 and still has one of these set, the build silently ignores it — the
|
|
@@ -39,6 +40,19 @@ export const REMOVED_ENV_VARS = [
|
|
|
39
40
|
remediation: `electron-builder in \`dependencies\` no longer errors and is excluded from the packaged app by default — remove this variable, and use the \`ignoredProductionDependencies\` option to customize exclusions.`,
|
|
40
41
|
},
|
|
41
42
|
];
|
|
43
|
+
/** The section of the v27 build-changes page that documents a removed environment variable. */
|
|
44
|
+
export function removedEnvVarDocsUrl(name) {
|
|
45
|
+
switch (name) {
|
|
46
|
+
case "CI_BUILD_TAG":
|
|
47
|
+
return `${BUILD_CHANGES_URL}#ci_build_tag-environment-variable`;
|
|
48
|
+
case "ELECTRON_BUILDER_BINARIES_ALLOW_HTTP":
|
|
49
|
+
return `${BUILD_CHANGES_URL}#electron_builder_binaries_allow_http-renamed`;
|
|
50
|
+
case "ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY":
|
|
51
|
+
return `${BUILD_CHANGES_URL}#allow_electron_builder_as_production_dependency-is-removed-and-the-default-flipped`;
|
|
52
|
+
default:
|
|
53
|
+
return `${BUILD_CHANGES_URL}#toolset-env-var-overrides-removed`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
/**
|
|
43
57
|
* Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the
|
|
44
58
|
* environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the
|
|
@@ -47,7 +61,7 @@ export const REMOVED_ENV_VARS = [
|
|
|
47
61
|
export function warnOnRemovedEnvVars(env = process.env) {
|
|
48
62
|
for (const { name, remediation } of REMOVED_ENV_VARS) {
|
|
49
63
|
if (env[name] != null) {
|
|
50
|
-
log.warn({ envVar: name }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`);
|
|
64
|
+
log.warn({ envVar: name, docs: removedEnvVarDocsUrl(name) }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`);
|
|
51
65
|
}
|
|
52
66
|
}
|
|
53
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removedEnvVars.js","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"removedEnvVars.js","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAA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gB,EAAE,WAAW,EAAE,2GAA2G,EAAE;IAEpJ,sDAAsD;IACtD,EAAE,IAAI,EAAE,sCAAsC,EAAE,WAAW,EAAE,+DAA+D,EAAE;IAC9H,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,kEAAkE,EAAE;IAEzG,+DAA+D;IAC/D;QACE,IAAI,EAAE,iDAAiD;QACvD,WAAW,EAAE,8MAA8M;KAC5N;CACF,CAAA;AAED,+FAA+F;AAC/F,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,cAAc;YACjB,OAAO,GAAG,iBAAiB,oCAAoC,CAAA;QACjE,KAAK,sCAAsC;YACzC,OAAO,GAAG,iBAAiB,+CAA+C,CAAA;QAC5E,KAAK,iDAAiD;YACpD,OAAO,GAAG,iBAAiB,qFAAqF,CAAA;QAClH;YACE,OAAO,GAAG,iBAAiB,oCAAoC,CAAA;IACnE,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvE,KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,gBAAgB,EAAE,CAAC;QACrD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,2FAA2F,WAAW,EAAE,CAAC,CAAA;QACxK,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { log } from \"builder-util\"\nimport { BUILD_CHANGES_URL } from \"./config/legacyOptions.js\"\n\ninterface RemovedEnvVar {\n /** The environment variable that was read in v26 but is no longer read in v27. */\n readonly name: string\n /** What to use instead, appended to the deprecation warning. */\n readonly remediation: string\n}\n\n/**\n * Environment variables that were honored in electron-builder v26 but were removed in v27. When a\n * project upgrades from v26 and still has one of these set, the build silently ignores it — the\n * `process.env` read was deleted, so there is no other signal. {@link warnOnRemovedEnvVars} scans\n * the environment once per build and logs a deprecation warning with the remediation.\n *\n * Deliberately excluded: internal/test-only variables that end users never set (`JEST_WORKER_ID`,\n * `TEST_SET_BABEL_PRESET`), and `npm_lifecycle_event` (npm sets it for every script, so presence is\n * not a signal — the removed `\"release\"` auto-publish behavior is covered in the migration docs).\n */\nexport const REMOVED_ENV_VARS: ReadonlyArray<RemovedEnvVar> = [\n // Toolset path/dir overrides — the `resolveEnvToolsetPath` mechanism was removed; supply a ToolsetCustom object instead.\n { name: \"APPIMAGE_TOOLS_PATH\", remediation: `set \\`toolsets.appimage: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"MKSQUASHFS_PATH\", remediation: `the mksquashfs binary now ships with the appimage toolset — set \\`toolsets.appimage: { url: \"file:///path/to/dir\" }\\` to override it.` },\n { name: \"LINUX_TOOLS_MAC_PATH\", remediation: `set \\`toolsets.linuxToolsMac: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"CUSTOM_FPM_PATH\", remediation: `set \\`toolsets.fpm: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_NSIS_DIR\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_NSIS_RESOURCES_DIR\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"CUSTOM_NSIS_RESOURCES\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_WINE_TOOLSET_DIR\", remediation: `set \\`toolsets.wine: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_7ZIP_PATH\", remediation: `set \\`toolsets.sevenZip: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_ICONS_TOOLSET_DIR\", remediation: `set \\`toolsets.icons: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_OSSL_SIGNCODE_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_RCEDIT_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_WINDOWS_KITS_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"SIGNTOOL_PATH\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n\n // `USE_SYSTEM_*` toggles — removed with no env-var replacement; configure via the toolset/signing config.\n { name: \"USE_SYSTEM_WINE\", remediation: `Linux uses the host \\`wine\\` by default; to use a custom Wine build set \\`toolsets.wine: { url: \"file:///path/to/dir\" }\\`.` },\n { name: \"USE_SYSTEM_SIGNCODE\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n { name: \"USE_SYSTEM_OSSLSIGNCODE\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n { name: \"USE_SYSTEM_FPM\", remediation: `set \\`toolsets.fpm: { url: \"file:///path/to/dir\" }\\` instead (required on Windows for FPM-based targets).` },\n\n // Renamed / replaced by another environment variable.\n { name: \"ELECTRON_BUILDER_BINARIES_ALLOW_HTTP\", remediation: `use \\`ELECTRON_BUILDER_DANGEROUSLY_ALLOW_HTTP=true\\` instead.` },\n { name: \"CI_BUILD_TAG\", remediation: `use \\`CI_COMMIT_TAG\\` (the standard GitLab CI variable) instead.` },\n\n // Replaced by a configuration option (with a behavior change).\n {\n name: \"ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY\",\n remediation: `electron-builder in \\`dependencies\\` no longer errors and is excluded from the packaged app by default — remove this variable, and use the \\`ignoredProductionDependencies\\` option to customize exclusions.`,\n },\n]\n\n/** The section of the v27 build-changes page that documents a removed environment variable. */\nexport function removedEnvVarDocsUrl(name: string): string {\n switch (name) {\n case \"CI_BUILD_TAG\":\n return `${BUILD_CHANGES_URL}#ci_build_tag-environment-variable`\n case \"ELECTRON_BUILDER_BINARIES_ALLOW_HTTP\":\n return `${BUILD_CHANGES_URL}#electron_builder_binaries_allow_http-renamed`\n case \"ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY\":\n return `${BUILD_CHANGES_URL}#allow_electron_builder_as_production_dependency-is-removed-and-the-default-flipped`\n default:\n return `${BUILD_CHANGES_URL}#toolset-env-var-overrides-removed`\n }\n}\n\n/**\n * Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the\n * environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the\n * programmatic `build()` API surface the same guidance.\n */\nexport function warnOnRemovedEnvVars(env: NodeJS.ProcessEnv = process.env): void {\n for (const { name, remediation } of REMOVED_ENV_VARS) {\n if (env[name] != null) {\n log.warn({ envVar: name, docs: removedEnvVarDocsUrl(name) }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`)\n }\n }\n}\n"]}
|
|
@@ -16,7 +16,9 @@ export interface StreamSpawnResult {
|
|
|
16
16
|
* which emits the DEP0190 "args with shell" deprecation warning and forces manual metacharacter
|
|
17
17
|
* escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)
|
|
18
18
|
* payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn
|
|
19
|
-
* directly with no shell
|
|
19
|
+
* directly with no shell, by its absolute path (`toolsets.executables.powershell` or its default location;
|
|
20
|
+
* never looked up in the current directory or on PATH).
|
|
21
|
+
* See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This
|
|
20
22
|
* also avoids the cmd.exe "The batch file cannot be found." re-open race that plagues `.cmd` shims.
|
|
21
23
|
*
|
|
22
24
|
* Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's
|