From d5d21da12f5efaf02659ce8d32c48440f6cf91ff Mon Sep 17 00:00:00 2001 From: rud-holmgren Date: Sun, 26 Jan 2020 08:20:41 +0100 Subject: [PATCH] feat(appx): add support for modifying .appx manifest (#4613) * Adding appx manifest created hook. * Removing surplus semicolon. --- packages/app-builder-lib/scheme.json | 14 ++++++++++++++ packages/app-builder-lib/src/configuration.ts | 5 ++++- packages/app-builder-lib/src/packager.ts | 7 +++++++ packages/app-builder-lib/src/targets/AppxTarget.ts | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index 2439b2b3f7..4176df2b45 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -5331,6 +5331,20 @@ ], "description": "The function (or path to file or module id) to be run on artifact build start." }, + "appxManifestCreated": { + "anyOf": [ + { + "typeof": "function" + }, + { + "type": [ + "null", + "string" + ] + } + ], + "description": "The function (or path to file or module id) to be run when appx manifest is created but before it is packed into the installer bundle." + }, "artifactName": { "description": "The [artifact file name template](/configuration/configuration#artifact-file-name-template). Defaults to `${productName}-${version}.${ext}` (some target can have other defaults, see corresponding options).", "type": [ diff --git a/packages/app-builder-lib/src/configuration.ts b/packages/app-builder-lib/src/configuration.ts index 7a25935918..8c3f8c55c9 100644 --- a/packages/app-builder-lib/src/configuration.ts +++ b/packages/app-builder-lib/src/configuration.ts @@ -198,7 +198,10 @@ export interface Configuration extends PlatformSpecificBuildOptions { * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild). */ readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise> | Array) | string | null - + /** + * Appx manifest created on disk - not packed into .appx package yet. + */ + readonly appxManifestCreated?: ((path: string) => Promise | any) | string | null /** * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. */ diff --git a/packages/app-builder-lib/src/packager.ts b/packages/app-builder-lib/src/packager.ts index cd5d4b6a76..7882d2e36e 100644 --- a/packages/app-builder-lib/src/packager.ts +++ b/packages/app-builder-lib/src/packager.ts @@ -284,6 +284,13 @@ export class Packager { } } + async callAppxManifestCreated(path: string): Promise { + const handler = resolveFunction(this.config.appxManifestCreated, "appxManifestCreated") + if (handler != null) { + await Promise.resolve(handler(path)) + } + } + async build(): Promise { let configPath: string | null = null let configFromOptions = this.options.config diff --git a/packages/app-builder-lib/src/targets/AppxTarget.ts b/packages/app-builder-lib/src/targets/AppxTarget.ts index 68fa575228..f95b484727 100644 --- a/packages/app-builder-lib/src/targets/AppxTarget.ts +++ b/packages/app-builder-lib/src/targets/AppxTarget.ts @@ -73,6 +73,7 @@ export default class AppXTarget extends Target { const manifestFile = stageDir.getTempFile("AppxManifest.xml") await this.writeManifest(manifestFile, arch, await this.computePublisherName(), userAssets) + await packager.info.callAppxManifestCreated(manifestFile) mappingList.push(assetInfo.mappings) mappingList.push([`"${vm.toVmFile(manifestFile)}" "AppxManifest.xml"`])