app-builder-lib 26.0.1 → 26.0.2

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.
@@ -35,7 +35,7 @@ class WindowsSignAzureManager {
35
35
  // Logging to debug just in case users run into this. If NuGet isn't present, Install-Module -Name TrustedSigning will fail, so we'll get the logs at that point
36
36
  builder_util_1.log.debug({ message: error.message || error.stack }, "unable to install PackageProvider Nuget. Might be a false alarm though as some systems already have it installed");
37
37
  }
38
- await vm.exec(ps, ["-NoProfile", "-NonInteractive", "-Command", "Install-Module -Name TrustedSigning -RequiredVersion 0.4.1 -Force -Repository PSGallery -Scope CurrentUser"]);
38
+ await vm.exec(ps, ["-NoProfile", "-NonInteractive", "-Command", "Install-Module -Name TrustedSigning -MinimumVersion 0.5.0 -Force -Repository PSGallery -Scope CurrentUser"]);
39
39
  // Preemptively check env vars once during initialization
40
40
  // Options: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition
41
41
  builder_util_1.log.info(null, "verifying env vars for authenticating to Microsoft Entra ID");
@@ -1 +1 @@
1
- {"version":3,"file":"windowsSignAzureManager.js","sourceRoot":"","sources":["../../src/codeSign/windowsSignAzureManager.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AACtE,+DAA+C;AAC/C,uCAA+B;AAO/B,MAAa,uBAAuB;IAgBlC,YAA6B,QAAqB;QAArB,aAAQ,GAAR,QAAQ,CAAa;QAbzC,0BAAqB,GAAG,IAAI,eAAI,CAAuB,GAAG,EAAE;;YACnE,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,4BAA4B,CAAC,gBAAgB,0CAAE,aAAa,CAAA;YACvF,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;iBAAM,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBACjC,OAAO,OAAO,CAAC,OAAO,C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,EAAE,UAAU,IAAI,QAAQ;YAClC,KAAK,EAAE,IAAI,OAAO,CAAC,IAAI,GAAG;SAC3B,CAAA;QACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;aACxC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC;aACrC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9B,OAAO,CAAC,GAAG,GAAG,EAAE,IAAI,KAAK,EAAE,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC,EAAE,EAAc,CAAC;aACjB,IAAI,CAAC,GAAG,CAAC,CAAA;QACZ,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,yBAAyB,YAAY,EAAE,CAAC,CAAC,CAAA;QAEzG,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAlID,0DAkIC","sourcesContent":["import { asArray, InvalidConfigurationError, log } from \"builder-util\"\nimport { MemoLazy } from \"builder-util-runtime\"\nimport { Lazy } from \"lazy-val\"\nimport { WindowsAzureSigningConfiguration, WindowsConfiguration } from \"../options/winOptions\"\nimport { WinPackager } from \"../winPackager\"\nimport { SignManager } from \"./signManager\"\nimport { WindowsSignOptions } from \"./windowsCodeSign\"\nimport { CertificateFromStoreInfo, FileCodeSigningInfo } from \"./windowsSignToolManager\"\n\nexport class WindowsSignAzureManager implements SignManager {\n private readonly platformSpecificBuildOptions: WindowsConfiguration\n\n readonly computedPublisherName = new Lazy<Array<string> | null>(() => {\n const publisherName = this.platformSpecificBuildOptions.azureSignOptions?.publisherName\n if (publisherName === null) {\n return Promise.resolve(null)\n } else if (publisherName != null) {\n return Promise.resolve(asArray(publisherName))\n }\n\n // TODO: Is there another way to automatically pull Publisher Name from AzureTrusted service?\n // For now return null.\n return Promise.resolve(null)\n })\n\n constructor(private readonly packager: WinPackager) {\n this.platformSpecificBuildOptions = packager.platformSpecificBuildOptions\n }\n\n async initialize() {\n const vm = await this.packager.vm.value\n const ps = await vm.powershellCommand.value\n\n log.info(null, \"installing required module (TrustedSigning) with scope CurrentUser\")\n try {\n await vm.exec(ps, [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser\"])\n } catch (error: any) {\n // Might not be needed, seems GH runners already have NuGet set up.\n // Logging to debug just in case users run into this. If NuGet isn't present, Install-Module -Name TrustedSigning will fail, so we'll get the logs at that point\n log.debug({ message: error.message || error.stack }, \"unable to install PackageProvider Nuget. Might be a false alarm though as some systems already have it installed\")\n }\n await vm.exec(ps, [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"Install-Module -Name TrustedSigning -RequiredVersion 0.4.1 -Force -Repository PSGallery -Scope CurrentUser\"])\n\n // Preemptively check env vars once during initialization\n // Options: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition\n log.info(null, \"verifying env vars for authenticating to Microsoft Entra ID\")\n this.verifyRequiredEnvVars()\n if (!(this.verifyPrincipleSecretEnv() || this.verifyPrincipleCertificateEnv() || this.verifyUsernamePasswordEnv())) {\n throw new InvalidConfigurationError(\n `Unable to find valid azure env configuration for signing. Missing field(s) can be debugged via \"DEBUG=electron-builder\". Please refer to: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition`\n )\n }\n }\n\n verifyRequiredEnvVars() {\n ;[\"AZURE_TENANT_ID\", \"AZURE_CLIENT_ID\"].forEach(field => {\n if (!process.env[field]) {\n throw new InvalidConfigurationError(\n `Unable to find valid azure env field ${field} for signing. Please refer to: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition`\n )\n }\n })\n }\n\n verifyPrincipleSecretEnv() {\n if (!process.env.AZURE_CLIENT_SECRET) {\n log.debug({ envVar: \"AZURE_CLIENT_SECRET\" }, \"no secret found for authenticating to Microsoft Entra ID\")\n return false\n }\n return true\n }\n\n verifyPrincipleCertificateEnv() {\n if (!process.env.AZURE_CLIENT_CERTIFICATE_PATH) {\n log.debug({ envVar: \"AZURE_CLIENT_CERTIFICATE_PATH\" }, \"no path found for signing certificate for authenticating to Microsoft Entra ID\")\n return false\n }\n if (!process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD) {\n log.debug({ envVar: \"AZURE_CLIENT_CERTIFICATE_PASSWORD\" }, \"(optional) certificate password not found, assuming no password\")\n }\n if (!process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN) {\n log.debug({ envVar: \"AZURE_CLIENT_SEND_CERTIFICATE_CHAIN\" }, \"(optional) certificate chain not found\")\n }\n return true\n }\n\n verifyUsernamePasswordEnv() {\n if (!process.env.AZURE_USERNAME) {\n log.debug({ envVar: \"AZURE_USERNAME\" }, \"no username found for authenticating to Microsoft Entra ID\")\n if (!process.env.AZURE_PASSWORD) {\n log.debug({ envVar: \"AZURE_PASSWORD\" }, \"no password found for authenticating to Microsoft Entra ID\")\n }\n return false\n }\n return true\n }\n\n computePublisherName(): Promise<string> {\n return Promise.resolve(this.packager.platformSpecificBuildOptions.azureSignOptions!.publisherName)\n }\n readonly cscInfo = new MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>(\n () => this.packager.platformSpecificBuildOptions,\n _selected => Promise.resolve(null)\n )\n // prerequisite: requires `initializeProviderModules` to already have been executed\n async signFile(options: WindowsSignOptions): Promise<boolean> {\n const vm = await this.packager.vm.value\n const ps = await vm.powershellCommand.value\n\n const {\n publisherName: _publisher, // extract from `extraSigningArgs`\n endpoint,\n certificateProfileName,\n codeSigningAccountName,\n fileDigest,\n timestampRfc3161,\n timestampDigest,\n ...extraSigningArgs\n }: WindowsAzureSigningConfiguration = options.options.azureSignOptions!\n const params = {\n ...extraSigningArgs,\n Endpoint: endpoint,\n CertificateProfileName: certificateProfileName,\n CodeSigningAccountName: codeSigningAccountName,\n TimestampRfc3161: timestampRfc3161 || \"http://timestamp.acs.microsoft.com\",\n TimestampDigest: timestampDigest || \"SHA256\",\n FileDigest: fileDigest || \"SHA256\",\n Files: `\"${options.path}\"`,\n }\n const paramsString = Object.entries(params)\n .filter(([_, value]) => value != null)\n .reduce((res, [field, value]) => {\n return [...res, `-${field}`, value]\n }, [] as string[])\n .join(\" \")\n await vm.exec(ps, [\"-NoProfile\", \"-NonInteractive\", \"-Command\", `Invoke-TrustedSigning ${paramsString}`])\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"windowsSignAzureManager.js","sourceRoot":"","sources":["../../src/codeSign/windowsSignAzureManager.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AACtE,+DAA+C;AAC/C,uCAA+B;AAO/B,MAAa,uBAAuB;IAgBlC,YAA6B,QAAqB;QAArB,aAAQ,GAAR,QAAQ,CAAa;QAbzC,0BAAqB,GAAG,IAAI,eAAI,CAAuB,GAAG,EAAE;;YACnE,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,4BAA4B,CAAC,gBAAgB,0CAAE,aAAa,CAAA;YACvF,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;iBAAM,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBACjC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAA,sBAAO,EAAC,aAAa,CAAC,CAAC,CAAA;YAChD,CAAC;YAED,6FAA6F;YAC7F,uBAAuB;YACvB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC,CAAC,CAAA;QA6EO,YAAO,GAAG,IAAI,+BAAQ,CAC7B,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,4BAA4B,EAChD,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAA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E,EAAE;YAC9B,OAAO,CAAC,GAAG,GAAG,EAAE,IAAI,KAAK,EAAE,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC,EAAE,EAAc,CAAC;aACjB,IAAI,CAAC,GAAG,CAAC,CAAA;QACZ,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,yBAAyB,YAAY,EAAE,CAAC,CAAC,CAAA;QAEzG,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAlID,0DAkIC","sourcesContent":["import { asArray, InvalidConfigurationError, log } from \"builder-util\"\nimport { MemoLazy } from \"builder-util-runtime\"\nimport { Lazy } from \"lazy-val\"\nimport { WindowsAzureSigningConfiguration, WindowsConfiguration } from \"../options/winOptions\"\nimport { WinPackager } from \"../winPackager\"\nimport { SignManager } from \"./signManager\"\nimport { WindowsSignOptions } from \"./windowsCodeSign\"\nimport { CertificateFromStoreInfo, FileCodeSigningInfo } from \"./windowsSignToolManager\"\n\nexport class WindowsSignAzureManager implements SignManager {\n private readonly platformSpecificBuildOptions: WindowsConfiguration\n\n readonly computedPublisherName = new Lazy<Array<string> | null>(() => {\n const publisherName = this.platformSpecificBuildOptions.azureSignOptions?.publisherName\n if (publisherName === null) {\n return Promise.resolve(null)\n } else if (publisherName != null) {\n return Promise.resolve(asArray(publisherName))\n }\n\n // TODO: Is there another way to automatically pull Publisher Name from AzureTrusted service?\n // For now return null.\n return Promise.resolve(null)\n })\n\n constructor(private readonly packager: WinPackager) {\n this.platformSpecificBuildOptions = packager.platformSpecificBuildOptions\n }\n\n async initialize() {\n const vm = await this.packager.vm.value\n const ps = await vm.powershellCommand.value\n\n log.info(null, \"installing required module (TrustedSigning) with scope CurrentUser\")\n try {\n await vm.exec(ps, [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser\"])\n } catch (error: any) {\n // Might not be needed, seems GH runners already have NuGet set up.\n // Logging to debug just in case users run into this. If NuGet isn't present, Install-Module -Name TrustedSigning will fail, so we'll get the logs at that point\n log.debug({ message: error.message || error.stack }, \"unable to install PackageProvider Nuget. Might be a false alarm though as some systems already have it installed\")\n }\n await vm.exec(ps, [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"Install-Module -Name TrustedSigning -MinimumVersion 0.5.0 -Force -Repository PSGallery -Scope CurrentUser\"])\n\n // Preemptively check env vars once during initialization\n // Options: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition\n log.info(null, \"verifying env vars for authenticating to Microsoft Entra ID\")\n this.verifyRequiredEnvVars()\n if (!(this.verifyPrincipleSecretEnv() || this.verifyPrincipleCertificateEnv() || this.verifyUsernamePasswordEnv())) {\n throw new InvalidConfigurationError(\n `Unable to find valid azure env configuration for signing. Missing field(s) can be debugged via \"DEBUG=electron-builder\". Please refer to: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition`\n )\n }\n }\n\n verifyRequiredEnvVars() {\n ;[\"AZURE_TENANT_ID\", \"AZURE_CLIENT_ID\"].forEach(field => {\n if (!process.env[field]) {\n throw new InvalidConfigurationError(\n `Unable to find valid azure env field ${field} for signing. Please refer to: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition`\n )\n }\n })\n }\n\n verifyPrincipleSecretEnv() {\n if (!process.env.AZURE_CLIENT_SECRET) {\n log.debug({ envVar: \"AZURE_CLIENT_SECRET\" }, \"no secret found for authenticating to Microsoft Entra ID\")\n return false\n }\n return true\n }\n\n verifyPrincipleCertificateEnv() {\n if (!process.env.AZURE_CLIENT_CERTIFICATE_PATH) {\n log.debug({ envVar: \"AZURE_CLIENT_CERTIFICATE_PATH\" }, \"no path found for signing certificate for authenticating to Microsoft Entra ID\")\n return false\n }\n if (!process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD) {\n log.debug({ envVar: \"AZURE_CLIENT_CERTIFICATE_PASSWORD\" }, \"(optional) certificate password not found, assuming no password\")\n }\n if (!process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN) {\n log.debug({ envVar: \"AZURE_CLIENT_SEND_CERTIFICATE_CHAIN\" }, \"(optional) certificate chain not found\")\n }\n return true\n }\n\n verifyUsernamePasswordEnv() {\n if (!process.env.AZURE_USERNAME) {\n log.debug({ envVar: \"AZURE_USERNAME\" }, \"no username found for authenticating to Microsoft Entra ID\")\n if (!process.env.AZURE_PASSWORD) {\n log.debug({ envVar: \"AZURE_PASSWORD\" }, \"no password found for authenticating to Microsoft Entra ID\")\n }\n return false\n }\n return true\n }\n\n computePublisherName(): Promise<string> {\n return Promise.resolve(this.packager.platformSpecificBuildOptions.azureSignOptions!.publisherName)\n }\n readonly cscInfo = new MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>(\n () => this.packager.platformSpecificBuildOptions,\n _selected => Promise.resolve(null)\n )\n // prerequisite: requires `initializeProviderModules` to already have been executed\n async signFile(options: WindowsSignOptions): Promise<boolean> {\n const vm = await this.packager.vm.value\n const ps = await vm.powershellCommand.value\n\n const {\n publisherName: _publisher, // extract from `extraSigningArgs`\n endpoint,\n certificateProfileName,\n codeSigningAccountName,\n fileDigest,\n timestampRfc3161,\n timestampDigest,\n ...extraSigningArgs\n }: WindowsAzureSigningConfiguration = options.options.azureSignOptions!\n const params = {\n ...extraSigningArgs,\n Endpoint: endpoint,\n CertificateProfileName: certificateProfileName,\n CodeSigningAccountName: codeSigningAccountName,\n TimestampRfc3161: timestampRfc3161 || \"http://timestamp.acs.microsoft.com\",\n TimestampDigest: timestampDigest || \"SHA256\",\n FileDigest: fileDigest || \"SHA256\",\n Files: `\"${options.path}\"`,\n }\n const paramsString = Object.entries(params)\n .filter(([_, value]) => value != null)\n .reduce((res, [field, value]) => {\n return [...res, `-${field}`, value]\n }, [] as string[])\n .join(\" \")\n await vm.exec(ps, [\"-NoProfile\", \"-NonInteractive\", \"-Command\", `Invoke-TrustedSigning ${paramsString}`])\n\n return true\n }\n}\n"]}
@@ -107,6 +107,11 @@ export interface PkgOptions extends TargetSpecificOptions {
107
107
  * @default upgrade
108
108
  */
109
109
  readonly overwriteAction?: "upgrade" | "update" | null;
110
+ /**
111
+ * The extra component packages directory (relative to build resources directory) for MacOS product archive
112
+ * Autoscans directory for any `.pkg` files and adds to `productbuild` command as `--package-path` and `--package` accordingly
113
+ */
114
+ readonly extraPkgsDir?: string | null;
110
115
  }
111
116
  /**
112
117
  * Options for the background image in a PKG installer
@@ -1 +1 @@
1
- {"version":3,"file":"pkgOptions.js","sourceRoot":"","sources":["../../src/options/pkgOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { TargetSpecificOptions } from \"../core\"\n\n// noinspection SpellCheckingInspection\nexport type BackgroundAlignment = \"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"topleft\" | \"topright\" | \"bottomleft\" | \"bottomright\"\n// noinspection SpellCheckingInspection\nexport type BackgroundScaling = \"tofit\" | \"none\" | \"proportional\"\n\n/**\n * macOS product archive options.\n */\nexport interface PkgOptions extends TargetSpecificOptions {\n /**\n * The scripts directory, relative to `build` (build resources directory).\n * The scripts can be in any language so long as the files are marked executable and have the appropriate shebang indicating the path to the interpreter.\n * Scripts are required to be executable (`chmod +x file`).\n * @default build/pkg-scripts\n * @see [Scripting in installer packages](http://macinstallers.blogspot.de/2012/07/scripting-in-installer-packages.html).\n */\n readonly scripts?: string | null\n\n /**\n * should be not documented, only to experiment\n * @private\n */\n readonly productbuild?: Array<string> | null\n\n /**\n * The install location. [Do not use it](https://stackoverflow.com/questions/12863944/how-do-you-specify-a-default-install-location-to-home-with-pkgbuild) to create per-user package.\n * Mostly never you will need to change this option. `/Applications` would install it as expected into `/Applications` if the local system domain is chosen, or into `$HOME/Applications` if the home installation is chosen.\n * @default /Applications\n */\n readonly installLocation?: string | null\n\n /**\n * Whether can be installed at the root of any volume, including non-system volumes. Otherwise, it cannot be installed at the root of a volume.\n *\n * Corresponds to [enable_anywhere](https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW70).\n * @default true\n */\n readonly allowAnywhere?: boolean | null\n\n /**\n * Whether can be installed into the current user’s home directory.\n * A home directory installation is done as the current user (not as root), and it cannot write outside of the home directory.\n * If the product cannot be installed in the user’s home directory and be not completely functional from user’s home directory.\n *\n * Corresponds to [enable_currentUserHome](https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW70).\n * @default true\n */\n readonly allowCurrentUserHome?: boolean | null\n\n /**\n * Whether can be installed into the root directory. Should usually be `true` unless the product can be installed only to the user’s home directory.\n *\n * Corresponds to [enable_localSystem](https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW70).\n * @default true\n */\n readonly allowRootDirectory?: boolean | null\n\n /**\n * The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](./code-signing.md) instead of specifying this option.\n */\n readonly identity?: string | null\n\n /**\n * The path to EULA license file. Defaults to `license.txt` or `eula.txt` (or uppercase variants). In addition to `txt`, `rtf` and `html` supported (don't forget to use `target=\"_blank\"` for links).\n */\n readonly license?: string | null\n\n /**\n * Options for the background image for the installer.\n */\n readonly background?: PkgBackgroundOptions | null\n\n /**\n * The path to the welcome file. This may be used to customize the text on the Introduction page of the installer.\n */\n readonly welcome?: string | null\n\n /**\n * Identifies applications that must be closed before the package is installed.\n *\n * Corresponds to [must-close](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW77).\n */\n readonly mustClose?: Array<string> | null\n\n /**\n * The path to the conclusion file. This may be used to customize the text on the final \"Summary\" page of the installer.\n */\n readonly conclusion?: string | null\n\n /**\n * Install bundle over previous version if moved by user?\n * @default true\n */\n readonly isRelocatable?: boolean | null\n\n /**\n * Don't install bundle if newer version on disk?\n * @default true\n */\n readonly isVersionChecked?: boolean | null\n\n /**\n * Require identical bundle identifiers at install path?\n * @default true\n */\n readonly hasStrictIdentifier?: boolean | null\n\n /**\n * Specifies how an existing version of the bundle on disk should be handled when the version in\n * the package is installed.\n *\n * If you specify upgrade, the bundle in the package atomi-cally replaces any version on disk;\n * this has the effect of deleting old paths that no longer exist in the new version of\n * the bundle.\n *\n * If you specify update, the bundle in the package overwrites the version on disk, and any files\n * not contained in the package will be left intact; this is appropriate when you are delivering\n * an update-only package.\n *\n * Another effect of update is that the package bundle will not be installed at all if there is\n * not already a version on disk; this allows a package to deliver an update for an app that\n * the user might have deleted.\n *\n * @default upgrade\n */\n readonly overwriteAction?: \"upgrade\" | \"update\" | null\n}\n\n/**\n * Options for the background image in a PKG installer\n */\nexport interface PkgBackgroundOptions {\n /**\n * Path to the image to use as an installer background.\n */\n file?: string\n\n /**\n * Alignment of the background image.\n * Options are: center, left, right, top, bottom, topleft, topright, bottomleft, bottomright\n * @default center\n */\n alignment?: BackgroundAlignment | null\n\n /**\n * Scaling of the background image.\n * Options are: tofit, none, proportional\n * @default tofit\n */\n scaling?: BackgroundScaling | null\n}\n"]}
1
+ {"version":3,"file":"pkgOptions.js","sourceRoot":"","sources":["../../src/options/pkgOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { TargetSpecificOptions } from \"../core\"\n\n// noinspection SpellCheckingInspection\nexport type BackgroundAlignment = \"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"topleft\" | \"topright\" | \"bottomleft\" | \"bottomright\"\n// noinspection SpellCheckingInspection\nexport type BackgroundScaling = \"tofit\" | \"none\" | \"proportional\"\n\n/**\n * macOS product archive options.\n */\nexport interface PkgOptions extends TargetSpecificOptions {\n /**\n * The scripts directory, relative to `build` (build resources directory).\n * The scripts can be in any language so long as the files are marked executable and have the appropriate shebang indicating the path to the interpreter.\n * Scripts are required to be executable (`chmod +x file`).\n * @default build/pkg-scripts\n * @see [Scripting in installer packages](http://macinstallers.blogspot.de/2012/07/scripting-in-installer-packages.html).\n */\n readonly scripts?: string | null\n\n /**\n * should be not documented, only to experiment\n * @private\n */\n readonly productbuild?: Array<string> | null\n\n /**\n * The install location. [Do not use it](https://stackoverflow.com/questions/12863944/how-do-you-specify-a-default-install-location-to-home-with-pkgbuild) to create per-user package.\n * Mostly never you will need to change this option. `/Applications` would install it as expected into `/Applications` if the local system domain is chosen, or into `$HOME/Applications` if the home installation is chosen.\n * @default /Applications\n */\n readonly installLocation?: string | null\n\n /**\n * Whether can be installed at the root of any volume, including non-system volumes. Otherwise, it cannot be installed at the root of a volume.\n *\n * Corresponds to [enable_anywhere](https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW70).\n * @default true\n */\n readonly allowAnywhere?: boolean | null\n\n /**\n * Whether can be installed into the current user’s home directory.\n * A home directory installation is done as the current user (not as root), and it cannot write outside of the home directory.\n * If the product cannot be installed in the user’s home directory and be not completely functional from user’s home directory.\n *\n * Corresponds to [enable_currentUserHome](https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW70).\n * @default true\n */\n readonly allowCurrentUserHome?: boolean | null\n\n /**\n * Whether can be installed into the root directory. Should usually be `true` unless the product can be installed only to the user’s home directory.\n *\n * Corresponds to [enable_localSystem](https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW70).\n * @default true\n */\n readonly allowRootDirectory?: boolean | null\n\n /**\n * The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](./code-signing.md) instead of specifying this option.\n */\n readonly identity?: string | null\n\n /**\n * The path to EULA license file. Defaults to `license.txt` or `eula.txt` (or uppercase variants). In addition to `txt`, `rtf` and `html` supported (don't forget to use `target=\"_blank\"` for links).\n */\n readonly license?: string | null\n\n /**\n * Options for the background image for the installer.\n */\n readonly background?: PkgBackgroundOptions | null\n\n /**\n * The path to the welcome file. This may be used to customize the text on the Introduction page of the installer.\n */\n readonly welcome?: string | null\n\n /**\n * Identifies applications that must be closed before the package is installed.\n *\n * Corresponds to [must-close](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW77).\n */\n readonly mustClose?: Array<string> | null\n\n /**\n * The path to the conclusion file. This may be used to customize the text on the final \"Summary\" page of the installer.\n */\n readonly conclusion?: string | null\n\n /**\n * Install bundle over previous version if moved by user?\n * @default true\n */\n readonly isRelocatable?: boolean | null\n\n /**\n * Don't install bundle if newer version on disk?\n * @default true\n */\n readonly isVersionChecked?: boolean | null\n\n /**\n * Require identical bundle identifiers at install path?\n * @default true\n */\n readonly hasStrictIdentifier?: boolean | null\n\n /**\n * Specifies how an existing version of the bundle on disk should be handled when the version in\n * the package is installed.\n *\n * If you specify upgrade, the bundle in the package atomi-cally replaces any version on disk;\n * this has the effect of deleting old paths that no longer exist in the new version of\n * the bundle.\n *\n * If you specify update, the bundle in the package overwrites the version on disk, and any files\n * not contained in the package will be left intact; this is appropriate when you are delivering\n * an update-only package.\n *\n * Another effect of update is that the package bundle will not be installed at all if there is\n * not already a version on disk; this allows a package to deliver an update for an app that\n * the user might have deleted.\n *\n * @default upgrade\n */\n readonly overwriteAction?: \"upgrade\" | \"update\" | null\n\n /**\n * The extra component packages directory (relative to build resources directory) for MacOS product archive\n * Autoscans directory for any `.pkg` files and adds to `productbuild` command as `--package-path` and `--package` accordingly\n */\n readonly extraPkgsDir?: string | null\n}\n\n/**\n * Options for the background image in a PKG installer\n */\nexport interface PkgBackgroundOptions {\n /**\n * Path to the image to use as an installer background.\n */\n file?: string\n\n /**\n * Alignment of the background image.\n * Options are: center, left, right, top, bottom, topleft, topright, bottomleft, bottomright\n * @default center\n */\n alignment?: BackgroundAlignment | null\n\n /**\n * Scaling of the background image.\n * Options are: tofit, none, proportional\n * @default tofit\n */\n scaling?: BackgroundScaling | null\n}\n"]}
@@ -10,6 +10,7 @@ export declare class PkgTarget extends Target {
10
10
  readonly options: PkgOptions;
11
11
  constructor(packager: MacPackager, outDir: string);
12
12
  build(appPath: string, arch: Arch): Promise<any>;
13
+ private getExtraPackages;
13
14
  private customizeDistributionConfiguration;
14
15
  private buildComponentPackage;
15
16
  }
@@ -44,11 +44,12 @@ class PkgTarget extends core_1.Target {
44
44
  const appOutDir = this.outDir;
45
45
  // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html
46
46
  const distInfoFile = path.join(appOutDir, "distribution.xml");
47
+ const extraPackages = this.getExtraPackages();
47
48
  const innerPackageFile = path.join(appOutDir, `${(0, appInfo_1.filterCFBundleIdentifier)(appInfo.id)}.pkg`);
48
49
  const componentPropertyListFile = path.join(appOutDir, `${(0, appInfo_1.filterCFBundleIdentifier)(appInfo.id)}.plist`);
49
50
  const identity = (await Promise.all([
50
51
  (0, macCodeSign_1.findIdentity)(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),
51
- this.customizeDistributionConfiguration(distInfoFile, appPath),
52
+ this.customizeDistributionConfiguration(distInfoFile, appPath, extraPackages),
52
53
  this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),
53
54
  ]))[0];
54
55
  if (identity == null && packager.forceCodeSigning) {
@@ -56,6 +57,9 @@ class PkgTarget extends core_1.Target {
56
57
  }
57
58
  const args = prepareProductBuildArgs(identity, keychainFile);
58
59
  args.push("--distribution", distInfoFile);
60
+ if (extraPackages) {
61
+ args.push("--package-path", extraPackages.packagePath);
62
+ }
59
63
  args.push(artifactPath);
60
64
  (0, builder_util_1.use)(options.productbuild, it => args.push(...it));
61
65
  await (0, builder_util_1.exec)("productbuild", args, {
@@ -64,11 +68,42 @@ class PkgTarget extends core_1.Target {
64
68
  await Promise.all([(0, promises_1.unlink)(innerPackageFile), (0, promises_1.unlink)(distInfoFile)]);
65
69
  await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, "pkg", arch));
66
70
  }
67
- async customizeDistributionConfiguration(distInfoFile, appPath) {
68
- await (0, builder_util_1.exec)("productbuild", ["--synthesize", "--component", appPath, distInfoFile], {
71
+ getExtraPackages() {
72
+ const extraPkgsDir = this.options.extraPkgsDir;
73
+ if (extraPkgsDir == null) {
74
+ return null;
75
+ }
76
+ const packagePath = path.join(this.packager.info.buildResourcesDir, extraPkgsDir);
77
+ let files;
78
+ try {
79
+ files = (0, fs_1.readdirSync)(packagePath);
80
+ }
81
+ catch (e) {
82
+ if (e.code === "ENOENT") {
83
+ return null;
84
+ }
85
+ else {
86
+ throw e;
87
+ }
88
+ }
89
+ const packages = files.filter(file => file.endsWith(".pkg"));
90
+ if (packages.length === 0) {
91
+ return null;
92
+ }
93
+ return { packagePath, packages };
94
+ }
95
+ async customizeDistributionConfiguration(distInfoFile, appPath, extraPackages) {
96
+ const options = this.options;
97
+ const args = ["--synthesize", "--component", appPath];
98
+ if (extraPackages) {
99
+ extraPackages.packages.forEach(pkg => {
100
+ args.push("--package", path.join(extraPackages.packagePath, pkg));
101
+ });
102
+ }
103
+ args.push(distInfoFile);
104
+ await (0, builder_util_1.exec)("productbuild", args, {
69
105
  cwd: this.outDir,
70
106
  });
71
- const options = this.options;
72
107
  let distInfo = await (0, promises_1.readFile)(distInfoFile, "utf-8");
73
108
  if (options.mustClose != null && options.mustClose.length !== 0) {
74
109
  const startContent = ` <pkg-ref id="${this.packager.appInfo.id}">\n <must-close>\n`;
@@ -1 +1 @@
1
- {"version":3,"file":"pkg.js","sourceRoot":"","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AAA,mBAAI,EAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC;CACF;AA3LD,8BA2LC;AAED,SAAgB,uBAAuB,CAAC,QAAyB,EAAE,QAA0B;IAC3F,MAAM,IAAI,GAAkB,EAAE,CAAA;IAC9B,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAK,CAAC,CAAA;QACnC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QACnC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { Arch, debug, exec, statOrNull, use } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { readdirSync } from \"fs\"\nimport { readFile, unlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { findIdentity, Identity } from \"../codeSign/macCodeSign\"\nimport { Target } from \"../core\"\nimport { MacPackager } from \"../macPackager\"\nimport { PkgOptions } from \"../options/pkgOptions\"\nimport { executeAppBuilderAndWriteJson, executeAppBuilderAsJson } from \"../util/appBuilder\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\n\nconst certType = \"Developer ID Installer\"\n\n// http://www.shanekirk.com/2013/10/creating-flat-packages-in-osx/\n// to use --scripts, we must build .app bundle separately using pkgbuild\n// productbuild --scripts doesn't work (because scripts in this case not added to our package)\n// https://github.com/electron-userland/@electron/osx-sign/issues/96#issuecomment-274986942\nexport class PkgTarget extends Target {\n readonly options: PkgOptions = {\n allowAnywhere: true,\n allowCurrentUserHome: true,\n allowRootDirectory: true,\n ...this.packager.config.pkg,\n }\n\n constructor(\n private readonly packager: MacPackager,\n readonly outDir: string\n ) {\n super(\"pkg\")\n }\n\n async build(appPath: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n const appInfo = packager.appInfo\n\n // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg)\n const artifactName = packager.expandArtifactNamePattern(options, \"pkg\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"pkg\",\n file: artifactPath,\n arch,\n })\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n\n const appOutDir = this.outDir\n // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html\n const distInfoFile = path.join(appOutDir, \"distribution.xml\")\n\n const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`)\n const componentPropertyListFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.plist`)\n const identity = (\n await Promise.all([\n findIdentity(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),\n this.customizeDistributionConfiguration(distInfoFile, appPath),\n this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),\n ])\n )[0]\n\n if (identity == null && packager.forceCodeSigning) {\n throw new Error(`Cannot find valid \"${certType}\" to sign standalone installer, please see https://electron.build/code-signing`)\n }\n\n const args = prepareProductBuildArgs(identity, keychainFile)\n args.push(\"--distribution\", distInfoFile)\n args.push(artifactPath)\n use(options.productbuild, it => args.push(...(it as any)))\n await exec(\"productbuild\", args, {\n cwd: appOutDir,\n })\n await Promise.all([unlink(innerPackageFile), unlink(distInfoFile)])\n\n await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, \"pkg\", arch))\n }\n\n private async customizeDistributionConfiguration(distInfoFile: string, appPath: string) {\n await exec(\"productbuild\", [\"--synthesize\", \"--component\", appPath, distInfoFile], {\n cwd: this.outDir,\n })\n\n const options = this.options\n let distInfo = await readFile(distInfoFile, \"utf-8\")\n\n if (options.mustClose != null && options.mustClose.length !== 0) {\n const startContent = ` <pkg-ref id=\"${this.packager.appInfo.id}\">\\n <must-close>\\n`\n const endContent = \" </must-close>\\n </pkg-ref>\\n</installer-gui-script>\"\n let mustCloseContent = \"\"\n options.mustClose.forEach(appId => {\n mustCloseContent += ` <app id=\"${appId}\"/>\\n`\n })\n distInfo = distInfo.replace(\"</installer-gui-script>\", `${startContent}${mustCloseContent}${endContent}`)\n }\n\n const insertIndex = distInfo.lastIndexOf(\"</installer-gui-script>\")\n distInfo =\n distInfo.substring(0, insertIndex) +\n ` <domains enable_anywhere=\"${options.allowAnywhere}\" enable_currentUserHome=\"${options.allowCurrentUserHome}\" enable_localSystem=\"${options.allowRootDirectory}\" />\\n` +\n distInfo.substring(insertIndex)\n\n if (options.background != null) {\n const background = await this.packager.getResource(options.background.file)\n if (background != null) {\n const alignment = options.background.alignment || \"center\"\n // noinspection SpellCheckingInspection\n const scaling = options.background.scaling || \"tofit\"\n distInfo = distInfo.substring(0, insertIndex) + ` <background file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n distInfo =\n distInfo.substring(0, insertIndex) + ` <background-darkAqua file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n }\n }\n\n const welcome = await this.packager.getResource(options.welcome)\n if (welcome != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <welcome file=\"${welcome}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const license = await getNotLocalizedLicenseFile(options.license, this.packager)\n if (license != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <license file=\"${license}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const conclusion = await this.packager.getResource(options.conclusion)\n if (conclusion != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <conclusion file=\"${conclusion}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n debug(distInfo)\n await writeFile(distInfoFile, distInfo)\n }\n\n private async buildComponentPackage(appPath: string, propertyListOutputFile: string, packageOutputFile: string) {\n const options = this.options\n const rootPath = path.dirname(appPath)\n\n // first produce a component plist template\n await exec(\"pkgbuild\", [\"--analyze\", \"--root\", rootPath, propertyListOutputFile])\n\n // process the template plist\n const plistInfo = (await executeAppBuilderAsJson<Array<any>>([\"decode-plist\", \"-f\", propertyListOutputFile]))[0].filter(\n (it: any) => it.RootRelativeBundlePath !== \"Electron.dSYM\"\n )\n let packageInfo: any = {}\n if (plistInfo.length > 0) {\n packageInfo = plistInfo[0]\n\n // ChildBundles lists all of electron binaries within the .app.\n // There is no particular reason for removing that key, except to be as close as possible to\n // the PackageInfo generated by previous versions of electron-builder.\n delete packageInfo.ChildBundles\n\n if (options.isRelocatable != null) {\n packageInfo.BundleIsRelocatable = options.isRelocatable\n }\n\n if (options.isVersionChecked != null) {\n packageInfo.BundleIsVersionChecked = options.isVersionChecked\n }\n\n if (options.hasStrictIdentifier != null) {\n packageInfo.BundleHasStrictIdentifier = options.hasStrictIdentifier\n }\n\n if (options.overwriteAction != null) {\n packageInfo.BundleOverwriteAction = options.overwriteAction\n }\n }\n\n // now build the package\n const args = [\"--root\", rootPath, \"--identifier\", this.packager.appInfo.id, \"--component-plist\", propertyListOutputFile]\n\n use(this.options.installLocation || \"/Applications\", it => args.push(\"--install-location\", it))\n\n // nasty nested ternary-statement, probably should optimize\n const scriptsDir =\n // user-provided scripts dir\n options.scripts != null\n ? path.resolve(this.packager.info.buildResourcesDir, options.scripts)\n : // fallback to default unless user explicitly sets null\n options.scripts !== null\n ? path.join(this.packager.info.buildResourcesDir, \"pkg-scripts\")\n : null\n if (scriptsDir && (await statOrNull(scriptsDir))?.isDirectory()) {\n const dirContents = readdirSync(scriptsDir)\n dirContents.forEach(name => {\n if (name.includes(\"preinstall\")) {\n packageInfo.BundlePreInstallScriptPath = name\n } else if (name.includes(\"postinstall\")) {\n packageInfo.BundlePostInstallScriptPath = name\n }\n })\n args.push(\"--scripts\", scriptsDir)\n }\n if (plistInfo.length > 0) {\n await executeAppBuilderAndWriteJson([\"encode-plist\"], { [propertyListOutputFile]: plistInfo })\n }\n\n args.push(packageOutputFile)\n\n await exec(\"pkgbuild\", args)\n }\n}\n\nexport function prepareProductBuildArgs(identity: Identity | null, keychain: string | Nullish): Array<string> {\n const args: Array<string> = []\n if (identity != null) {\n args.push(\"--sign\", identity.hash!)\n if (keychain != null) {\n args.push(\"--keychain\", keychain)\n }\n }\n return args\n}\n"]}
1
+ {"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../src/targets/pkg.ts"],"names":[],"mappings":";;;AAwPA,0DASC;AAjQD,+CAAiE;AAEjE,2BAAgC;AAChC,0CAAyD;AACzD,6BAA4B;AAC5B,wCAAqD;AACrD,yDAAgE;AAChE,kCAAgC;AAGhC,mDAA2F;AAC3F,6CAA4D;AAE5D,MAAM,QAAQ,GAAG,wBAAwB,CAAA;AAOzC,kEAAkE;AAClE,wEAAwE;AACxE,8FAA8F;AAC9F,2FAA2F;AAC3F,MAAa,SAAU,SAAQ,aAAM;IAQnC,YACmB,QAAqB,EAC7B,MAAc;QAEvB,KAAK,CAAC,KAAK,CAAC,CAAA;QAHK,aAAQ,GAAR,QAAQ,CAAa;QAC7B,WAAM,GAAN,MAAM,CAAQ;QAThB,YAAO,GAAe;YAC7B,aAAa,EAAE,IAAI;YACnB,oBAAoB,EAAE,IAAI;YAC1B,kBAAkB,EAAE,IAAI;YACxB,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;SAC5B,CAAA;IAOD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAe,EAAE,IAAU;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;QAEhC,8IAA8I;QAC9I,MAAM,YAAY,GAAG,QAAQ,CAAC,yBAAyB,CAAC,OAAO,EAAE,KAAK,E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Q,CAAC,aAAa,CAAC,EAAE,CAAC;oBACxC,WAAW,CAAC,2BAA2B,GAAG,IAAI,CAAA;gBAChD,CAAC;YACH,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QACpC,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAA,0CAA6B,EAAC,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;QAChG,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAE5B,MAAM,IAAA,mBAAI,EAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC;CACF;AA9ND,8BA8NC;AAED,SAAgB,uBAAuB,CAAC,QAAyB,EAAE,QAA0B;IAC3F,MAAM,IAAI,GAAkB,EAAE,CAAA;IAC9B,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAK,CAAC,CAAA;QACnC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QACnC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { Arch, debug, exec, statOrNull, use } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { readdirSync } from \"fs\"\nimport { readFile, unlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { findIdentity, Identity } from \"../codeSign/macCodeSign\"\nimport { Target } from \"../core\"\nimport { MacPackager } from \"../macPackager\"\nimport { PkgOptions } from \"../options/pkgOptions\"\nimport { executeAppBuilderAndWriteJson, executeAppBuilderAsJson } from \"../util/appBuilder\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\n\nconst certType = \"Developer ID Installer\"\n\ntype ExtraPackages = {\n packagePath: string\n packages: string[]\n}\n\n// http://www.shanekirk.com/2013/10/creating-flat-packages-in-osx/\n// to use --scripts, we must build .app bundle separately using pkgbuild\n// productbuild --scripts doesn't work (because scripts in this case not added to our package)\n// https://github.com/electron-userland/@electron/osx-sign/issues/96#issuecomment-274986942\nexport class PkgTarget extends Target {\n readonly options: PkgOptions = {\n allowAnywhere: true,\n allowCurrentUserHome: true,\n allowRootDirectory: true,\n ...this.packager.config.pkg,\n }\n\n constructor(\n private readonly packager: MacPackager,\n readonly outDir: string\n ) {\n super(\"pkg\")\n }\n\n async build(appPath: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n const appInfo = packager.appInfo\n\n // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg)\n const artifactName = packager.expandArtifactNamePattern(options, \"pkg\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"pkg\",\n file: artifactPath,\n arch,\n })\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n\n const appOutDir = this.outDir\n // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html\n const distInfoFile = path.join(appOutDir, \"distribution.xml\")\n\n const extraPackages = this.getExtraPackages()\n\n const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`)\n const componentPropertyListFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.plist`)\n const identity = (\n await Promise.all([\n findIdentity(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),\n this.customizeDistributionConfiguration(distInfoFile, appPath, extraPackages),\n this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),\n ])\n )[0]\n\n if (identity == null && packager.forceCodeSigning) {\n throw new Error(`Cannot find valid \"${certType}\" to sign standalone installer, please see https://electron.build/code-signing`)\n }\n\n const args = prepareProductBuildArgs(identity, keychainFile)\n args.push(\"--distribution\", distInfoFile)\n if (extraPackages) {\n args.push(\"--package-path\", extraPackages.packagePath)\n }\n args.push(artifactPath)\n use(options.productbuild, it => args.push(...(it as any)))\n await exec(\"productbuild\", args, {\n cwd: appOutDir,\n })\n await Promise.all([unlink(innerPackageFile), unlink(distInfoFile)])\n\n await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, \"pkg\", arch))\n }\n\n private getExtraPackages(): ExtraPackages | null {\n const extraPkgsDir = this.options.extraPkgsDir\n if (extraPkgsDir == null) {\n return null\n }\n const packagePath = path.join(this.packager.info.buildResourcesDir, extraPkgsDir)\n let files: Array<string>\n try {\n files = readdirSync(packagePath)\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n return null\n } else {\n throw e\n }\n }\n const packages = files.filter(file => file.endsWith(\".pkg\"))\n if (packages.length === 0) {\n return null\n }\n return { packagePath, packages }\n }\n\n private async customizeDistributionConfiguration(distInfoFile: string, appPath: string, extraPackages: ExtraPackages | null) {\n const options = this.options\n const args = [\"--synthesize\", \"--component\", appPath]\n if (extraPackages) {\n extraPackages.packages.forEach(pkg => {\n args.push(\"--package\", path.join(extraPackages.packagePath, pkg))\n })\n }\n args.push(distInfoFile)\n await exec(\"productbuild\", args, {\n cwd: this.outDir,\n })\n\n let distInfo = await readFile(distInfoFile, \"utf-8\")\n\n if (options.mustClose != null && options.mustClose.length !== 0) {\n const startContent = ` <pkg-ref id=\"${this.packager.appInfo.id}\">\\n <must-close>\\n`\n const endContent = \" </must-close>\\n </pkg-ref>\\n</installer-gui-script>\"\n let mustCloseContent = \"\"\n options.mustClose.forEach(appId => {\n mustCloseContent += ` <app id=\"${appId}\"/>\\n`\n })\n distInfo = distInfo.replace(\"</installer-gui-script>\", `${startContent}${mustCloseContent}${endContent}`)\n }\n\n const insertIndex = distInfo.lastIndexOf(\"</installer-gui-script>\")\n distInfo =\n distInfo.substring(0, insertIndex) +\n ` <domains enable_anywhere=\"${options.allowAnywhere}\" enable_currentUserHome=\"${options.allowCurrentUserHome}\" enable_localSystem=\"${options.allowRootDirectory}\" />\\n` +\n distInfo.substring(insertIndex)\n\n if (options.background != null) {\n const background = await this.packager.getResource(options.background.file)\n if (background != null) {\n const alignment = options.background.alignment || \"center\"\n // noinspection SpellCheckingInspection\n const scaling = options.background.scaling || \"tofit\"\n distInfo = distInfo.substring(0, insertIndex) + ` <background file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n distInfo =\n distInfo.substring(0, insertIndex) + ` <background-darkAqua file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n }\n }\n\n const welcome = await this.packager.getResource(options.welcome)\n if (welcome != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <welcome file=\"${welcome}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const license = await getNotLocalizedLicenseFile(options.license, this.packager)\n if (license != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <license file=\"${license}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const conclusion = await this.packager.getResource(options.conclusion)\n if (conclusion != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <conclusion file=\"${conclusion}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n debug(distInfo)\n await writeFile(distInfoFile, distInfo)\n }\n\n private async buildComponentPackage(appPath: string, propertyListOutputFile: string, packageOutputFile: string) {\n const options = this.options\n const rootPath = path.dirname(appPath)\n\n // first produce a component plist template\n await exec(\"pkgbuild\", [\"--analyze\", \"--root\", rootPath, propertyListOutputFile])\n\n // process the template plist\n const plistInfo = (await executeAppBuilderAsJson<Array<any>>([\"decode-plist\", \"-f\", propertyListOutputFile]))[0].filter(\n (it: any) => it.RootRelativeBundlePath !== \"Electron.dSYM\"\n )\n let packageInfo: any = {}\n if (plistInfo.length > 0) {\n packageInfo = plistInfo[0]\n\n // ChildBundles lists all of electron binaries within the .app.\n // There is no particular reason for removing that key, except to be as close as possible to\n // the PackageInfo generated by previous versions of electron-builder.\n delete packageInfo.ChildBundles\n\n if (options.isRelocatable != null) {\n packageInfo.BundleIsRelocatable = options.isRelocatable\n }\n\n if (options.isVersionChecked != null) {\n packageInfo.BundleIsVersionChecked = options.isVersionChecked\n }\n\n if (options.hasStrictIdentifier != null) {\n packageInfo.BundleHasStrictIdentifier = options.hasStrictIdentifier\n }\n\n if (options.overwriteAction != null) {\n packageInfo.BundleOverwriteAction = options.overwriteAction\n }\n }\n\n // now build the package\n const args = [\"--root\", rootPath, \"--identifier\", this.packager.appInfo.id, \"--component-plist\", propertyListOutputFile]\n\n use(this.options.installLocation || \"/Applications\", it => args.push(\"--install-location\", it))\n\n // nasty nested ternary-statement, probably should optimize\n const scriptsDir =\n // user-provided scripts dir\n options.scripts != null\n ? path.resolve(this.packager.info.buildResourcesDir, options.scripts)\n : // fallback to default unless user explicitly sets null\n options.scripts !== null\n ? path.join(this.packager.info.buildResourcesDir, \"pkg-scripts\")\n : null\n if (scriptsDir && (await statOrNull(scriptsDir))?.isDirectory()) {\n const dirContents = readdirSync(scriptsDir)\n dirContents.forEach(name => {\n if (name.includes(\"preinstall\")) {\n packageInfo.BundlePreInstallScriptPath = name\n } else if (name.includes(\"postinstall\")) {\n packageInfo.BundlePostInstallScriptPath = name\n }\n })\n args.push(\"--scripts\", scriptsDir)\n }\n if (plistInfo.length > 0) {\n await executeAppBuilderAndWriteJson([\"encode-plist\"], { [propertyListOutputFile]: plistInfo })\n }\n\n args.push(packageOutputFile)\n\n await exec(\"pkgbuild\", args)\n }\n}\n\nexport function prepareProductBuildArgs(identity: Identity | null, keychain: string | Nullish): Array<string> {\n const args: Array<string> = []\n if (identity != null) {\n args.push(\"--sign\", identity.hash!)\n if (keychain != null) {\n args.push(\"--keychain\", keychain)\n }\n }\n return args\n}\n"]}
@@ -80,10 +80,20 @@ function checkDependencies(dependencies, errors) {
80
80
  if (dependencies == null) {
81
81
  return;
82
82
  }
83
- const updaterVersion = dependencies["electron-updater"];
84
- const requiredElectronUpdaterVersion = "4.0.0";
85
- if (updaterVersion != null && !versionSatisfies(updaterVersion, `>=${requiredElectronUpdaterVersion}`)) {
86
- errors.push(`At least electron-updater ${requiredElectronUpdaterVersion} is recommended by current electron-builder version. Please set electron-updater version to "^${requiredElectronUpdaterVersion}"`);
83
+ let updaterVersion = dependencies["electron-updater"];
84
+ if (updaterVersion != null) {
85
+ // Pick the version out of yarn berry patch syntax
86
+ // "patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch"
87
+ if (updaterVersion.startsWith("patch:")) {
88
+ const match = updaterVersion.match(/@npm%3A(.+?)#/);
89
+ if (match) {
90
+ updaterVersion = match[1];
91
+ }
92
+ }
93
+ const requiredElectronUpdaterVersion = "4.0.0";
94
+ if (!versionSatisfies(updaterVersion, `>=${requiredElectronUpdaterVersion}`)) {
95
+ errors.push(`At least electron-updater ${requiredElectronUpdaterVersion} is recommended by current electron-builder version. Please set electron-updater version to "^${requiredElectronUpdaterVersion}"`);
96
+ }
87
97
  }
88
98
  const swVersion = dependencies["electron-builder-squirrel-windows"];
89
99
  if (swVersion != null && !versionSatisfies(swVersion, ">=20.32.0")) {
@@ -1 +1 @@
1
- {"version":3,"file":"packageMetadata.js","sourceRoot":"","sources":["../../src/util/packageMetadata.ts"],"names":[],"mappings":";;AASA,0CAQC;AAkBD,sCA6CC;AAhFD,+CAA8E;AAE9E,uCAA6C;AAC7C,6BAA4B;AAC5B,iCAAgC;AAEhC,iEAA6D;AAE7D,gBAAgB;AACT,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAA;IACjC,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAA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C,YAAY,IAAI,0CAA0C,GAAG,wEAAwE,CAAC,CAAA;QACpJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { readFile, readJson } from \"fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Metadata } from \"../options/metadata\"\nimport { normalizePackageData } from \"./normalizePackageData\"\n\n/** @internal */\nexport async function readPackageJson(file: string): Promise<any> {\n const data = await 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 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): 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 if ((metadata as any).directories != null) {\n errors.push(`\"directories\" in the root is deprecated, please specify in the \"build\"`)\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)\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 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>) {\n if (dependencies == null) {\n return\n }\n\n const updaterVersion = dependencies[\"electron-updater\"]\n const requiredElectronUpdaterVersion = \"4.0.0\"\n if (updaterVersion != null && !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}\"`\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 const deps = [\"electron\", \"electron-prebuilt\", \"electron-rebuild\"]\n if (process.env.ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY !== \"true\") {\n deps.push(\"electron-builder\")\n }\n for (const name of deps) {\n if (name in dependencies) {\n errors.push(`Package \"${name}\" is only allowed in \"devDependencies\". ` + `Please remove it from the \"dependencies\" section in your package.json.`)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"packageMetadata.js","sourceRoot":"","sources":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AA8B,iGAAiG,8BAA8B,GAAG,CAC9L,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;IAED,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAA;IAClE,IAAI,OAAO,CAAC,GAAG,CAAC,+CAA+C,KAAK,MAAM,EAAE,CAAC;QAC3E,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC/B,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,IAAI,IAAI,YAAY,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,YAAY,IAAI,0CAA0C,GAAG,wEAAwE,CAAC,CAAA;QACpJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { readFile, readJson } from \"fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Metadata } from \"../options/metadata\"\nimport { normalizePackageData } from \"./normalizePackageData\"\n\n/** @internal */\nexport async function readPackageJson(file: string): Promise<any> {\n const data = await 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 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): 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 if ((metadata as any).directories != null) {\n errors.push(`\"directories\" in the root is deprecated, please specify in the \"build\"`)\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)\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 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>) {\n if (dependencies == null) {\n return\n }\n\n let updaterVersion = dependencies[\"electron-updater\"]\n if (updaterVersion != null) {\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 match = updaterVersion.match(/@npm%3A(.+?)#/)\n if (match) {\n updaterVersion = match[1]\n }\n }\n\n const requiredElectronUpdaterVersion = \"4.0.0\"\n if (!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}\"`\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 const deps = [\"electron\", \"electron-prebuilt\", \"electron-rebuild\"]\n if (process.env.ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY !== \"true\") {\n deps.push(\"electron-builder\")\n }\n for (const name of deps) {\n if (name in dependencies) {\n errors.push(`Package \"${name}\" is only allowed in \"devDependencies\". ` + `Please remove it from the \"dependencies\" section in your package.json.`)\n }\n }\n}\n"]}
package/out/util/yarn.js CHANGED
@@ -59,7 +59,7 @@ function getGypEnv(frameworkInfo, platform, arch, buildFromSource) {
59
59
  // https://github.com/nodejs/node-gyp/issues/21
60
60
  return {
61
61
  ...common,
62
- npm_config_disturl: "https://electronjs.org/headers",
62
+ npm_config_disturl: common.npm_config_electron_mirror || "https://electronjs.org/headers",
63
63
  npm_config_target: frameworkInfo.version,
64
64
  npm_config_runtime: "electron",
65
65
  npm_config_devdir: getElectronGypCacheDir(),
@@ -1 +1 @@
1
- {"version":3,"file":"yarn.js","sourceRoot":"","sources":["../../src/util/yarn.ts"],"names":[],"mappings":";;AAcA,4CAqBC;AAWD,8BAiCC;AAkDD,wCAiBC;AA4BD,0BAuCC;AApND,uEAAwE;AAExE,+CA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GAAG,aAAa,CAAA;IAEzD,IAAI,MAAM,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,CAAC,CAAA;QAC7E,OAAO,IAAA,0CAA6B,EAAC,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;IACrG,CAAC;IAED,MAAM,EACJ,aAAa,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,GAC5C,GAAG,OAAO,CAAA;IACX,MAAM,OAAO,GAAG;QACd,eAAe;QACf,IAAI;QACJ,eAAe;QACf,MAAM,EAAE,kBAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI;KACrC,CAAA;IACD,kBAAG,CAAC,IAAI,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAA;IAEhD,MAAM,cAAc,GAAmC;QACrD,SAAS,EAAE,MAAM;QACjB,eAAe;QACf,IAAI;QACJ,QAAQ;QACR,eAAe;QACf,eAAe,EAAE,MAAM,IAAA,kCAAkB,EAAC,MAAM,CAAC;QACjD,IAAI,EAAG,MAAM,CAAC,eAA+B,IAAI,YAAY;QAC7D,iBAAiB,EAAE,IAAI;KACxB,CAAA;IACD,OAAO,IAAA,iBAAa,EAAC,cAAc,CAAC,CAAA;AACtC,CAAC","sourcesContent":["import * as electronRebuild from \"@electron/rebuild\"\nimport { getProjectRootPath } from \"@electron/rebuild/lib/search-module\"\nimport { RebuildMode } from \"@electron/rebuild/lib/types\"\nimport { asArray, log, spawn } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { pathExists } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport { homedir } from \"os\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { executeAppBuilderAndWriteJson } from \"./appBuilder\"\nimport { NodeModuleDirInfo } from \"./packageDependencies\"\nimport { rebuild as remoteRebuild } from \"./rebuild/rebuild\"\n\nexport async function installOrRebuild(config: Configuration, appDir: string, options: RebuildOptions, forceInstall = false) {\n const effectiveOptions: RebuildOptions = {\n buildFromSource: config.buildDependenciesFromSource === true,\n additionalArgs: asArray(config.npmArgs),\n ...options,\n }\n let isDependenciesInstalled = false\n\n for (const fileOrDir of [\"node_modules\", \".pnp.js\"]) {\n if (await pathExists(path.join(appDir, fileOrDir))) {\n isDependenciesInstalled = true\n\n break\n }\n }\n\n if (forceInstall || !isDependenciesInstalled) {\n await installDependencies(config, appDir, effectiveOptions)\n } else {\n await rebuild(config, appDir, effectiveOptions)\n }\n}\n\nexport interface DesktopFrameworkInfo {\n version: string\n useCustomDist: boolean\n}\n\nfunction getElectronGypCacheDir() {\n return path.join(homedir(), \".electron-gyp\")\n}\n\nexport function getGypEnv(frameworkInfo: DesktopFrameworkInfo, platform: NodeJS.Platform, arch: string, buildFromSource: boolean) {\n const npmConfigArch = arch === \"armv7l\" ? \"arm\" : arch\n const common: any = {\n ...process.env,\n npm_config_arch: npmConfigArch,\n npm_config_target_arch: npmConfigArch,\n npm_config_platform: platform,\n npm_config_build_from_source: buildFromSource,\n // required for node-pre-gyp\n npm_config_target_platform: platform,\n npm_config_update_binary: true,\n npm_config_fallback_to_build: true,\n }\n\n if (platform !== process.platform) {\n common.npm_config_force = \"true\"\n }\n if (platform === \"win32\" || platform === \"darwin\") {\n common.npm_config_target_libc = \"unknown\"\n }\n\n if (!frameworkInfo.useCustomDist) {\n return common\n }\n\n // https://github.com/nodejs/node-gyp/issues/21\n return {\n ...common,\n npm_config_disturl: \"https://electronjs.org/headers\",\n npm_config_target: frameworkInfo.version,\n npm_config_runtime: \"electron\",\n npm_config_devdir: getElectronGypCacheDir(),\n }\n}\n\nfunction checkYarnBerry() {\n const npmUserAgent = process.env[\"npm_config_user_agent\"] || \"\"\n const regex = /yarn\\/(\\d+)\\./gm\n\n const yarnVersionMatch = regex.exec(npmUserAgent)\n const yarnMajorVersion = Number(yarnVersionMatch?.[1] ?? 0)\n return yarnMajorVersion >= 2\n}\n\nasync function installDependencies(config: Configuration, appDir: string, options: RebuildOptions): Promise<any> {\n const platform = options.platform || process.platform\n const arch = options.arch || process.arch\n const additionalArgs = options.additionalArgs\n\n log.info({ platform, arch, appDir }, `installing production dependencies`)\n let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS\n const execArgs = [\"install\"]\n const isYarnBerry = checkYarnBerry()\n if (!isYarnBerry) {\n if (process.env.NPM_NO_BIN_LINKS === \"true\") {\n execArgs.push(\"--no-bin-links\")\n }\n }\n\n if (!isRunningYarn(execPath)) {\n execArgs.push(\"--prefer-offline\")\n }\n\n if (execPath == null) {\n execPath = getPackageToolPath()\n } else if (!isYarnBerry) {\n execArgs.unshift(execPath)\n execPath = process.env.npm_node_execpath || process.env.NODE_EXE || \"node\"\n }\n\n if (additionalArgs != null) {\n execArgs.push(...additionalArgs)\n }\n await spawn(execPath, execArgs, {\n cwd: appDir,\n env: getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),\n })\n\n // Some native dependencies no longer use `install` hook for building their native module, (yarn 3+ removed implicit link of `install` and `rebuild` steps)\n // https://github.com/electron-userland/electron-builder/issues/8024\n return rebuild(config, appDir, options)\n}\n\nexport async function nodeGypRebuild(platform: NodeJS.Platform, arch: string, frameworkInfo: DesktopFrameworkInfo) {\n log.info({ platform, arch }, \"executing node-gyp rebuild\")\n // this script must be used only for electron\n const nodeGyp = `node-gyp${process.platform === \"win32\" ? \".cmd\" : \"\"}`\n const args = [\"rebuild\"]\n // headers of old Electron versions do not have a valid config.gypi file\n // and --force-process-config must be passed to node-gyp >= 8.4.0 to\n // correctly build modules for them.\n // see also https://github.com/nodejs/node-gyp/pull/2497\n const [major, minor] = frameworkInfo.version\n .split(\".\")\n .slice(0, 2)\n .map(n => parseInt(n, 10))\n if (major <= 13 || (major == 14 && minor <= 1) || (major == 15 && minor <= 2)) {\n args.push(\"--force-process-config\")\n }\n await spawn(nodeGyp, args, { env: getGypEnv(frameworkInfo, platform, arch, true) })\n}\n\nfunction getPackageToolPath() {\n if (process.env.FORCE_YARN === \"true\") {\n return process.platform === \"win32\" ? \"yarn.cmd\" : \"yarn\"\n } else {\n return process.platform === \"win32\" ? \"npm.cmd\" : \"npm\"\n }\n}\n\nfunction isRunningYarn(execPath: string | Nullish) {\n const userAgent = process.env.npm_config_user_agent\n return process.env.FORCE_YARN === \"true\" || (execPath != null && path.basename(execPath).startsWith(\"yarn\")) || (userAgent != null && /\\byarn\\b/.test(userAgent))\n}\n\nexport interface RebuildOptions {\n frameworkInfo: DesktopFrameworkInfo\n productionDeps: Lazy<Array<NodeModuleDirInfo>>\n\n platform?: NodeJS.Platform\n arch?: string\n\n buildFromSource?: boolean\n\n additionalArgs?: Array<string> | null\n}\n\n/** @internal */\nexport async function rebuild(config: Configuration, appDir: string, options: RebuildOptions) {\n const configuration = {\n dependencies: await options.productionDeps.value,\n nodeExecPath: process.execPath,\n platform: options.platform || process.platform,\n arch: options.arch || process.arch,\n additionalArgs: options.additionalArgs,\n execPath: process.env.npm_execpath || process.env.NPM_CLI_JS,\n buildFromSource: options.buildFromSource === true,\n }\n const { arch, buildFromSource, platform } = configuration\n\n if (config.nativeRebuilder === \"legacy\") {\n const env = getGypEnv(options.frameworkInfo, platform, arch, buildFromSource)\n return executeAppBuilderAndWriteJson([\"rebuild-node-modules\"], configuration, { env, cwd: appDir })\n }\n\n const {\n frameworkInfo: { version: electronVersion },\n } = options\n const logInfo = {\n electronVersion,\n arch,\n buildFromSource,\n appDir: log.filePath(appDir) || \"./\",\n }\n log.info(logInfo, \"executing @electron/rebuild\")\n\n const rebuildOptions: electronRebuild.RebuildOptions = {\n buildPath: appDir,\n electronVersion,\n arch,\n platform,\n buildFromSource,\n projectRootPath: await getProjectRootPath(appDir),\n mode: (config.nativeRebuilder as RebuildMode) || \"sequential\",\n disablePreGypCopy: true,\n }\n return remoteRebuild(rebuildOptions)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Q,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU;QAC5D,eAAe,EAAE,OAAO,CAAC,eAAe,KAAK,IAAI;KAClD,CAAA;IACD,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAA;IAEzD,IAAI,MAAM,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,CAAC,CAAA;QAC7E,OAAO,IAAA,0CAA6B,EAAC,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;IACrG,CAAC;IAED,MAAM,EACJ,aAAa,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,GAC5C,GAAG,OAAO,CAAA;IACX,MAAM,OAAO,GAAG;QACd,eAAe;QACf,IAAI;QACJ,eAAe;QACf,MAAM,EAAE,kBAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI;KACrC,CAAA;IACD,kBAAG,CAAC,IAAI,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAA;IAEhD,MAAM,cAAc,GAAmC;QACrD,SAAS,EAAE,MAAM;QACjB,eAAe;QACf,IAAI;QACJ,QAAQ;QACR,eAAe;QACf,eAAe,EAAE,MAAM,IAAA,kCAAkB,EAAC,MAAM,CAAC;QACjD,IAAI,EAAG,MAAM,CAAC,eAA+B,IAAI,YAAY;QAC7D,iBAAiB,EAAE,IAAI;KACxB,CAAA;IACD,OAAO,IAAA,iBAAa,EAAC,cAAc,CAAC,CAAA;AACtC,CAAC","sourcesContent":["import * as electronRebuild from \"@electron/rebuild\"\nimport { getProjectRootPath } from \"@electron/rebuild/lib/search-module\"\nimport { RebuildMode } from \"@electron/rebuild/lib/types\"\nimport { asArray, log, spawn } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { pathExists } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport { homedir } from \"os\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { executeAppBuilderAndWriteJson } from \"./appBuilder\"\nimport { NodeModuleDirInfo } from \"./packageDependencies\"\nimport { rebuild as remoteRebuild } from \"./rebuild/rebuild\"\n\nexport async function installOrRebuild(config: Configuration, appDir: string, options: RebuildOptions, forceInstall = false) {\n const effectiveOptions: RebuildOptions = {\n buildFromSource: config.buildDependenciesFromSource === true,\n additionalArgs: asArray(config.npmArgs),\n ...options,\n }\n let isDependenciesInstalled = false\n\n for (const fileOrDir of [\"node_modules\", \".pnp.js\"]) {\n if (await pathExists(path.join(appDir, fileOrDir))) {\n isDependenciesInstalled = true\n\n break\n }\n }\n\n if (forceInstall || !isDependenciesInstalled) {\n await installDependencies(config, appDir, effectiveOptions)\n } else {\n await rebuild(config, appDir, effectiveOptions)\n }\n}\n\nexport interface DesktopFrameworkInfo {\n version: string\n useCustomDist: boolean\n}\n\nfunction getElectronGypCacheDir() {\n return path.join(homedir(), \".electron-gyp\")\n}\n\nexport function getGypEnv(frameworkInfo: DesktopFrameworkInfo, platform: NodeJS.Platform, arch: string, buildFromSource: boolean) {\n const npmConfigArch = arch === \"armv7l\" ? \"arm\" : arch\n const common: any = {\n ...process.env,\n npm_config_arch: npmConfigArch,\n npm_config_target_arch: npmConfigArch,\n npm_config_platform: platform,\n npm_config_build_from_source: buildFromSource,\n // required for node-pre-gyp\n npm_config_target_platform: platform,\n npm_config_update_binary: true,\n npm_config_fallback_to_build: true,\n }\n\n if (platform !== process.platform) {\n common.npm_config_force = \"true\"\n }\n if (platform === \"win32\" || platform === \"darwin\") {\n common.npm_config_target_libc = \"unknown\"\n }\n\n if (!frameworkInfo.useCustomDist) {\n return common\n }\n\n // https://github.com/nodejs/node-gyp/issues/21\n return {\n ...common,\n npm_config_disturl: common.npm_config_electron_mirror || \"https://electronjs.org/headers\",\n npm_config_target: frameworkInfo.version,\n npm_config_runtime: \"electron\",\n npm_config_devdir: getElectronGypCacheDir(),\n }\n}\n\nfunction checkYarnBerry() {\n const npmUserAgent = process.env[\"npm_config_user_agent\"] || \"\"\n const regex = /yarn\\/(\\d+)\\./gm\n\n const yarnVersionMatch = regex.exec(npmUserAgent)\n const yarnMajorVersion = Number(yarnVersionMatch?.[1] ?? 0)\n return yarnMajorVersion >= 2\n}\n\nasync function installDependencies(config: Configuration, appDir: string, options: RebuildOptions): Promise<any> {\n const platform = options.platform || process.platform\n const arch = options.arch || process.arch\n const additionalArgs = options.additionalArgs\n\n log.info({ platform, arch, appDir }, `installing production dependencies`)\n let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS\n const execArgs = [\"install\"]\n const isYarnBerry = checkYarnBerry()\n if (!isYarnBerry) {\n if (process.env.NPM_NO_BIN_LINKS === \"true\") {\n execArgs.push(\"--no-bin-links\")\n }\n }\n\n if (!isRunningYarn(execPath)) {\n execArgs.push(\"--prefer-offline\")\n }\n\n if (execPath == null) {\n execPath = getPackageToolPath()\n } else if (!isYarnBerry) {\n execArgs.unshift(execPath)\n execPath = process.env.npm_node_execpath || process.env.NODE_EXE || \"node\"\n }\n\n if (additionalArgs != null) {\n execArgs.push(...additionalArgs)\n }\n await spawn(execPath, execArgs, {\n cwd: appDir,\n env: getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),\n })\n\n // Some native dependencies no longer use `install` hook for building their native module, (yarn 3+ removed implicit link of `install` and `rebuild` steps)\n // https://github.com/electron-userland/electron-builder/issues/8024\n return rebuild(config, appDir, options)\n}\n\nexport async function nodeGypRebuild(platform: NodeJS.Platform, arch: string, frameworkInfo: DesktopFrameworkInfo) {\n log.info({ platform, arch }, \"executing node-gyp rebuild\")\n // this script must be used only for electron\n const nodeGyp = `node-gyp${process.platform === \"win32\" ? \".cmd\" : \"\"}`\n const args = [\"rebuild\"]\n // headers of old Electron versions do not have a valid config.gypi file\n // and --force-process-config must be passed to node-gyp >= 8.4.0 to\n // correctly build modules for them.\n // see also https://github.com/nodejs/node-gyp/pull/2497\n const [major, minor] = frameworkInfo.version\n .split(\".\")\n .slice(0, 2)\n .map(n => parseInt(n, 10))\n if (major <= 13 || (major == 14 && minor <= 1) || (major == 15 && minor <= 2)) {\n args.push(\"--force-process-config\")\n }\n await spawn(nodeGyp, args, { env: getGypEnv(frameworkInfo, platform, arch, true) })\n}\n\nfunction getPackageToolPath() {\n if (process.env.FORCE_YARN === \"true\") {\n return process.platform === \"win32\" ? \"yarn.cmd\" : \"yarn\"\n } else {\n return process.platform === \"win32\" ? \"npm.cmd\" : \"npm\"\n }\n}\n\nfunction isRunningYarn(execPath: string | Nullish) {\n const userAgent = process.env.npm_config_user_agent\n return process.env.FORCE_YARN === \"true\" || (execPath != null && path.basename(execPath).startsWith(\"yarn\")) || (userAgent != null && /\\byarn\\b/.test(userAgent))\n}\n\nexport interface RebuildOptions {\n frameworkInfo: DesktopFrameworkInfo\n productionDeps: Lazy<Array<NodeModuleDirInfo>>\n\n platform?: NodeJS.Platform\n arch?: string\n\n buildFromSource?: boolean\n\n additionalArgs?: Array<string> | null\n}\n\n/** @internal */\nexport async function rebuild(config: Configuration, appDir: string, options: RebuildOptions) {\n const configuration = {\n dependencies: await options.productionDeps.value,\n nodeExecPath: process.execPath,\n platform: options.platform || process.platform,\n arch: options.arch || process.arch,\n additionalArgs: options.additionalArgs,\n execPath: process.env.npm_execpath || process.env.NPM_CLI_JS,\n buildFromSource: options.buildFromSource === true,\n }\n const { arch, buildFromSource, platform } = configuration\n\n if (config.nativeRebuilder === \"legacy\") {\n const env = getGypEnv(options.frameworkInfo, platform, arch, buildFromSource)\n return executeAppBuilderAndWriteJson([\"rebuild-node-modules\"], configuration, { env, cwd: appDir })\n }\n\n const {\n frameworkInfo: { version: electronVersion },\n } = options\n const logInfo = {\n electronVersion,\n arch,\n buildFromSource,\n appDir: log.filePath(appDir) || \"./\",\n }\n log.info(logInfo, \"executing @electron/rebuild\")\n\n const rebuildOptions: electronRebuild.RebuildOptions = {\n buildPath: appDir,\n electronVersion,\n arch,\n platform,\n buildFromSource,\n projectRootPath: await getProjectRootPath(appDir),\n mode: (config.nativeRebuilder as RebuildMode) || \"sequential\",\n disablePreGypCopy: true,\n }\n return remoteRebuild(rebuildOptions)\n}\n"]}
package/out/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "26.0.1";
1
+ export declare const PACKAGE_VERSION = "26.0.2";
package/out/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = "26.0.1";
4
+ exports.PACKAGE_VERSION = "26.0.2";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"26.0.1\"\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"26.0.2\"\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "app-builder-lib",
3
3
  "description": "electron-builder lib",
4
- "version": "26.0.1",
4
+ "version": "26.0.2",
5
5
  "main": "out/index.js",
6
6
  "files": [
7
7
  "out",
@@ -75,9 +75,9 @@
75
75
  "tar": "^6.1.12",
76
76
  "temp-file": "^3.4.0",
77
77
  "tiny-async-pool": "1.3.0",
78
- "builder-util": "26.0.1",
79
78
  "builder-util-runtime": "9.3.1",
80
- "electron-publish": "26.0.1"
79
+ "electron-publish": "26.0.1",
80
+ "builder-util": "26.0.1"
81
81
  },
82
82
  "///": "babel in devDependencies for proton tests",
83
83
  "devDependencies": {
@@ -109,12 +109,12 @@
109
109
  "@types/tar": "^6.1.3",
110
110
  "@types/tiny-async-pool": "^1",
111
111
  "toml": "^3.0.0",
112
- "electron-builder-squirrel-windows": "26.0.1",
113
- "dmg-builder": "26.0.1"
112
+ "dmg-builder": "26.0.2",
113
+ "electron-builder-squirrel-windows": "26.0.2"
114
114
  },
115
115
  "peerDependencies": {
116
- "dmg-builder": "26.0.1",
117
- "electron-builder-squirrel-windows": "26.0.1"
116
+ "dmg-builder": "26.0.2",
117
+ "electron-builder-squirrel-windows": "26.0.2"
118
118
  },
119
119
  "//": "electron-builder-squirrel-windows and dmg-builder added as dev dep for tests (as otherwise `require` doesn't work using Yarn 2)",
120
120
  "typings": "./out/index.d.ts"
package/scheme.json CHANGED
@@ -4971,6 +4971,13 @@
4971
4971
  "string"
4972
4972
  ]
4973
4973
  },
4974
+ "extraPkgsDir": {
4975
+ "description": "The extra component packages directory (relative to build resources directory) for MacOS product archive\nAutoscans directory for any `.pkg` files and adds to `productbuild` command as `--package-path` and `--package` accordingly",
4976
+ "type": [
4977
+ "null",
4978
+ "string"
4979
+ ]
4980
+ },
4974
4981
  "hasStrictIdentifier": {
4975
4982
  "default": true,
4976
4983
  "description": "Require identical bundle identifiers at install path?",