Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Extract NotarizeNotaryOptions and NotarizeLegacyOptions to explicitly define required vars #7797

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-dogs-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix: Extract `NotarizeNotaryOptions` and `NotarizeLegacyOptions` to explicitly define required vars
2 changes: 1 addition & 1 deletion docs/configuration/mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The top-level [mac](configuration.md#Configuration-mac) key contains set of opti
<p>This option has no effect unless building for “universal” arch and applies only if <code>mergeASARs</code> is <code>true</code>.</p>
</li>
<li>
<p><code id="MacConfiguration-notarize">notarize</code> module:app-builder-lib/out/options/macOptions.NotarizeOptions | Boolean | “undefined” - Options to use for @electron/notarize (ref: <a href="https://github.com/electron/notarize">https://github.com/electron/notarize</a>). Supports both <code>legacy</code> and <code>notarytool</code> notarization tools. Use <code>false</code> to explicitly disable</p>
<p><code id="MacConfiguration-notarize">notarize</code> module:app-builder-lib/out/options/macOptions.NotarizeLegacyOptions | module:app-builder-lib/out/options/macOptions.NotarizeNotaryOptions | Boolean | “undefined” - Options to use for @electron/notarize (ref: <a href="https://github.com/electron/notarize">https://github.com/electron/notarize</a>). Supports both <code>legacy</code> and <code>notarytool</code> notarization tools. Use <code>false</code> to explicitly disable</p>
<p>Note: You MUST specify <code>APPLE_ID</code> and <code>APPLE_APP_SPECIFIC_PASSWORD</code> via environment variables to activate notarization step</p>
</li>
</ul>
Expand Down
30 changes: 21 additions & 9 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,10 @@
"notarize": {
"anyOf": [
{
"$ref": "#/definitions/NotarizeOptions"
"$ref": "#/definitions/NotarizeLegacyOptions"
},
{
"$ref": "#/definitions/NotarizeNotaryOptions"
},
{
"type": [
Expand Down Expand Up @@ -3298,7 +3301,10 @@
"notarize": {
"anyOf": [
{
"$ref": "#/definitions/NotarizeOptions"
"$ref": "#/definitions/NotarizeLegacyOptions"
},
{
"$ref": "#/definitions/NotarizeNotaryOptions"
},
{
"type": [
Expand Down Expand Up @@ -3872,7 +3878,7 @@
},
"type": "object"
},
"NotarizeOptions": {
"NotarizeLegacyOptions": {
"additionalProperties": false,
"properties": {
"appBundleId": {
Expand All @@ -3888,15 +3894,21 @@
"null",
"string"
]
},
}
},
"type": "object"
},
"NotarizeNotaryOptions": {
"additionalProperties": false,
"properties": {
"teamId": {
"description": "The team ID you want to notarize under. Only needed if using `notarytool`",
"type": [
"null",
"string"
]
"description": "The team ID you want to notarize under for when using `notarytool`",
"type": "string"
}
},
"required": [
"teamId"
],
"type": "object"
},
"NsisOptions": {
Expand Down
24 changes: 13 additions & 11 deletions packages/app-builder-lib/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AppInfo } from "./appInfo"
import { CertType, CodeSigningInfo, createKeychain, findIdentity, Identity, isSignAllowed, removeKeychain, reportError } from "./codeSign/macCodeSign"
import { DIR_TARGET, Platform, Target } from "./core"
import { AfterPackContext, ElectronPlatformName } from "./index"
import { MacConfiguration, MasConfiguration } from "./options/macOptions"
import { MacConfiguration, MasConfiguration, NotarizeLegacyOptions, NotarizeNotaryOptions } from "./options/macOptions"
import { Packager } from "./packager"
import { chooseNotNull, PlatformPackager } from "./platformPackager"
import { ArchiveTarget } from "./targets/ArchiveTarget"
Expand All @@ -21,6 +21,7 @@ import { isMacOsHighSierra } from "./util/macosVersion"
import { getTemplatePath } from "./util/pathManager"
import * as fs from "fs/promises"
import { notarize, NotarizeOptions } from "@electron/notarize"
import { LegacyNotarizePasswordCredentials, LegacyNotarizeStartOptions, NotaryToolNotarizeAppOptions, NotaryToolStartOptions } from "@electron/notarize/lib/types"

export default class MacPackager extends PlatformPackager<MacConfiguration> {
readonly codeSigningInfo = new Lazy<CodeSigningInfo>(() => {
Expand Down Expand Up @@ -502,27 +503,28 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> {
}

private generateNotarizeOptions(appPath: string, appleId: string, appleIdPassword: string): NotarizeOptions {
const baseOptions = { appPath, appleId, appleIdPassword }
const baseOptions: NotaryToolNotarizeAppOptions & LegacyNotarizePasswordCredentials = { appPath, appleId, appleIdPassword }
const options = this.platformSpecificBuildOptions.notarize
if (typeof options === "boolean") {
return {
const proj: LegacyNotarizeStartOptions = {
...baseOptions,
tool: "legacy",
appBundleId: this.appInfo.id,
}
return proj
}
if (options?.teamId) {
return {
const { teamId } = options as NotarizeNotaryOptions
if (teamId) {
const proj: NotaryToolStartOptions = {
...baseOptions,
tool: "notarytool",
teamId: options.teamId,
teamId,
}
return { tool: "notarytool", ...proj }
}
const { appBundleId, ascProvider } = options as NotarizeLegacyOptions
return {
...baseOptions,
tool: "legacy",
appBundleId: options?.appBundleId || this.appInfo.id,
ascProvider: options?.ascProvider || undefined,
appBundleId: appBundleId || this.appInfo.id,
ascProvider: ascProvider || undefined,
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions packages/app-builder-lib/src/options/macOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ export interface MacConfiguration extends PlatformSpecificBuildOptions {
*
* Note: You MUST specify `APPLE_ID` and `APPLE_APP_SPECIFIC_PASSWORD` via environment variables to activate notarization step
*/
readonly notarize?: NotarizeOptions | boolean | null
readonly notarize?: NotarizeLegacyOptions | NotarizeNotaryOptions | boolean | null
}

export interface NotarizeOptions {
export interface NotarizeLegacyOptions {
/**
* The app bundle identifier your Electron app is using. E.g. com.github.electron. Useful if notarization ID differs from app ID (unlikely).
* Only used by `legacy` notarization tool
Expand All @@ -226,11 +226,13 @@ export interface NotarizeOptions {
* Your Team Short Name. Only used by `legacy` notarization tool
*/
readonly ascProvider?: string | null
}

export interface NotarizeNotaryOptions {
/**
* The team ID you want to notarize under. Only needed if using `notarytool`
* The team ID you want to notarize under for when using `notarytool`
*/
readonly teamId?: string | null
readonly teamId: string
}

export interface DmgOptions extends TargetSpecificOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>

// convert if need, validate size (it is a reason why tool is called even if file has target extension (already specified as foo.icns for example))
async resolveIcon(sources: Array<string>, fallbackSources: Array<string>, outputFormat: IconFormat): Promise<Array<IconInfo>> {
const output = this.expandMacro(this.config.directories!.output!);
const output = this.expandMacro(this.config.directories!.output!)
const args = [
"icon",
"--format",
Expand Down
Loading