update electron to v43
All checks were successful
Android Build / publish (push) Successful in 55s
Linux Build / publish (push) Successful in 1m6s

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -1,6 +1,6 @@
export declare class DebugLogger {
readonly isEnabled: boolean;
readonly data: any;
readonly data: Map<string, any>;
constructor(isEnabled?: boolean);
add(key: string, value: any): void;
save(file: string): Promise<void>;

View file

@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.DebugLogger = void 0;
const fs_extra_1 = require("fs-extra");
const util_1 = require("./util");
const builder_util_runtime_1 = require("builder-util-runtime");
class DebugLogger {
constructor(isEnabled = true) {
this.isEnabled = isEnabled;
this.data = {};
this.data = new Map();
}
add(key, value) {
if (!this.isEnabled) {
@ -21,26 +22,27 @@ class DebugLogger {
break;
}
else {
if (o[p] == null) {
o[p] = Object.create(null);
if (!o.has(p)) {
o.set(p, new Map());
}
else if (typeof o[p] === "string") {
o[p] = [o[p]];
else if (typeof o.get(p) === "string") {
o.set(p, [o.get(p)]);
}
o = o[p];
o = o.get(p);
}
}
if (Array.isArray(o[lastName])) {
o[lastName] = [...o[lastName], value];
if (Array.isArray(o.get(lastName))) {
o.set(lastName, [...o.get(lastName), value]);
}
else {
o[lastName] = value;
o.set(lastName, value);
}
}
save(file) {
const data = (0, builder_util_runtime_1.mapToObject)(this.data);
// toml and json doesn't correctly output multiline string as multiline
if (this.isEnabled && Object.keys(this.data).length > 0) {
return fs_extra_1.outputFile(file, util_1.serializeToYaml(this.data));
if (this.isEnabled && Object.keys(data).length > 0) {
return (0, fs_extra_1.outputFile)(file, (0, util_1.serializeToYaml)(data));
}
else {
return Promise.resolve();

View file

@ -1 +1 @@
{"version":3,"file":"DebugLogger.js","sourceRoot":"","sources":["../src/DebugLogger.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,iCAAwC;AAExC,MAAa,WAAW;IAGtB,YAAqB,YAAY,IAAI;QA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AAG,CAAC,EAAE;YACvD,OAAO,qBAAU,CAAC,IAAI,EAAE,sBAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;SACpD;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;SACzB;IACH,CAAC;CACF;AA1CD,kCA0CC","sourcesContent":["import { outputFile } from \"fs-extra\"\nimport { serializeToYaml } from \"./util\"\n\nexport class DebugLogger {\n readonly data: any = {}\n\n constructor(readonly isEnabled = true) {}\n\n add(key: string, value: any) {\n if (!this.isEnabled) {\n return\n }\n\n const dataPath = key.split(\".\")\n let o = this.data\n let lastName: string | null = null\n for (const p of dataPath) {\n if (p === dataPath[dataPath.length - 1]) {\n lastName = p\n break\n } else {\n if (o[p] == null) {\n o[p] = Object.create(null)\n } else if (typeof o[p] === \"string\") {\n o[p] = [o[p]]\n }\n o = o[p]\n }\n }\n\n if (Array.isArray(o[lastName!])) {\n o[lastName!] = [...o[lastName!], value]\n } else {\n o[lastName!] = value\n }\n }\n\n save(file: string) {\n // toml and json doesn't correctly output multiline string as multiline\n if (this.isEnabled && Object.keys(this.data).length > 0) {\n return outputFile(file, serializeToYaml(this.data))\n } else {\n return Promise.resolve()\n }\n }\n}\n"]}
{"version":3,"file":"DebugLogger.js","sourceRoot":"","sources":["../src/DebugLogger.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,iCAAwC;AACxC,+DAAkD;AAElD,MAAa,WAAW;IAGtB,YAAqB,YAAY,IAAI;QAAhB,cAAS,GAAT,SAAS,CAAO;QAF5B,SAAI,GAAG,IAAI,GAAG,EAAe,CAAA;IAEE,CAAC;IAEzC,GAAG,CAAC,GAAW,EAAE,KAAU;QACzB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAM;QACR,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAA;QAC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AAC,IAAI,EAAE,IAAA,sBAAe,EAAC,IAAI,CAAC,CAAC,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC;IACH,CAAC;CACF;AA3CD,kCA2CC","sourcesContent":["import { outputFile } from \"fs-extra\"\nimport { serializeToYaml } from \"./util\"\nimport { mapToObject } from \"builder-util-runtime\"\n\nexport class DebugLogger {\n readonly data = new Map<string, any>()\n\n constructor(readonly isEnabled = true) {}\n\n add(key: string, value: any) {\n if (!this.isEnabled) {\n return\n }\n\n const dataPath = key.split(\".\")\n let o = this.data\n let lastName: string | null = null\n for (const p of dataPath) {\n if (p === dataPath[dataPath.length - 1]) {\n lastName = p\n break\n } else {\n if (!o.has(p)) {\n o.set(p, new Map<string, any>())\n } else if (typeof o.get(p) === \"string\") {\n o.set(p, [o.get(p)])\n }\n o = o.get(p)\n }\n }\n\n if (Array.isArray(o.get(lastName!))) {\n o.set(lastName!, [...o.get(lastName!), value])\n } else {\n o.set(lastName!, value)\n }\n }\n\n save(file: string) {\n const data = mapToObject(this.data)\n // toml and json doesn't correctly output multiline string as multiline\n if (this.isEnabled && Object.keys(data).length > 0) {\n return outputFile(file, serializeToYaml(data))\n } else {\n return Promise.resolve()\n }\n }\n}\n"]}

View file

@ -5,7 +5,7 @@ export declare enum Arch {
arm64 = 3,
universal = 4
}
export declare type ArchType = "x64" | "ia32" | "armv7l" | "arm64" | "universal";
export type ArchType = "x64" | "ia32" | "armv7l" | "arm64" | "universal";
export declare function toLinuxArchString(arch: Arch, targetName: string): string;
export declare function getArchCliNames(): Array<string>;
export declare function getArchSuffix(arch: Arch, defaultArch?: string): string;

View file

@ -1,6 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getArtifactArchName = exports.defaultArchFromString = exports.archFromString = exports.getArchSuffix = exports.getArchCliNames = exports.toLinuxArchString = exports.Arch = void 0;
exports.Arch = void 0;
exports.toLinuxArchString = toLinuxArchString;
exports.getArchCliNames = getArchCliNames;
exports.getArchSuffix = getArchSuffix;
exports.archFromString = archFromString;
exports.defaultArchFromString = defaultArchFromString;
exports.getArtifactArchName = getArtifactArchName;
var Arch;
(function (Arch) {
Arch[Arch["ia32"] = 0] = "ia32";
@ -8,7 +14,7 @@ var Arch;
Arch[Arch["armv7l"] = 2] = "armv7l";
Arch[Arch["arm64"] = 3] = "arm64";
Arch[Arch["universal"] = 4] = "universal";
})(Arch = exports.Arch || (exports.Arch = {}));
})(Arch || (exports.Arch = Arch = {}));
function toLinuxArchString(arch, targetName) {
switch (arch) {
case Arch.x64:
@ -18,20 +24,17 @@ function toLinuxArchString(arch, targetName) {
case Arch.armv7l:
return targetName === "snap" || targetName === "deb" ? "armhf" : targetName === "flatpak" ? "arm" : "armv7l";
case Arch.arm64:
return targetName === "pacman" || targetName === "flatpak" ? "aarch64" : "arm64";
return targetName === "pacman" || targetName === "rpm" || targetName === "flatpak" ? "aarch64" : "arm64";
default:
throw new Error(`Unsupported arch ${arch}`);
}
}
exports.toLinuxArchString = toLinuxArchString;
function getArchCliNames() {
return [Arch[Arch.ia32], Arch[Arch.x64], Arch[Arch.armv7l], Arch[Arch.arm64]];
}
exports.getArchCliNames = getArchCliNames;
function getArchSuffix(arch, defaultArch) {
return arch === defaultArchFromString(defaultArch) ? "" : `-${Arch[arch]}`;
}
exports.getArchSuffix = getArchSuffix;
function archFromString(name) {
switch (name) {
case "x64":
@ -49,11 +52,9 @@ function archFromString(name) {
throw new Error(`Unsupported arch ${name}`);
}
}
exports.archFromString = archFromString;
function defaultArchFromString(name) {
return name ? archFromString(name) : Arch.x64;
}
exports.defaultArchFromString = defaultArchFromString;
function getArtifactArchName(arch, ext) {
let archName = Arch[arch];
const isAppImage = ext === "AppImage" || ext === "appimage";
@ -88,5 +89,4 @@ function getArtifactArchName(arch, ext) {
}
return archName;
}
exports.getArtifactArchName = getArtifactArchName;
//# sourceMappingURL=arch.js.map

File diff suppressed because one or more lines are too long

View file

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CAAC,MAAM,GAAG,CAAC,CAAA;aACjB;SACF;QACD,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;CACF;AA7ED,4CA6EC;AAED,SAAS,UAAU,CAAC,MAAoB;IACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,MAAM,CAAC,CAAC,CAAC,CAAA;KAChB;SAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,MAAM,IAAI,qBAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;KAClD;AACH,CAAC","sourcesContent":["import { CancellationToken } from \"builder-util-runtime\"\nimport { log } from \"./log\"\nimport { NestedError } from \"./promise\"\n\nexport class AsyncTaskManager {\n readonly tasks: Array<Promise<any>> = []\n private readonly errors: Array<Error> = []\n\n constructor(private readonly cancellationToken: CancellationToken) {}\n\n add(task: () => Promise<any>) {\n if (this.cancellationToken == null || !this.cancellationToken.cancelled) {\n this.addTask(task())\n }\n }\n\n addTask(promise: Promise<any>) {\n if (this.cancellationToken.cancelled) {\n log.debug({ reason: \"cancelled\", stack: new Error().stack }, \"async task not added\")\n if (\"cancel\" in promise) {\n ;(promise as any).cancel()\n }\n return\n }\n\n this.tasks.push(\n promise.catch(it => {\n log.debug({ error: it.message || it.toString() }, \"async task error\")\n this.errors.push(it)\n return Promise.resolve(null)\n })\n )\n }\n\n cancelTasks() {\n for (const task of this.tasks) {\n if (\"cancel\" in task) {\n ;(task as any).cancel()\n }\n }\n this.tasks.length = 0\n }\n\n async awaitTasks(): Promise<Array<any>> {\n if (this.cancellationToken.cancelled) {\n this.cancelTasks()\n return []\n }\n\n const checkErrors = () => {\n if (this.errors.length > 0) {\n this.cancelTasks()\n throwError(this.errors)\n return\n }\n }\n\n checkErrors()\n\n let result: Array<any> | null = null\n const tasks = this.tasks\n let list = tasks.slice()\n tasks.length = 0\n while (list.length > 0) {\n const subResult = await Promise.all(list)\n result = result == null ? subResult : result.concat(subResult)\n checkErrors()\n if (tasks.length === 0) {\n break\n } else {\n if (this.cancellationToken.cancelled) {\n this.cancelTasks()\n return []\n }\n\n list = tasks.slice()\n tasks.length = 0\n }\n }\n return result || []\n }\n}\n\nfunction throwError(errors: Array<Error>) {\n if (errors.length === 1) {\n throw errors[0]\n } else if (errors.length > 1) {\n throw new NestedError(errors, \"Cannot cleanup: \")\n }\n}\n"]}
{"version":3,"file":"asyncTaskManager.js","sourceRoot":"","sources":["../src/asyncTaskManager.ts"],"names":[],"mappings":";;;AACA,+BAA2B;AAC3B,uCAAuC;AAEvC,MAAa,gBAAgB;IAI3B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;QAHxD,UAAK,GAAwB,EAAE,CAAA;QACvB,WAAM,GAAiB,EAAE,CAAA;IAE0B,CAAC;IAErE,GAAG,CAAC,IAAwB;QAC1B,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACxE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAqB;QAC3B,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACrC,SAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,sBAAsB,CAAC,CAAA;YACpF,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;gBACxB,CAAC;gBAAC,OAAe,CAAC,MAAM,EAAE,CAAA;YAC5B,CAAC;YACD,OAAM;QACR,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YACjB,SAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,QAAQ,EAAE,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M,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAC9D,WAAW,EAAE,CAAA;YACb,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAK;YACP,CAAC;iBAAM,CAAC;gBACN,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;oBACrC,IAAI,CAAC,WAAW,EAAE,CAAA;oBAClB,OAAO,EAAE,CAAA;gBACX,CAAC;gBAED,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;gBACpB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;YAClB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;CACF;AA7ED,4CA6EC;AAED,SAAS,UAAU,CAAC,MAAoB;IACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,qBAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IACnD,CAAC;AACH,CAAC","sourcesContent":["import { CancellationToken } from \"builder-util-runtime\"\nimport { log } from \"./log\"\nimport { NestedError } from \"./promise\"\n\nexport class AsyncTaskManager {\n readonly tasks: Array<Promise<any>> = []\n private readonly errors: Array<Error> = []\n\n constructor(private readonly cancellationToken: CancellationToken) {}\n\n add(task: () => Promise<any>) {\n if (this.cancellationToken == null || !this.cancellationToken.cancelled) {\n this.addTask(task())\n }\n }\n\n addTask(promise: Promise<any>) {\n if (this.cancellationToken.cancelled) {\n log.debug({ reason: \"cancelled\", stack: new Error().stack }, \"async task not added\")\n if (\"cancel\" in promise) {\n ;(promise as any).cancel()\n }\n return\n }\n\n this.tasks.push(\n promise.catch(it => {\n log.debug({ error: it.message || it.toString() }, \"async task error\")\n this.errors.push(it)\n return Promise.resolve(null)\n })\n )\n }\n\n cancelTasks() {\n for (const task of this.tasks) {\n if (\"cancel\" in task) {\n ;(task as any).cancel()\n }\n }\n this.tasks.length = 0\n }\n\n async awaitTasks(): Promise<Array<any>> {\n if (this.cancellationToken.cancelled) {\n this.cancelTasks()\n return []\n }\n\n const checkErrors = () => {\n if (this.errors.length > 0) {\n this.cancelTasks()\n throwError(this.errors)\n return\n }\n }\n\n checkErrors()\n\n let result: Array<any> | null = null\n const tasks = this.tasks\n let list = tasks.slice()\n tasks.length = 0\n while (list.length > 0) {\n const subResult = await Promise.all(list)\n result = result == null ? subResult : result.concat(subResult)\n checkErrors()\n if (tasks.length === 0) {\n break\n } else {\n if (this.cancellationToken.cancelled) {\n this.cancelTasks()\n return []\n }\n\n list = tasks.slice()\n tasks.length = 0\n }\n }\n return result || []\n }\n}\n\nfunction throwError(errors: Array<Error>) {\n if (errors.length === 1) {\n throw errors[0]\n } else if (errors.length > 1) {\n throw new NestedError(errors, \"Cannot cleanup: \")\n }\n}\n"]}

12
electron/node_modules/builder-util/out/cscLink.d.ts generated vendored Normal file
View file

@ -0,0 +1,12 @@
/** Decodes a base64 CSC link to a Buffer, or returns null if the value is not base64. */
export declare function decodeCscLinkBase64(link: string): Buffer | null;
/** Resolves a CSC link file path, expanding `~/`, `file://`, and relative paths against `cwd`. */
export declare function resolveCscLinkPath(cscLink: string, resourcesDir: string | undefined): string;
/**
* Resolves a CSC link to its text content.
*
* Formats accepted:
* - Base64: detected by `data:…;base64,` prefix, length > 2048, or trailing `=`
* - File path: `~/…`, `file://…`, absolute, or relative to `cwd`
*/
export declare function loadCscLink(link: string, resourcesDir: string | undefined): Promise<string>;

63
electron/node_modules/builder-util/out/cscLink.js generated vendored Normal file
View file

@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeCscLinkBase64 = decodeCscLinkBase64;
exports.resolveCscLinkPath = resolveCscLinkPath;
exports.loadCscLink = loadCscLink;
const promises_1 = require("fs/promises");
const os_1 = require("os");
const path = require("path");
const fs_1 = require("./fs");
/** Decodes a base64 CSC link to a Buffer, or returns null if the value is not base64. */
function decodeCscLinkBase64(link) {
var _a;
const mimeMatch = /^data:.*;base64,/.exec(link);
if (mimeMatch || link.length > 2048 || link.endsWith("=")) {
return Buffer.from(link.substring((_a = mimeMatch === null || mimeMatch === void 0 ? void 0 : mimeMatch[0].length) !== null && _a !== void 0 ? _a : 0), "base64");
}
return null;
}
/** Resolves a CSC link file path, expanding `~/`, `file://`, and relative paths against `cwd`. */
function resolveCscLinkPath(cscLink, resourcesDir) {
let link = cscLink;
let baseDir = resourcesDir;
const filePrefix = "file://";
if (link.startsWith("~/")) {
baseDir = (0, os_1.homedir)();
link = link.slice(2);
}
else if (cscLink.startsWith(filePrefix)) {
link = cscLink.slice(filePrefix.length);
}
if (path.isAbsolute(link)) {
return link;
}
if (baseDir == null) {
// No base directory to resolve relative path against
throw new Error(`CSC link is a relative path but no resourcesDir provided: ${cscLink}`);
}
return path.resolve(baseDir, link);
}
/**
* Resolves a CSC link to its text content.
*
* Formats accepted:
* - Base64: detected by `data:…;base64,` prefix, length > 2048, or trailing `=`
* - File path: `~/…`, `file://…`, absolute, or relative to `cwd`
*/
async function loadCscLink(link, resourcesDir) {
const trimmed = link.trim();
const decoded = decodeCscLinkBase64(trimmed);
if (decoded) {
return decoded.toString("utf8");
}
const filePath = resolveCscLinkPath(trimmed, resourcesDir);
const stat = await (0, fs_1.statOrNull)(filePath);
if (stat == null) {
throw new Error(`${filePath} doesn't exist`);
}
else if (!stat.isFile()) {
throw new Error(`${filePath} not a file`);
}
return (0, promises_1.readFile)(filePath, "utf8");
}
//# sourceMappingURL=cscLink.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"cscLink.js","sourceRoot":"","sources":["../src/cscLink.ts"],"names":[],"mappings":";;AAMA,kDAMC;AAGD,gDAmBC;AASD,kCAgBC;AA3DD,0CAAsC;AACtC,2BAA4B;AAC5B,6BAA4B;AAC5B,6BAAiC;AAEj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C;AAED;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,YAAgC;IAC9E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAE3B,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAC5C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACjC,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAC1D,MAAM,IAAI,GAAG,MAAM,IAAA,eAAU,EAAC,QAAQ,CAAC,CAAA;IACvC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,gBAAgB,CAAC,CAAA;IAC9C,CAAC;SAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,aAAa,CAAC,CAAA;IAC3C,CAAC;IACD,OAAO,IAAA,mBAAQ,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AACnC,CAAC","sourcesContent":["import { readFile } from \"fs/promises\"\nimport { homedir } from \"os\"\nimport * as path from \"path\"\nimport { statOrNull } from \"./fs\"\n\n/** Decodes a base64 CSC link to a Buffer, or returns null if the value is not base64. */\nexport function decodeCscLinkBase64(link: string): Buffer | null {\n const mimeMatch = /^data:.*;base64,/.exec(link)\n if (mimeMatch || link.length > 2048 || link.endsWith(\"=\")) {\n return Buffer.from(link.substring(mimeMatch?.[0].length ?? 0), \"base64\")\n }\n return null\n}\n\n/** Resolves a CSC link file path, expanding `~/`, `file://`, and relative paths against `cwd`. */\nexport function resolveCscLinkPath(cscLink: string, resourcesDir: string | undefined): string {\n let link = cscLink\n let baseDir = resourcesDir\n const filePrefix = \"file://\"\n\n if (link.startsWith(\"~/\")) {\n baseDir = homedir()\n link = link.slice(2)\n } else if (cscLink.startsWith(filePrefix)) {\n link = cscLink.slice(filePrefix.length)\n }\n if (path.isAbsolute(link)) {\n return link\n }\n if (baseDir == null) {\n // No base directory to resolve relative path against\n throw new Error(`CSC link is a relative path but no resourcesDir provided: ${cscLink}`)\n }\n return path.resolve(baseDir, link)\n}\n\n/**\n * Resolves a CSC link to its text content.\n *\n * Formats accepted:\n * - Base64: detected by `data:…;base64,` prefix, length > 2048, or trailing `=`\n * - File path: `~/…`, `file://…`, absolute, or relative to `cwd`\n */\nexport async function loadCscLink(link: string, resourcesDir: string | undefined): Promise<string> {\n const trimmed = link.trim()\n\n const decoded = decodeCscLinkBase64(trimmed)\n if (decoded) {\n return decoded.toString(\"utf8\")\n }\n\n const filePath = resolveCscLinkPath(trimmed, resourcesDir)\n const stat = await statOrNull(filePath)\n if (stat == null) {\n throw new Error(`${filePath} doesn't exist`)\n } else if (!stat.isFile()) {\n throw new Error(`${filePath} not a file`)\n }\n return readFile(filePath, \"utf8\")\n}\n"]}

View file

@ -1 +0,0 @@
export declare function deepAssign<T>(target: T, ...objects: Array<any>): T;

View file

@ -1,48 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepAssign = void 0;
function isObject(x) {
if (Array.isArray(x)) {
return false;
}
const type = typeof x;
return type === "object" || type === "function";
}
function assignKey(target, from, key) {
const value = from[key];
// https://github.com/electron-userland/electron-builder/pull/562
if (value === undefined) {
return;
}
const prevValue = target[key];
if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {
// Merge arrays.
if (Array.isArray(prevValue) && Array.isArray(value)) {
target[key] = Array.from(new Set(prevValue.concat(value)));
}
else {
target[key] = value;
}
}
else {
target[key] = assign(prevValue, value);
}
}
function assign(to, from) {
if (to !== from) {
for (const key of Object.getOwnPropertyNames(from)) {
assignKey(to, from, key);
}
}
return to;
}
function deepAssign(target, ...objects) {
for (const o of objects) {
if (o != null) {
assign(target, o);
}
}
return target;
}
exports.deepAssign = deepAssign;
//# s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,mBAAmB,CAAC,IAAI,CAAC,EAAE;YAClD,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;SACzB;KACF;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAgB,UAAU,CAAI,MAAS,EAAE,GAAG,OAAmB;IAC7D,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;QACvB,IAAI,CAAC,IAAI,IAAI,EAAE;YACb,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;SAClB;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAPD,gCAOC","sourcesContent":["function isObject(x: any) {\n if (Array.isArray(x)) {\n return false\n }\n\n const type = typeof x\n return type === \"object\" || type === \"function\"\n}\n\nfunction assignKey(target: any, from: any, key: string) {\n const value = from[key]\n // https://github.com/electron-userland/electron-builder/pull/562\n if (value === undefined) {\n return\n }\n\n const prevValue = target[key]\n if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {\n // Merge arrays.\n if (Array.isArray(prevValue) && Array.isArray(value)) {\n target[key] = Array.from(new Set(prevValue.concat(value)))\n } else {\n target[key] = value\n }\n } else {\n target[key] = assign(prevValue, value)\n }\n}\n\nfunction assign(to: any, from: any) {\n if (to !== from) {\n for (const key of Object.getOwnPropertyNames(from)) {\n assignKey(to, from, key)\n }\n }\n return to\n}\n\nexport function deepAssign<T>(target: T, ...objects: Array<any>): T {\n for (const o of objects) {\n if (o != null) {\n assign(target, o)\n }\n }\n return target\n}\n"]}

3
electron/node_modules/builder-util/out/envUtil.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
export declare function resolveEnvShellValue(envVarName: string): string | null;
export declare function resolveEnvToolsetPath(envVarKey: string, expectedType: "directory" | "file"): Promise<string | null>;
export declare function parseValidEnvVarUrl(envVarName: string, allowHttp?: boolean): string | null;

68
electron/node_modules/builder-util/out/envUtil.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveEnvShellValue = resolveEnvShellValue;
exports.resolveEnvToolsetPath = resolveEnvToolsetPath;
exports.parseValidEnvVarUrl = parseValidEnvVarUrl;
const path = require("path");
const stringUtil_1 = require("./stringUtil");
const log_1 = require("./log");
const fs_1 = require("./fs");
const promises_1 = require("fs/promises");
function resolveEnvShellValue(envVarName) {
const rawValue = process.env[envVarName];
if ((0, stringUtil_1.isEmptyOrSpaces)(rawValue)) {
return null;
}
const trimmed = rawValue.trim();
// On Windows, backslash is the native path separator and must not be rejected
const shellUnsafeChars = process.platform === "win32" ? /[;&|`$<>"']/ : /[;&|`$<>"'\\]/;
if (shellUnsafeChars.test(trimmed)) {
throw new Error(`${envVarName} contains shell-unsafe characters: ${trimmed}`);
}
return trimmed;
}
async function resolveEnvToolsetPath(envVarKey, expectedType) {
const value = resolveEnvShellValue(envVarKey);
if (value == null) {
return null;
}
if (!path.isAbsolute(value)) {
throw new Error(`${envVarKey} must be an absolute path: ${value}`);
}
const p = path.resolve(value);
if (!(await (0, fs_1.exists)(p))) {
throw new Error(`${envVarKey} path does not exist: ${p}`);
}
const targetStat = await (0, promises_1.stat)(p);
const targetType = targetStat.isDirectory() ? "directory" : targetStat.isFile() ? "file" : "unknown";
if (targetType !== expectedType) {
throw new Error(`${envVarKey} path must be a ${expectedType}, but got ${targetType}: ${p}`);
}
log_1.log.info({ [envVarKey]: p }, `resolved ${envVarKey} from environment variable`);
return p;
}
const LOCALHOST_HOSTNAMES = new Set(["localhost", "127.0.0.1", "[::1]"]);
function parseValidEnvVarUrl(envVarName, allowHttp = false) {
var _a;
const url = (_a = process.env[envVarName]) === null || _a === void 0 ? void 0 : _a.trim();
if (url == null || url === "") {
return null;
}
let parsed;
try {
parsed = new URL(url);
}
catch {
throw new Error(`${envVarName} is not a valid URL: ${url}`);
}
if (parsed.protocol !== "https:") {
// Always permit plain HTTP to loopback addresses (local dev / air-gapped CI mirrors
// running on the build machine itself). For any other host, require opt-in.
const isLocalhost = parsed.protocol === "http:" && LOCALHOST_HOSTNAMES.has(parsed.hostname);
if (!isLocalhost && !allowHttp) {
throw new Error(`${envVarName} must use https:// (got ${parsed.protocol}). For non-localhost HTTP mirrors set ELECTRON_BUILDER_BINARIES_ALLOW_HTTP=true`);
}
}
return url;
}
//# sourceMappingURL=envUtil.js.map

File diff suppressed because one or more lines are too long

2
electron/node_modules/builder-util/out/filename.d.ts generated vendored Normal file
View file

@ -0,0 +1,2 @@
export declare function sanitizeFileName(s: string, normalizeNfd?: boolean): string;
export declare function getCompleteExtname(filename: string): string;

39
electron/node_modules/builder-util/out/filename.js generated vendored Normal file
View file

@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitizeFileName = sanitizeFileName;
exports.getCompleteExtname = getCompleteExtname;
const path = require("path");
// @ts-ignore
const _sanitizeFileName = require("sanitize-filename");
function sanitizeFileName(s, normalizeNfd = false) {
const sanitized = _sanitizeFileName(s);
return normalizeNfd ? sanitized.normalize("NFD") : sanitized;
}
// Get the filetype from a filename. Returns a string of one or more file extensions,
// e.g. .zip, .dmg, .tar.gz, .tar.bz2, .exe.blockmap. We'd normally use `path.extname()`,
// but it doesn't support multiple extensions, e.g. Foo-1.0.0.dmg.blockmap should be
// .dmg.blockmap, not .blockmap.
function getCompleteExtname(filename) {
let extname = path.extname(filename);
switch (extname) {
// Append leading extension for blockmap filetype
case ".blockmap": {
extname = path.extname(filename.replace(extname, "")) + extname;
break;
}
// Append leading extension for known compressed tar formats
case ".bz2":
case ".gz":
case ".lz":
case ".xz":
case ".7z": {
const ext = path.extname(filename.replace(extname, ""));
if (ext === ".tar") {
extname = ext + extname;
}
break;
}
}
return extname;
}
//# sourceMappingURL=filename.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"filename.js","sourceRoot":"","sources":["../src/filename.ts"],"names":[],"mappings":";;AAIA,4CAGC;AAMD,gDA0BC;AAvCD,6BAA4B;AAC5B,aAAa;AACb,uDAAsD;AAEtD,SAAgB,gBAAgB,CAAC,CAAS,EAAE,YAAY,GAAG,KAAK;IAC9D,MAAM,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;IACtC,OAAO,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9D,CAAC;AAED,qFAAqF;AACrF,yFAAyF;AACzF,oFAAoF;AACpF,gCAAgC;AAChC,SAAgB,kBAAkB,CAAC,QAAgB;IACjD,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAEpC,QAAQ,OAAO,EAAE,CAAC;QAChB,iDAAiD;QACjD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,CAAA;YAE/D,MAAK;QACP,CAAC;QACD,4DAA4D;QAC5D,KAAK,MAAM,CAAC;QACZ,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;YACvD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;gBACnB,OAAO,GAAG,GAAG,GAAG,OAAO,CAAA;YACzB,CAAC;YAED,MAAK;QACP,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import * as path from \"path\"\n// @ts-ignore\nimport * as _sanitizeFileName from \"sanitize-filename\"\n\nexport function sanitizeFileName(s: string, normalizeNfd = false): string {\n const sanitized = _sanitizeFileName(s)\n return normalizeNfd ? sanitized.normalize(\"NFD\") : sanitized\n}\n\n// Get the filetype from a filename. Returns a string of one or more file extensions,\n// e.g. .zip, .dmg, .tar.gz, .tar.bz2, .exe.blockmap. We'd normally use `path.extname()`,\n// but it doesn't support multiple extensions, e.g. Foo-1.0.0.dmg.blockmap should be\n// .dmg.blockmap, not .blockmap.\nexport function getCompleteExtname(filename: string): string {\n let extname = path.extname(filename)\n\n switch (extname) {\n // Append leading extension for blockmap filetype\n case \".blockmap\": {\n extname = path.extname(filename.replace(extname, \"\")) + extname\n\n break\n }\n // Append leading extension for known compressed tar formats\n case \".bz2\":\n case \".gz\":\n case \".lz\":\n case \".xz\":\n case \".7z\": {\n const ext = path.extname(filename.replace(extname, \"\"))\n if (ext === \".tar\") {\n extname = ext + extname\n }\n\n break\n }\n }\n\n return extname\n}\n"]}

View file

@ -1,16 +1,19 @@
/// <reference types="node" />
import { Stats } from "fs";
export declare const MAX_FILE_REQUESTS = 8;
export declare const CONCURRENCY: {
concurrency: number;
};
export declare type AfterCopyFileTransformer = (file: string) => Promise<void>;
export type AfterCopyFileTransformer = (file: string) => Promise<boolean>;
export declare class CopyFileTransformer {
readonly afterCopyTransformer: AfterCopyFileTransformer;
constructor(afterCopyTransformer: AfterCopyFileTransformer);
}
export declare type FileTransformer = (file: string) => Promise<null | string | Buffer | CopyFileTransformer> | null | string | Buffer | CopyFileTransformer;
export declare type Filter = (file: string, stat: Stats) => boolean;
export type FileTransformer = (file: string) => Promise<null | string | Buffer | CopyFileTransformer> | null | string | Buffer | CopyFileTransformer;
export interface FilterStats extends Stats {
moduleName?: string;
moduleRootPath?: string;
moduleFullFilePath?: string;
relativeLink?: string;
linkRelativeToFile?: string;
}
export type Filter = (file: string, stat: FilterStats) => boolean;
export declare function unlinkIfExists(file: string): Promise<void>;
export declare function statOrNull(file: string): Promise<Stats | null>;
export declare function exists(file: string): Promise<boolean>;
@ -37,7 +40,7 @@ export declare class FileCopier {
private readonly isUseHardLinkFunction?;
private readonly transformer?;
isUseHardLink: boolean;
constructor(isUseHardLinkFunction?: ((file: string) => boolean) | null | undefined, transformer?: FileTransformer | null | undefined);
constructor(isUseHardLinkFunction?: ((file: string) => boolean) | null | undefined, transformer?: (FileTransformer | null) | undefined);
copy(src: string, dest: string, stat: Stats | undefined): Promise<void>;
}
export interface CopyDirOptions {
@ -50,6 +53,7 @@ export interface CopyDirOptions {
* Hard links is used if supported and allowed.
*/
export declare function copyDir(src: string, destination: string, options?: CopyDirOptions): Promise<any>;
export declare function dirSize(dirPath: string): Promise<number>;
export declare const DO_NOT_USE_HARD_LINKS: (file: string) => boolean;
export declare const USE_HARD_LINKS: (file: string) => boolean;
export interface Link {

View file

@ -1,17 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.USE_HARD_LINKS = exports.DO_NOT_USE_HARD_LINKS = exports.copyDir = exports.FileCopier = exports.copyOrLinkFile = exports.copyFile = exports.walk = exports.exists = exports.statOrNull = exports.unlinkIfExists = exports.CopyFileTransformer = exports.CONCURRENCY = exports.MAX_FILE_REQUESTS = void 0;
const bluebird_lst_1 = require("bluebird-lst");
exports.USE_HARD_LINKS = exports.DO_NOT_USE_HARD_LINKS = exports.FileCopier = exports.CopyFileTransformer = exports.MAX_FILE_REQUESTS = void 0;
exports.unlinkIfExists = unlinkIfExists;
exports.statOrNull = statOrNull;
exports.exists = exists;
exports.walk = walk;
exports.copyFile = copyFile;
exports.copyOrLinkFile = copyOrLinkFile;
exports.copyDir = copyDir;
exports.dirSize = dirSize;
const fs_extra_1 = require("fs-extra");
const os_1 = require("os");
const promises_1 = require("fs/promises");
const os_1 = require("os");
const path = require("path");
const stat_mode_1 = require("stat-mode");
const tiny_async_pool_1 = require("tiny-async-pool");
const log_1 = require("./log");
const promise_1 = require("./promise");
const isCI = require("is-ci");
exports.MAX_FILE_REQUESTS = 8;
exports.CONCURRENCY = { concurrency: exports.MAX_FILE_REQUESTS };
class CopyFileTransformer {
constructor(afterCopyTransformer) {
this.afterCopyTransformer = afterCopyTransformer;
@ -19,25 +25,22 @@ class CopyFileTransformer {
}
exports.CopyFileTransformer = CopyFileTransformer;
function unlinkIfExists(file) {
return promises_1.unlink(file).catch(() => {
return (0, promises_1.unlink)(file).catch(() => {
/* ignore */
});
}
exports.unlinkIfExists = unlinkIfExists;
async function statOrNull(file) {
return promise_1.orNullIfFileNotExist(promises_1.stat(file));
return (0, promise_1.orNullIfFileNotExist)((0, promises_1.stat)(file));
}
exports.statOrNull = statOrNull;
async function exists(file) {
try {
await promises_1.access(file);
await (0, promises_1.access)(file);
return true;
}
catch (e) {
catch (_e) {
return false;
}
}
exports.exists = exists;
/**
* Returns list of file paths (system-dependent file separator)
*/
@ -56,25 +59,25 @@ async function walk(initialDirPath, filter, consumer) {
addDirToResult = true;
}
}
const childNames = await promise_1.orIfFileNotExist(promises_1.readdir(dirPath), []);
const childNames = await (0, promise_1.orIfFileNotExist)((0, promises_1.readdir)(dirPath), []);
childNames.sort();
let nodeModuleContent = null;
const dirs = [];
// our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map
const sortedFilePaths = await bluebird_lst_1.default.map(childNames, name => {
const sortedFilePaths = await (0, tiny_async_pool_1.default)(exports.MAX_FILE_REQUESTS, childNames, async (name) => {
if (name === ".DS_Store" || name === ".gitkeep") {
return null;
}
const filePath = dirPath + path.sep + name;
return promises_1.lstat(filePath).then(stat => {
return (0, promises_1.lstat)(filePath).then(stat => {
if (filter != null && !filter(filePath, stat)) {
return null;
}
const consumerResult = consumer == null ? null : consumer.consume(filePath, stat, dirPath, childNames);
if (consumerResult === false) {
if (consumerResult === true) {
return null;
}
else if (consumerResult == null || !("then" in consumerResult)) {
else if (consumerResult === false || consumerResult == null || !("then" in consumerResult)) {
if (stat.isDirectory()) {
dirs.push(name);
return null;
@ -100,7 +103,7 @@ async function walk(initialDirPath, filter, consumer) {
});
}
});
}, exports.CONCURRENCY);
});
for (const child of sortedFilePaths) {
if (child != null) {
result.push(child);
@ -116,12 +119,13 @@ async function walk(initialDirPath, filter, consumer) {
}
return result;
}
exports.walk = walk;
const _isUseHardLink = process.platform !== "win32" && process.env.USE_HARD_LINKS !== "false" && (isCI || process.env.USE_HARD_LINKS === "true");
// performance optimization. only enable hard links during unit tests on non-Windows platforms by default
// This is to optimize disk space and speed during tests, while avoiding potential issues with hard links in distribution builds
// https://github.com/electron-userland/electron-builder/issues/5721
const _isUseHardLink = process.platform !== "win32" && (process.env.USE_HARD_LINKS === "true" || process.env.VITEST != null);
function copyFile(src, dest, isEnsureDir = true) {
return (isEnsureDir ? promises_1.mkdir(path.dirname(dest), { recursive: true }) : Promise.resolve()).then(() => copyOrLinkFile(src, dest, null, false));
return (isEnsureDir ? (0, promises_1.mkdir)(path.dirname(dest), { recursive: true }) : Promise.resolve()).then(() => copyOrLinkFile(src, dest, null, false));
}
exports.copyFile = copyFile;
/**
* Hard links is used if supported and allowed.
* File permission is fixed allow execute for all if owner can, allow read for all if owner can.
@ -158,7 +162,7 @@ function copyOrLinkFile(src, dest, stats, isUseHardLink, exDevErrorHandler) {
}
}
if (isUseHardLink) {
return promises_1.link(src, dest).catch(e => {
return (0, promises_1.link)(src, dest).catch((e) => {
if (e.code === "EXDEV") {
const isLog = exDevErrorHandler == null ? true : exDevErrorHandler();
if (isLog && log_1.log.isDebugEnabled) {
@ -173,13 +177,12 @@ function copyOrLinkFile(src, dest, stats, isUseHardLink, exDevErrorHandler) {
}
return doCopyFile(src, dest, stats);
}
exports.copyOrLinkFile = copyOrLinkFile;
function doCopyFile(src, dest, stats) {
const promise = fs_extra_1.copyFile(src, dest);
const promise = (0, fs_extra_1.copyFile)(src, dest);
if (stats == null) {
return promise;
}
return promise.then(() => promises_1.chmod(dest, stats.mode));
return promise.then(() => (0, promises_1.chmod)(dest, stats.mode));
}
class FileCopier {
constructor(isUseHardLinkFunction, transformer) {
@ -205,7 +208,7 @@ class FileCopier {
afterCopyTransformer = data.afterCopyTransformer;
}
else {
await promises_1.writeFile(dest, data);
await (0, promises_1.writeFile)(dest, data);
return;
}
}
@ -234,21 +237,19 @@ exports.FileCopier = FileCopier;
* Empty directories is never created.
* Hard links is used if supported and allowed.
*/
function copyDir(src, destination, options = {}) {
async function copyDir(src, destination, options = {}) {
const fileCopier = new FileCopier(options.isUseHardLink, options.transformer);
if (log_1.log.isDebugEnabled) {
log_1.log.debug({ src, destination }, `copying${fileCopier.isUseHardLink ? " using hard links" : ""}`);
}
log_1.log.debug({ src, destination }, `copying${fileCopier.isUseHardLink ? " using hard links" : ""}`);
const createdSourceDirs = new Set();
const links = [];
const symlinkType = os_1.platform() === "win32" ? "junction" : "file";
return walk(src, options.filter, {
const symlinkType = (0, os_1.platform)() === "win32" ? "junction" : "file";
return await walk(src, options.filter, {
consume: async (file, stat, parent) => {
if (!stat.isFile() && !stat.isSymbolicLink()) {
return;
}
if (!createdSourceDirs.has(parent)) {
await promises_1.mkdir(parent.replace(src, destination), { recursive: true });
await (0, promises_1.mkdir)(parent.replace(src, destination), { recursive: true });
createdSourceDirs.add(parent);
}
const destFile = file.replace(src, destination);
@ -256,12 +257,26 @@ function copyDir(src, destination, options = {}) {
await fileCopier.copy(file, destFile, stat);
}
else {
links.push({ file: destFile, link: await promises_1.readlink(file) });
links.push({ file: destFile, link: await (0, promises_1.readlink)(file) });
}
},
}).then(() => bluebird_lst_1.default.map(links, it => promises_1.symlink(it.link, it.file, symlinkType), exports.CONCURRENCY));
}).then(() => (0, tiny_async_pool_1.default)(exports.MAX_FILE_REQUESTS, links, it => (0, promises_1.symlink)(it.link, it.file, symlinkType)));
}
async function dirSize(dirPath) {
const entries = await (0, promises_1.readdir)(dirPath, { withFileTypes: true });
const entrySizes = entries.map(async (entry) => {
const entryPath = path.join(dirPath, entry.name);
if (entry.isDirectory()) {
return await dirSize(entryPath);
}
if (entry.isFile()) {
const { size } = await (0, promises_1.stat)(entryPath);
return size;
}
return 0;
});
return (await Promise.all(entrySizes)).reduce((entrySize, totalSize) => entrySize + totalSize, 0);
}
exports.copyDir = copyDir;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const DO_NOT_USE_HARD_LINKS = (file) => false;
exports.DO_NOT_USE_HARD_LINKS = DO_NOT_USE_HARD_LINKS;

File diff suppressed because one or more lines are too long

6
electron/node_modules/builder-util/out/ksuid.d.ts generated vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* Generates a K-Sortable Unique Identifier (KSUID): a 27-char base62 string
* encoding 4 bytes of timestamp + 16 bytes of random data.
* Compatible with https://github.com/segmentio/ksuid
*/
export declare function generateKsuid(): string;

31
electron/node_modules/builder-util/out/ksuid.js generated vendored Normal file
View file

@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateKsuid = generateKsuid;
const crypto_1 = require("crypto");
// KSUID custom epoch (May 13, 2014 in Unix seconds)
const KSUID_EPOCH = BigInt(1400000000);
const ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const BASE = BigInt(62);
/**
* Generates a K-Sortable Unique Identifier (KSUID): a 27-char base62 string
* encoding 4 bytes of timestamp + 16 bytes of random data.
* Compatible with https://github.com/segmentio/ksuid
*/
function generateKsuid() {
const ts = BigInt(Math.floor(Date.now() / 1000)) - KSUID_EPOCH;
const buf = Buffer.allocUnsafe(20);
buf.writeUInt32BE(Number(ts), 0);
(0, crypto_1.randomBytes)(16).copy(buf, 4);
return base62Encode(buf);
}
function base62Encode(buf) {
let n = BigInt("0x" + buf.toString("hex"));
let result = "";
// 27 digits: ceil(160 / log2(62)) = 27
for (let i = 0; i < 27; i++) {
result = ALPHABET[Number(n % BASE)] + result;
n /= BASE;
}
return result;
}
//# sourceMappingURL=ksuid.js.map

1
electron/node_modules/builder-util/out/ksuid.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"ksuid.js","sourceRoot":"","sources":["../src/ksuid.ts"],"names":[],"mappings":";;AAYA,sCAMC;AAlBD,mCAAoC;AAEpC,oDAAoD;AACpD,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;AACtC,MAAM,QAAQ,GAAG,gEAAgE,CAAA;AACjF,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;AAEvB;;;;GAIG;AACH,SAAgB,aAAa;IAC3B,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,WAAW,CAAA;IAC9D,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAClC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAChC,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC5B,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1C,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,uCAAuC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM,CAAA;QAC5C,CAAC,IAAI,IAAI,CAAA;IACX,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { randomBytes } from \"crypto\"\n\n// KSUID custom epoch (May 13, 2014 in Unix seconds)\nconst KSUID_EPOCH = BigInt(1400000000)\nconst ALPHABET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\nconst BASE = BigInt(62)\n\n/**\n * Generates a K-Sortable Unique Identifier (KSUID): a 27-char base62 string\n * encoding 4 bytes of timestamp + 16 bytes of random data.\n * Compatible with https://github.com/segmentio/ksuid\n */\nexport function generateKsuid(): string {\n const ts = BigInt(Math.floor(Date.now() / 1000)) - KSUID_EPOCH\n const buf = Buffer.allocUnsafe(20)\n buf.writeUInt32BE(Number(ts), 0)\n randomBytes(16).copy(buf, 4)\n return base62Encode(buf)\n}\n\nfunction base62Encode(buf: Buffer): string {\n let n = BigInt(\"0x\" + buf.toString(\"hex\"))\n let result = \"\"\n // 27 digits: ceil(160 / log2(62)) = 27\n for (let i = 0; i < 27; i++) {\n result = ALPHABET[Number(n % BASE)] + result\n n /= BASE\n }\n return result\n}\n"]}

View file

@ -1,4 +1,3 @@
/// <reference types="node" />
import _debug from "debug";
import WritableStream = NodeJS.WritableStream;
export declare const debug: _debug.Debugger;
@ -6,8 +5,9 @@ export interface Fields {
[index: string]: any;
}
export declare function setPrinter(value: ((message: string) => void) | null): void;
export declare type LogLevel = "info" | "warn" | "debug" | "notice" | "error";
export type LogLevel = "info" | "warn" | "debug" | "error";
export declare const PADDING = 2;
export declare const shouldDisableNonErrorLoggingVitest: boolean | "" | undefined;
export declare class Logger {
protected readonly stream: WritableStream;
constructor(stream: WritableStream);

View file

@ -1,15 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = exports.Logger = exports.PADDING = exports.setPrinter = exports.debug = void 0;
exports.log = exports.Logger = exports.shouldDisableNonErrorLoggingVitest = exports.PADDING = exports.debug = void 0;
exports.setPrinter = setPrinter;
const chalk = require("chalk");
const debug_1 = require("debug");
let printer = null;
exports.debug = debug_1.default("electron-builder");
exports.debug = (0, debug_1.default)("electron-builder");
function setPrinter(value) {
printer = value;
}
exports.setPrinter = setPrinter;
exports.PADDING = 2;
// clean up logs since concurrent tests are impossible to track logic execution with console concurrency "noise"
exports.shouldDisableNonErrorLoggingVitest = process.env.VITEST && !exports.debug.enabled;
class Logger {
constructor(stream) {
this.stream = stream;
@ -46,6 +48,16 @@ class Logger {
}
}
_doLog(message, fields, level) {
if (exports.shouldDisableNonErrorLoggingVitest) {
if ([
// "warn", // is sometimes a bit too noisy
"error",
].includes(level)) {
// log error message to console so VITEST can capture stacktrace as well
console.log(message, fields);
}
return; // ignore info/warn message during VITEST workflow if debug flag is disabled
}
// noinspection SuspiciousInstanceOfGuard
if (message instanceof Error) {
message = message.stack || message.toString();

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,12 @@
/// <reference types="node" />
import { HttpExecutor } from "builder-util-runtime";
import { ClientRequest } from "http";
import { HttpProxyAgent } from "http-proxy-agent";
import { HttpsProxyAgent } from "https-proxy-agent";
export declare class NodeHttpExecutor extends HttpExecutor<ClientRequest> {
createRequest(options: any, callback: (response: any) => void): ClientRequest;
}
export declare const httpExecutor: NodeHttpExecutor;
export declare function buildGotProxyAgent(): {
http?: HttpProxyAgent<string>;
https?: HttpsProxyAgent<string>;
} | undefined;

View file

@ -1,11 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.httpExecutor = exports.NodeHttpExecutor = void 0;
exports.buildGotProxyAgent = buildGotProxyAgent;
const builder_util_runtime_1 = require("builder-util-runtime");
const http_1 = require("http");
const http_proxy_agent_1 = require("http-proxy-agent");
const https = require("https");
const https_proxy_agent_1 = require("https-proxy-agent");
const stringUtil_1 = require("./stringUtil");
class NodeHttpExecutor extends builder_util_runtime_1.HttpExecutor {
// noinspection JSMethodCanBeStatic
// noinspection JSUnusedGlobalSymbols
@ -21,4 +23,16 @@ class NodeHttpExecutor extends builder_util_runtime_1.HttpExecutor {
}
exports.NodeHttpExecutor = NodeHttpExecutor;
exports.httpExecutor = new NodeHttpExecutor();
function buildGotProxyAgent() {
// Use Array.find so a whitespace-only uppercase var doesn't block the lowercase fallback.
const httpsProxy = [process.env.HTTPS_PROXY, process.env.https_proxy].find(v => !(0, stringUtil_1.isEmptyOrSpaces)(v));
const httpProxy = [process.env.HTTP_PROXY, process.env.http_proxy].find(v => !(0, stringUtil_1.isEmptyOrSpaces)(v));
if (!httpsProxy && !httpProxy) {
return undefined;
}
return {
...(httpProxy ? { http: new http_proxy_agent_1.HttpProxyAgent(httpProxy) } : {}),
...(httpsProxy ? { https: new https_proxy_agent_1.HttpsProxyAgent(httpsProxy) } : {}),
};
}
//# sourceMappingURL=nodeHttpExecutor.js.map

View file

@ -1 +1 @@
{"version":3,"file":"nodeHttpExecutor.js","sourceRoot":"","sources":["../src/nodeHttpExecutor.ts"],"names":[],"mappings":";;;AAAA,+DAAmD;AACnD,+BAA4D;AAC5D,uDAAiD;AACjD,+BAA8B;AAC9B,yDAAmD;AAEnD,MAAa,gBAAiB,SAAQ,mCAA2B;IAC/D,mCAAmC;IACnC,qCAAqC;IACrC,aAAa,CAAC,OAAY,EAAE,QAAiC;QAC3D,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC7E,OAAO,CAAC,KAAK,GAAG,IAAI,mCAAe,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAA;SAChE;aAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAClF,OAAO,CAAC,KAAK,GAAG,IAAI,iCAAc,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;SAC9D;QACD,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,cAAW,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACxF,CAAC;CACF;AAXD,4CAWC;AAEY,QAAA,YAAY,GAAG,IAAI,gBAAgB,EAAE,CAAA","sourcesContent":["import { HttpExecutor } from \"builder-util-runtime\"\nimport { ClientRequest, request as httpRequest } from \"http\"\nimport { HttpProxyAgent } from \"http-proxy-agent\"\nimport * as https from \"https\"\nimport { HttpsProxyAgent } from \"https-proxy-agent\"\n\nexport class NodeHttpExecutor extends HttpExecutor<ClientRequest> {\n // noinspection JSMethodCanBeStatic\n // noinspection JSUnusedGlobalSymbols\n createRequest(options: any, callback: (response: any) => void): ClientRequest {\n if (process.env[\"https_proxy\"] !== undefined && options.protocol === \"https:\") {\n options.agent = new HttpsProxyAgent(process.env[\"https_proxy\"])\n } else if (process.env[\"http_proxy\"] !== undefined && options.protocol === \"http:\") {\n options.agent = new HttpProxyAgent(process.env[\"http_proxy\"])\n }\n return (options.protocol === \"http:\" ? httpRequest : https.request)(options, callback)\n }\n}\n\nexport const httpExecutor = new NodeHttpExecutor()\n"]}
{"version":3,"file":"nodeHttpExecutor.js","sourceRoot":"","sources":["../src/nodeHttpExecutor.ts"],"names":[],"mappings":";;;AAsBA,gDAWC;AAjCD,+DAAmD;AACnD,+BAA4D;AAC5D,uDAAiD;AACjD,+BAA8B;AAC9B,yDAAmD;AACnD,6CAA8C;AAE9C,MAAa,gBAAiB,SAAQ,mCAA2B;IAC/D,mCAAmC;IACnC,qCAAqC;IACrC,aAAa,CAAC,OAAY,EAAE,QAAiC;QAC3D,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC9E,OAAO,CAAC,KAAK,GAAG,IAAI,mCAAe,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAA;QACjE,CAAC;aAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACnF,OAAO,CAAC,KAAK,GAAG,IAAI,iCAAc,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;QAC/D,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,cAAW,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACxF,CAAC;CACF;AAXD,4CAWC;AAEY,QAAA,YAAY,GAAG,IAAI,gBAAgB,EAAE,CAAA;AAElD,SAAgB,kBAAkB;IAChC,0FAA0F;IAC1F,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,CAAC,CAAA;IACpG,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,CAAC,CAAA;IACjG,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO;QACL,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,iCAAc,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,mCAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAA;AACH,CAAC","sourcesContent":["import { HttpExecutor } from \"builder-util-runtime\"\nimport { ClientRequest, request as httpRequest } from \"http\"\nimport { HttpProxyAgent } from \"http-proxy-agent\"\nimport * as https from \"https\"\nimport { HttpsProxyAgent } from \"https-proxy-agent\"\nimport { isEmptyOrSpaces } from \"./stringUtil\"\n\nexport class NodeHttpExecutor extends HttpExecutor<ClientRequest> {\n // noinspection JSMethodCanBeStatic\n // noinspection JSUnusedGlobalSymbols\n createRequest(options: any, callback: (response: any) => void): ClientRequest {\n if (process.env[\"https_proxy\"] !== undefined && options.protocol === \"https:\") {\n options.agent = new HttpsProxyAgent(process.env[\"https_proxy\"])\n } else if (process.env[\"http_proxy\"] !== undefined && options.protocol === \"http:\") {\n options.agent = new HttpProxyAgent(process.env[\"http_proxy\"])\n }\n return (options.protocol === \"http:\" ? httpRequest : https.request)(options, callback)\n }\n}\n\nexport const httpExecutor = new NodeHttpExecutor()\n\nexport function buildGotProxyAgent(): { http?: HttpProxyAgent<string>; https?: HttpsProxyAgent<string> } | undefined {\n // Use Array.find so a whitespace-only uppercase var doesn't block the lowercase fallback.\n const httpsProxy = [process.env.HTTPS_PROXY, process.env.https_proxy].find(v => !isEmptyOrSpaces(v))\n const httpProxy = [process.env.HTTP_PROXY, process.env.http_proxy].find(v => !isEmptyOrSpaces(v))\n if (!httpsProxy && !httpProxy) {\n return undefined\n }\n return {\n ...(httpProxy ? { http: new HttpProxyAgent(httpProxy) } : {}),\n ...(httpsProxy ? { https: new HttpsProxyAgent(httpsProxy) } : {}),\n }\n}\n"]}

View file

@ -1,12 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.orIfFileNotExist = exports.orNullIfFileNotExist = exports.NestedError = exports.executeFinally = exports.printErrorAndExit = void 0;
exports.NestedError = void 0;
exports.printErrorAndExit = printErrorAndExit;
exports.executeFinally = executeFinally;
exports.orNullIfFileNotExist = orNullIfFileNotExist;
exports.orIfFileNotExist = orIfFileNotExist;
const chalk = require("chalk");
function printErrorAndExit(error) {
console.error(chalk.red((error.stack || error).toString()));
process.exit(1);
}
exports.printErrorAndExit = printErrorAndExit;
// you don't need to handle error in your task - it is passed only indicate status of promise
async function executeFinally(promise, task) {
let result = null;
@ -25,7 +28,6 @@ async function executeFinally(promise, task) {
await task(false);
return result;
}
exports.executeFinally = executeFinally;
class NestedError extends Error {
constructor(errors, message = "Compound error: ") {
let m = message;
@ -41,14 +43,12 @@ exports.NestedError = NestedError;
function orNullIfFileNotExist(promise) {
return orIfFileNotExist(promise, null);
}
exports.orNullIfFileNotExist = orNullIfFileNotExist;
function orIfFileNotExist(promise, fallbackValue) {
return promise.catch(e => {
return promise.catch((e) => {
if (e.code === "ENOENT" || e.code === "ENOTDIR") {
return fallbackValue;
}
throw e;
});
}
exports.orIfFileNotExist = orIfFileNotExist;
//# sourceMappingURL=promise.js.map

View file

@ -1 +1 @@
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAE9B,SAAgB,iBAAiB,CAAC,KAAY;IAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAHD,8CAGC;AAED,6FAA6F;AACtF,KAAK,UAAU,cAAc,CAAI,OAAmB,EAAE,IAAgD;IAC3G,IAAI,MAAM,GAAa,IAAI,CAAA;IAC3B,IAAI;QACF,MAAM,GAAG,MAAM,OAAO,CAAA;KACvB;IAAC,OAAO,aAAa,EAAE;QACtB,IAAI;YACF,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;SACjB;QAAC,OAAO,SAAS,EAAE;YAClB,MAAM,IAAI,WAAW,CAAC,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAA;SAClD;QAED,MAAM,aAAa,CAAA;KACpB;IAED,MAAM,IAAI,CAAC,KAAK,CAAC,CAAA;IACjB,OAAO,MAAM,CAAA;AACf,CAAC;AAhBD,wCAgBC;AAED,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,MAAoB,EAAE,OAAO,GAAG,kBAAkB;QAC5D,IAAI,CAAC,GAAG,OAAO,CAAA;QACf,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,GAAG,CAAA;YAC/B,CAAC,IAAI,OAAO,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,KAAK,EAAE,CAAA;SACtD;QACD,KAAK,CAAC,CAAC,CAAC,CAAA;IACV,CAAC;CACF;AAVD,kCAUC;AAED,SAAgB,oBAAoB,CAAI,OAAmB;IACzD,OAAO,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC;AAFD,oDAEC;AAED,SAAgB,gBAAgB,CAAI,OAAmB,EAAE,aAAgB;IACvE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACvB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,EAAE;YAC/C,OAAO,aAAa,CAAA;SACrB;QACD,MAAM,CAAC,CAAA;IACT,CAAC,CAAC,CAAA;AACJ,CAAC;AAPD,4CAOC","sourcesContent":["import * as chalk from \"chalk\"\n\nexport function printErrorAndExit(error: Error) {\n console.error(chalk.red((error.stack || error).toString()))\n process.exit(1)\n}\n\n// you don't need to handle error in your task - it is passed only indicate status of promise\nexport async function executeFinally<T>(promise: Promise<T>, task: (isErrorOccurred: boolean) => Promise<any>): Promise<T> {\n let result: T | null = null\n try {\n result = await promise\n } catch (originalError) {\n try {\n await task(true)\n } catch (taskError) {\n throw new NestedError([originalError, taskError])\n }\n\n throw originalError\n }\n\n await task(false)\n return result\n}\n\nexport class NestedError extends Error {\n constructor(errors: Array<Error>, message = \"Compound error: \") {\n let m = message\n let i = 1\n for (const error of errors) {\n const prefix = `Error #${i++} `\n m += `\\n\\n${prefix}${\"-\".repeat(80)}\\n${error.stack}`\n }\n super(m)\n }\n}\n\nexport function orNullIfFileNotExist<T>(promise: Promise<T>): Promise<T | null> {\n return orIfFileNotExist(promise, null)\n}\n\nexport function orIfFileNotExist<T>(promise: Promise<T>, fallbackValue: T): Promise<T> {\n return promise.catch(e => {\n if (e.code === \"ENOENT\" || e.code === \"ENOTDIR\") {\n return fallbackValue\n }\n throw e\n })\n}\n"]}
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":";;;AAEA,8CAGC;AAGD,wCAgBC;AAcD,oDAEC;AAED,4CAOC;AAjDD,+BAA8B;AAE9B,SAAgB,iBAAiB,CAAC,KAAY;IAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,6FAA6F;AACtF,KAAK,UAAU,cAAc,CAAI,OAAmB,EAAE,IAAgD;IAC3G,IAAI,MAAM,GAAa,IAAI,CAAA;IAC3B,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,OAAO,CAAA;IACxB,CAAC;IAAC,OAAO,aAAkB,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;QAAC,OAAO,SAAc,EAAE,CAAC;YACxB,MAAM,IAAI,WAAW,CAAC,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAA;QACnD,CAAC;QAED,MAAM,aAAa,CAAA;IACrB,CAAC;IAED,MAAM,IAAI,CAAC,KAAK,CAAC,CAAA;IACjB,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,MAAoB,EAAE,OAAO,GAAG,kBAAkB;QAC5D,IAAI,CAAC,GAAG,OAAO,CAAA;QACf,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,GAAG,CAAA;YAC/B,CAAC,IAAI,OAAO,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,KAAK,EAAE,CAAA;QACvD,CAAC;QACD,KAAK,CAAC,CAAC,CAAC,CAAA;IACV,CAAC;CACF;AAVD,kCAUC;AAED,SAAgB,oBAAoB,CAAI,OAAmB;IACzD,OAAO,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC;AAED,SAAgB,gBAAgB,CAAI,OAAmB,EAAE,aAAgB;IACvE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE;QAC9B,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAChD,OAAO,aAAa,CAAA;QACtB,CAAC;QACD,MAAM,CAAC,CAAA;IACT,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import * as chalk from \"chalk\"\n\nexport function printErrorAndExit(error: Error) {\n console.error(chalk.red((error.stack || error).toString()))\n process.exit(1)\n}\n\n// you don't need to handle error in your task - it is passed only indicate status of promise\nexport async function executeFinally<T>(promise: Promise<T>, task: (isErrorOccurred: boolean) => Promise<any>): Promise<T> {\n let result: T | null = null\n try {\n result = await promise\n } catch (originalError: any) {\n try {\n await task(true)\n } catch (taskError: any) {\n throw new NestedError([originalError, taskError])\n }\n\n throw originalError\n }\n\n await task(false)\n return result\n}\n\nexport class NestedError extends Error {\n constructor(errors: Array<Error>, message = \"Compound error: \") {\n let m = message\n let i = 1\n for (const error of errors) {\n const prefix = `Error #${i++} `\n m += `\\n\\n${prefix}${\"-\".repeat(80)}\\n${error.stack}`\n }\n super(m)\n }\n}\n\nexport function orNullIfFileNotExist<T>(promise: Promise<T>): Promise<T | null> {\n return orIfFileNotExist(promise, null)\n}\n\nexport function orIfFileNotExist<T>(promise: Promise<T>, fallbackValue: T): Promise<T> {\n return promise.catch((e: any) => {\n if (e.code === \"ENOENT\" || e.code === \"ENOTDIR\") {\n return fallbackValue\n }\n throw e\n })\n}\n"]}

View file

@ -0,0 +1,2 @@
import { Nullish } from "builder-util-runtime";
export declare function isEmptyOrSpaces(s: string | Nullish): s is "" | Nullish;

7
electron/node_modules/builder-util/out/stringUtil.js generated vendored Normal file
View file

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEmptyOrSpaces = isEmptyOrSpaces;
function isEmptyOrSpaces(s) {
return s == null || s.trim().length === 0;
}
//# sourceMappingURL=stringUtil.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"stringUtil.js","sourceRoot":"","sources":["../src/stringUtil.ts"],"names":[],"mappings":";;AAEA,0CAEC;AAFD,SAAgB,eAAe,CAAC,CAAmB;IACjD,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\n\nexport function isEmptyOrSpaces(s: string | Nullish): s is \"\" | Nullish {\n return s == null || s.trim().length === 0\n}\n"]}

View file

@ -1,41 +1,86 @@
/// <reference types="node" />
import { Nullish } from "builder-util-runtime";
import { ChildProcess, ExecFileOptions, SpawnOptions } from "child_process";
import _debug from "debug";
export { safeStringifyJson } from "builder-util-runtime";
export { isEmptyOrSpaces } from "./stringUtil";
export { safeStringifyJson, retry } from "builder-util-runtime";
export { TmpDir } from "temp-file";
export { log, debug } from "./log";
export { Arch, getArchCliNames, toLinuxArchString, getArchSuffix, ArchType, archFromString, defaultArchFromString } from "./arch";
export * from "./arch";
export { Arch, archFromString, ArchType, defaultArchFromString, getArchCliNames, getArchSuffix, toLinuxArchString } from "./arch";
export { AsyncTaskManager } from "./asyncTaskManager";
export { DebugLogger } from "./DebugLogger";
export { copyFile, exists } from "./fs";
export { asArray } from "builder-util-runtime";
export { deepAssign } from "./deepAssign";
export * from "./log";
export { buildGotProxyAgent, httpExecutor, NodeHttpExecutor } from "./nodeHttpExecutor";
export * from "./promise";
export * from "./envUtil";
export { parseValidEnvVarUrl } from "./envUtil";
export { asArray, deepAssign, isValidKey } from "builder-util-runtime";
export * from "./fs";
export { generateKsuid } from "./ksuid";
export { loadCscLink, decodeCscLinkBase64, resolveCscLinkPath } from "./cscLink";
export declare const debug7z: _debug.Debugger;
export declare function serializeToYaml(object: any, skipInvalid?: boolean, noRefs?: boolean): string;
export declare function removePassword(input: string): string;
/**
* Returns a copy of the environment with sensitive keys removed.
* Use this when building the environment for child processes that do not
* need signing credentials, tokens, or passwords (e.g. package managers).
*/
export declare function stripSensitiveEnvVars(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
export declare function filterSensitiveEnv(env: Record<string, string | undefined>): Record<string, string | undefined>;
export declare function exec(file: string, args?: Array<string> | null, options?: ExecFileOptions, isLogOutIfDebug?: boolean): Promise<string>;
export interface ExtraSpawnOptions {
isPipeInput?: boolean;
}
export declare function doSpawn(command: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): ChildProcess;
export declare function spawnAndWrite(command: string, args: Array<string>, data: string, options?: SpawnOptions): Promise<any>;
export declare function spawnAndWriteWithOutput(command: string, args: Array<string>, data: string, options?: SpawnOptions): Promise<{
stdout: string;
stderr: string;
}>;
export declare function spawn(command: string, args?: Array<string> | null, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any>;
export declare class ExecError extends Error {
readonly exitCode: number;
alreadyLogged: boolean;
static code: string;
constructor(command: string, exitCode: number, out: string, errorOut: string, code?: string);
}
declare type Nullish = null | undefined;
export declare function use<T, R>(value: T | Nullish, task: (value: T) => R): R | null;
export declare function isEmptyOrSpaces(s: string | null | undefined): s is "" | null | undefined;
export declare function isTokenCharValid(token: string): boolean;
export declare function getUserDefinedCacheDir(): Promise<string | undefined>;
export declare function addValue<K, T>(map: Map<K, Array<T>>, key: K, value: T): void;
export declare function replaceDefault(inList: Array<string> | null | undefined, defaultList: Array<string>): Array<string>;
export declare function getPlatformIconFileName(value: string | null | undefined, isMac: boolean): string | null | undefined;
export declare function isArrayEqualRegardlessOfSort(a: Array<string>, b: Array<string>): boolean;
/**
* Recursively removes all undefined and null values from an object
*/
export declare function removeNullish<T>(obj: T): T;
export declare function replaceDefault(inList: Array<string> | Nullish, defaultList: Array<string>): Array<string>;
export declare function getPlatformIconFileName(value: string | Nullish, isMac: boolean): string | null | undefined;
export declare function isPullRequest(): boolean | "" | undefined;
export declare function isEnvTrue(value: string | null | undefined): boolean;
export declare function isEnvTrue(value: string | Nullish): boolean;
export declare class InvalidConfigurationError extends Error {
constructor(message: string, code?: string);
}
export declare function executeAppBuilder(args: Array<string>, childProcessConsumer?: (childProcess: ChildProcess) => void, extraOptions?: SpawnOptions, maxRetries?: number): Promise<string>;
export declare function retry<T>(task: () => Promise<T>, retriesLeft: number, interval: number): Promise<T>;
/**
* Resolves a user-supplied path to an absolute form and validates it.
*
* Always rejects paths containing null bytes or newlines (C-level argument
* injection risk even with array-form execFile).
*
* When `base` is provided, also enforces containment: the resolved path must
* start with the resolved `base` directory. This `startsWith`-based check is
* the pattern that CodeQL's path-injection analysis recognises as a sanitizer,
* clearing the taint on the returned value for interprocedural analysis.
*/
export declare function sanitizeDirPath(p: string, base?: string): string;
/**
* Validates a path and returns the complete 7-Zip `-o<dir>` switch token.
*
* Input is first normalized via `sanitizeDirPath` (absolute resolution + null/newline
* rejection), then validated for 7za switch-token safety.
*
* Allowlist rejects:
* - empty string (7za would receive bare `-o`, which fails)
* - leading `-` (7za would misparse the token as a new switch)
* - control chars 0x000x1F and DEL 0x7F (C-level truncation/control risk)
*/
export declare function to7zaOutputSwitch(p: string): string;

View file

@ -1,71 +1,161 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.retry = exports.executeAppBuilder = exports.InvalidConfigurationError = exports.isEnvTrue = exports.isPullRequest = exports.getPlatformIconFileName = exports.replaceDefault = exports.addValue = exports.isTokenCharValid = exports.isEmptyOrSpaces = exports.use = exports.ExecError = exports.spawn = exports.spawnAndWrite = exports.doSpawn = exports.exec = exports.removePassword = exports.serializeToYaml = exports.debug7z = exports.deepAssign = exports.asArray = exports.exists = exports.copyFile = exports.DebugLogger = exports.AsyncTaskManager = exports.defaultArchFromString = exports.archFromString = exports.getArchSuffix = exports.toLinuxArchString = exports.getArchCliNames = exports.Arch = exports.debug = exports.log = exports.TmpDir = exports.safeStringifyJson = void 0;
const _7zip_bin_1 = require("7zip-bin");
const app_builder_bin_1 = require("app-builder-bin");
exports.InvalidConfigurationError = exports.ExecError = exports.debug7z = exports.resolveCscLinkPath = exports.decodeCscLinkBase64 = exports.loadCscLink = exports.generateKsuid = exports.isValidKey = exports.deepAssign = exports.asArray = exports.parseValidEnvVarUrl = exports.NodeHttpExecutor = exports.httpExecutor = exports.buildGotProxyAgent = exports.DebugLogger = exports.AsyncTaskManager = exports.toLinuxArchString = exports.getArchSuffix = exports.getArchCliNames = exports.defaultArchFromString = exports.archFromString = exports.Arch = exports.TmpDir = exports.retry = exports.safeStringifyJson = exports.isEmptyOrSpaces = void 0;
exports.serializeToYaml = serializeToYaml;
exports.removePassword = removePassword;
exports.stripSensitiveEnvVars = stripSensitiveEnvVars;
exports.filterSensitiveEnv = filterSensitiveEnv;
exports.exec = exec;
exports.doSpawn = doSpawn;
exports.spawnAndWrite = spawnAndWrite;
exports.spawnAndWriteWithOutput = spawnAndWriteWithOutput;
exports.spawn = spawn;
exports.use = use;
exports.isTokenCharValid = isTokenCharValid;
exports.getUserDefinedCacheDir = getUserDefinedCacheDir;
exports.addValue = addValue;
exports.isArrayEqualRegardlessOfSort = isArrayEqualRegardlessOfSort;
exports.removeNullish = removeNullish;
exports.replaceDefault = replaceDefault;
exports.getPlatformIconFileName = getPlatformIconFileName;
exports.isPullRequest = isPullRequest;
exports.isEnvTrue = isEnvTrue;
exports.sanitizeDirPath = sanitizeDirPath;
exports.to7zaOutputSwitch = to7zaOutputSwitch;
const builder_util_runtime_1 = require("builder-util-runtime");
const chalk = require("chalk");
const child_process_1 = require("child_process");
const cross_spawn_1 = require("cross-spawn");
const crypto_1 = require("crypto");
const debug_1 = require("debug");
const js_yaml_1 = require("js-yaml");
const path = require("path");
const log_1 = require("./log");
const source_map_support_1 = require("source-map-support");
const log_1 = require("./log");
const fs_1 = require("./fs");
const fs_extra_1 = require("fs-extra");
const stringUtil_1 = require("./stringUtil");
if (process.env.JEST_WORKER_ID == null) {
source_map_support_1.install();
(0, source_map_support_1.install)();
}
var stringUtil_2 = require("./stringUtil");
Object.defineProperty(exports, "isEmptyOrSpaces", { enumerable: true, get: function () { return stringUtil_2.isEmptyOrSpaces; } });
var builder_util_runtime_2 = require("builder-util-runtime");
Object.defineProperty(exports, "safeStringifyJson", { enumerable: true, get: function () { return builder_util_runtime_2.safeStringifyJson; } });
Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return builder_util_runtime_2.retry; } });
var temp_file_1 = require("temp-file");
Object.defineProperty(exports, "TmpDir", { enumerable: true, get: function () { return temp_file_1.TmpDir; } });
var log_2 = require("./log");
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_2.log; } });
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return log_2.debug; } });
__exportStar(require("./arch"), exports);
var arch_1 = require("./arch");
Object.defineProperty(exports, "Arch", { enumerable: true, get: function () { return arch_1.Arch; } });
Object.defineProperty(exports, "getArchCliNames", { enumerable: true, get: function () { return arch_1.getArchCliNames; } });
Object.defineProperty(exports, "toLinuxArchString", { enumerable: true, get: function () { return arch_1.toLinuxArchString; } });
Object.defineProperty(exports, "getArchSuffix", { enumerable: true, get: function () { return arch_1.getArchSuffix; } });
Object.defineProperty(exports, "archFromString", { enumerable: true, get: function () { return arch_1.archFromString; } });
Object.defineProperty(exports, "defaultArchFromString", { enumerable: true, get: function () { return arch_1.defaultArchFromString; } });
Object.defineProperty(exports, "getArchCliNames", { enumerable: true, get: function () { return arch_1.getArchCliNames; } });
Object.defineProperty(exports, "getArchSuffix", { enumerable: true, get: function () { return arch_1.getArchSuffix; } });
Object.defineProperty(exports, "toLinuxArchString", { enumerable: true, get: function () { return arch_1.toLinuxArchString; } });
var asyncTaskManager_1 = require("./asyncTaskManager");
Object.defineProperty(exports, "AsyncTaskManager", { enumerable: true, get: function () { return asyncTaskManager_1.AsyncTaskManager; } });
var DebugLogger_1 = require("./DebugLogger");
Object.defineProperty(exports, "DebugLogger", { enumerable: true, get: function () { return DebugLogger_1.DebugLogger; } });
var fs_1 = require("./fs");
Object.defineProperty(exports, "copyFile", { enumerable: true, get: function () { return fs_1.copyFile; } });
Object.defineProperty(exports, "exists", { enumerable: true, get: function () { return fs_1.exists; } });
__exportStar(require("./log"), exports);
var nodeHttpExecutor_1 = require("./nodeHttpExecutor");
Object.defineProperty(exports, "buildGotProxyAgent", { enumerable: true, get: function () { return nodeHttpExecutor_1.buildGotProxyAgent; } });
Object.defineProperty(exports, "httpExecutor", { enumerable: true, get: function () { return nodeHttpExecutor_1.httpExecutor; } });
Object.defineProperty(exports, "NodeHttpExecutor", { enumerable: true, get: function () { return nodeHttpExecutor_1.NodeHttpExecutor; } });
__exportStar(require("./promise"), exports);
__exportStar(require("./envUtil"), exports);
var envUtil_1 = require("./envUtil");
Object.defineProperty(exports, "parseValidEnvVarUrl", { enumerable: true, get: function () { return envUtil_1.parseValidEnvVarUrl; } });
var builder_util_runtime_3 = require("builder-util-runtime");
Object.defineProperty(exports, "asArray", { enumerable: true, get: function () { return builder_util_runtime_3.asArray; } });
var deepAssign_1 = require("./deepAssign");
Object.defineProperty(exports, "deepAssign", { enumerable: true, get: function () { return deepAssign_1.deepAssign; } });
exports.debug7z = debug_1.default("electron-builder:7z");
Object.defineProperty(exports, "deepAssign", { enumerable: true, get: function () { return builder_util_runtime_3.deepAssign; } });
Object.defineProperty(exports, "isValidKey", { enumerable: true, get: function () { return builder_util_runtime_3.isValidKey; } });
__exportStar(require("./fs"), exports);
var ksuid_1 = require("./ksuid");
Object.defineProperty(exports, "generateKsuid", { enumerable: true, get: function () { return ksuid_1.generateKsuid; } });
var cscLink_1 = require("./cscLink");
Object.defineProperty(exports, "loadCscLink", { enumerable: true, get: function () { return cscLink_1.loadCscLink; } });
Object.defineProperty(exports, "decodeCscLinkBase64", { enumerable: true, get: function () { return cscLink_1.decodeCscLinkBase64; } });
Object.defineProperty(exports, "resolveCscLinkPath", { enumerable: true, get: function () { return cscLink_1.resolveCscLinkPath; } });
exports.debug7z = (0, debug_1.default)("electron-builder:7z");
function serializeToYaml(object, skipInvalid = false, noRefs = false) {
return js_yaml_1.dump(object, {
return (0, js_yaml_1.dump)(object, {
lineWidth: 8000,
skipInvalid,
noRefs,
});
}
exports.serializeToYaml = serializeToYaml;
function removePassword(input) {
return input.replace(/(-String |-P |pass:| \/p |-pass |--secretKey |--accessKey |-p )([^ ]+)/g, (match, p1, p2) => {
if (p1.trim() === "/p" && p2.startsWith("\\\\Mac\\Host\\\\")) {
// appx /p
return `${p1}${p2}`;
// Sensitive parameter stems — any of `-`, `--`, or `/` prefix is accepted for all stems.
// `pass:` is intentionally absent; the dedicated pass: handler below covers it without double-processing.
const sensitiveStems = ["accessKey", "secretKey", "privateToken", "apiKey", "passphrase", "password", "secret", "token", "String", "pass", "p"];
const stemAlt = sensitiveStems.map(s => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
// (?:--?|/) matches -, --, or / prefix. Longest stems listed first to minimise backtracking.
// (?<!\S) / (?=[\s"']|$) word-boundary guards prevent matching -path, -StringLength, etc.
const flagPattern = new RegExp(`(?<!\\S)((?:--?|/)(?:${stemAlt}))(?=[\\s"']|$)\\s*(?:(["'])(.*?)\\2|([^\\s]+))`, "gi");
input = input.replace(flagPattern, (_match, prefix, quote, quotedVal, unquotedVal) => {
const value = quotedVal !== null && quotedVal !== void 0 ? quotedVal : unquotedVal;
if (prefix.trim().toLowerCase() === "/p" && value.startsWith("\\\\Mac\\Host\\")) {
return `${prefix} ${quote !== null && quote !== void 0 ? quote : ""}${value}${quote !== null && quote !== void 0 ? quote : ""}`;
}
return `${p1}${crypto_1.createHash("sha256").update(p2).digest("hex")} (sha256 hash)`;
return `${prefix} ${quote !== null && quote !== void 0 ? quote : ""}${(0, builder_util_runtime_1.hashSensitiveValue)(value)}${quote !== null && quote !== void 0 ? quote : ""}`;
});
// pass:value — colon acts as separator; handles both pass:secret (no space) and pass: secret (space)
// Quoted phrases (pass:'a b c' or pass:"a b c") are captured in full so the whole phrase is hashed.
input = input.replace(/(?<!\S)pass:\s*(?:(["'])(.*?)\1|([^\s]+))/gi, (_match, quote, quotedVal, unquotedVal) => {
const value = quotedVal !== null && quotedVal !== void 0 ? quotedVal : unquotedVal;
return quote ? `pass:${quote}${(0, builder_util_runtime_1.hashSensitiveValue)(value)}${quote}` : `pass:${(0, builder_util_runtime_1.hashSensitiveValue)(value)}`;
});
// /b … /c block format
return input.replace(/(\/b\s+)(.*?)(\s+\/c)/g, (_match, p1, p2, p3) => {
return `${p1}${(0, builder_util_runtime_1.hashSensitiveValue)(p2)}${p3}`;
});
}
exports.removePassword = removePassword;
const SENSITIVE_ENV_KEY_RE = /KEY|TOKEN|SECRET|PASSWORD|PASS|CREDENTIAL|CSC/i;
/**
* Returns a copy of the environment with sensitive keys removed.
* Use this when building the environment for child processes that do not
* need signing credentials, tokens, or passwords (e.g. package managers).
*/
function stripSensitiveEnvVars(env) {
const out = {};
for (const [k, v] of Object.entries(env)) {
if ((0, builder_util_runtime_1.isValidKey)(k) && !(0, builder_util_runtime_1.isSensitiveFieldName)(k) && !SENSITIVE_ENV_KEY_RE.test(k)) {
out[k] = v;
}
}
return out;
}
function filterSensitiveEnv(env) {
const out = {};
for (const [k, v] of Object.entries(env)) {
out[k] = ((0, builder_util_runtime_1.isSensitiveFieldName)(k) || SENSITIVE_ENV_KEY_RE.test(k)) && v != null ? (0, builder_util_runtime_1.hashSensitiveValue)(v) : v;
}
return out;
}
function getProcessEnv(env) {
// Windows: passing a filtered env to execFile drops critical system vars (PATH, SYSTEMROOT, TEMP)
// that many tools require. Credential stripping is therefore not applied on Windows.
if (process.platform === "win32") {
return env == null ? undefined : env;
}
// When no explicit env is provided, strip credential env vars so child processes
// (package managers, signing tools, etc.) don't inherit secrets they don't need.
const finalEnv = {
...(env || process.env),
...(env == null ? stripSensitiveEnvVars(process.env) : env),
};
// without LC_CTYPE dpkg can returns encoded unicode symbols
// set LC_CTYPE to avoid crash https://github.com/electron-userland/electron-builder/issues/503 Even "en_DE.UTF-8" leads to error.
@ -92,16 +182,16 @@ function exec(file, args, options, isLogOutIfDebug = true) {
delete diffEnv[name];
}
}
logFields.env = builder_util_runtime_1.safeStringifyJson(diffEnv);
logFields.env = (0, builder_util_runtime_1.safeStringifyJson)(filterSensitiveEnv(diffEnv));
}
}
log_1.log.debug(logFields, "executing");
}
return new Promise((resolve, reject) => {
child_process_1.execFile(file, args, {
(0, child_process_1.execFile)(file, args, {
...options,
maxBuffer: 1000 * 1024 * 1024,
env: getProcessEnv(options == null ? null : options.env),
env: getProcessEnv(options == null ? null : options.env), // codeql[js/shell-command-injection-from-environment] - env filtered via getProcessEnv/stripSensitiveEnvVars; execFile array args (no shell)
}, (error, stdout, stderr) => {
if (error == null) {
if (isLogOutIfDebug && log_1.log.isDebugEnabled) {
@ -124,20 +214,20 @@ function exec(file, args, options, isLogOutIfDebug = true) {
if (file.endsWith("wine")) {
stdout = stdout.toString();
}
message += `\n${chalk.yellow(stdout.toString())}`;
message += `\n${chalk.yellow(removePassword(stdout.toString()))}`;
}
if (stderr.length !== 0) {
if (file.endsWith("wine")) {
stderr = stderr.toString();
}
message += `\n${chalk.red(stderr.toString())}`;
message += `\n${chalk.red(removePassword(stderr.toString()))}`;
}
reject(new Error(message));
// TODO: switch to ECMA Script 2026 Error class with `cause` property to return stack trace
reject(new ExecError(file, error.code, message, "", `${error.code || ExecError.code}`));
}
});
});
}
exports.exec = exec;
function logSpawn(command, args, options) {
// use general debug.enabled to log spawn, because it doesn't produce a lot of output (the only line), but important in any case
if (!log_1.log.isDebugEnabled) {
@ -164,13 +254,12 @@ function doSpawn(command, args, options, extraOptions) {
}
logSpawn(command, args, options);
try {
return cross_spawn_1.spawn(command, args, options);
return (0, cross_spawn_1.spawn)(command, args, options);
}
catch (e) {
throw new Error(`Cannot spawn ${command}: ${e.stack || e}`);
}
}
exports.doSpawn = doSpawn;
function spawnAndWrite(command, args, data, options) {
const childProcess = doSpawn(command, args, options, { isPipeInput: true });
const timeout = setTimeout(() => childProcess.kill(), 4 * 60 * 1000);
@ -193,13 +282,53 @@ function spawnAndWrite(command, args, data, options) {
childProcess.stdin.end(data);
});
}
exports.spawnAndWrite = spawnAndWrite;
function spawnAndWriteWithOutput(command, args, data, options) {
const childProcess = doSpawn(command, args, { ...options, stdio: ["pipe", "pipe", "pipe"] });
const isDebugEnabled = log_1.debug.enabled;
return new Promise((resolve, reject) => {
let stdout = "";
let stderr = "";
let timedOut = false;
const timeout = setTimeout(() => {
timedOut = true;
childProcess.kill();
}, 4 * 60 * 1000);
childProcess.on("error", (err) => {
clearTimeout(timeout);
reject(err);
});
childProcess.stdout.on("data", (chunk) => {
stdout += chunk.toString();
if (isDebugEnabled) {
process.stdout.write(chunk);
}
});
childProcess.stderr.on("data", (chunk) => {
stderr += chunk.toString();
if (isDebugEnabled) {
process.stderr.write(chunk);
}
});
childProcess.stdin.end(data);
childProcess.once("close", (code) => {
clearTimeout(timeout);
if (timedOut) {
reject(new Error(`${command} timed out after 4 minutes`));
}
else if (code === 0) {
resolve({ stdout, stderr });
}
else {
reject(new ExecError(command, code !== null && code !== void 0 ? code : -1, stdout, stderr));
}
});
});
}
function spawn(command, args, options, extraOptions) {
return new Promise((resolve, reject) => {
handleProcess("close", doSpawn(command, args || [], options, extraOptions), command, resolve, reject);
});
}
exports.spawn = spawn;
function handleProcess(event, childProcess, command, resolve, reject) {
childProcess.on("error", reject);
let out = "";
@ -240,7 +369,7 @@ function formatOut(text, title) {
return text.length === 0 ? "" : `\n${title}:\n${text}`;
}
class ExecError extends Error {
constructor(command, exitCode, out, errorOut, code = "ERR_ELECTRON_BUILDER_CANNOT_EXECUTE") {
constructor(command, exitCode, out, errorOut, code = ExecError.code) {
super(`${command} process failed ${code}${formatOut(String(exitCode), "Exit code")}${formatOut(out, "Output")}${formatOut(errorOut, "Error output")}`);
this.exitCode = exitCode;
this.alreadyLogged = false;
@ -248,18 +377,24 @@ class ExecError extends Error {
}
}
exports.ExecError = ExecError;
ExecError.code = "ERR_ELECTRON_BUILDER_CANNOT_EXECUTE";
function use(value, task) {
return value == null ? null : task(value);
}
exports.use = use;
function isEmptyOrSpaces(s) {
return s == null || s.trim().length === 0;
}
exports.isEmptyOrSpaces = isEmptyOrSpaces;
function isTokenCharValid(token) {
return /^[.\w/=+-]+$/.test(token);
}
exports.isTokenCharValid = isTokenCharValid;
async function getUserDefinedCacheDir() {
let cacheEnv = process.env.ELECTRON_BUILDER_CACHE;
if (!(0, stringUtil_1.isEmptyOrSpaces)(cacheEnv)) {
cacheEnv = path.resolve(cacheEnv);
if (!(await (0, fs_1.exists)(cacheEnv))) {
await (0, fs_extra_1.mkdir)(cacheEnv);
}
return cacheEnv;
}
return undefined;
}
function addValue(map, key, value) {
const list = map.get(key);
if (list == null) {
@ -269,7 +404,31 @@ function addValue(map, key, value) {
list.push(value);
}
}
exports.addValue = addValue;
function isArrayEqualRegardlessOfSort(a, b) {
a = a.slice();
b = b.slice();
a.sort();
b.sort();
return a.length === b.length && a.every((value, index) => value === b[index]);
}
/**
* Recursively removes all undefined and null values from an object
*/
function removeNullish(obj) {
if (obj === null || typeof obj !== "object") {
return obj;
}
if (Array.isArray(obj)) {
return obj.map(removeNullish);
}
const result = {};
for (const [key, value] of Object.entries(obj)) {
if (value != null) {
result[key] = removeNullish(value);
}
}
return result;
}
function replaceDefault(inList, defaultList) {
if (inList == null || (inList.length === 1 && inList[0] === "default")) {
return defaultList;
@ -285,7 +444,6 @@ function replaceDefault(inList, defaultList) {
}
return inList;
}
exports.replaceDefault = replaceDefault;
function getPlatformIconFileName(value, isMac) {
if (value === undefined) {
return undefined;
@ -298,7 +456,6 @@ function getPlatformIconFileName(value, isMac) {
}
return value.replace(isMac ? ".ico" : ".icns", isMac ? ".icns" : ".ico");
}
exports.getPlatformIconFileName = getPlatformIconFileName;
function isPullRequest() {
// TRAVIS_PULL_REQUEST is set to the pull request number if the current job is a pull request build, or false if its not.
function isSet(value) {
@ -311,14 +468,12 @@ function isPullRequest() {
isSet(process.env.APPVEYOR_PULL_REQUEST_NUMBER) ||
isSet(process.env.GITHUB_BASE_REF));
}
exports.isPullRequest = isPullRequest;
function isEnvTrue(value) {
if (value != null) {
value = value.trim();
}
return value === "true" || value === "" || value === "1";
}
exports.isEnvTrue = isEnvTrue;
class InvalidConfigurationError extends Error {
constructor(message, code = "ERR_ELECTRON_BUILDER_INVALID_CONFIGURATION") {
super(message);
@ -326,60 +481,50 @@ class InvalidConfigurationError extends Error {
}
}
exports.InvalidConfigurationError = InvalidConfigurationError;
function executeAppBuilder(args, childProcessConsumer, extraOptions = {}, maxRetries = 0) {
const command = app_builder_bin_1.appBuilderPath;
const env = {
...process.env,
SZA_PATH: _7zip_bin_1.path7za,
FORCE_COLOR: chalk.level === 0 ? "0" : "1",
};
const cacheEnv = process.env.ELECTRON_BUILDER_CACHE;
if (cacheEnv != null && cacheEnv.length > 0) {
env.ELECTRON_BUILDER_CACHE = path.resolve(cacheEnv);
/**
* Resolves a user-supplied path to an absolute form and validates it.
*
* Always rejects paths containing null bytes or newlines (C-level argument
* injection risk even with array-form execFile).
*
* When `base` is provided, also enforces containment: the resolved path must
* start with the resolved `base` directory. This `startsWith`-based check is
* the pattern that CodeQL's path-injection analysis recognises as a sanitizer,
* clearing the taint on the returned value for interprocedural analysis.
*/
function sanitizeDirPath(p, base) {
if ((0, stringUtil_1.isEmptyOrSpaces)(p)) {
throw new InvalidConfigurationError("Directory path must be a non-empty string");
}
if (extraOptions.env != null) {
Object.assign(env, extraOptions.env);
if (p.includes("\0") || p.includes("\n") || p.includes("\r")) {
throw new InvalidConfigurationError(`Directory path contains illegal characters: "${p}"`);
}
function runCommand() {
return new Promise((resolve, reject) => {
const childProcess = doSpawn(command, args, {
stdio: ["ignore", "pipe", process.stdout],
...extraOptions,
env,
});
if (childProcessConsumer != null) {
childProcessConsumer(childProcess);
}
handleProcess("close", childProcess, command, resolve, error => {
if (error instanceof ExecError && error.exitCode === 2) {
error.alreadyLogged = true;
}
reject(error);
});
});
}
if (maxRetries === 0) {
return runCommand();
}
else {
return retry(runCommand, maxRetries, 1000);
}
}
exports.executeAppBuilder = executeAppBuilder;
async function retry(task, retriesLeft, interval) {
try {
return await task();
}
catch (error) {
log_1.log.info(`Above command failed, retrying ${retriesLeft} more times`);
if (retriesLeft > 0) {
await new Promise(resolve => setTimeout(resolve, interval));
return await retry(task, retriesLeft - 1, interval);
}
else {
throw error;
const resolved = path.resolve(p);
if (base != null) {
const resolvedBase = path.resolve(base);
if (resolved !== resolvedBase && !resolved.startsWith(resolvedBase + path.sep)) {
throw new InvalidConfigurationError(`Path "${p}" must be within "${base}"`);
}
}
return resolved;
}
/**
* Validates a path and returns the complete 7-Zip `-o<dir>` switch token.
*
* Input is first normalized via `sanitizeDirPath` (absolute resolution + null/newline
* rejection), then validated for 7za switch-token safety.
*
* Allowlist rejects:
* - empty string (7za would receive bare `-o`, which fails)
* - leading `-` (7za would misparse the token as a new switch)
* - control chars 0x000x1F and DEL 0x7F (C-level truncation/control risk)
*/
function to7zaOutputSwitch(p) {
const safePath = sanitizeDirPath(p);
// eslint-disable-next-line no-control-regex
if (!/^[^\x00-\x1F\x7F-][^\x00-\x1F\x7F]*$/.test(safePath)) {
throw new InvalidConfigurationError(`7za output path is empty, starts with "-", or contains control characters: "${p}"`);
}
return "-o" + safePath;
}
exports.retry = retry;
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long