-
-
Notifications
You must be signed in to change notification settings - Fork 29
feat: allow extension of helper app plists with extendHelperInfo #1233
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,16 +132,16 @@ class MacApp extends App { | |
| return this.updatePlist(base, `${this.appName} ${helperSuffix}`, identifier, name) | ||
| } | ||
|
|
||
| async extendAppPlist (propsOrFilename) { | ||
| async extendPlist (base, propsOrFilename) { | ||
MarshallOfSound marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!propsOrFilename) { | ||
| return Promise.resolve() | ||
| } | ||
|
|
||
| if (typeof propsOrFilename === 'string') { | ||
| const plist = await this.loadPlist(propsOrFilename) | ||
| return Object.assign(this.appPlist, plist) | ||
| return Object.assign(base, plist) | ||
MarshallOfSound marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| return Object.assign(this.appPlist, propsOrFilename) | ||
| return Object.assign(base, propsOrFilename) | ||
MarshallOfSound marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -189,21 +189,34 @@ class MacApp extends App { | |
|
|
||
| const plists = await this.determinePlistFilesToUpdate() | ||
| await Promise.all(plists.map(plistArgs => this.loadPlist(...plistArgs))) | ||
| await this.extendAppPlist(this.opts.extendInfo) | ||
| await this.extendPlist(this.appPlist, this.opts.extendInfo) | ||
| this.appPlist = this.updatePlist(this.appPlist, this.executableName, appBundleIdentifier, this.appName) | ||
| this.helperPlist = this.updateHelperPlist(this.helperPlist) | ||
|
|
||
| const updateIfExists = [ | ||
| ['helperRendererPlist', '(Renderer)', true], | ||
| ['helperPluginPlist', '(Plugin)', true], | ||
| ['helperGPUPlist', '(GPU)', true], | ||
| ['helperEHPlist', 'EH'], | ||
| ['helperNPPlist', 'NP'] | ||
| ] | ||
|
|
||
| for (const [plistKey] of [...updateIfExists, ['helperPlist']]) { | ||
|
||
| if (!this[plistKey]) continue | ||
| await this.extendPlist(this[plistKey], this.opts.extendHelperInfo) | ||
| } | ||
|
|
||
| this.helperPlist = this.updateHelperPlist(this.helperPlist) | ||
| for (const [plistKey, ...suffixArgs] of updateIfExists) { | ||
| if (!this[plistKey]) continue | ||
| this[plistKey] = this.updateHelperPlist(this[plistKey], ...suffixArgs) | ||
| } | ||
|
|
||
| // Some properties need to go on all helpers as well, version, usage info, etc. | ||
| const plistsToUpdate = updateIfExists | ||
| .filter(([key]) => !!this[key]) | ||
| .map(([key]) => key) | ||
| .concat(['appPlist', 'helperPlist']) | ||
|
|
||
| if (this.loginHelperPlist) { | ||
| const loginHelperName = common.sanitizeAppName(`${this.appName} Login Helper`) | ||
| this.loginHelperPlist.CFBundleExecutable = loginHelperName | ||
|
|
@@ -212,11 +225,16 @@ class MacApp extends App { | |
| } | ||
|
|
||
| if (this.appVersion) { | ||
| this.appPlist.CFBundleShortVersionString = this.appPlist.CFBundleVersion = '' + this.appVersion | ||
| const appVersionString = '' + this.appVersion | ||
| for (const plistKey of plistsToUpdate) { | ||
| this[plistKey].CFBundleShortVersionString = this[plistKey].CFBundleVersion = appVersionString | ||
| } | ||
| } | ||
|
|
||
| if (this.buildVersion) { | ||
| this.appPlist.CFBundleVersion = '' + this.buildVersion | ||
| for (const plistKey of plistsToUpdate) { | ||
| this[plistKey].CFBundleVersion = '' + this.buildVersion | ||
| } | ||
MarshallOfSound marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if (this.opts.protocols && this.opts.protocols.length) { | ||
|
|
@@ -237,7 +255,11 @@ class MacApp extends App { | |
|
|
||
| if (this.usageDescription) { | ||
| for (const [type, description] of Object.entries(this.usageDescription)) { | ||
| this.appPlist[`NS${type}UsageDescription`] = description | ||
| const usageTypeKey = `NS${type}UsageDescription` | ||
| for (const plistKey of plistsToUpdate) { | ||
| this[plistKey][usageTypeKey] = description | ||
| } | ||
MarshallOfSound marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.appPlist[usageTypeKey] = description | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.