1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const builder_util_1 = require("builder-util");
|
4 | const fs_extra_1 = require("fs-extra");
|
5 | const lazy_val_1 = require("lazy-val");
|
6 | const path = require("path");
|
7 | const core_1 = require("../core");
|
8 | const PublishManager_1 = require("../publish/PublishManager");
|
9 | const appBuilder_1 = require("../util/appBuilder");
|
10 | const license_1 = require("../util/license");
|
11 | const targetUtil_1 = require("./targetUtil");
|
12 |
|
13 | class AppImageTarget extends core_1.Target {
|
14 | constructor(ignored, packager, helper, outDir) {
|
15 | super("appImage");
|
16 | this.packager = packager;
|
17 | this.helper = helper;
|
18 | this.outDir = outDir;
|
19 | this.options = { ...this.packager.platformSpecificBuildOptions, ...this.packager.config[this.name] };
|
20 | this.desktopEntry = new lazy_val_1.Lazy(() => {
|
21 | var _a;
|
22 | const args = ((_a = this.options.executableArgs) === null || _a === void 0 ? void 0 : _a.join(" ")) || "--no-sandbox";
|
23 | return helper.computeDesktopEntry(this.options, `AppRun ${args} %U`, {
|
24 | "X-AppImage-Version": `${packager.appInfo.buildVersion}`,
|
25 | });
|
26 | });
|
27 | }
|
28 | async build(appOutDir, arch) {
|
29 | const packager = this.packager;
|
30 | const options = this.options;
|
31 |
|
32 |
|
33 |
|
34 | const artifactName = packager.expandArtifactNamePattern(options, "AppImage", arch);
|
35 | const artifactPath = path.join(this.outDir, artifactName);
|
36 | await packager.info.callArtifactBuildStarted({
|
37 | targetPresentableName: "AppImage",
|
38 | file: artifactPath,
|
39 | arch,
|
40 | });
|
41 | const c = await Promise.all([
|
42 | this.desktopEntry.value,
|
43 | this.helper.icons,
|
44 | (0, PublishManager_1.getAppUpdatePublishConfiguration)(packager, arch, false ),
|
45 | (0, license_1.getNotLocalizedLicenseFile)(options.license, this.packager, ["txt", "html"]),
|
46 | (0, targetUtil_1.createStageDir)(this, packager, arch),
|
47 | ]);
|
48 | const license = c[3];
|
49 | const stageDir = c[4];
|
50 | const publishConfig = c[2];
|
51 | if (publishConfig != null) {
|
52 | await (0, fs_extra_1.outputFile)(path.join(packager.getResourcesDir(stageDir.dir), "app-update.yml"), (0, builder_util_1.serializeToYaml)(publishConfig));
|
53 | }
|
54 | if (this.packager.packagerOptions.effectiveOptionComputed != null &&
|
55 | (await this.packager.packagerOptions.effectiveOptionComputed({ desktop: await this.desktopEntry.value }))) {
|
56 | return;
|
57 | }
|
58 | const args = [
|
59 | "appimage",
|
60 | "--stage",
|
61 | stageDir.dir,
|
62 | "--arch",
|
63 | builder_util_1.Arch[arch],
|
64 | "--output",
|
65 | artifactPath,
|
66 | "--app",
|
67 | appOutDir,
|
68 | "--configuration",
|
69 | JSON.stringify({
|
70 | productName: this.packager.appInfo.productName,
|
71 | productFilename: this.packager.appInfo.productFilename,
|
72 | desktopEntry: c[0],
|
73 | executableName: this.packager.executableName,
|
74 | icons: c[1],
|
75 | fileAssociations: this.packager.fileAssociations,
|
76 | ...options,
|
77 | }),
|
78 | ];
|
79 | (0, appBuilder_1.objectToArgs)(args, {
|
80 | license,
|
81 | });
|
82 | if (packager.compression === "maximum") {
|
83 | args.push("--compression", "xz");
|
84 | }
|
85 | await packager.info.callArtifactBuildCompleted({
|
86 | file: artifactPath,
|
87 | safeArtifactName: packager.computeSafeArtifactName(artifactName, "AppImage", arch, false),
|
88 | target: this,
|
89 | arch,
|
90 | packager,
|
91 | isWriteUpdateInfo: true,
|
92 | updateInfo: await (0, appBuilder_1.executeAppBuilderAsJson)(args),
|
93 | });
|
94 | }
|
95 | }
|
96 | exports.default = AppImageTarget;
|
97 |
|
\ | No newline at end of file |