From 4d8884867b66018cd97481a7759b39d11fe0e378 Mon Sep 17 00:00:00 2001 From: Black-Hole <158blackhole@gmail.com> Date: Wed, 27 Nov 2019 14:15:35 +0800 Subject: [PATCH] feat(app-builder-lib): the pkg interface adds the must-close attribute (#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 --- packages/app-builder-lib/scheme.json | 14 ++++++++++++++ packages/app-builder-lib/src/options/pkgOptions.ts | 5 +++++ packages/app-builder-lib/src/targets/pkg.ts | 11 +++++++++++ 3 files changed, 30 insertions(+) diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index a1c6ac34b7d..91342ad7ac9 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -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" diff --git a/packages/app-builder-lib/src/options/pkgOptions.ts b/packages/app-builder-lib/src/options/pkgOptions.ts index f633b1feef7..5746c89ec24 100644 --- a/packages/app-builder-lib/src/options/pkgOptions.ts +++ b/packages/app-builder-lib/src/options/pkgOptions.ts @@ -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 | null + /** * The path to the conclusion file. This may be used to customize the text on the final "Summary" page of the installer. */ diff --git a/packages/app-builder-lib/src/targets/pkg.ts b/packages/app-builder-lib/src/targets/pkg.ts index 913faec8235..4678dbe80b1 100644 --- a/packages/app-builder-lib/src/targets/pkg.ts +++ b/packages/app-builder-lib/src/targets/pkg.ts @@ -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 = ` \n \n` + const endContent = " \n \n" + let mustCloseContent = "" + options.mustClose.forEach(appId => { + mustCloseContent += ` \n` + }) + distInfo = distInfo.replace("", `${startContent}${mustCloseContent}${endContent}`) + } + const insertIndex = distInfo.lastIndexOf("") distInfo = distInfo.substring(0, insertIndex) + ` \n` + distInfo.substring(insertIndex)