Skip to content

Commit

Permalink
Implement custom maker extensions.
Browse files Browse the repository at this point in the history
This is for a (possibly) future implementation of Forge's
unofficial maker extensions, allowing for a set of integrations
with third-party Forge Core/CLI implementations.
  • Loading branch information
SpacingBat3 committed Jan 23, 2024
1 parent ef2aa46 commit d10a258
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions makers/appimage/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
chmod,
symlink
} from "fs/promises";
import { EventEmitter } from "events";

import MakerBase from "@electron-forge/maker-base";
import sanitizeName from "@spacingbat3/lss";
Expand Down Expand Up @@ -93,11 +94,13 @@ const enum RemoteDefaults {
* ```
*/
export default class MakerAppImage<C extends MakerAppImageConfig> extends MakerBase<C> {
/** @internal */
readonly __VndReForgedAPI = 1 as const;
defaultPlatforms:["linux"] = ["linux"];
name = "AppImage" as const;
override requiredExternalBinaries:["mksquashfs"] = ["mksquashfs"];
override isSupportedOnCurrentPlatform:()=>true = ()=>true;
override async make({appName,dir,makeDir,packageJSON,targetArch}: MakerMeta) {
override async make({appName,dir,makeDir,packageJSON,targetArch}: MakerMeta, ...vendorExt: unknown[]) {
const {
actions,
categories,
Expand Down Expand Up @@ -339,12 +342,17 @@ export default class MakerAppImage<C extends MakerAppImageConfig> extends MakerB
);
await new Promise((resolve, reject) => {
mkdir(dirname(outFile), {recursive: true}).then(() => {
mkSquashFs(...mkSquashFsArgs)
.once("close", (code,_signal,msg) => code !== 0 ?
reject(new Error(`mksquashfs returned ${msg ? `'${msg}' in stderr` : "non-zero code"} (${code}).`)):
resolve(undefined)
)
.once("error", (error) => reject(error));
const evtCh = mkSquashFs(...mkSquashFsArgs)
.once("close", (code,_signal,msg) => code !== 0 ?
reject(new Error(`mksquashfs returned ${msg ? `'${msg}' in stderr` : "non-zero code"} (${code}).`)):
resolve(undefined)
)
.once("error", (error) => reject(error));
for(let vndHead; vndHead !== undefined && vndHead !== "RF1"; vndHead=vendorExt.pop());
const [vndCh] = vendorExt;
// Leak current progress to API consumers if supported
if(vndCh instanceof EventEmitter)
evtCh.on("progress", percent => vndCh.emit("progress", percent));
}).catch(error => reject(error));
});
// Append runtime to SquashFS image and wait for that task to finish
Expand Down

0 comments on commit d10a258

Please sign in to comment.