electron-updater 6.6.4 → 6.6.6
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/AppImageUpdater.js +1 -1
- package/out/AppImageUpdater.js.map +1 -1
- package/out/AppUpdater.d.ts +11 -0
- package/out/AppUpdater.js +40 -3
- package/out/AppUpdater.js.map +1 -1
- package/out/BaseUpdater.d.ts +0 -1
- package/out/BaseUpdater.js +1 -18
- package/out/BaseUpdater.js.map +1 -1
- package/out/DebUpdater.d.ts +5 -3
- package/out/DebUpdater.js +47 -12
- package/out/DebUpdater.js.map +1 -1
- package/out/LinuxUpdater.d.ts +27 -0
- package/out/LinuxUpdater.js +95 -0
- package/out/LinuxUpdater.js.map +1 -0
- package/out/NsisUpdater.js +1 -1
- package/out/NsisUpdater.js.map +1 -1
- package/out/PacmanUpdater.d.ts +5 -3
- package/out/PacmanUpdater.js +31 -13
- package/out/PacmanUpdater.js.map +1 -1
- package/out/RpmUpdater.d.ts +5 -3
- package/out/RpmUpdater.js +26 -18
- package/out/RpmUpdater.js.map +1 -1
- package/out/main.js +1 -1
- package/out/main.js.map +1 -1
- package/out/util.d.ts +1 -1
- package/out/util.js +2 -2
- package/out/util.js.map +1 -1
- package/package.json +1 -1
package/out/DebUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebUpdater.js","sourceRoot":"","sources":["../src/DebUpdater.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DebUpdater.js","sourceRoot":"","sources":["../src/DebUpdater.ts"],"names":[],"mappings":";;;AAIA,mDAA+C;AAC/C,mCAAmD;AACnD,iDAA6C;AAE7C,MAAa,UAAW,SAAQ,2BAAY;IAC1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,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AoB,EAAE,+BAA+B;gBACrD,8BAA8B;gBAC9B,aAAa;aACd,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,mBAAmB,cAAc,gBAAgB,CAAC,CAAA;QACpE,CAAC;IACH,CAAC;CACF;AAzED,gCAyEC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { InstallOptions } from \"./BaseUpdater\"\nimport { findFile } from \"./providers/Provider\"\nimport { DOWNLOAD_PROGRESS, Logger } from \"./types\"\nimport { LinuxUpdater } from \"./LinuxUpdater\"\n\nexport class DebUpdater extends LinuxUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"deb\", [\"AppImage\", \"rpm\", \"pacman\"])!\n return this.executeDownload({\n fileExtension: \"deb\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n if (!this.hasCommand(\"dpkg\") && !this.hasCommand(\"apt\")) {\n this.dispatchError(new Error(\"Neither dpkg nor apt command found. Cannot install .deb package.\"))\n return false\n }\n const priorityList = [\"dpkg\", \"apt\"]\n const packageManager = this.detectPackageManager(priorityList)\n try {\n DebUpdater.installWithCommandRunner(packageManager as any, installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger)\n } catch (error: any) {\n this.dispatchError(error)\n return false\n }\n if (options.isForceRunAfter) {\n this.app.relaunch()\n }\n return true\n }\n\n static installWithCommandRunner(packageManager: \"dpkg\" | \"apt\", installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger) {\n if (packageManager === \"dpkg\") {\n try {\n // Primary: Install unsigned .deb directly with dpkg\n commandRunner([\"dpkg\", \"-i\", installerPath])\n } catch (error: any) {\n // Handle missing dependencies via apt-get\n logger.warn(error.message ?? error)\n logger.warn(\"dpkg installation failed, trying to fix broken dependencies with apt-get\")\n commandRunner([\"apt-get\", \"install\", \"-f\", \"-y\"])\n }\n } else if (packageManager === \"apt\") {\n // Fallback: Use apt for direct install (less safe for unsigned .deb)\n logger.warn(\"Using apt to install a local .deb. This may fail for unsigned packages unless properly configured.\")\n commandRunner([\n \"apt\",\n \"install\",\n \"-y\",\n \"--allow-unauthenticated\", // needed for unsigned .debs\n \"--allow-downgrades\", // allow lower version installs\n \"--allow-change-held-packages\",\n installerPath,\n ])\n } else {\n throw new Error(`Package manager ${packageManager} not supported`)\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
|
+
import { AppAdapter } from "./AppAdapter";
|
|
3
|
+
import { BaseUpdater } from "./BaseUpdater";
|
|
4
|
+
export declare abstract class LinuxUpdater extends BaseUpdater {
|
|
5
|
+
constructor(options?: AllPublishOptions | null, app?: AppAdapter);
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if the current process is running as root.
|
|
8
|
+
*/
|
|
9
|
+
protected isRunningAsRoot(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Sanitizies the installer path for using with command line tools.
|
|
12
|
+
*/
|
|
13
|
+
protected get installerPath(): string | null;
|
|
14
|
+
protected runCommandWithSudoIfNeeded(commandWithArgs: string[]): string;
|
|
15
|
+
protected sudoWithArgs(installComment: string): string[];
|
|
16
|
+
protected hasCommand(cmd: string): boolean;
|
|
17
|
+
protected determineSudoCommand(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Detects the package manager to use based on the available commands.
|
|
20
|
+
* Allows overriding the default behavior by setting the ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER environment variable.
|
|
21
|
+
* If the environment variable is set, it will be used directly. (This is useful for testing each package manager logic path.)
|
|
22
|
+
* Otherwise, it checks for the presence of the specified package manager commands in the order provided.
|
|
23
|
+
* @param pms - An array of package manager commands to check for, in priority order.
|
|
24
|
+
* @returns The detected package manager command or "unknown" if none are found.
|
|
25
|
+
*/
|
|
26
|
+
protected detectPackageManager(pms: string[]): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinuxUpdater = void 0;
|
|
4
|
+
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
|
+
class LinuxUpdater extends BaseUpdater_1.BaseUpdater {
|
|
6
|
+
constructor(options, app) {
|
|
7
|
+
super(options, app);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if the current process is running as root.
|
|
11
|
+
*/
|
|
12
|
+
isRunningAsRoot() {
|
|
13
|
+
var _a;
|
|
14
|
+
return ((_a = process.getuid) === null || _a === void 0 ? void 0 : _a.call(process)) === 0;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sanitizies the installer path for using with command line tools.
|
|
18
|
+
*/
|
|
19
|
+
get installerPath() {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (_b = (_a = super.installerPath) === null || _a === void 0 ? void 0 : _a.replace(/\\/g, "\\\\").replace(/ /g, "\\ ")) !== null && _b !== void 0 ? _b : null;
|
|
22
|
+
}
|
|
23
|
+
runCommandWithSudoIfNeeded(commandWithArgs) {
|
|
24
|
+
if (this.isRunningAsRoot()) {
|
|
25
|
+
this._logger.info("Running as root, no need to use sudo");
|
|
26
|
+
return this.spawnSyncLog(commandWithArgs[0], commandWithArgs.slice(1));
|
|
27
|
+
}
|
|
28
|
+
const { name } = this.app;
|
|
29
|
+
const installComment = `"${name} would like to update"`;
|
|
30
|
+
const sudo = this.sudoWithArgs(installComment);
|
|
31
|
+
this._logger.info(`Running as non-root user, using sudo to install: ${sudo}`);
|
|
32
|
+
// pkexec doesn't want the command to be wrapped in " quotes
|
|
33
|
+
const wrapper = /pkexec/i.test(sudo[0]) ? "" : `"`;
|
|
34
|
+
return this.spawnSyncLog(sudo[0], [...(sudo.length > 1 ? sudo.slice(1) : []), `${wrapper}/bin/bash`, "-c", `'${commandWithArgs.join(" ")}'${wrapper}`]);
|
|
35
|
+
}
|
|
36
|
+
sudoWithArgs(installComment) {
|
|
37
|
+
const sudo = this.determineSudoCommand();
|
|
38
|
+
const command = [sudo];
|
|
39
|
+
if (/kdesudo/i.test(sudo)) {
|
|
40
|
+
command.push("--comment", installComment);
|
|
41
|
+
command.push("-c");
|
|
42
|
+
}
|
|
43
|
+
else if (/gksudo/i.test(sudo)) {
|
|
44
|
+
command.push("--message", installComment);
|
|
45
|
+
}
|
|
46
|
+
else if (/pkexec/i.test(sudo)) {
|
|
47
|
+
command.push("--disable-internal-agent");
|
|
48
|
+
}
|
|
49
|
+
return command;
|
|
50
|
+
}
|
|
51
|
+
hasCommand(cmd) {
|
|
52
|
+
try {
|
|
53
|
+
this.spawnSyncLog(`command`, ["-v", cmd]);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
determineSudoCommand() {
|
|
61
|
+
const sudos = ["gksudo", "kdesudo", "pkexec", "beesu"];
|
|
62
|
+
for (const sudo of sudos) {
|
|
63
|
+
if (this.hasCommand(sudo)) {
|
|
64
|
+
return sudo;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return "sudo";
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Detects the package manager to use based on the available commands.
|
|
71
|
+
* Allows overriding the default behavior by setting the ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER environment variable.
|
|
72
|
+
* If the environment variable is set, it will be used directly. (This is useful for testing each package manager logic path.)
|
|
73
|
+
* Otherwise, it checks for the presence of the specified package manager commands in the order provided.
|
|
74
|
+
* @param pms - An array of package manager commands to check for, in priority order.
|
|
75
|
+
* @returns The detected package manager command or "unknown" if none are found.
|
|
76
|
+
*/
|
|
77
|
+
detectPackageManager(pms) {
|
|
78
|
+
var _a;
|
|
79
|
+
const pmOverride = (_a = process.env.ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER) === null || _a === void 0 ? void 0 : _a.trim();
|
|
80
|
+
if (pmOverride) {
|
|
81
|
+
return pmOverride;
|
|
82
|
+
}
|
|
83
|
+
// Check for the package manager in the order of priority
|
|
84
|
+
for (const pm of pms) {
|
|
85
|
+
if (this.hasCommand(pm)) {
|
|
86
|
+
return pm;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// return the first package manager in the list if none are found, this will throw upstream for proper logging
|
|
90
|
+
this._logger.warn(`No package manager found in the list: ${pms.join(", ")}. Defaulting to the first one: ${pms[0]}`);
|
|
91
|
+
return pms[0];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.LinuxUpdater = LinuxUpdater;
|
|
95
|
+
//# sourceMappingURL=LinuxUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinuxUpdater.js","sourceRoot":"","sources":["../src/LinuxUpdater.ts"],"names":[],"mappings":";;;AAEA,+CAA2C;AAE3C,MAAsB,YAAa,SAAQ,yBAAW;IACpD,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED;;OAEG;IACO,eAAe;;QACvB,OAAO,CAAA,MAAA,OAAO,CAAC,MAAM,uDA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A;QAC7E,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAA;QACnB,CAAC;QACD,yDAAyD;QACzD,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC;QACD,8GAA8G;QAC9G,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,yCAAyC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,kCAAkC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QACpH,OAAO,GAAG,CAAC,CAAC,CAAC,CAAA;IACf,CAAC;CACF;AA1FD,oCA0FC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { BaseUpdater } from \"./BaseUpdater\"\n\nexport abstract class LinuxUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /**\n * Returns true if the current process is running as root.\n */\n protected isRunningAsRoot(): boolean {\n return process.getuid?.() === 0\n }\n\n /**\n * Sanitizies the installer path for using with command line tools.\n */\n protected get installerPath(): string | null {\n return super.installerPath?.replace(/\\\\/g, \"\\\\\\\\\").replace(/ /g, \"\\\\ \") ?? null\n }\n\n protected runCommandWithSudoIfNeeded(commandWithArgs: string[]) {\n if (this.isRunningAsRoot()) {\n this._logger.info(\"Running as root, no need to use sudo\")\n return this.spawnSyncLog(commandWithArgs[0], commandWithArgs.slice(1))\n }\n\n const { name } = this.app\n const installComment = `\"${name} would like to update\"`\n const sudo = this.sudoWithArgs(installComment)\n this._logger.info(`Running as non-root user, using sudo to install: ${sudo}`)\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo[0]) ? \"\" : `\"`\n return this.spawnSyncLog(sudo[0], [...(sudo.length > 1 ? sudo.slice(1) : []), `${wrapper}/bin/bash`, \"-c\", `'${commandWithArgs.join(\" \")}'${wrapper}`])\n }\n\n protected sudoWithArgs(installComment: string): string[] {\n const sudo = this.determineSudoCommand()\n const command = [sudo]\n if (/kdesudo/i.test(sudo)) {\n command.push(\"--comment\", installComment)\n command.push(\"-c\")\n } else if (/gksudo/i.test(sudo)) {\n command.push(\"--message\", installComment)\n } else if (/pkexec/i.test(sudo)) {\n command.push(\"--disable-internal-agent\")\n }\n return command\n }\n\n protected hasCommand(cmd: string): boolean {\n try {\n this.spawnSyncLog(`command`, [\"-v\", cmd])\n return true\n } catch {\n return false\n }\n }\n\n protected determineSudoCommand(): string {\n const sudos = [\"gksudo\", \"kdesudo\", \"pkexec\", \"beesu\"]\n for (const sudo of sudos) {\n if (this.hasCommand(sudo)) {\n return sudo\n }\n }\n return \"sudo\"\n }\n\n /**\n * Detects the package manager to use based on the available commands.\n * Allows overriding the default behavior by setting the ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER environment variable.\n * If the environment variable is set, it will be used directly. (This is useful for testing each package manager logic path.)\n * Otherwise, it checks for the presence of the specified package manager commands in the order provided.\n * @param pms - An array of package manager commands to check for, in priority order.\n * @returns The detected package manager command or \"unknown\" if none are found.\n */\n protected detectPackageManager(pms: string[]): string {\n const pmOverride = process.env.ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER?.trim()\n if (pmOverride) {\n return pmOverride\n }\n // Check for the package manager in the order of priority\n for (const pm of pms) {\n if (this.hasCommand(pm)) {\n return pm\n }\n }\n // return the first package manager in the list if none are found, this will throw upstream for proper logging\n this._logger.warn(`No package manager found in the list: ${pms.join(\", \")}. Defaulting to the first one: ${pms[0]}`)\n return pms[0]\n }\n}\n"]}
|
package/out/NsisUpdater.js
CHANGED
|
@@ -101,7 +101,7 @@ class NsisUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
101
101
|
doInstall(options) {
|
|
102
102
|
const installerPath = this.installerPath;
|
|
103
103
|
if (installerPath == null) {
|
|
104
|
-
this.dispatchError(new Error("No
|
|
104
|
+
this.dispatchError(new Error("No update filepath provided, can't quit and install"));
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
107
|
const args = ["--updated"];
|
package/out/NsisUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAmJ;AACnJ,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,mCAA2C;AAE3C,mDAAyD;AACzD,uCAAiC;AACjC,qGAA0E;AAC1E,6BAAyB;AAEzB,MAAa,WAAY,SAAQ,yBAAW;IAO1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAGX,+BAA0B,GAA8B,CAAC,cAA6B,EAAE,uBAA+B,EAAE,EAAE,CACnI,IAAA,wDAAe,EAAC,cAAc,EAAE,uBAAuB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAHxE,CAAC;IAKD;;;OAGG;IACH,IAAI,yBAAyB;QAC3B,OAAO,IAAI,CAAC,0BAA0B,CAAA;IACxC,CAAC;IAED,IAAI,yBAAyB,CAAC,KAAgC;QAC5D,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAA;QACzC,CAAC;IACH,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAE,CAAA;QAC1G,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,KAAK;YACpB,qBAAqB;YACrB,QAAQ;YACR,IAAI,EAAE,KAAK,EAAE,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sBAAuB,CAAC,QAAQ,EAAE,oDAA6B,CAAC;gBACxF,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,OAAO,EAAE,WAAW;gBACpB,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,yBAAyB,EAAE,QAAQ,CAAC,yBAAyB;gBAC7D,iBAAiB,EAAE,qBAAqB,CAAC,iBAAiB;aAC3D,CAAA;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,yBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB,EAAE,EAAE,CAAC,CAAA;YACrE,CAAC;YAED,MAAM,IAAI,+FAA8C,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;QACtH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,mEAAmE;YACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;QACrC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAzMD,kCAyMC","sourcesContent":["import { AllPublishOptions, newError, PackageFileInfo, CURRENT_APP_INSTALLER_FILE_NAME, CURRENT_APP_PACKAGE_FILE_NAME } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS } from \"./types\"\nimport { VerifyUpdateCodeSignature } from \"./main\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { unlink } from \"fs-extra\"\nimport { verifySignature } from \"./windowsExecutableCodeSignatureVerifier\"\nimport { URL } from \"url\"\n\nexport class NsisUpdater extends BaseUpdater {\n /**\n * Specify custom install directory path\n *\n */\n installDirectory?: string\n\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n protected _verifyUpdateCodeSignature: VerifyUpdateCodeSignature = (publisherNames: Array<string>, unescapedTempUpdateFile: string) =>\n verifySignature(publisherNames, unescapedTempUpdateFile, this._logger)\n\n /**\n * The verifyUpdateCodeSignature. You can pass [win-verify-signature](https://github.com/beyondkmp/win-verify-trust) or another custom verify function: ` (publisherName: string[], path: string) => Promise<string | null>`.\n * The default verify function uses [windowsExecutableCodeSignatureVerifier](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts)\n */\n get verifyUpdateCodeSignature(): VerifyUpdateCodeSignature {\n return this._verifyUpdateCodeSignature\n }\n\n set verifyUpdateCodeSignature(value: VerifyUpdateCodeSignature) {\n if (value) {\n this._verifyUpdateCodeSignature = value\n }\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"exe\")!\n return this.executeDownload({\n fileExtension: \"exe\",\n downloadUpdateOptions,\n fileInfo,\n task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {\n const packageInfo = fileInfo.packageInfo\n const isWebInstaller = packageInfo != null && packageFile != null\n if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {\n throw newError(\n `Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,\n \"ERR_UPDATER_WEB_INSTALLER_DISABLED\"\n )\n }\n if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {\n this._logger.warn(\n \"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version.\"\n )\n }\n if (\n isWebInstaller ||\n downloadUpdateOptions.disableDifferentialDownload ||\n (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_APP_INSTALLER_FILE_NAME))\n ) {\n await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)\n }\n\n const signatureVerificationStatus = await this.verifySignature(destinationFile)\n if (signatureVerificationStatus != null) {\n await removeTempDirIfAny()\n // noinspection ThrowInsideFinallyBlockJS\n throw newError(\n `New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`,\n \"ERR_UPDATER_INVALID_SIGNATURE\"\n )\n }\n\n if (isWebInstaller) {\n if (await this.differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packageFile, provider)) {\n try {\n await this.httpExecutor.download(new URL(packageInfo.path), packageFile, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n sha512: packageInfo.sha512,\n })\n } catch (e: any) {\n try {\n await unlink(packageFile)\n } catch (_ignored) {\n // ignore\n }\n\n throw e\n }\n }\n }\n },\n })\n }\n\n // $certificateInfo = (Get-AuthenticodeSignature 'xxx\\yyy.exe'\n // | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains(\"CN=siemens.com\")})\n // | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }\n private async verifySignature(tempUpdateFile: string): Promise<string | null> {\n let publisherName: Array<string> | string | null\n try {\n publisherName = (await this.configOnDisk.value).publisherName\n if (publisherName == null) {\n return null\n }\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // no app-update.yml\n return null\n }\n throw e\n }\n return await this._verifyUpdateCodeSignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile)\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n\n const args = [\"--updated\"]\n if (options.isSilent) {\n args.push(\"/S\")\n }\n\n if (options.isForceRunAfter) {\n args.push(\"--force-run\")\n }\n\n if (this.installDirectory) {\n // maybe check if folder exists\n args.push(`/D=${this.installDirectory}`)\n }\n\n const packagePath = this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.packageFile\n if (packagePath != null) {\n // only = form is supported\n args.push(`--package-file=${packagePath}`)\n }\n\n const callUsingElevation = (): void => {\n this.spawnLog(path.join(process.resourcesPath, \"elevate.exe\"), [installerPath].concat(args)).catch(e => this.dispatchError(e))\n }\n\n if (options.isAdminRightsRequired) {\n this._logger.info(\"isAdminRightsRequired is set to true, run installer using elevate.exe\")\n callUsingElevation()\n return true\n }\n\n this.spawnLog(installerPath, args).catch((e: Error) => {\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n const errorCode = (e as NodeJS.ErrnoException).code\n this._logger.info(\n `Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`\n )\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else if (errorCode === \"ENOENT\") {\n require(\"electron\")\n .shell.openPath(installerPath)\n .catch((err: Error) => this.dispatchError(err))\n } else {\n this.dispatchError(e)\n }\n })\n return true\n }\n\n private async differentialDownloadWebPackage(\n downloadUpdateOptions: DownloadUpdateOptions,\n packageInfo: PackageFileInfo,\n packagePath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n if (packageInfo.blockMapSize == null) {\n return true\n }\n\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: new URL(packageInfo.path),\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_PACKAGE_FILE_NAME),\n logger: this._logger,\n newFile: packagePath,\n requestHeaders: this.requestHeaders,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac or linux) we must throw error\n return process.platform === \"win32\"\n }\n return false\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAmJ;AACnJ,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,mCAA2C;AAE3C,mDAAyD;AACzD,uCAAiC;AACjC,qGAA0E;AAC1E,6BAAyB;AAEzB,MAAa,WAAY,SAAQ,yBAAW;IAO1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAGX,+BAA0B,GAA8B,CAAC,cAA6B,EAAE,uBAA+B,EAAE,EAAE,CACnI,IAAA,wDAAe,EAAC,cAAc,EAAE,uBAAuB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAHxE,CAAC;IAKD;;;OAGG;IACH,IAAI,yBAAyB;QAC3B,OAAO,IAAI,CAAC,0BAA0B,CAAA;IACxC,CAAC;IAED,IAAI,yBAAyB,CAAC,KAAgC;QAC5D,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAA;QACzC,CAAC;IACH,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CA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nB,QAAuB;QAEvB,IAAI,WAAW,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;YACrC,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC;YACH,MAAM,eAAe,GAAkC;gBACrD,MAAM,EAAE,IAAI,SAAG,CAAC,WAAW,CAAC,IAAI,CAAC;gBACjC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAuB,CAAC,QAAQ,EAAE,oDAA6B,CAAC;gBACxF,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,OAAO,EAAE,WAAW;gBACpB,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,yBAAyB,EAAE,QAAQ,CAAC,yBAAyB;gBAC7D,iBAAiB,EAAE,qBAAqB,CAAC,iBAAiB;aAC3D,CAAA;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,yBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB,EAAE,EAAE,CAAC,CAAA;YACrE,CAAC;YAED,MAAM,IAAI,+FAA8C,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;QACtH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,mEAAmE;YACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;QACrC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAzMD,kCAyMC","sourcesContent":["import { AllPublishOptions, newError, PackageFileInfo, CURRENT_APP_INSTALLER_FILE_NAME, CURRENT_APP_PACKAGE_FILE_NAME } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS } from \"./types\"\nimport { VerifyUpdateCodeSignature } from \"./main\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { unlink } from \"fs-extra\"\nimport { verifySignature } from \"./windowsExecutableCodeSignatureVerifier\"\nimport { URL } from \"url\"\n\nexport class NsisUpdater extends BaseUpdater {\n /**\n * Specify custom install directory path\n *\n */\n installDirectory?: string\n\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n protected _verifyUpdateCodeSignature: VerifyUpdateCodeSignature = (publisherNames: Array<string>, unescapedTempUpdateFile: string) =>\n verifySignature(publisherNames, unescapedTempUpdateFile, this._logger)\n\n /**\n * The verifyUpdateCodeSignature. You can pass [win-verify-signature](https://github.com/beyondkmp/win-verify-trust) or another custom verify function: ` (publisherName: string[], path: string) => Promise<string | null>`.\n * The default verify function uses [windowsExecutableCodeSignatureVerifier](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts)\n */\n get verifyUpdateCodeSignature(): VerifyUpdateCodeSignature {\n return this._verifyUpdateCodeSignature\n }\n\n set verifyUpdateCodeSignature(value: VerifyUpdateCodeSignature) {\n if (value) {\n this._verifyUpdateCodeSignature = value\n }\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"exe\")!\n return this.executeDownload({\n fileExtension: \"exe\",\n downloadUpdateOptions,\n fileInfo,\n task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {\n const packageInfo = fileInfo.packageInfo\n const isWebInstaller = packageInfo != null && packageFile != null\n if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {\n throw newError(\n `Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,\n \"ERR_UPDATER_WEB_INSTALLER_DISABLED\"\n )\n }\n if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {\n this._logger.warn(\n \"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version.\"\n )\n }\n if (\n isWebInstaller ||\n downloadUpdateOptions.disableDifferentialDownload ||\n (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_APP_INSTALLER_FILE_NAME))\n ) {\n await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)\n }\n\n const signatureVerificationStatus = await this.verifySignature(destinationFile)\n if (signatureVerificationStatus != null) {\n await removeTempDirIfAny()\n // noinspection ThrowInsideFinallyBlockJS\n throw newError(\n `New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`,\n \"ERR_UPDATER_INVALID_SIGNATURE\"\n )\n }\n\n if (isWebInstaller) {\n if (await this.differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packageFile, provider)) {\n try {\n await this.httpExecutor.download(new URL(packageInfo.path), packageFile, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n sha512: packageInfo.sha512,\n })\n } catch (e: any) {\n try {\n await unlink(packageFile)\n } catch (_ignored) {\n // ignore\n }\n\n throw e\n }\n }\n }\n },\n })\n }\n\n // $certificateInfo = (Get-AuthenticodeSignature 'xxx\\yyy.exe'\n // | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains(\"CN=siemens.com\")})\n // | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }\n private async verifySignature(tempUpdateFile: string): Promise<string | null> {\n let publisherName: Array<string> | string | null\n try {\n publisherName = (await this.configOnDisk.value).publisherName\n if (publisherName == null) {\n return null\n }\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // no app-update.yml\n return null\n }\n throw e\n }\n return await this._verifyUpdateCodeSignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile)\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n\n const args = [\"--updated\"]\n if (options.isSilent) {\n args.push(\"/S\")\n }\n\n if (options.isForceRunAfter) {\n args.push(\"--force-run\")\n }\n\n if (this.installDirectory) {\n // maybe check if folder exists\n args.push(`/D=${this.installDirectory}`)\n }\n\n const packagePath = this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.packageFile\n if (packagePath != null) {\n // only = form is supported\n args.push(`--package-file=${packagePath}`)\n }\n\n const callUsingElevation = (): void => {\n this.spawnLog(path.join(process.resourcesPath, \"elevate.exe\"), [installerPath].concat(args)).catch(e => this.dispatchError(e))\n }\n\n if (options.isAdminRightsRequired) {\n this._logger.info(\"isAdminRightsRequired is set to true, run installer using elevate.exe\")\n callUsingElevation()\n return true\n }\n\n this.spawnLog(installerPath, args).catch((e: Error) => {\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n const errorCode = (e as NodeJS.ErrnoException).code\n this._logger.info(\n `Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`\n )\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else if (errorCode === \"ENOENT\") {\n require(\"electron\")\n .shell.openPath(installerPath)\n .catch((err: Error) => this.dispatchError(err))\n } else {\n this.dispatchError(e)\n }\n })\n return true\n }\n\n private async differentialDownloadWebPackage(\n downloadUpdateOptions: DownloadUpdateOptions,\n packageInfo: PackageFileInfo,\n packagePath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n if (packageInfo.blockMapSize == null) {\n return true\n }\n\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: new URL(packageInfo.path),\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_PACKAGE_FILE_NAME),\n logger: this._logger,\n newFile: packagePath,\n requestHeaders: this.requestHeaders,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac or linux) we must throw error\n return process.platform === \"win32\"\n }\n return false\n }\n}\n"]}
|
package/out/PacmanUpdater.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
2
|
import { AppAdapter } from "./AppAdapter";
|
|
3
3
|
import { DownloadUpdateOptions } from "./AppUpdater";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { InstallOptions } from "./BaseUpdater";
|
|
5
|
+
import { Logger } from "./types";
|
|
6
|
+
import { LinuxUpdater } from "./LinuxUpdater";
|
|
7
|
+
export declare class PacmanUpdater extends LinuxUpdater {
|
|
6
8
|
constructor(options?: AllPublishOptions | null, app?: AppAdapter);
|
|
7
9
|
/*** @private */
|
|
8
10
|
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
|
9
|
-
protected get installerPath(): string | null;
|
|
10
11
|
protected doInstall(options: InstallOptions): boolean;
|
|
12
|
+
static installWithCommandRunner(installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger): void;
|
|
11
13
|
}
|
package/out/PacmanUpdater.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PacmanUpdater = void 0;
|
|
4
|
-
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
4
|
const types_1 = require("./types");
|
|
6
5
|
const Provider_1 = require("./providers/Provider");
|
|
7
|
-
|
|
6
|
+
const LinuxUpdater_1 = require("./LinuxUpdater");
|
|
7
|
+
class PacmanUpdater extends LinuxUpdater_1.LinuxUpdater {
|
|
8
8
|
constructor(options, app) {
|
|
9
9
|
super(options, app);
|
|
10
10
|
}
|
|
@@ -24,26 +24,44 @@ class PacmanUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
get installerPath() {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
return (_b = (_a = super.installerPath) === null || _a === void 0 ? void 0 : _a.replace(/ /g, "\\ ")) !== null && _b !== void 0 ? _b : null;
|
|
30
|
-
}
|
|
31
27
|
doInstall(options) {
|
|
32
|
-
const sudo = this.wrapSudo();
|
|
33
|
-
// pkexec doesn't want the command to be wrapped in " quotes
|
|
34
|
-
const wrapper = /pkexec/i.test(sudo) ? "" : `"`;
|
|
35
28
|
const installerPath = this.installerPath;
|
|
36
29
|
if (installerPath == null) {
|
|
37
|
-
this.dispatchError(new Error("No
|
|
30
|
+
this.dispatchError(new Error("No update filepath provided, can't quit and install"));
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
PacmanUpdater.installWithCommandRunner(installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
this.dispatchError(error);
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
|
-
const cmd = ["pacman", "-U", "--noconfirm", installerPath];
|
|
41
|
-
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]);
|
|
42
40
|
if (options.isForceRunAfter) {
|
|
43
|
-
this.app.relaunch();
|
|
41
|
+
this.app.relaunch(); // note: `app` is undefined in tests since vite doesn't run in electron
|
|
44
42
|
}
|
|
45
43
|
return true;
|
|
46
44
|
}
|
|
45
|
+
static installWithCommandRunner(installerPath, commandRunner, logger) {
|
|
46
|
+
var _a;
|
|
47
|
+
try {
|
|
48
|
+
commandRunner(["pacman", "-U", "--noconfirm", installerPath]);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logger.warn((_a = error.message) !== null && _a !== void 0 ? _a : error);
|
|
52
|
+
logger.warn("pacman installation failed, attempting to update package database and retry");
|
|
53
|
+
try {
|
|
54
|
+
// Update package database (not a full upgrade, just sync)
|
|
55
|
+
commandRunner(["pacman", "-Sy", "--noconfirm"]);
|
|
56
|
+
// Retry installation
|
|
57
|
+
commandRunner(["pacman", "-U", "--noconfirm", installerPath]);
|
|
58
|
+
}
|
|
59
|
+
catch (retryError) {
|
|
60
|
+
logger.error("Retry after pacman -Sy failed");
|
|
61
|
+
throw retryError;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
66
|
exports.PacmanUpdater = PacmanUpdater;
|
|
49
67
|
//# sourceMappingURL=PacmanUpdater.js.map
|
package/out/PacmanUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PacmanUpdater.js","sourceRoot":"","sources":["../src/PacmanUpdater.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PacmanUpdater.js","sourceRoot":"","sources":["../src/PacmanUpdater.ts"],"names":[],"mappings":";;;AAIA,mCAAmD;AACnD,mDAA+C;AAC/C,iDAA6C;AAE7C,MAAa,aAAc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,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACjH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YACzB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA,CAAC,uEAAuE;QAC7F,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,aAAqB,EAAE,aAAkD,EAAE,MAAc;;QACvH,IAAI,CAAC;YACH,aAAa,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;QAC/D,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,CAAA;YACnC,MAAM,CAAC,IAAI,CAAC,6EAA6E,CAAC,CAAA;YAE1F,IAAI,CAAC;gBACH,0DAA0D;gBAC1D,aAAa,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAA;gBAC/C,qBAAqB;gBACrB,aAAa,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;YAC/D,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACzB,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;gBAC7C,MAAM,UAAU,CAAA;YAClB,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA1DD,sCA0DC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS, Logger } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\nimport { LinuxUpdater } from \"./LinuxUpdater\"\n\nexport class PacmanUpdater extends LinuxUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"pacman\", [\"AppImage\", \"deb\", \"rpm\"])!\n return this.executeDownload({\n fileExtension: \"pacman\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n try {\n PacmanUpdater.installWithCommandRunner(installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger)\n } catch (error: any) {\n this.dispatchError(error)\n return false\n }\n if (options.isForceRunAfter) {\n this.app.relaunch() // note: `app` is undefined in tests since vite doesn't run in electron\n }\n return true\n }\n\n static installWithCommandRunner(installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger) {\n try {\n commandRunner([\"pacman\", \"-U\", \"--noconfirm\", installerPath])\n } catch (error: any) {\n logger.warn(error.message ?? error)\n logger.warn(\"pacman installation failed, attempting to update package database and retry\")\n\n try {\n // Update package database (not a full upgrade, just sync)\n commandRunner([\"pacman\", \"-Sy\", \"--noconfirm\"])\n // Retry installation\n commandRunner([\"pacman\", \"-U\", \"--noconfirm\", installerPath])\n } catch (retryError: any) {\n logger.error(\"Retry after pacman -Sy failed\")\n throw retryError\n }\n }\n }\n}\n"]}
|
package/out/RpmUpdater.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
2
|
import { AppAdapter } from "./AppAdapter";
|
|
3
3
|
import { DownloadUpdateOptions } from "./AppUpdater";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { InstallOptions } from "./BaseUpdater";
|
|
5
|
+
import { Logger } from "./types";
|
|
6
|
+
import { LinuxUpdater } from "./LinuxUpdater";
|
|
7
|
+
export declare class RpmUpdater extends LinuxUpdater {
|
|
6
8
|
constructor(options?: AllPublishOptions | null, app?: AppAdapter);
|
|
7
9
|
/*** @private */
|
|
8
10
|
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
|
9
|
-
protected get installerPath(): string | null;
|
|
10
11
|
protected doInstall(options: InstallOptions): boolean;
|
|
12
|
+
static installWithCommandRunner(packageManager: "zypper" | "dnf" | "yum" | "rpm", installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger): void;
|
|
11
13
|
}
|
package/out/RpmUpdater.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RpmUpdater = void 0;
|
|
4
|
-
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
4
|
const types_1 = require("./types");
|
|
6
5
|
const Provider_1 = require("./providers/Provider");
|
|
7
|
-
|
|
6
|
+
const LinuxUpdater_1 = require("./LinuxUpdater");
|
|
7
|
+
class RpmUpdater extends LinuxUpdater_1.LinuxUpdater {
|
|
8
8
|
constructor(options, app) {
|
|
9
9
|
super(options, app);
|
|
10
10
|
}
|
|
@@ -24,34 +24,42 @@ class RpmUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
get installerPath() {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
return (_b = (_a = super.installerPath) === null || _a === void 0 ? void 0 : _a.replace(/ /g, "\\ ")) !== null && _b !== void 0 ? _b : null;
|
|
30
|
-
}
|
|
31
27
|
doInstall(options) {
|
|
32
|
-
const sudo = this.wrapSudo();
|
|
33
|
-
// pkexec doesn't want the command to be wrapped in " quotes
|
|
34
|
-
const wrapper = /pkexec/i.test(sudo) ? "" : `"`;
|
|
35
|
-
const packageManager = this.spawnSyncLog("which zypper");
|
|
36
28
|
const installerPath = this.installerPath;
|
|
37
29
|
if (installerPath == null) {
|
|
38
|
-
this.dispatchError(new Error("No
|
|
30
|
+
this.dispatchError(new Error("No update filepath provided, can't quit and install"));
|
|
39
31
|
return false;
|
|
40
32
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
const priorityList = ["zypper", "dnf", "yum", "rpm"];
|
|
34
|
+
const packageManager = this.detectPackageManager(priorityList);
|
|
35
|
+
try {
|
|
36
|
+
RpmUpdater.installWithCommandRunner(packageManager, installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger);
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
catch (error) {
|
|
39
|
+
this.dispatchError(error);
|
|
40
|
+
return false;
|
|
48
41
|
}
|
|
49
|
-
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]);
|
|
50
42
|
if (options.isForceRunAfter) {
|
|
51
43
|
this.app.relaunch();
|
|
52
44
|
}
|
|
53
45
|
return true;
|
|
54
46
|
}
|
|
47
|
+
static installWithCommandRunner(packageManager, installerPath, commandRunner, logger) {
|
|
48
|
+
if (packageManager === "zypper") {
|
|
49
|
+
return commandRunner(["zypper", "--non-interactive", "--no-refresh", "install", "--allow-unsigned-rpm", "-f", installerPath]);
|
|
50
|
+
}
|
|
51
|
+
if (packageManager === "dnf") {
|
|
52
|
+
return commandRunner(["dnf", "install", "--nogpgcheck", "-y", installerPath]);
|
|
53
|
+
}
|
|
54
|
+
if (packageManager === "yum") {
|
|
55
|
+
return commandRunner(["yum", "install", "--nogpgcheck", "-y", installerPath]);
|
|
56
|
+
}
|
|
57
|
+
if (packageManager === "rpm") {
|
|
58
|
+
logger.warn("Installing with rpm only (no dependency resolution).");
|
|
59
|
+
return commandRunner(["rpm", "-Uvh", "--replacepkgs", "--replacefiles", "--nodeps", installerPath]);
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`Package manager ${packageManager} not supported`);
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
64
|
exports.RpmUpdater = RpmUpdater;
|
|
57
65
|
//# sourceMappingURL=RpmUpdater.js.map
|
package/out/RpmUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpmUpdater.js","sourceRoot":"","sources":["../src/RpmUpdater.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RpmUpdater.js","sourceRoot":"","sources":["../src/RpmUpdater.ts"],"names":[],"mappings":";;;AAIA,mCAAmD;AACnD,mDAA+C;AAC/C,iDAA6C;AAE7C,MAAa,UAAW,SAAQ,2BAAY;IAC1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAE,CAAA;QACzI,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,KAAK;YACpB,QAAQ;YACR,qBAAqB;YACrB,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE;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zK,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,aAAa,CAAC,CAAC,QAAQ,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,sBAAsB,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAA;QAC/H,CAAC;QACD,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;YAC7B,OAAO,aAAa,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAA;QAC/E,CAAC;QACD,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;YAC7B,OAAO,aAAa,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAA;QAC/E,CAAC;QACD,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;YACnE,OAAO,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAA;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,cAAc,gBAAgB,CAAC,CAAA;IACpE,CAAC;CACF;AA3DD,gCA2DC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS, Logger } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\nimport { LinuxUpdater } from \"./LinuxUpdater\"\n\nexport class RpmUpdater extends LinuxUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"rpm\", [\"AppImage\", \"deb\", \"pacman\"])!\n return this.executeDownload({\n fileExtension: \"rpm\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n\n const priorityList = [\"zypper\", \"dnf\", \"yum\", \"rpm\"]\n const packageManager = this.detectPackageManager(priorityList)\n try {\n RpmUpdater.installWithCommandRunner(packageManager as any, installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger)\n } catch (error: any) {\n this.dispatchError(error)\n return false\n }\n if (options.isForceRunAfter) {\n this.app.relaunch()\n }\n return true\n }\n\n static installWithCommandRunner(packageManager: \"zypper\" | \"dnf\" | \"yum\" | \"rpm\", installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger) {\n if (packageManager === \"zypper\") {\n return commandRunner([\"zypper\", \"--non-interactive\", \"--no-refresh\", \"install\", \"--allow-unsigned-rpm\", \"-f\", installerPath])\n }\n if (packageManager === \"dnf\") {\n return commandRunner([\"dnf\", \"install\", \"--nogpgcheck\", \"-y\", installerPath])\n }\n if (packageManager === \"yum\") {\n return commandRunner([\"yum\", \"install\", \"--nogpgcheck\", \"-y\", installerPath])\n }\n if (packageManager === \"rpm\") {\n logger.warn(\"Installing with rpm only (no dependency resolution).\")\n return commandRunner([\"rpm\", \"-Uvh\", \"--replacepkgs\", \"--replacefiles\", \"--nodeps\", installerPath])\n }\n throw new Error(`Package manager ${packageManager} not supported`)\n }\n}\n"]}
|
package/out/main.js
CHANGED
|
@@ -72,7 +72,7 @@ function doLoadAutoUpdater() {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
catch (error) {
|
|
75
|
-
console.warn("Unable to detect 'package-type' for autoUpdater (beta rpm/deb support). If you'd like to expand support, please consider contributing to electron-builder", error.message);
|
|
75
|
+
console.warn("Unable to detect 'package-type' for autoUpdater (beta rpm/deb/pacman support). If you'd like to expand support, please consider contributing to electron-builder", error.message);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
return _autoUpdater;
|
package/out/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAmD;AACnD,6BAA4B;AAI5B,6CAA2C;AAAlC,0GAAA,WAAW,OAAA;AACpB,2CAAqD;AAA5C,wGAAA,UAAU,OAAA;AAAE,wGAAA,UAAU,OAAA;AAC/B,iDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AACtB,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,0GAAA,WAAW,OAAA;AAEpB,0CAAuB;AAEvB,oDAAoD;AACpD,IAAI,YAAiB,CAAA;AAKrB,SAAS,iBAAiB;IACxB,+CAA+C;IAC/C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,WAAW,CAAC,EAAE,CAAA;IAC7D,CAAC;SAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACzC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,UAA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,CAAC,CAAA;YAC7C,QAAQ,QAAQ,EAAE,CAAC;gBACjB,KAAK,KAAK;oBACR,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,EAAE,CAAA;oBACzD,MAAK;gBACP,KAAK,KAAK;oBACR,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,EAAE,CAAA;oBACzD,MAAK;gBACP,KAAK,QAAQ;oBACX,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,aAAa,CAAC,EAAE,CAAA;oBAC/D,MAAK;gBACP;oBACE,MAAK;YACT,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CACV,kKAAkK,EAClK,KAAK,CAAC,OAAO,CACd,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE;IAC5C,UAAU,EAAE,IAAI;IAChB,GAAG,EAAE,GAAG,EAAE;QACR,OAAO,YAAY,IAAI,iBAAiB,EAAE,CAAA;IAC5C,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { existsSync, readFileSync } from \"fs-extra\"\nimport * as path from \"path\"\nimport { AppUpdater } from \"./AppUpdater\"\nimport { UpdateInfo } from \"builder-util-runtime\"\n\nexport { BaseUpdater } from \"./BaseUpdater\"\nexport { AppUpdater, NoOpLogger } from \"./AppUpdater\"\nexport { Provider } from \"./providers/Provider\"\nexport { AppImageUpdater } from \"./AppImageUpdater\"\nexport { DebUpdater } from \"./DebUpdater\"\nexport { PacmanUpdater } from \"./PacmanUpdater\"\nexport { RpmUpdater } from \"./RpmUpdater\"\nexport { MacUpdater } from \"./MacUpdater\"\nexport { NsisUpdater } from \"./NsisUpdater\"\n\nexport * from \"./types\"\n\n// autoUpdater to mimic electron bundled autoUpdater\nlet _autoUpdater: any\n\n// required for jsdoc\nexport declare const autoUpdater: AppUpdater\n\nfunction doLoadAutoUpdater(): AppUpdater {\n // tslint:disable:prefer-conditional-expression\n if (process.platform === \"win32\") {\n _autoUpdater = new (require(\"./NsisUpdater\").NsisUpdater)()\n } else if (process.platform === \"darwin\") {\n _autoUpdater = new (require(\"./MacUpdater\").MacUpdater)()\n } else {\n _autoUpdater = new (require(\"./AppImageUpdater\").AppImageUpdater)()\n try {\n const identity = path.join(process.resourcesPath, \"package-type\")\n if (!existsSync(identity)) {\n return _autoUpdater\n }\n console.info(\"Checking for beta autoupdate feature for deb/rpm distributions\")\n const fileType = readFileSync(identity).toString().trim()\n console.info(\"Found package-type:\", fileType)\n switch (fileType) {\n case \"deb\":\n _autoUpdater = new (require(\"./DebUpdater\").DebUpdater)()\n break\n case \"rpm\":\n _autoUpdater = new (require(\"./RpmUpdater\").RpmUpdater)()\n break\n case \"pacman\":\n _autoUpdater = new (require(\"./PacmanUpdater\").PacmanUpdater)()\n break\n default:\n break\n }\n } catch (error: any) {\n console.warn(\n \"Unable to detect 'package-type' for autoUpdater (beta rpm/deb/pacman support). If you'd like to expand support, please consider contributing to electron-builder\",\n error.message\n )\n }\n }\n return _autoUpdater\n}\n\nObject.defineProperty(exports, \"autoUpdater\", {\n enumerable: true,\n get: () => {\n return _autoUpdater || doLoadAutoUpdater()\n },\n})\n\n/**\n * return null if verify signature succeed\n * return error message if verify signature failed\n */\nexport type VerifyUpdateCodeSignature = (publisherName: string[], path: string) => Promise<string | null>\n\nexport type VerifyUpdateSupport = (updateInfo: UpdateInfo) => boolean | Promise<boolean>\n"]}
|
package/out/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { URL } from "url";
|
|
2
2
|
export declare function newUrlFromBase(pathname: string, baseUrl: URL, addRandomQueryToAvoidCaching?: boolean): URL;
|
|
3
3
|
export declare function getChannelFilename(channel: string): string;
|
|
4
|
-
export declare function blockmapFiles(baseUrl: URL, oldVersion: string, newVersion: string): URL[];
|
|
4
|
+
export declare function blockmapFiles(baseUrl: URL, oldVersion: string, newVersion: string, oldBlockMapFileBaseUrl?: string | null): URL[];
|
package/out/util.js
CHANGED
|
@@ -33,9 +33,9 @@ function newUrlFromBase(pathname, baseUrl, addRandomQueryToAvoidCaching = false)
|
|
|
33
33
|
function getChannelFilename(channel) {
|
|
34
34
|
return `${channel}.yml`;
|
|
35
35
|
}
|
|
36
|
-
function blockmapFiles(baseUrl, oldVersion, newVersion) {
|
|
36
|
+
function blockmapFiles(baseUrl, oldVersion, newVersion, oldBlockMapFileBaseUrl = null) {
|
|
37
37
|
const newBlockMapUrl = newUrlFromBase(`${baseUrl.pathname}.blockmap`, baseUrl);
|
|
38
|
-
const oldBlockMapUrl = newUrlFromBase(`${baseUrl.pathname.replace(new RegExp(escapeRegExp(newVersion), "g"), oldVersion)}.blockmap`, baseUrl);
|
|
38
|
+
const oldBlockMapUrl = newUrlFromBase(`${baseUrl.pathname.replace(new RegExp(escapeRegExp(newVersion), "g"), oldVersion)}.blockmap`, oldBlockMapFileBaseUrl ? new url_1.URL(oldBlockMapFileBaseUrl) : baseUrl);
|
|
39
39
|
return [oldBlockMapUrl, newBlockMapUrl];
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=util.js.map
|
package/out/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAMA,gCAMC;AAID,wCAUC;AAED,gDAEC;AAED,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAMA,gCAMC;AAID,wCAUC;AAED,gDAEC;AAED,sCAQC;AAxCD,mHAAmH;AACnH,6BAAyB;AACzB,aAAa;AACb,oDAAmD;AAEnD,gBAAgB;AAChB,SAAgB,UAAU,CAAC,GAAW;IACpC,MAAM,MAAM,GAAG,IAAI,SAAG,CAAC,GAAG,CAAC,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O,CACnE,CAAA;IAED,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;AACzC,CAAC","sourcesContent":["// if baseUrl path doesn't ends with /, this path will be not prepended to passed pathname for new URL(input, base)\nimport { URL } from \"url\"\n// @ts-ignore\nimport * as escapeRegExp from \"lodash.escaperegexp\"\n\n/** @internal */\nexport function newBaseUrl(url: string): URL {\n const result = new URL(url)\n if (!result.pathname.endsWith(\"/\")) {\n result.pathname += \"/\"\n }\n return result\n}\n\n// addRandomQueryToAvoidCaching is false by default because in most cases URL already contains version number,\n// so, it makes sense only for Generic Provider for channel files\nexport function newUrlFromBase(pathname: string, baseUrl: URL, addRandomQueryToAvoidCaching = false): URL {\n const result = new URL(pathname, baseUrl)\n // search is not propagated (search is an empty string if not specified)\n const search = baseUrl.search\n if (search != null && search.length !== 0) {\n result.search = search\n } else if (addRandomQueryToAvoidCaching) {\n result.search = `noCache=${Date.now().toString(32)}`\n }\n return result\n}\n\nexport function getChannelFilename(channel: string): string {\n return `${channel}.yml`\n}\n\nexport function blockmapFiles(baseUrl: URL, oldVersion: string, newVersion: string, oldBlockMapFileBaseUrl: string | null = null): URL[] {\n const newBlockMapUrl = newUrlFromBase(`${baseUrl.pathname}.blockmap`, baseUrl)\n const oldBlockMapUrl = newUrlFromBase(\n `${baseUrl.pathname.replace(new RegExp(escapeRegExp(newVersion), \"g\"), oldVersion)}.blockmap`,\n oldBlockMapFileBaseUrl ? new URL(oldBlockMapFileBaseUrl) : baseUrl\n )\n\n return [oldBlockMapUrl, newBlockMapUrl]\n}\n"]}
|