Skip to content

Commit

Permalink
feat: add afterExtract hook for after electron distributable has be…
Browse files Browse the repository at this point in the history
…en unpacked (#8194)
  • Loading branch information
rafaberaldo committed May 7, 2024
1 parent 2a9ccbf commit 588c5db
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .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`
14 changes: 14 additions & 0 deletions packages/app-builder-lib/scheme.json
Expand Up @@ -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": [
{
Expand Down
6 changes: 6 additions & 0 deletions packages/app-builder-lib/src/configuration.ts
Expand Up @@ -220,6 +220,11 @@ export interface Configuration extends PlatformSpecificBuildOptions {
*/
readonly beforePack?: ((context: BeforePackContext) => Promise<any> | 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> | 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).
*/
Expand Down Expand Up @@ -297,6 +302,7 @@ interface PackContext {
}
export type AfterPackContext = PackContext
export type BeforePackContext = PackContext
export type AfterExtractContext = PackContext

export interface MetadataDirectories {
/**
Expand Down
12 changes: 12 additions & 0 deletions packages/app-builder-lib/src/platformPackager.ts
Expand Up @@ -245,6 +245,18 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
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<Minimatch> = []

const computeParsedPatterns = (patterns: Array<FileMatcher> | null) => {
Expand Down

0 comments on commit 588c5db

Please sign in to comment.