Skip to content

Commit

Permalink
feat(app-builder-lib): the pkg interface adds the must-close attribute (
Browse files Browse the repository at this point in the history
#4380) (#4382)

Add mustClsoe key in pkg
Identifies applications that must be closed before the package is installed.
must-close: https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW77

refactor(code-style): delete semicolon
  • Loading branch information
BlackHole1 authored and develar committed Nov 27, 2019
1 parent b8105ff commit 4d88848
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3831,6 +3831,20 @@
"null",
"string"
]
},
"mustClose": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"description": "Identifies applications that must be closed before the package is installed.\n\nCorresponds 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)"
}
},
"type": "object"
Expand Down
5 changes: 5 additions & 0 deletions packages/app-builder-lib/src/options/pkgOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export interface PkgOptions extends TargetSpecificOptions {
*/
readonly welcome?: string | null

/**
* Identifies applications that must be closed before the package is installed.\n\nCorresponds 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)
*/
readonly mustClose?: Array<string> | null

/**
* The path to the conclusion file. This may be used to customize the text on the final "Summary" page of the installer.
*/
Expand Down
11 changes: 11 additions & 0 deletions packages/app-builder-lib/src/targets/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ export class PkgTarget extends Target {

const options = this.options
let distInfo = await readFile(distInfoFile, "utf-8")

if (options.mustClose != null && options.mustClose.length !== 0) {
const startContent = ` <pkg-ref id="${this.packager.appInfo.id}">\n <must-close>\n`
const endContent = " </must-close>\n </pkg-ref>\n</installer-gui-script>"
let mustCloseContent = ""
options.mustClose.forEach(appId => {
mustCloseContent += ` <app id="${appId}"/>\n`
})
distInfo = distInfo.replace("</installer-gui-script>", `${startContent}${mustCloseContent}${endContent}`)
}

const insertIndex = distInfo.lastIndexOf("</installer-gui-script>")
distInfo = distInfo.substring(0, insertIndex) + ` <domains enable_anywhere="${options.allowAnywhere}" enable_currentUserHome="${options.allowCurrentUserHome}" enable_localSystem="${options.allowRootDirectory}" />\n` + distInfo.substring(insertIndex)

Expand Down

0 comments on commit 4d88848

Please sign in to comment.