app-builder-lib 26.15.3 → 26.15.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/targets/ArchiveTarget.js +1 -1
- package/out/targets/ArchiveTarget.js.map +1 -1
- package/out/targets/LinuxTargetHelper.d.ts +12 -0
- package/out/targets/LinuxTargetHelper.js +11 -33
- package/out/targets/LinuxTargetHelper.js.map +1 -1
- package/out/targets/appimage/AppImageTarget.js +2 -1
- package/out/targets/appimage/AppImageTarget.js.map +1 -1
- package/out/targets/archive.d.ts +10 -2
- package/out/targets/archive.js +26 -6
- package/out/targets/archive.js.map +1 -1
- package/out/targets/nsis/NsisTarget.js +3 -3
- package/out/targets/nsis/NsisTarget.js.map +1 -1
- package/out/targets/nsis/nsisScriptGenerator.js +1 -1
- package/out/targets/nsis/nsisScriptGenerator.js.map +1 -1
- package/out/targets/snap/core24.d.ts +3 -1
- package/out/targets/snap/core24.js +49 -9
- package/out/targets/snap/core24.js.map +1 -1
- package/out/targets/snap/coreLegacy.d.ts +2 -2
- package/out/targets/snap/coreLegacy.js +7 -10
- package/out/targets/snap/coreLegacy.js.map +1 -1
- package/out/targets/snap/snapCommand.d.ts +18 -0
- package/out/targets/snap/snapCommand.js +42 -0
- package/out/targets/snap/snapCommand.js.map +1 -0
- package/out/toolsets/icons.js +2 -2
- package/out/toolsets/icons.js.map +1 -1
- package/out/util/electronGet.js +102 -29
- package/out/util/electronGet.js.map +1 -1
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/package.json +6 -6
|
@@ -58,7 +58,7 @@ class ArchiveTarget extends core_1.Target {
|
|
|
58
58
|
const archiveOptions = {
|
|
59
59
|
compression: packager.compression,
|
|
60
60
|
withoutDir,
|
|
61
|
-
preserveSymlinks:
|
|
61
|
+
preserveSymlinks: (0, archive_1.shouldPreserveSymlinks)(packager.platform),
|
|
62
62
|
};
|
|
63
63
|
await (0, archive_1.archive)(format, artifactPath, dirToArchive, archiveOptions);
|
|
64
64
|
if (this.isWriteUpdateInfo && format === "zip") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArchiveTarget.js","sourceRoot":"","sources":["../../src/targets/ArchiveTarget.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,6BAA4B;AAC5B,kCAAiE;AACjE,gDAA2D;AAE3D,
|
|
1
|
+
{"version":3,"file":"ArchiveTarget.js","sourceRoot":"","sources":["../../src/targets/ArchiveTarget.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,6BAA4B;AAC5B,kCAAiE;AACjE,gDAA2D;AAE3D,uCAAgE;AAChE,mFAAgF;AAEhF,MAAa,aAAc,SAAQ,aAAM;IAGvC,YACE,IAAY,EACH,MAAc,EACN,QAA+B,EAC/B,oBAAoB,KAAK;QAE1C,KAAK,CAAC,IAAI,CAAC,CAAA;QAJF,WAAM,GAAN,MAAM,CAAQ;QACN,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,sBAAiB,GAAjB,iBAAiB,CAAQ;QANnC,YAAO,GAA2B,IAAI,CAAC,QAAQ,CAAC,MAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IASlF,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,SAAiB,EAAE,IAAU;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,KAAK,eAAQ,CAAC,GAAG,CAAA;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAA;QAExB,IAAI,cAAsB,CAAA;QAC1B,MAAM,WAAW,GAAS,IAAA,oCAAqB,EAAC,QAAQ,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAA;QAClG,IAAI,QAAQ,CAAC,QAAQ,KAAK,eAAQ,CAAC,KAAK,EAAE,CAAC;YACzC,uDAAuD;YACvD,cAAc,GAAG,oBAAoB,GAAG,CAAC,IAAI,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,KAAK,EACL,QAAQ,CAAC,4BAA4B,CAAC,WAAW,EACjD,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,CACpD;gBACD,MAAM,EAAE,IAAI;gBACZ,IAAI;gBACJ,QAAQ;gBACR,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;aAC1C,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;CACF;AA9FD,sCA8FC","sourcesContent":["import { Arch, defaultArchFromString } from \"builder-util\"\nimport * as path from \"path\"\nimport { Platform, Target, TargetSpecificOptions } from \"../core\"\nimport { copyFiles, getFileMatchers } from \"../fileMatcher\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { archive, shouldPreserveSymlinks, tar } from \"./archive\"\nimport { appendBlockmap, createBlockmap } from \"./differentialUpdateInfoBuilder\"\n\nexport class ArchiveTarget extends Target {\n readonly options: TargetSpecificOptions = (this.packager.config as any)[this.name]\n\n constructor(\n name: string,\n readonly outDir: string,\n private readonly packager: PlatformPackager<any>,\n private readonly isWriteUpdateInfo = false\n ) {\n super(name)\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const isMac = packager.platform === Platform.MAC\n const format = this.name\n\n let defaultPattern: string\n const defaultArch: Arch = defaultArchFromString(packager.platformSpecificBuildOptions.defaultArch)\n if (packager.platform === Platform.LINUX) {\n // tslint:disable-next-line:no-invalid-template-strings\n defaultPattern = \"${name}-${version}\" + (arch === defaultArch ? \"\" : \"-${arch}\") + \".${ext}\"\n } else {\n // tslint:disable-next-line:no-invalid-template-strings\n defaultPattern = \"${productName}-${version}\" + (arch === defaultArch ? \"\" : \"-${arch}\") + \"-${os}.${ext}\"\n }\n\n this.buildQueueManager.add(async () => {\n const artifactName = packager.expandArtifactNamePattern(this.options, format, arch, defaultPattern, false)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: `${isMac ? \"macOS \" : \"\"}${format}`,\n file: artifactPath,\n arch,\n })\n let updateInfo: any = null\n if (format.startsWith(\"tar.\")) {\n await tar({ compression: packager.compression, format, outFile: artifactPath, dirToArchive: appOutDir, isMacApp: isMac, tempDirManager: packager.info.tempDirManager })\n } else {\n let withoutDir = !isMac\n let dirToArchive = appOutDir\n if (isMac) {\n dirToArchive = path.dirname(appOutDir)\n const fileMatchers = getFileMatchers(\n packager.config,\n \"extraDistFiles\",\n dirToArchive,\n packager.createGetFileMatchersOptions(this.outDir, arch, packager.platformSpecificBuildOptions)\n )\n if (fileMatchers == null) {\n dirToArchive = appOutDir\n } else {\n await copyFiles(fileMatchers, null, true)\n withoutDir = true\n }\n }\n\n const archiveOptions = {\n compression: packager.compression,\n withoutDir,\n preserveSymlinks: shouldPreserveSymlinks(packager.platform),\n }\n await archive(format, artifactPath, dirToArchive, archiveOptions)\n\n if (this.isWriteUpdateInfo && format === \"zip\") {\n if (isMac) {\n updateInfo = await createBlockmap(artifactPath, this, packager, artifactName)\n } else {\n updateInfo = await appendBlockmap(artifactPath)\n }\n }\n }\n\n await packager.info.emitArtifactBuildCompleted({\n updateInfo,\n file: artifactPath,\n // tslint:disable-next-line:no-invalid-template-strings\n safeArtifactName: packager.computeSafeArtifactName(\n artifactName,\n format,\n arch,\n false,\n packager.platformSpecificBuildOptions.defaultArch,\n defaultPattern.replace(\"${productName}\", \"${name}\")\n ),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: this.isWriteUpdateInfo,\n })\n })\n return Promise.resolve()\n }\n}\n"]}
|
|
@@ -2,6 +2,18 @@ import { LinuxPackager } from "../linuxPackager";
|
|
|
2
2
|
import { CommonLinuxOptions } from "../options/linuxOptions";
|
|
3
3
|
import { SnapCore } from "./snap/SnapTarget";
|
|
4
4
|
import { IconInfo } from "../util/iconConverter";
|
|
5
|
+
/**
|
|
6
|
+
* Build the argument portion of a .desktop Exec line.
|
|
7
|
+
*
|
|
8
|
+
* executableArgs are written verbatim — matching AppImage and the behavior that
|
|
9
|
+
* shipped for years — so an arg like `--js-flags="--max-old-space-size=12288"`
|
|
10
|
+
* reaches the launcher exactly as the developer specified. Only carriage-return
|
|
11
|
+
* and newline characters are removed: the Exec key is a single line, and an
|
|
12
|
+
* embedded line break would split it into additional .desktop entries.
|
|
13
|
+
*
|
|
14
|
+
* @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildExecArgs(executableArgs: ReadonlyArray<string>): string;
|
|
5
17
|
export declare const installPrefix = "/opt";
|
|
6
18
|
export declare class LinuxTargetHelper {
|
|
7
19
|
private packager;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinuxTargetHelper = exports.installPrefix = void 0;
|
|
4
|
+
exports.buildExecArgs = buildExecArgs;
|
|
4
5
|
const builder_util_1 = require("builder-util");
|
|
5
6
|
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
6
7
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -31,38 +32,18 @@ function desktopStringEscape(value) {
|
|
|
31
32
|
return value.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
-
* freedesktop Desktop Entry Specification. Plain alphanumeric args and
|
|
36
|
-
* field codes must NOT be wrapped in quotes.
|
|
35
|
+
* Build the argument portion of a .desktop Exec line.
|
|
37
36
|
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* Field codes (`%f`, `%u`, `%F`, `%U`, etc.) MUST be left unquoted — the
|
|
45
|
-
* desktop launcher only expands them in unquoted token positions. Wrapping
|
|
46
|
-
* them in `"…"` causes the launcher to treat them as literal strings, which
|
|
47
|
-
* breaks file-association / drag-and-drop functionality.
|
|
48
|
-
*
|
|
49
|
-
* For all other arguments, double-quoting is used when the argument contains
|
|
50
|
-
* any character that would be misinterpreted by the launcher without quoting
|
|
51
|
-
* (spaces, shell metacharacters, etc.). Safe plain-word args are passed
|
|
52
|
-
* through unchanged to keep the Exec line readable.
|
|
37
|
+
* executableArgs are written verbatim — matching AppImage and the behavior that
|
|
38
|
+
* shipped for years — so an arg like `--js-flags="--max-old-space-size=12288"`
|
|
39
|
+
* reaches the launcher exactly as the developer specified. Only carriage-return
|
|
40
|
+
* and newline characters are removed: the Exec key is a single line, and an
|
|
41
|
+
* embedded line break would split it into additional .desktop entries.
|
|
53
42
|
*
|
|
54
43
|
* @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
|
|
55
44
|
*/
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
if (/^%[a-zA-Z]$/.test(arg)) {
|
|
59
|
-
return arg;
|
|
60
|
-
}
|
|
61
|
-
// Only quote when the arg actually contains characters that need it.
|
|
62
|
-
if (EXEC_RESERVED_RE.test(arg)) {
|
|
63
|
-
return `"${arg.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
64
|
-
}
|
|
65
|
-
return arg;
|
|
45
|
+
function buildExecArgs(executableArgs) {
|
|
46
|
+
return executableArgs.map(arg => arg.replace(/[\r\n]+/g, "")).join(" ");
|
|
66
47
|
}
|
|
67
48
|
function mapLinuxCompressionToSnap(level) {
|
|
68
49
|
if (level === "store") {
|
|
@@ -234,11 +215,8 @@ class LinuxTargetHelper {
|
|
|
234
215
|
if (!/^[/0-9A-Za-z._-]+$/.test(exec)) {
|
|
235
216
|
exec = `"${exec}"`;
|
|
236
217
|
}
|
|
237
|
-
if (executableArgs) {
|
|
238
|
-
exec += " ";
|
|
239
|
-
// Each arg is double-quoted per the freedesktop Exec key spec so that
|
|
240
|
-
// spaces, $, ;, & and other reserved characters are not misinterpreted.
|
|
241
|
-
exec += executableArgs.map(desktopExecArgEscape).join(" ");
|
|
218
|
+
if (executableArgs && executableArgs.length > 0) {
|
|
219
|
+
exec += " " + buildExecArgs(executableArgs);
|
|
242
220
|
}
|
|
243
221
|
// https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
|
|
244
222
|
const execCodes = ["%f", "%u", "%F", "%U"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinuxTargetHelper.js","sourceRoot":"","sources":["../../src/targets/LinuxTargetHelper.ts"],"names":[],"mappings":";;;AAAA,+CAA+F;AAC/F,+DAAiD;AACjD,uCAAqC;AACrC,uCAA+B;AAC/B,+BAA2B;AAC3B,iCAAgC;AAKhC,0CAA0C;AAC1C,kDAAkD;AAClD,kDAAkD;AAGlD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACvG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AAEhD;;;;;;;;;;;;;;GAcG;AACH,SAAS,oBAAoB,CAAC,GAAW;IACvC,oEAAoE;IACpE,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,qEAAqE;IACrE,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAA;IAC/D,CAAC;IACD,OAAO,GAAG,CAA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Array, exists, InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { deepAssign } from \"builder-util-runtime\"\nimport { outputFile } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport { join } from \"path\"\nimport * as semver from \"semver\"\nimport { CompressionLevel } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { CommonLinuxOptions } from \"../options/linuxOptions\"\nimport { SnapCore } from \"./snap/SnapTarget\"\nimport { SnapCore24 } from \"./snap/core24\"\nimport { SnapCoreCustom } from \"./snap/coreCustom\"\nimport { SnapCoreLegacy } from \"./snap/coreLegacy\"\nimport { IconInfo } from \"../util/iconConverter\"\n\n/**\n * Escape a string value for use in a freedesktop .desktop file string field\n * (Name, Comment, StartupWMClass, etc.).\n *\n * The freedesktop Desktop Entry Specification requires that the following\n * characters be escaped in string / localestring values:\n * \\n → \\\\n (newline — would inject new key=value lines otherwise)\n * \\r → \\\\r\n * \\t → \\\\t\n * \\\\ → \\\\\\\\\n *\n * Without escaping, a productName or description containing a literal newline\n * can inject arbitrary key=value pairs into the generated .desktop file,\n * potentially overriding the Exec key.\n *\n * @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#value-types\n */\nfunction desktopStringEscape(value: string): string {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\n/g, \"\\\\n\").replace(/\\r/g, \"\\\\r\").replace(/\\t/g, \"\\\\t\")\n}\n\n/**\n * Characters that require an Exec argument to be double-quoted per the\n * freedesktop Desktop Entry Specification. Plain alphanumeric args and\n * field codes must NOT be wrapped in quotes.\n *\n * @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables\n */\nconst EXEC_RESERVED_RE = /[\\s\"'`\\\\<>~|&;$*?#()]/\n\n/**\n * Quote a single argument for use in a .desktop file Exec key.\n *\n * Field codes (`%f`, `%u`, `%F`, `%U`, etc.) MUST be left unquoted — the\n * desktop launcher only expands them in unquoted token positions. Wrapping\n * them in `\"…\"` causes the launcher to treat them as literal strings, which\n * breaks file-association / drag-and-drop functionality.\n *\n * For all other arguments, double-quoting is used when the argument contains\n * any character that would be misinterpreted by the launcher without quoting\n * (spaces, shell metacharacters, etc.). Safe plain-word args are passed\n * through unchanged to keep the Exec line readable.\n *\n * @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables\n */\nfunction desktopExecArgEscape(arg: string): string {\n // Field codes (%f, %u, %F, %U, %i, %c, %k, …) must never be quoted.\n if (/^%[a-zA-Z]$/.test(arg)) {\n return arg\n }\n // Only quote when the arg actually contains characters that need it.\n if (EXEC_RESERVED_RE.test(arg)) {\n return `\"${arg.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"`\n }\n return arg\n}\n\nfunction mapLinuxCompressionToSnap(level: CompressionLevel | null | undefined): \"xz\" | \"lzo\" | undefined {\n if (level === \"store\") {\n return \"lzo\"\n }\n if (level === \"maximum\") {\n return \"xz\"\n }\n return undefined\n}\n\nexport const installPrefix = \"/opt\"\n\nexport class LinuxTargetHelper {\n private readonly iconPromise = new Lazy(() => this.computeDesktopIcons())\n\n private readonly mimeTypeFilesPromise = new Lazy(() => this.computeMimeTypeFiles())\n\n maxIconPath: string | null = null\n\n constructor(private packager: LinuxPackager) {}\n\n get icons(): Promise<Array<IconInfo>> {\n return this.iconPromise.value\n }\n\n get mimeTypeFiles(): Promise<string | null> {\n return this.mimeTypeFilesPromise.value\n }\n\n getSnapCore(): SnapCore<any> {\n const { snapcraft, snap: legacySnap } = this.packager.config\n if (snapcraft != null && legacySnap != null) {\n log.warn(\"Both `snapcraft` and `snap` configurations are present. `snapcraft` takes precedence; please remove the `snap` key to silence this warning.\")\n }\n\n // Merge linux-level options (category, description, mimeTypes, etc.) as the base so they\n // propagate into the generated snapcraft.yaml and .desktop file without requiring users to\n // duplicate them under core24/core18/etc. Per-core options always win for conflicts.\n // linux.compression is a CompressionLevel (\"store\"/\"normal\"/\"maximum\"); snap compression is an\n // algorithm (\"xz\"/\"lzo\"). Map the level to the nearest algorithm; per-core options override.\n const { compression: linuxCompression, ...linuxOptions } = this.packager.platformSpecificBuildOptions\n const snapLinuxOptions = { ...linuxOptions, compression: mapLinuxCompressionToSnap(linuxCompression) }\n\n if (snapcraft != null) {\n const core = snapcraft.base\n const options = snapcraft[core] || {}\n switch (core) {\n case \"core18\":\n case \"core20\":\n case \"core22\":\n if (!this.isElectronVersionGreaterOrEqualThan(\"4.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThan(\"2.0.0-beta.1\")) {\n throw new InvalidConfigurationError(\"Electron 2 and higher is required to build Snap with core18/core20/core22\")\n }\n log.warn(null, \"electron 4 and higher is highly recommended for Snap with core18/core20/core22\")\n }\n return new SnapCoreLegacy(this.packager, this, deepAssign({}, snapLinuxOptions, { base: core, ...options }))\n case \"core24\":\n if (!this.isElectronVersionGreaterOrEqualThan(\"28.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThan(\"25.0.0\")) {\n throw new InvalidConfigurationError(\"Electron 25 and higher is required to build Snap with core24\")\n }\n log.warn(null, \"electron 28 and higher is highly recommended for Snap with core24\")\n }\n return new SnapCore24(this.packager, this, deepAssign({}, snapLinuxOptions, options))\n case \"custom\":\n // Pass-through: do not inject linux options into user-supplied yaml\n return new SnapCoreCustom(this.packager, this, snapcraft.custom || {})\n }\n }\n\n if (legacySnap != null) {\n log.warn(\n {\n reason: \"`snap` configuration is deprecated\",\n docs: \"https://www.electron.build/snapcraft\",\n },\n \"please consider migrating `snap` configuration to `snapcraft.<core>` and remove `snap` configuration\"\n )\n }\n return new SnapCoreLegacy(this.packager, this, deepAssign({}, snapLinuxOptions, legacySnap ?? {}))\n }\n\n isElectronVersionGreaterOrEqualThan(version: string, fallback?: string): boolean {\n const electronVersion = this.packager.config.electronVersion\n if (!electronVersion) {\n return fallback ? semver.gte(fallback, version) : true\n }\n return semver.gte(electronVersion, version)\n }\n\n private async computeMimeTypeFiles(): Promise<string | null> {\n const items: Array<string> = []\n for (const fileAssociation of this.packager.fileAssociations) {\n if (!fileAssociation.mimeType) {\n continue\n }\n\n const data = `<mime-type type=\"${fileAssociation.mimeType}\">\n <glob pattern=\"*.${fileAssociation.ext}\"/>\n ${fileAssociation.description ? `<comment>${fileAssociation.description}</comment>` : \"\"}\n <icon name=\"x-office-document\" />\n</mime-type>`\n items.push(data)\n }\n\n if (items.length === 0) {\n return null\n }\n\n const file = await this.packager.getTempFile(\".xml\")\n await outputFile(\n file,\n '<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\\n' + items.join(\"\\n\") + \"\\n</mime-info>\"\n )\n return file\n }\n\n // must be name without spaces and other special characters, but not product name used\n private async computeDesktopIcons(): Promise<Array<IconInfo>> {\n const packager = this.packager\n const { platformSpecificBuildOptions, config } = packager\n\n const sources = [platformSpecificBuildOptions.icon, config.mac?.icon ?? config.icon].filter(str => !!str) as string[]\n\n // If no explicit sources are defined, fallback to buildResources directory, then default framework icon\n let fallbackSources = [...asArray(packager.getDefaultFrameworkIcon())]\n const buildResources = config.directories?.buildResources\n if (buildResources && (await exists(join(buildResources, \"icons\")))) {\n fallbackSources = [buildResources, ...fallbackSources]\n }\n\n // need to put here and not as default because need to resolve image size\n const result = await packager.resolveIcon(sources, fallbackSources, \"set\")\n this.maxIconPath = result[result.length - 1].file\n\n // Ignore .icon files for linux (they are exclusive for macOS)\n return result.filter(icon => !icon.file.endsWith(\".icon\"))\n }\n\n getDescription(options: CommonLinuxOptions) {\n return options.description || this.packager.appInfo.description\n }\n\n getSanitizedVersion(target: string) {\n const {\n appInfo: { version },\n } = this.packager\n switch (target) {\n case \"pacman\":\n return version.replace(/-/g, \"_\")\n case \"rpm\":\n case \"deb\":\n return version.replace(/-/g, \"~\")\n default:\n return version\n }\n }\n\n async writeDesktopEntry(targetSpecificOptions: CommonLinuxOptions, exec?: string, destination?: string | null, extra?: Record<string, string>): Promise<string> {\n const data = await this.computeDesktopEntry(targetSpecificOptions, exec, extra)\n const file = destination || (await this.packager.getTempFile(`${this.packager.appInfo.productFilename}.desktop`))\n await outputFile(file, data)\n return file\n }\n\n getDesktopFileName(fallback: string = this.packager.executableName): string {\n if (!this.packager.platformSpecificBuildOptions.syncDesktopName) {\n return fallback\n }\n const trimmedDesktopName = this.packager.info.metadata.desktopName?.trim()\n if (isEmptyOrSpaces(trimmedDesktopName)) {\n return fallback\n }\n const basename = trimmedDesktopName.replace(/\\.desktop$/, \"\")\n // Guard against path traversal: desktopName flows into filesystem paths\n // (snap/gui/<name>.desktop, /usr/share/applications/<name>.desktop, etc.).\n if (/[/\\\\]/.test(basename) || [...basename].some(c => c.charCodeAt(0) === 0)) {\n throw new InvalidConfigurationError(`desktopName \"${trimmedDesktopName}\" produces an invalid .desktop filename — remove any path separators or NUL characters`)\n }\n return basename\n }\n\n computeDesktopEntry(targetSpecificOptions: CommonLinuxOptions, exec?: string, extra?: Record<string, string>): Promise<string> {\n if (exec != null && exec.length === 0) {\n throw new Error(\"Specified exec is empty\")\n }\n // https://github.com/electron-userland/electron-builder/issues/3418\n if (targetSpecificOptions.desktop?.entry?.Exec) {\n throw new Error(\"Please specify executable name as linux.executableName instead of linux.desktop.Exec\")\n }\n\n const packager = this.packager\n const appInfo = packager.appInfo\n\n const executableArgs = targetSpecificOptions.executableArgs\n if (exec == null) {\n exec = `${installPrefix}/${appInfo.sanitizedProductName}/${packager.executableName}`\n if (!/^[/0-9A-Za-z._-]+$/.test(exec)) {\n exec = `\"${exec}\"`\n }\n if (executableArgs) {\n exec += \" \"\n // Each arg is double-quoted per the freedesktop Exec key spec so that\n // spaces, $, ;, & and other reserved characters are not misinterpreted.\n exec += executableArgs.map(desktopExecArgEscape).join(\" \")\n }\n // https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables\n const execCodes = [\"%f\", \"%u\", \"%F\", \"%U\"]\n if (executableArgs == null || executableArgs.findIndex(arg => execCodes.includes(arg)) === -1) {\n exec += \" %U\"\n }\n }\n\n // https://github.com/electron-userland/electron-builder/issues/9103\n // Electron derives app_id from desktopName in package.json; StartupWMClass must match.\n // https://github.com/electron/electron/blob/9a7b73b5334f1d72c08e2d5e94106706ed751186/lib/browser/init.ts#L128-L133\n const trimmedDesktopName = packager.info.metadata.desktopName?.trim()\n if (isEmptyOrSpaces(trimmedDesktopName)) {\n log.warn(\n {\n reason: \"desktopName is not set in package.json\",\n docs: \"https://www.electron.build/linux#window-association-desktopname--syncdesktopname\",\n },\n \"electron uses desktopName as app_id / WM_CLASS for window association. Without it desktop environments may not link running windows to this .desktop entry. Set desktopName in package.json and linux.syncDesktopName: true to fix.\"\n )\n }\n const wmClass = !isEmptyOrSpaces(trimmedDesktopName) ? trimmedDesktopName.replace(/\\.desktop$/, \"\") : appInfo.productName\n\n const desktopMeta = deepAssign<any>(\n {\n // String values are escaped per the freedesktop spec (\\\\, \\n, \\r, \\t)\n // so that a product name containing a newline cannot inject new key=value\n // pairs into the .desktop file (e.g. overriding the Exec key).\n Name: desktopStringEscape(appInfo.productName),\n Exec: exec,\n Terminal: \"false\",\n Type: \"Application\",\n Icon: packager.executableName,\n // https://askubuntu.com/questions/367396/what-represent-the-startupwmclass-field-of-a-desktop-file\n // Set to desktopName (minus .desktop suffix) when provided, so it matches Electron's\n // app_id and desktop environments can associate running windows with this entry.\n // Falls back to productName for apps that don't set desktopName.\n // to get WM_CLASS of running window: xprop WM_CLASS\n // StartupWMClass doesn't work for unicode\n // https://github.com/electron/electron/blob/2-0-x/atom/browser/native_window_views.cc#L226\n StartupWMClass: desktopStringEscape(wmClass),\n },\n extra,\n targetSpecificOptions.desktop?.entry ?? {}\n )\n\n const description = this.getDescription(targetSpecificOptions)\n if (!isEmptyOrSpaces(description)) {\n desktopMeta.Comment = desktopStringEscape(description)\n }\n\n const mimeTypes: Array<string> = asArray(targetSpecificOptions.mimeTypes)\n for (const fileAssociation of packager.fileAssociations) {\n if (fileAssociation.mimeType != null) {\n mimeTypes.push(fileAssociation.mimeType)\n }\n }\n\n for (const protocol of asArray(packager.config.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))) {\n for (const scheme of asArray(protocol.schemes)) {\n mimeTypes.push(`x-scheme-handler/${scheme}`)\n }\n }\n\n if (mimeTypes.length !== 0) {\n desktopMeta.MimeType = mimeTypes.join(\";\") + \";\"\n }\n\n let category = targetSpecificOptions.category\n if (isEmptyOrSpaces(category)) {\n const macCategory = (packager.config.mac || {}).category\n if (macCategory != null) {\n category = macToLinuxCategory[macCategory]\n }\n\n if (category == null) {\n // https://github.com/develar/onshape-desktop-shell/issues/48\n if (macCategory != null) {\n log.warn({ macCategory }, \"cannot map macOS category to Linux. If possible mapping is known for you, please file issue to add it.\")\n }\n log.warn(\n {\n reason: \"linux.category is not set and cannot map from macOS\",\n docs: \"https://www.electron.build/linux\",\n },\n 'application Linux category is set to default \"Utility\"'\n )\n category = \"Utility\"\n }\n }\n desktopMeta.Categories = `${category}${category.endsWith(\";\") ? \"\" : \";\"}`\n\n let data = `[Desktop Entry]`\n for (const name of Object.keys(desktopMeta)) {\n data += `\\n${name}=${desktopMeta[name]}`\n }\n data += \"\\n\"\n const desktopActions = targetSpecificOptions.desktop?.desktopActions ?? {}\n for (const [actionName, config] of Object.entries(desktopActions)) {\n if (!Object.keys(config ?? {}).length) {\n continue\n }\n data += `\\n[Desktop Action ${actionName}]`\n for (const [key, value] of Object.entries(config ?? {})) {\n data += `\\n${key}=${value}`\n }\n data += \"\\n\"\n }\n return Promise.resolve(data)\n }\n}\n\nconst macToLinuxCategory: any = {\n \"public.app-category.graphics-design\": \"Graphics\",\n \"public.app-category.developer-tools\": \"Development\",\n \"public.app-category.education\": \"Education\",\n \"public.app-category.games\": \"Game\",\n \"public.app-category.video\": \"Video;AudioVideo\",\n \"public.app-category.utilities\": \"Utility\",\n \"public.app-category.social-networking\": \"Network;Chat\",\n \"public.app-category.finance\": \"Office;Finance\",\n \"public.app-category.music\": \"Audio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;YACD,IAAI,IAAI,qBAAqB,UAAU,GAAG,CAAA;YAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,EAAE,CAAC;gBACxD,IAAI,IAAI,KAAK,GAAG,IAAI,KAAK,EAAE,CAAA;YAC7B,CAAC;YACD,IAAI,IAAI,IAAI,CAAA;QACd,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;CACF;AA7SD,8CA6SC;AAED,MAAM,kBAAkB,GAAQ;IAC9B,qCAAqC,EAAE,UAAU;IACjD,qCAAqC,EAAE,aAAa;IACpD,+BAA+B,EAAE,WAAW;IAC5C,2BAA2B,EAAE,MAAM;IACnC,2BAA2B,EAAE,kBAAkB;IAC/C,+BAA+B,EAAE,SAAS;IAC1C,uCAAuC,EAAE,cAAc;IACvD,6BAA6B,EAAE,gBAAgB;IAC/C,2BAA2B,EAAE,kBAAkB;CAChD,CAAA","sourcesContent":["import { asArray, exists, InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { deepAssign } from \"builder-util-runtime\"\nimport { outputFile } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport { join } from \"path\"\nimport * as semver from \"semver\"\nimport { CompressionLevel } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { CommonLinuxOptions } from \"../options/linuxOptions\"\nimport { SnapCore } from \"./snap/SnapTarget\"\nimport { SnapCore24 } from \"./snap/core24\"\nimport { SnapCoreCustom } from \"./snap/coreCustom\"\nimport { SnapCoreLegacy } from \"./snap/coreLegacy\"\nimport { IconInfo } from \"../util/iconConverter\"\n\n/**\n * Escape a string value for use in a freedesktop .desktop file string field\n * (Name, Comment, StartupWMClass, etc.).\n *\n * The freedesktop Desktop Entry Specification requires that the following\n * characters be escaped in string / localestring values:\n * \\n → \\\\n (newline — would inject new key=value lines otherwise)\n * \\r → \\\\r\n * \\t → \\\\t\n * \\\\ → \\\\\\\\\n *\n * Without escaping, a productName or description containing a literal newline\n * can inject arbitrary key=value pairs into the generated .desktop file,\n * potentially overriding the Exec key.\n *\n * @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#value-types\n */\nfunction desktopStringEscape(value: string): string {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\n/g, \"\\\\n\").replace(/\\r/g, \"\\\\r\").replace(/\\t/g, \"\\\\t\")\n}\n\n/**\n * Build the argument portion of a .desktop Exec line.\n *\n * executableArgs are written verbatim — matching AppImage and the behavior that\n * shipped for years — so an arg like `--js-flags=\"--max-old-space-size=12288\"`\n * reaches the launcher exactly as the developer specified. Only carriage-return\n * and newline characters are removed: the Exec key is a single line, and an\n * embedded line break would split it into additional .desktop entries.\n *\n * @see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables\n */\nexport function buildExecArgs(executableArgs: ReadonlyArray<string>): string {\n return executableArgs.map(arg => arg.replace(/[\\r\\n]+/g, \"\")).join(\" \")\n}\n\nfunction mapLinuxCompressionToSnap(level: CompressionLevel | null | undefined): \"xz\" | \"lzo\" | undefined {\n if (level === \"store\") {\n return \"lzo\"\n }\n if (level === \"maximum\") {\n return \"xz\"\n }\n return undefined\n}\n\nexport const installPrefix = \"/opt\"\n\nexport class LinuxTargetHelper {\n private readonly iconPromise = new Lazy(() => this.computeDesktopIcons())\n\n private readonly mimeTypeFilesPromise = new Lazy(() => this.computeMimeTypeFiles())\n\n maxIconPath: string | null = null\n\n constructor(private packager: LinuxPackager) {}\n\n get icons(): Promise<Array<IconInfo>> {\n return this.iconPromise.value\n }\n\n get mimeTypeFiles(): Promise<string | null> {\n return this.mimeTypeFilesPromise.value\n }\n\n getSnapCore(): SnapCore<any> {\n const { snapcraft, snap: legacySnap } = this.packager.config\n if (snapcraft != null && legacySnap != null) {\n log.warn(\"Both `snapcraft` and `snap` configurations are present. `snapcraft` takes precedence; please remove the `snap` key to silence this warning.\")\n }\n\n // Merge linux-level options (category, description, mimeTypes, etc.) as the base so they\n // propagate into the generated snapcraft.yaml and .desktop file without requiring users to\n // duplicate them under core24/core18/etc. Per-core options always win for conflicts.\n // linux.compression is a CompressionLevel (\"store\"/\"normal\"/\"maximum\"); snap compression is an\n // algorithm (\"xz\"/\"lzo\"). Map the level to the nearest algorithm; per-core options override.\n const { compression: linuxCompression, ...linuxOptions } = this.packager.platformSpecificBuildOptions\n const snapLinuxOptions = { ...linuxOptions, compression: mapLinuxCompressionToSnap(linuxCompression) }\n\n if (snapcraft != null) {\n const core = snapcraft.base\n const options = snapcraft[core] || {}\n switch (core) {\n case \"core18\":\n case \"core20\":\n case \"core22\":\n if (!this.isElectronVersionGreaterOrEqualThan(\"4.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThan(\"2.0.0-beta.1\")) {\n throw new InvalidConfigurationError(\"Electron 2 and higher is required to build Snap with core18/core20/core22\")\n }\n log.warn(null, \"electron 4 and higher is highly recommended for Snap with core18/core20/core22\")\n }\n return new SnapCoreLegacy(this.packager, this, deepAssign({}, snapLinuxOptions, { base: core, ...options }))\n case \"core24\":\n if (!this.isElectronVersionGreaterOrEqualThan(\"28.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThan(\"25.0.0\")) {\n throw new InvalidConfigurationError(\"Electron 25 and higher is required to build Snap with core24\")\n }\n log.warn(null, \"electron 28 and higher is highly recommended for Snap with core24\")\n }\n return new SnapCore24(this.packager, this, deepAssign({}, snapLinuxOptions, options))\n case \"custom\":\n // Pass-through: do not inject linux options into user-supplied yaml\n return new SnapCoreCustom(this.packager, this, snapcraft.custom || {})\n }\n }\n\n if (legacySnap != null) {\n log.warn(\n {\n reason: \"`snap` configuration is deprecated\",\n docs: \"https://www.electron.build/snapcraft\",\n },\n \"please consider migrating `snap` configuration to `snapcraft.<core>` and remove `snap` configuration\"\n )\n }\n return new SnapCoreLegacy(this.packager, this, deepAssign({}, snapLinuxOptions, legacySnap ?? {}))\n }\n\n isElectronVersionGreaterOrEqualThan(version: string, fallback?: string): boolean {\n const electronVersion = this.packager.config.electronVersion\n if (!electronVersion) {\n return fallback ? semver.gte(fallback, version) : true\n }\n return semver.gte(electronVersion, version)\n }\n\n private async computeMimeTypeFiles(): Promise<string | null> {\n const items: Array<string> = []\n for (const fileAssociation of this.packager.fileAssociations) {\n if (!fileAssociation.mimeType) {\n continue\n }\n\n const data = `<mime-type type=\"${fileAssociation.mimeType}\">\n <glob pattern=\"*.${fileAssociation.ext}\"/>\n ${fileAssociation.description ? `<comment>${fileAssociation.description}</comment>` : \"\"}\n <icon name=\"x-office-document\" />\n</mime-type>`\n items.push(data)\n }\n\n if (items.length === 0) {\n return null\n }\n\n const file = await this.packager.getTempFile(\".xml\")\n await outputFile(\n file,\n '<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\\n' + items.join(\"\\n\") + \"\\n</mime-info>\"\n )\n return file\n }\n\n // must be name without spaces and other special characters, but not product name used\n private async computeDesktopIcons(): Promise<Array<IconInfo>> {\n const packager = this.packager\n const { platformSpecificBuildOptions, config } = packager\n\n const sources = [platformSpecificBuildOptions.icon, config.mac?.icon ?? config.icon].filter(str => !!str) as string[]\n\n // If no explicit sources are defined, fallback to buildResources directory, then default framework icon\n let fallbackSources = [...asArray(packager.getDefaultFrameworkIcon())]\n const buildResources = config.directories?.buildResources\n if (buildResources && (await exists(join(buildResources, \"icons\")))) {\n fallbackSources = [buildResources, ...fallbackSources]\n }\n\n // need to put here and not as default because need to resolve image size\n const result = await packager.resolveIcon(sources, fallbackSources, \"set\")\n this.maxIconPath = result[result.length - 1].file\n\n // Ignore .icon files for linux (they are exclusive for macOS)\n return result.filter(icon => !icon.file.endsWith(\".icon\"))\n }\n\n getDescription(options: CommonLinuxOptions) {\n return options.description || this.packager.appInfo.description\n }\n\n getSanitizedVersion(target: string) {\n const {\n appInfo: { version },\n } = this.packager\n switch (target) {\n case \"pacman\":\n return version.replace(/-/g, \"_\")\n case \"rpm\":\n case \"deb\":\n return version.replace(/-/g, \"~\")\n default:\n return version\n }\n }\n\n async writeDesktopEntry(targetSpecificOptions: CommonLinuxOptions, exec?: string, destination?: string | null, extra?: Record<string, string>): Promise<string> {\n const data = await this.computeDesktopEntry(targetSpecificOptions, exec, extra)\n const file = destination || (await this.packager.getTempFile(`${this.packager.appInfo.productFilename}.desktop`))\n await outputFile(file, data)\n return file\n }\n\n getDesktopFileName(fallback: string = this.packager.executableName): string {\n if (!this.packager.platformSpecificBuildOptions.syncDesktopName) {\n return fallback\n }\n const trimmedDesktopName = this.packager.info.metadata.desktopName?.trim()\n if (isEmptyOrSpaces(trimmedDesktopName)) {\n return fallback\n }\n const basename = trimmedDesktopName.replace(/\\.desktop$/, \"\")\n // Guard against path traversal: desktopName flows into filesystem paths\n // (snap/gui/<name>.desktop, /usr/share/applications/<name>.desktop, etc.).\n if (/[/\\\\]/.test(basename) || [...basename].some(c => c.charCodeAt(0) === 0)) {\n throw new InvalidConfigurationError(`desktopName \"${trimmedDesktopName}\" produces an invalid .desktop filename — remove any path separators or NUL characters`)\n }\n return basename\n }\n\n computeDesktopEntry(targetSpecificOptions: CommonLinuxOptions, exec?: string, extra?: Record<string, string>): Promise<string> {\n if (exec != null && exec.length === 0) {\n throw new Error(\"Specified exec is empty\")\n }\n // https://github.com/electron-userland/electron-builder/issues/3418\n if (targetSpecificOptions.desktop?.entry?.Exec) {\n throw new Error(\"Please specify executable name as linux.executableName instead of linux.desktop.Exec\")\n }\n\n const packager = this.packager\n const appInfo = packager.appInfo\n\n const executableArgs = targetSpecificOptions.executableArgs\n if (exec == null) {\n exec = `${installPrefix}/${appInfo.sanitizedProductName}/${packager.executableName}`\n if (!/^[/0-9A-Za-z._-]+$/.test(exec)) {\n exec = `\"${exec}\"`\n }\n if (executableArgs && executableArgs.length > 0) {\n exec += \" \" + buildExecArgs(executableArgs)\n }\n // https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables\n const execCodes = [\"%f\", \"%u\", \"%F\", \"%U\"]\n if (executableArgs == null || executableArgs.findIndex(arg => execCodes.includes(arg)) === -1) {\n exec += \" %U\"\n }\n }\n\n // https://github.com/electron-userland/electron-builder/issues/9103\n // Electron derives app_id from desktopName in package.json; StartupWMClass must match.\n // https://github.com/electron/electron/blob/9a7b73b5334f1d72c08e2d5e94106706ed751186/lib/browser/init.ts#L128-L133\n const trimmedDesktopName = packager.info.metadata.desktopName?.trim()\n if (isEmptyOrSpaces(trimmedDesktopName)) {\n log.warn(\n {\n reason: \"desktopName is not set in package.json\",\n docs: \"https://www.electron.build/linux#window-association-desktopname--syncdesktopname\",\n },\n \"electron uses desktopName as app_id / WM_CLASS for window association. Without it desktop environments may not link running windows to this .desktop entry. Set desktopName in package.json and linux.syncDesktopName: true to fix.\"\n )\n }\n const wmClass = !isEmptyOrSpaces(trimmedDesktopName) ? trimmedDesktopName.replace(/\\.desktop$/, \"\") : appInfo.productName\n\n const desktopMeta = deepAssign<any>(\n {\n // String values are escaped per the freedesktop spec (\\\\, \\n, \\r, \\t)\n // so that a product name containing a newline cannot inject new key=value\n // pairs into the .desktop file (e.g. overriding the Exec key).\n Name: desktopStringEscape(appInfo.productName),\n Exec: exec,\n Terminal: \"false\",\n Type: \"Application\",\n Icon: packager.executableName,\n // https://askubuntu.com/questions/367396/what-represent-the-startupwmclass-field-of-a-desktop-file\n // Set to desktopName (minus .desktop suffix) when provided, so it matches Electron's\n // app_id and desktop environments can associate running windows with this entry.\n // Falls back to productName for apps that don't set desktopName.\n // to get WM_CLASS of running window: xprop WM_CLASS\n // StartupWMClass doesn't work for unicode\n // https://github.com/electron/electron/blob/2-0-x/atom/browser/native_window_views.cc#L226\n StartupWMClass: desktopStringEscape(wmClass),\n },\n extra,\n targetSpecificOptions.desktop?.entry ?? {}\n )\n\n const description = this.getDescription(targetSpecificOptions)\n if (!isEmptyOrSpaces(description)) {\n desktopMeta.Comment = desktopStringEscape(description)\n }\n\n const mimeTypes: Array<string> = asArray(targetSpecificOptions.mimeTypes)\n for (const fileAssociation of packager.fileAssociations) {\n if (fileAssociation.mimeType != null) {\n mimeTypes.push(fileAssociation.mimeType)\n }\n }\n\n for (const protocol of asArray(packager.config.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))) {\n for (const scheme of asArray(protocol.schemes)) {\n mimeTypes.push(`x-scheme-handler/${scheme}`)\n }\n }\n\n if (mimeTypes.length !== 0) {\n desktopMeta.MimeType = mimeTypes.join(\";\") + \";\"\n }\n\n let category = targetSpecificOptions.category\n if (isEmptyOrSpaces(category)) {\n const macCategory = (packager.config.mac || {}).category\n if (macCategory != null) {\n category = macToLinuxCategory[macCategory]\n }\n\n if (category == null) {\n // https://github.com/develar/onshape-desktop-shell/issues/48\n if (macCategory != null) {\n log.warn({ macCategory }, \"cannot map macOS category to Linux. If possible mapping is known for you, please file issue to add it.\")\n }\n log.warn(\n {\n reason: \"linux.category is not set and cannot map from macOS\",\n docs: \"https://www.electron.build/linux\",\n },\n 'application Linux category is set to default \"Utility\"'\n )\n category = \"Utility\"\n }\n }\n desktopMeta.Categories = `${category}${category.endsWith(\";\") ? \"\" : \";\"}`\n\n let data = `[Desktop Entry]`\n for (const name of Object.keys(desktopMeta)) {\n data += `\\n${name}=${desktopMeta[name]}`\n }\n data += \"\\n\"\n const desktopActions = targetSpecificOptions.desktop?.desktopActions ?? {}\n for (const [actionName, config] of Object.entries(desktopActions)) {\n if (!Object.keys(config ?? {}).length) {\n continue\n }\n data += `\\n[Desktop Action ${actionName}]`\n for (const [key, value] of Object.entries(config ?? {})) {\n data += `\\n${key}=${value}`\n }\n data += \"\\n\"\n }\n return Promise.resolve(data)\n }\n}\n\nconst macToLinuxCategory: any = {\n \"public.app-category.graphics-design\": \"Graphics\",\n \"public.app-category.developer-tools\": \"Development\",\n \"public.app-category.education\": \"Education\",\n \"public.app-category.games\": \"Game\",\n \"public.app-category.video\": \"Video;AudioVideo\",\n \"public.app-category.utilities\": \"Utility\",\n \"public.app-category.social-networking\": \"Network;Chat\",\n \"public.app-category.finance\": \"Office;Finance\",\n \"public.app-category.music\": \"Audio;AudioVideo\",\n}\n"]}
|
|
@@ -8,6 +8,7 @@ const path = require("path");
|
|
|
8
8
|
const core_1 = require("../../core");
|
|
9
9
|
const PublishManager_1 = require("../../publish/PublishManager");
|
|
10
10
|
const license_1 = require("../../util/license");
|
|
11
|
+
const LinuxTargetHelper_1 = require("../LinuxTargetHelper");
|
|
11
12
|
const targetUtil_1 = require("../targetUtil");
|
|
12
13
|
const appImageUtil_1 = require("./appImageUtil");
|
|
13
14
|
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
@@ -25,7 +26,7 @@ class AppImageTarget extends core_1.Target {
|
|
|
25
26
|
const appimageTool = (_a = packager.config.toolsets) === null || _a === void 0 ? void 0 : _a.appimage;
|
|
26
27
|
const defaultArgs = appimageTool == null || appimageTool === "0.0.0" ? ["--no-sandbox"] : [];
|
|
27
28
|
const args = (_b = this.options.executableArgs) !== null && _b !== void 0 ? _b : defaultArgs;
|
|
28
|
-
const exec = [exports.APP_RUN_ENTRYPOINT,
|
|
29
|
+
const exec = [exports.APP_RUN_ENTRYPOINT, (0, LinuxTargetHelper_1.buildExecArgs)(args), "%U"].filter(Boolean).join(" ");
|
|
29
30
|
return helper.computeDesktopEntry(this.options, exec, {
|
|
30
31
|
"X-AppImage-Version": `${packager.appInfo.buildVersion}`,
|
|
31
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppImageTarget.js","sourceRoot":"","sources":["../../../src/targets/appimage/AppImageTarget.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,uCAAqC;AACrC,uCAA+B;AAC/B,6BAA4B;AAC5B,qCAAmC;AAGnC,iEAA+E;AAC/E,gDAA+D;AAE/D,8CAA8C;AAC9C,iDAAqF;AACrF,+DAAqE;AAErE,+FAA+F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gBAAgB,EAAE,QAAQ,CAAC,uBAAuB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC;YACzF,MAAM,EAAE,IAAI;YACZ,IAAI;YACJ,QAAQ;YACR,iBAAiB,EAAE,IAAI;YACvB,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;CACF;AA7ID,iCA6IC","sourcesContent":["import { Arch, log, serializeToYaml } from \"builder-util\"\nimport { outputFile } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../../core\"\nimport { LinuxPackager } from \"../../linuxPackager\"\nimport { AppImageOptions } from \"../../options/linuxOptions\"\nimport { getAppUpdatePublishConfiguration } from \"../../publish/PublishManager\"\nimport { getNotLocalizedLicenseFile } from \"../../util/license\"\nimport { LinuxTargetHelper } from \"../LinuxTargetHelper\"\nimport { createStageDir } from \"../targetUtil\"\nimport { buildLegacyFuse2AppImage, buildStaticRuntimeAppImage } from \"./appImageUtil\"\nimport { BlockMapDataHolder, deepAssign } from \"builder-util-runtime\"\n\n// https://unix.stackexchange.com/questions/375191/append-to-sub-directory-inside-squashfs-file\n\nexport const APP_RUN_ENTRYPOINT = \"AppRun\"\n\nexport default class AppImageTarget extends Target {\n readonly options: AppImageOptions = deepAssign({}, this.packager.platformSpecificBuildOptions, (this.packager.config as any)[this.name])\n\n private readonly desktopEntry: Lazy<string>\n\n constructor(\n _ignored: string,\n private readonly packager: LinuxPackager,\n private readonly helper: LinuxTargetHelper,\n readonly outDir: string\n ) {\n super(\"appImage\")\n\n this.desktopEntry = new Lazy<string>(() => {\n const appimageTool = packager.config.toolsets?.appimage\n const defaultArgs = appimageTool == null || appimageTool === \"0.0.0\" ? [\"--no-sandbox\"] : []\n const args = this.options.executableArgs ?? defaultArgs\n const exec = [APP_RUN_ENTRYPOINT, ...args, \"%U\"].join(\" \")\n return helper.computeDesktopEntry(this.options, exec, {\n \"X-AppImage-Version\": `${packager.appInfo.buildVersion}`,\n })\n })\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n\n const options = this.options\n // https://github.com/electron-userland/electron-builder/issues/775\n // https://github.com/electron-userland/electron-builder/issues/1726\n const artifactName = packager.expandArtifactNamePattern(options, \"AppImage\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: \"AppImage\",\n file: artifactPath,\n arch,\n })\n\n // Parallelize independent async operations\n const [publishConfig, stageDir, desktopEntry, icons, license] = await Promise.all([\n getAppUpdatePublishConfiguration(packager, options, arch, false),\n createStageDir(this, packager, arch),\n this.desktopEntry.value,\n this.helper.icons,\n getNotLocalizedLicenseFile(options.license, this.packager, [\"txt\", \"html\"]),\n ])\n\n if (publishConfig != null) {\n await outputFile(path.join(packager.getResourcesDir(appOutDir), \"app-update.yml\"), serializeToYaml(publishConfig))\n }\n\n // Validated once here; throws InvalidConfigurationError for path traversal / NUL.\n const desktopBaseName = this.helper.getDesktopFileName()\n\n if (\n this.packager.packagerOptions.effectiveOptionComputed != null &&\n (await this.packager.packagerOptions.effectiveOptionComputed({ desktop: desktopEntry, desktopFileName: `${desktopBaseName}.desktop` }))\n ) {\n await stageDir.cleanup()\n return\n }\n\n let updateInfo: BlockMapDataHolder\n try {\n const appimageTool = this.packager.config.toolsets?.appimage\n if (appimageTool == null || appimageTool === \"0.0.0\") {\n updateInfo = await buildLegacyFuse2AppImage({\n appDir: appOutDir,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"xz\" || c === \"gzip\") {\n return c\n }\n if (packager.compression === \"maximum\") {\n return \"xz\"\n }\n return undefined // normal/store/unset/zstd → mksquashfs defaults to gzip\n })(),\n },\n })\n } else {\n updateInfo = await buildStaticRuntimeAppImage(appimageTool, {\n appDir: appOutDir,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"gzip\" || c === \"zstd\") {\n return c\n }\n if (c === \"xz\") {\n return \"zstd\" // nearest equivalent; static runtime does not support xz\n }\n if (packager.compression === \"store\") {\n return \"gzip\"\n }\n return \"zstd\" // maximum/normal/unset → zstd for static runtime\n })(),\n },\n })\n }\n } catch (error: any) {\n log.error({ error: error.message }, \"failed to build AppImage\")\n throw error\n } finally {\n await stageDir.cleanup().catch(() => {})\n }\n\n await packager.info.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"AppImage\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: true,\n updateInfo,\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AppImageTarget.js","sourceRoot":"","sources":["../../../src/targets/appimage/AppImageTarget.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,uCAAqC;AACrC,uCAA+B;AAC/B,6BAA4B;AAC5B,qCAAmC;AAGnC,iEAA+E;AAC/E,gDAA+D;AAC/D,4DAAuE;AACvE,8CAA8C;AAC9C,iDAAqF;AACrF,+DAAqE;AAErE,+FAA+F;AAElF,QAAA,kBAAkB,GAAG,QAAQ,CAAA;AAE1C,MAAqB,cAAe,SAAQ,aAAM;IAKhD,YACE,QAAgB,EACC,QAAuB,EACvB,MAAyB,EACjC,MAAc;QAEvB,KAAK,CAAC,UAAU,CAAC,CAAA;QAJA,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAmB;QACjC,WAAM,GAAN,MAAM,CAAQ;QARhB,YAAO,GAAoB,IAAA,iCAAU,EAAC,EAAE,EAAE,IAAI,CAAC,QA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"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../../core\"\nimport { LinuxPackager } from \"../../linuxPackager\"\nimport { AppImageOptions } from \"../../options/linuxOptions\"\nimport { getAppUpdatePublishConfiguration } from \"../../publish/PublishManager\"\nimport { getNotLocalizedLicenseFile } from \"../../util/license\"\nimport { buildExecArgs, LinuxTargetHelper } from \"../LinuxTargetHelper\"\nimport { createStageDir } from \"../targetUtil\"\nimport { buildLegacyFuse2AppImage, buildStaticRuntimeAppImage } from \"./appImageUtil\"\nimport { BlockMapDataHolder, deepAssign } from \"builder-util-runtime\"\n\n// https://unix.stackexchange.com/questions/375191/append-to-sub-directory-inside-squashfs-file\n\nexport const APP_RUN_ENTRYPOINT = \"AppRun\"\n\nexport default class AppImageTarget extends Target {\n readonly options: AppImageOptions = deepAssign({}, this.packager.platformSpecificBuildOptions, (this.packager.config as any)[this.name])\n\n private readonly desktopEntry: Lazy<string>\n\n constructor(\n _ignored: string,\n private readonly packager: LinuxPackager,\n private readonly helper: LinuxTargetHelper,\n readonly outDir: string\n ) {\n super(\"appImage\")\n\n this.desktopEntry = new Lazy<string>(() => {\n const appimageTool = packager.config.toolsets?.appimage\n const defaultArgs = appimageTool == null || appimageTool === \"0.0.0\" ? [\"--no-sandbox\"] : []\n const args = this.options.executableArgs ?? defaultArgs\n const exec = [APP_RUN_ENTRYPOINT, buildExecArgs(args), \"%U\"].filter(Boolean).join(\" \")\n return helper.computeDesktopEntry(this.options, exec, {\n \"X-AppImage-Version\": `${packager.appInfo.buildVersion}`,\n })\n })\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n\n const options = this.options\n // https://github.com/electron-userland/electron-builder/issues/775\n // https://github.com/electron-userland/electron-builder/issues/1726\n const artifactName = packager.expandArtifactNamePattern(options, \"AppImage\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: \"AppImage\",\n file: artifactPath,\n arch,\n })\n\n // Parallelize independent async operations\n const [publishConfig, stageDir, desktopEntry, icons, license] = await Promise.all([\n getAppUpdatePublishConfiguration(packager, options, arch, false),\n createStageDir(this, packager, arch),\n this.desktopEntry.value,\n this.helper.icons,\n getNotLocalizedLicenseFile(options.license, this.packager, [\"txt\", \"html\"]),\n ])\n\n if (publishConfig != null) {\n await outputFile(path.join(packager.getResourcesDir(appOutDir), \"app-update.yml\"), serializeToYaml(publishConfig))\n }\n\n // Validated once here; throws InvalidConfigurationError for path traversal / NUL.\n const desktopBaseName = this.helper.getDesktopFileName()\n\n if (\n this.packager.packagerOptions.effectiveOptionComputed != null &&\n (await this.packager.packagerOptions.effectiveOptionComputed({ desktop: desktopEntry, desktopFileName: `${desktopBaseName}.desktop` }))\n ) {\n await stageDir.cleanup()\n return\n }\n\n let updateInfo: BlockMapDataHolder\n try {\n const appimageTool = this.packager.config.toolsets?.appimage\n if (appimageTool == null || appimageTool === \"0.0.0\") {\n updateInfo = await buildLegacyFuse2AppImage({\n appDir: appOutDir,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"xz\" || c === \"gzip\") {\n return c\n }\n if (packager.compression === \"maximum\") {\n return \"xz\"\n }\n return undefined // normal/store/unset/zstd → mksquashfs defaults to gzip\n })(),\n },\n })\n } else {\n updateInfo = await buildStaticRuntimeAppImage(appimageTool, {\n appDir: appOutDir,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"gzip\" || c === \"zstd\") {\n return c\n }\n if (c === \"xz\") {\n return \"zstd\" // nearest equivalent; static runtime does not support xz\n }\n if (packager.compression === \"store\") {\n return \"gzip\"\n }\n return \"zstd\" // maximum/normal/unset → zstd for static runtime\n })(),\n },\n })\n }\n } catch (error: any) {\n log.error({ error: error.message }, \"failed to build AppImage\")\n throw error\n } finally {\n await stageDir.cleanup().catch(() => {})\n }\n\n await packager.info.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"AppImage\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: true,\n updateInfo,\n })\n }\n}\n"]}
|
package/out/targets/archive.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompressionLevel } from "../core";
|
|
1
|
+
import { CompressionLevel, Platform } from "../core";
|
|
2
2
|
export interface ArchiveOptions {
|
|
3
3
|
compression?: CompressionLevel | null;
|
|
4
4
|
/**
|
|
@@ -18,9 +18,17 @@ export interface ArchiveOptions {
|
|
|
18
18
|
method?: "Copy" | "LZMA" | "Deflate" | "DEFAULT";
|
|
19
19
|
isRegularFile?: boolean;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.
|
|
22
|
+
* Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.
|
|
22
23
|
* @default false
|
|
23
24
|
*/
|
|
24
25
|
preserveSymlinks?: boolean;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).
|
|
29
|
+
* Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)
|
|
30
|
+
* and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks
|
|
31
|
+
* there requires elevated privileges. Keyed on the target platform, not the build host.
|
|
32
|
+
*/
|
|
33
|
+
export declare function shouldPreserveSymlinks(platform: Platform): boolean;
|
|
26
34
|
export declare function compute7zCompressArgs(format: string, options?: ArchiveOptions): string[];
|
package/out/targets/archive.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tar = tar;
|
|
4
|
+
exports.shouldPreserveSymlinks = shouldPreserveSymlinks;
|
|
4
5
|
exports.compute7zCompressArgs = compute7zCompressArgs;
|
|
5
6
|
exports.archive = archive;
|
|
6
7
|
const builder_util_1 = require("builder-util");
|
|
7
8
|
const fs_extra_1 = require("fs-extra");
|
|
8
9
|
const path = require("path");
|
|
9
10
|
const tar_1 = require("tar");
|
|
11
|
+
const core_1 = require("../core");
|
|
10
12
|
const linux_1 = require("../toolsets/linux");
|
|
11
13
|
const _7zip_1 = require("../toolsets/7zip");
|
|
12
14
|
const ALLOWED_7Z_FILTERS = new Set(["BCJ", "BCJ2", "ARM", "ARMT", "IA64", "PPC", "SPARC", "DELTA"]);
|
|
@@ -47,6 +49,15 @@ async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempD
|
|
|
47
49
|
args.push(outFile, tarFile);
|
|
48
50
|
await (0, builder_util_1.exec)(await (0, _7zip_1.getPath7za)(), args, { cwd: path.dirname(dirToArchive) }, builder_util_1.debug7z.enabled);
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).
|
|
54
|
+
* Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)
|
|
55
|
+
* and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks
|
|
56
|
+
* there requires elevated privileges. Keyed on the target platform, not the build host.
|
|
57
|
+
*/
|
|
58
|
+
function shouldPreserveSymlinks(platform) {
|
|
59
|
+
return platform !== core_1.Platform.WINDOWS;
|
|
60
|
+
}
|
|
50
61
|
function compute7zCompressArgs(format, options = {}) {
|
|
51
62
|
let storeOnly = options.compression === "store";
|
|
52
63
|
const args = debug7zArgs("a");
|
|
@@ -113,13 +124,22 @@ async function archive(format, outFile, dirToArchive, options = {}) {
|
|
|
113
124
|
builder_util_1.log.info({ reason: "Archive file is up to date", outFile }, `skipped archiving`);
|
|
114
125
|
return outFile;
|
|
115
126
|
}
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
// Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a
|
|
128
|
+
// fallback for NFD-normalized filenames, which 7za mangles.
|
|
129
|
+
let use7z = true;
|
|
130
|
+
if (process.platform === "darwin" && format === "zip" && dirToArchive.normalize("NFC") !== dirToArchive) {
|
|
131
|
+
builder_util_1.log.warn({ reason: "7z doesn't support NFD-normalized filenames" }, `using zip`);
|
|
132
|
+
use7z = false;
|
|
133
|
+
}
|
|
121
134
|
if (use7z) {
|
|
122
135
|
const args = compute7zCompressArgs(format, options);
|
|
136
|
+
// Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before
|
|
137
|
+
// 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts
|
|
138
|
+
// as a real directory → codesign "bundle format is ambiguous" → breaks Squirrel.Mac
|
|
139
|
+
// auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).
|
|
140
|
+
if (options.preserveSymlinks) {
|
|
141
|
+
args.push("-snl");
|
|
142
|
+
}
|
|
123
143
|
await (0, builder_util_1.unlinkIfExists)(outFile);
|
|
124
144
|
args.push(outFile, options.withoutDir ? "." : path.basename(dirToArchive));
|
|
125
145
|
if (options.excluded != null) {
|
|
@@ -143,7 +163,7 @@ async function archive(format, outFile, dirToArchive, options = {}) {
|
|
|
143
163
|
}
|
|
144
164
|
}
|
|
145
165
|
else {
|
|
146
|
-
// macOS native zip: -y preserves symlinks
|
|
166
|
+
// macOS native zip (NFD fallback): -y preserves symlinks
|
|
147
167
|
const args = ["-q", "-r", "-y"];
|
|
148
168
|
if (builder_util_1.debug7z.enabled) {
|
|
149
169
|
args.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AAA;QAC1E,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACpC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,MAAM,IAAI,KAAK,CAAC,+DAA+D,IAAI,GAAG,CAAC,CAAA;gBACzF,CAAC;gBACD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QACD,MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\nconst ALLOWED_7Z_FILTERS = new Set([\"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Use native macOS `zip` to preserve symlinks. Required for .framework bundles.\n * @default false\n */\n preserveSymlinks?: boolean\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n if (!ALLOWED_7Z_FILTERS.has(sevenZFilter.toUpperCase())) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${sevenZFilter}`)\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // On macOS, use native `zip` when symlink preservation is required (e.g. .framework bundles).\n // 7zip dereferences symlinks, corrupting .framework structure and breaking codesign.\n // Only opt in via preserveSymlinks — Windows zip targets built on macOS still use 7z\n // so that the UTF-8 bit (-mcu) is set correctly in the zip header.\n const use7z = !(process.platform === \"darwin\" && format === \"zip\" && options.preserveSymlinks)\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n if (options.excluded != null) {\n for (const mask of options.excluded) {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n args.push(`-xr!${mask}`)\n }\n }\n\n try {\n await exec(await getPath7za(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n } else {\n // macOS native zip: -y preserves symlinks (required for .framework bundles)\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n if (options.excluded != null) {\n for (const mask of options.excluded) {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n args.push(`-x${mask}`)\n }\n }\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
|
|
1
|
+
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA4BA,kBAiCC;AA0CD,wDAEC;AAED,sDA8DC;AAID,0BAsEC;AAnPD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AAEnG,SAAS,wBAAwB,CAAC,KAAa;IAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wEAAwE,KAAK,GAAG,CAAC,CAAA;IACnG,CAAC;AACH,CAAC;AAWD,gBAAgB;AACT,KAAK,UAAU,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAa;IAC3G,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,WAAW,C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MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\nconst ALLOWED_7Z_FILTERS = new Set([\"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n if (!ALLOWED_7Z_FILTERS.has(sevenZFilter.toUpperCase())) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${sevenZFilter}`)\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n if (options.excluded != null) {\n for (const mask of options.excluded) {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n args.push(`-xr!${mask}`)\n }\n }\n\n try {\n await exec(await getPath7za(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n if (options.excluded != null) {\n for (const mask of options.excluded) {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n args.push(`-x${mask}`)\n }\n }\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
|
|
@@ -524,9 +524,9 @@ class NsisTarget extends core_1.Target {
|
|
|
524
524
|
// would terminate the current script line and let whatever follows
|
|
525
525
|
// be parsed as a new preprocessor directive (e.g. !system, !include).
|
|
526
526
|
// 2. bare $ → escaped to $$; unescaped $ in a define value would cause
|
|
527
|
-
// NSIS to expand an unintended variable reference. ${...}
|
|
528
|
-
//
|
|
529
|
-
// expand correctly.
|
|
527
|
+
// NSIS to expand an unintended variable reference. ${...} define
|
|
528
|
+
// references (e.g. ${NSISDIR}) and $(...) LangString references
|
|
529
|
+
// (e.g. $(customSN)) are left intact so they still expand correctly.
|
|
530
530
|
// 3. " chars → escaped to $\"; an unescaped " would break out of
|
|
531
531
|
// double-quoted NSIS string literals where ${DEFINE} is expanded.
|
|
532
532
|
args.push(`-D${name}=${(0, nsisScriptGenerator_1.nsisEscapeString)(String(value))}`);
|