diff --git a/.changeset/tough-clouds-think.md b/.changeset/tough-clouds-think.md new file mode 100644 index 0000000000..8c5110443f --- /dev/null +++ b/.changeset/tough-clouds-think.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": minor +--- + +feat: add `afterExtract` hook to build process with the same payload interface as `beforePack` and `afterPack` diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index a957fe60b6..3031c87fe2 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -6418,6 +6418,20 @@ ], "description": "The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild)." }, + "afterExtract": { + "anyOf": [ + { + "typeof": "function" + }, + { + "type": [ + "null", + "string" + ] + } + ], + "description": "The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)" + }, "afterPack": { "anyOf": [ { diff --git a/packages/app-builder-lib/src/configuration.ts b/packages/app-builder-lib/src/configuration.ts index 4a9fbcdd2b..71e8540219 100644 --- a/packages/app-builder-lib/src/configuration.ts +++ b/packages/app-builder-lib/src/configuration.ts @@ -220,6 +220,11 @@ export interface Configuration extends PlatformSpecificBuildOptions { */ readonly beforePack?: ((context: BeforePackContext) => Promise | any) | string | null + /** + * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract) + */ + readonly afterExtract?: ((context: AfterExtractContext) => Promise | any) | string | null + /** * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign). */ @@ -297,6 +302,7 @@ interface PackContext { } export type AfterPackContext = PackContext export type BeforePackContext = PackContext +export type AfterExtractContext = PackContext export interface MetadataDirectories { /** diff --git a/packages/app-builder-lib/src/platformPackager.ts b/packages/app-builder-lib/src/platformPackager.ts index 6ebed64b2e..10730a6dd4 100644 --- a/packages/app-builder-lib/src/platformPackager.ts +++ b/packages/app-builder-lib/src/platformPackager.ts @@ -245,6 +245,18 @@ export abstract class PlatformPackager version: framework.version, }) + const afterExtract = await resolveFunction(this.appInfo.type, this.config.afterExtract, "afterExtract") + if (afterExtract != null) { + await afterExtract({ + appOutDir, + outDir, + arch, + targets, + packager: this, + electronPlatformName: platformName, + }) + } + const excludePatterns: Array = [] const computeParsedPatterns = (patterns: Array | null) => {