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: implement signApp function for macPackager #3912

Merged
merged 2 commits into from
May 25, 2019
Merged
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
34 changes: 30 additions & 4 deletions packages/app-builder-lib/src/macPackager.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import BluebirdPromise from "bluebird-lst"
import { deepAssign, Arch, AsyncTaskManager, exec, InvalidConfigurationError, log, use } from "builder-util"
import { signAsync, SignOptions } from "electron-osx-sign"
import { ensureDir } from "fs-extra-p"
import { ensureDir, readdir } from "fs-extra-p"
import { Lazy } from "lazy-val"
import * as path from "path"
import { copyFile, unlinkIfExists } from "builder-util/out/fs"
import { orIfFileNotExist } from "builder-util/out/promise"
import { AppInfo } from "./appInfo"
import { appleCertificatePrefixes, CertType, CodeSigningInfo, createKeychain, findIdentity, Identity, isSignAllowed, reportError } from "./codeSign/macCodeSign"
import { DIR_TARGET, Platform, Target } from "./core"
import { ElectronPlatformName } from "./index"
import { AfterPackContext, ElectronPlatformName } from "./index"
import { MacConfiguration, MasConfiguration } from "./options/macOptions"
import { Packager } from "./packager"
import { chooseNotNull, PlatformPackager } from "./platformPackager"
Expand Down Expand Up @@ -86,7 +88,6 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> {
if (!hasMas || targets.length > 1) {
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${this.appInfo.productFilename}.app`) : prepackaged
nonMasPromise = (prepackaged ? Promise.resolve() : this.doPack(outDir, path.dirname(appPath), this.platform.nodeName as ElectronPlatformName, arch, this.platformSpecificBuildOptions, targets))
.then(() => this.sign(appPath, null, null))
.then(() => this.packageInDistributableFormat(appPath, Arch.x64, targets, taskManager))
}

Expand Down Expand Up @@ -305,11 +306,36 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> {
Object.assign(appPlist, extendInfo)
}
}

protected async signApp(packContext: AfterPackContext, isAsar: boolean): Promise<any> {
const appFileName = `${this.appInfo.productFilename}.app`

await BluebirdPromise.map(readdir(packContext.appOutDir), (file: string): any => {
if (file === appFileName) {
return this.sign(path.join(packContext.appOutDir, file), null, null)
}
return null
})

if (!isAsar) {
return
}

const outResourcesDir = path.join(packContext.appOutDir, "resources", "app.asar.unpacked")
await BluebirdPromise.map(orIfFileNotExist(readdir(outResourcesDir), []), (file: string): any => {
if (file.endsWith(".app")) {
return this.sign(path.join(outResourcesDir, file), null, null)
}
else {
return null
}
})
}
}

function getCertificateType(isMas: boolean, isDevelopment: boolean): CertType {
if (isDevelopment) {
return "Mac Developer"
}
return isMas ? "3rd Party Mac Developer Application" : "Developer ID Application"
}
}