Skip to content

Commit

Permalink
feat(appx): add support for modifying .appx manifest (#4613)
Browse files Browse the repository at this point in the history
* Adding appx manifest created hook.

* Removing surplus semicolon.
  • Loading branch information
rud-holmgren authored and develar committed Jan 26, 2020
1 parent 244abfb commit d5d21da
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
5 changes: 4 additions & 1 deletion packages/app-builder-lib/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>> | Array<string>) | string | null

/**
* Appx manifest created on disk - not packed into .appx package yet.
*/
readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null
/**
* The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file.
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ export class Packager {
}
}

async callAppxManifestCreated(path: string): Promise<void> {
const handler = resolveFunction(this.config.appxManifestCreated, "appxManifestCreated")
if (handler != null) {
await Promise.resolve(handler(path))
}
}

async build(): Promise<BuildResult> {
let configPath: string | null = null
let configFromOptions = this.options.config
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/targets/AppxTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"`])

Expand Down

0 comments on commit d5d21da

Please sign in to comment.