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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support Electron v6 helpers #1033

Merged
merged 1 commit into from
Jul 24, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/mac.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class MacApp extends App {
]

const possiblePlists = [
[this.ehPlistFilename('Electron Helper (Renderer).app'), 'helperPlist'],
[this.ehPlistFilename('Electron Helper (Plugin).app'), 'helperPlist'],
[this.ehPlistFilename('Electron Helper EH.app'), 'helperEHPlist'],
[this.ehPlistFilename('Electron Helper NP.app'), 'helperNPPlist'],
[this.helperPlistFilename(this.loginHelperPath), 'loginHelperPlist']
Expand Down Expand Up @@ -224,7 +226,7 @@ class MacApp extends App {
}

async moveHelpers () {
const helpers = [' Helper', ' Helper EH', ' Helper NP']
const helpers = [' Helper', ' Helper EH', ' Helper NP', ' Helper (Renderer)', ' Helper (Plugin)']
await Promise.all(helpers.map(suffix => this.moveHelper(this.frameworksPath, suffix)))
if (await fs.pathExists(this.loginItemsPath)) {
await this.moveHelper(this.loginItemsPath, ' Login Helper')
Expand Down
9 changes: 8 additions & 1 deletion test/_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ async function downloadAll (version) {
const combinations = download.createDownloadCombos({ electronVersion: config.version, all: true }, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips)

await downloadElectronChecksum(version)
return Promise.all(combinations.map(combination => downloadElectronZip(version, combination)))
return Promise.all(
[
...combinations.map(combination => downloadElectronZip(version, combination)),
downloadElectronZip('6.0.0-beta.15', {
platform: 'darwin'
})
]
)
}

async function downloadElectronChecksum (version) {
Expand Down
23 changes: 23 additions & 0 deletions test/darwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,27 @@ async function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) {
return assertCFBundleIdentifierValue(t, helperNPObj, helperBundleIdentifier + '.NP', 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper NP app')
}

async function appHelpersBundleElectron6Test (t, opts) {
opts.electronVersion = '6.0.0-beta.15'
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
const defaultBundleName = `com.electron.${opts.name.toLowerCase()}`
const appBundleIdentifier = mac.filterCFBundleIdentifier(opts.appBundleId || defaultBundleName)
const helperBundleIdentifier = mac.filterCFBundleIdentifier(opts.helperBundleId || appBundleIdentifier + '.helper')

const finalPath = (await packager(opts))[0]
const frameworksPath = path.join(finalPath, `${opts.name}.app`, 'Contents', 'Frameworks')
const helperObj = await util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper.app`))
assertPlistStringValue(t, helperObj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, helperObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')

const helperPluginObj = await util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper (Plugin).app`))
assertPlistStringValue(t, helperPluginObj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, helperPluginObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')

const helperRendererObj = await util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper (Renderer).app`))
assertPlistStringValue(t, helperRendererObj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, helperRendererObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')
}

if (!(process.env.CI && process.platform === 'win32')) {
test.serial('helper app paths', darwinTest(helperAppPathsTest))
test.serial('helper app paths test with app name needing sanitization', darwinTest(helperAppPathsTest, { name: '@username/package-name' }, '@username-package-name'))
Expand Down Expand Up @@ -349,6 +370,8 @@ if (!(process.env.CI && process.platform === 'win32')) {
test.serial('app helpers bundle helper-bundle-id fallback to app-bundle-id (w/ special characters)', darwinTest(appHelpersBundleTest, null, 'com.electron."b茫艣猫 t毛脽t!!@#$%^&*()?\''))
test.serial('app helpers bundle helper-bundle-id & app-bundle-id fallback', darwinTest(appHelpersBundleTest))

test.serial('app helpers bundle with renderer/plugin helpers', darwinTest(appHelpersBundleElectron6Test))

test.serial('EH/NP helpers do not exist', darwinTest(async (t, baseOpts) => {
const helpers = [
'Helper EH',
Expand Down