electron-updater 6.6.4 → 6.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/AppImageUpdater.js +1 -1
- package/out/AppImageUpdater.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/package.json +1 -1
package/out/AppImageUpdater.js
CHANGED
|
@@ -80,7 +80,7 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
80
80
|
const existingBaseName = path.basename(appImageFile);
|
|
81
81
|
const installerPath = this.installerPath;
|
|
82
82
|
if (installerPath == null) {
|
|
83
|
-
this.dispatchError(new Error("No
|
|
83
|
+
this.dispatchError(new Error("No update filepath provided, can't quit and install"));
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
// https://github.com/electron-userland/electron-builder/issues/2964
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AAClE,iDAA4C;AAC5C,uCAAgC;AAChC,2BAA+B;AAC/B,6BAA4B;AAE5B,+CAA2D;AAE3D,4IAAwI;AACxI,mDAAyD;AACzD,mCAAmE;AAEnE,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GC","sourcesContent":["import { AllPublishOptions, newError } from \"builder-util-runtime\"\nimport { execFileSync } from \"child_process\"\nimport { chmod } from \"fs-extra\"\nimport { unlinkSync } from \"fs\"\nimport * as path from \"path\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./types\"\n\nexport class AppImageUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: any) {\n super(options, app)\n }\n\n public isUpdaterActive(): boolean {\n if (process.env[\"APPIMAGE\"] == null && !this.forceDevUpdateConfig) {\n if (process.env[\"SNAP\"] == null) {\n this._logger.warn(\"APPIMAGE env is not defined, current application is not an AppImage\")\n } else {\n this._logger.info(\"SNAP env is defined, updater is disabled\")\n }\n return false\n }\n return super.isUpdaterActive()\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), \"AppImage\", [\"rpm\", \"deb\", \"pacman\"])!\n return this.executeDownload({\n fileExtension: \"AppImage\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n const oldFile = process.env[\"APPIMAGE\"]!\n if (oldFile == null) {\n throw newError(\"APPIMAGE env is not defined\", \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n\n if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n }\n\n await chmod(updateFile, 0o755)\n },\n })\n }\n\n private async downloadDifferential(fileInfo: ResolvedUpdateFileInfo, oldFile: string, updateFile: string, provider: Provider<any>, downloadUpdateOptions: DownloadUpdateOptions) {\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile,\n logger: this._logger,\n newFile: updateFile,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\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(fileInfo.info, this.httpExecutor, downloadOptions).download()\n return false\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac) we must throw error\n return process.platform === \"linux\"\n }\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const appImageFile = process.env[\"APPIMAGE\"]!\n if (appImageFile == null) {\n throw newError(\"APPIMAGE env is not defined\", \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n\n // https://stackoverflow.com/a/1712051/1910191\n unlinkSync(appImageFile)\n\n let destination: string\n const existingBaseName = path.basename(appImageFile)\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 // https://github.com/electron-userland/electron-builder/issues/2964\n // if no version in existing file name, it means that user wants to preserve current custom name\n if (path.basename(installerPath) === existingBaseName || !/\\d+\\.\\d+\\.\\d+/.test(existingBaseName)) {\n // no version in the file name, overwrite existing\n destination = appImageFile\n } else {\n destination = path.join(path.dirname(appImageFile), path.basename(installerPath))\n }\n\n execFileSync(\"mv\", [\"-f\", installerPath, destination])\n if (destination !== appImageFile) {\n this.emit(\"appimage-filename-updated\", destination)\n }\n\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n APPIMAGE_SILENT_INSTALL: \"true\",\n }\n\n if (options.isForceRunAfter) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.spawnLog(destination, [], env)\n } else {\n env.APPIMAGE_EXIT_AFTER_INSTALL = \"true\"\n execFileSync(destination, [], { env })\n }\n return true\n }\n}\n"]}
|
package/out/BaseUpdater.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare abstract class BaseUpdater extends AppUpdater {
|
|
|
12
12
|
protected abstract doInstall(options: InstallOptions): boolean;
|
|
13
13
|
install(isSilent?: boolean, isForceRunAfter?: boolean): boolean;
|
|
14
14
|
protected addQuitHandler(): void;
|
|
15
|
-
protected wrapSudo(): string;
|
|
16
15
|
protected spawnSyncLog(cmd: string, args?: string[], env?: {}): string;
|
|
17
16
|
/**
|
|
18
17
|
* This handles both node 8 and node 10 way of emitting error when spawning a process
|
package/out/BaseUpdater.js
CHANGED
|
@@ -47,7 +47,7 @@ class BaseUpdater extends AppUpdater_1.AppUpdater {
|
|
|
47
47
|
const installerPath = this.installerPath;
|
|
48
48
|
const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo;
|
|
49
49
|
if (installerPath == null || downloadedFileInfo == null) {
|
|
50
|
-
this.dispatchError(new Error("No
|
|
50
|
+
this.dispatchError(new Error("No update filepath provided, can't quit and install"));
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
// prevent calling several times
|
|
@@ -87,23 +87,6 @@ class BaseUpdater extends AppUpdater_1.AppUpdater {
|
|
|
87
87
|
this.install(true, false);
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
wrapSudo() {
|
|
91
|
-
const { name } = this.app;
|
|
92
|
-
const installComment = `"${name} would like to update"`;
|
|
93
|
-
const sudo = this.spawnSyncLog("which gksudo || which kdesudo || which pkexec || which beesu");
|
|
94
|
-
const command = [sudo];
|
|
95
|
-
if (/kdesudo/i.test(sudo)) {
|
|
96
|
-
command.push("--comment", installComment);
|
|
97
|
-
command.push("-c");
|
|
98
|
-
}
|
|
99
|
-
else if (/gksudo/i.test(sudo)) {
|
|
100
|
-
command.push("--message", installComment);
|
|
101
|
-
}
|
|
102
|
-
else if (/pkexec/i.test(sudo)) {
|
|
103
|
-
command.push("--disable-internal-agent");
|
|
104
|
-
}
|
|
105
|
-
return command.join(" ");
|
|
106
|
-
}
|
|
107
90
|
spawnSyncLog(cmd, args = [], env = {}) {
|
|
108
91
|
this._logger.info(`Executing: ${cmd} with args: ${args}`);
|
|
109
92
|
const response = (0, child_process_1.spawnSync)(cmd, args, {
|
package/out/BaseUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseUpdater.js","sourceRoot":"","sources":["../src/BaseUpdater.ts"],"names":[],"mappings":";;;AACA,iDAA4E;AAE5E,6CAA+D;AAE/D,MAAsB,WAAY,SAAQ,uBAAU;IAIlD,YAAsB,OAAkC,EAAE,GAAgB;QACxE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAJX,yBAAoB,GAAG,KAAK,CAAA;QAC9B,qBAAgB,GAAG,KAAK,CAAA;IAIhC,CAAC;IAED,cAAc,CAAC,QAAQ,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;QACtD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;QACvD,+FAA+F;QAC/F,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;QACpG,IAAI,WAAW,EAAE,CAAC;YAChB,YAAY,CAAC,GAAG,EAAE;gBAChB,iFAAiF;gBACjF,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;gBAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YACjB,CAAC,CAAC,C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StdioOptions } from \"child_process\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadExecutorTask } from \"./AppUpdater\"\n\nexport abstract class BaseUpdater extends AppUpdater {\n protected quitAndInstallCalled = false\n private quitHandlerAdded = false\n\n protected constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n quitAndInstall(isSilent = false, isForceRunAfter = false): void {\n this._logger.info(`Install on explicit quitAndInstall`)\n // If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app\n const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)\n if (isInstalled) {\n setImmediate(() => {\n // this event is normally emitted when calling quitAndInstall, this emulates that\n require(\"electron\").autoUpdater.emit(\"before-quit-for-update\")\n this.app.quit()\n })\n } else {\n this.quitAndInstallCalled = false\n }\n }\n\n protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n return super.executeDownload({\n ...taskOptions,\n done: event => {\n this.dispatchUpdateDownloaded(event)\n this.addQuitHandler()\n return Promise.resolve()\n },\n })\n }\n\n protected get installerPath(): string | null {\n return this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.file\n }\n\n // must be sync\n protected abstract doInstall(options: InstallOptions): boolean\n\n // must be sync (because quit even handler is not async)\n install(isSilent = false, isForceRunAfter = false): boolean {\n if (this.quitAndInstallCalled) {\n this._logger.warn(\"install call ignored: quitAndInstallCalled is set to true\")\n return false\n }\n\n const downloadedUpdateHelper = this.downloadedUpdateHelper\n const installerPath = this.installerPath\n const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo\n if (installerPath == null || downloadedFileInfo == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n\n // prevent calling several times\n this.quitAndInstallCalled = true\n\n try {\n this._logger.info(`Install: isSilent: ${isSilent}, isForceRunAfter: ${isForceRunAfter}`)\n return this.doInstall({\n isSilent,\n isForceRunAfter,\n isAdminRightsRequired: downloadedFileInfo.isAdminRightsRequired,\n })\n } catch (e: any) {\n this.dispatchError(e)\n return false\n }\n }\n\n protected addQuitHandler(): void {\n if (this.quitHandlerAdded || !this.autoInstallOnAppQuit) {\n return\n }\n\n this.quitHandlerAdded = true\n\n this.app.onQuit(exitCode => {\n if (this.quitAndInstallCalled) {\n this._logger.info(\"Update installer has already been triggered. Quitting application.\")\n return\n }\n\n if (!this.autoInstallOnAppQuit) {\n this._logger.info(\"Update will not be installed on quit because autoInstallOnAppQuit is set to false.\")\n return\n }\n\n if (exitCode !== 0) {\n this._logger.info(`Update will be not installed on quit because application is quitting with exit code ${exitCode}`)\n return\n }\n\n this._logger.info(\"Auto install update on quit\")\n this.install(true, false)\n })\n }\n\n protected wrapSudo() {\n const { name } = this.app\n const installComment = `\"${name} would like to update\"`\n const sudo = this.spawnSyncLog(\"which gksudo || which kdesudo || which pkexec || which beesu\")\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.join(\" \")\n }\n\n protected spawnSyncLog(cmd: string, args: string[] = [], env = {}): string {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n const response = spawnSync(cmd, args, {\n env: { ...process.env, ...env },\n encoding: \"utf-8\",\n shell: true,\n })\n\n const { error, status, stdout, stderr } = response\n if (error != null) {\n this._logger.error(stderr)\n throw error\n } else if (status != null && status !== 0) {\n this._logger.error(stderr)\n throw new Error(`Command ${cmd} exited with code ${status}`)\n }\n\n return stdout.trim()\n }\n\n /**\n * This handles both node 8 and node 10 way of emitting error when spawning a process\n * - node 8: Throws the error\n * - node 10: Emit the error(Need to listen with on)\n */\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 protected async spawnLog(cmd: string, args: string[] = [], env: any = undefined, stdio: StdioOptions = \"ignore\"): Promise<boolean> {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n return new Promise<boolean>((resolve, reject) => {\n try {\n const params: SpawnOptions = { stdio, env, detached: true }\n const p = spawn(cmd, args, params)\n p.on(\"error\", error => {\n reject(error)\n })\n p.unref()\n if (p.pid !== undefined) {\n resolve(true)\n }\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\nexport interface InstallOptions {\n readonly isSilent: boolean\n readonly isForceRunAfter: boolean\n readonly isAdminRightsRequired: boolean\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BaseUpdater.js","sourceRoot":"","sources":["../src/BaseUpdater.ts"],"names":[],"mappings":";;;AACA,iDAA4E;AAE5E,6CAA+D;AAE/D,MAAsB,WAAY,SAAQ,uBAAU;IAIlD,YAAsB,OAAkC,EAAE,GAAgB;QACxE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAJX,yBAAoB,GAAG,KAAK,CAAA;QAC9B,qBAAgB,GAAG,KAAK,CAAA;IAIhC,CAAC;IAED,cAAc,CAAC,QAAQ,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;QACtD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;QACvD,+FAA+F;QAC/F,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;QACpG,IAAI,WAAW,EAAE,CAAC;YAChB,YAAY,CAAC,GAAG,EAAE;gBAChB,iFAAiF;gBACjF,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;gBAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YACjB,CAAC,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,I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AAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACpB,MAAM,CAAC,KAAK,CAAC,CAAA;gBACf,CAAC,CAAC,CAAA;gBACF,CAAC,CAAC,KAAK,EAAE,CAAA;gBACT,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;oBACxB,OAAO,CAAC,IAAI,CAAC,CAAA;gBACf,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,CAAA;YACf,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAjJD,kCAiJC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { spawn, SpawnOptions, spawnSync, StdioOptions } from \"child_process\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadExecutorTask } from \"./AppUpdater\"\n\nexport abstract class BaseUpdater extends AppUpdater {\n protected quitAndInstallCalled = false\n private quitHandlerAdded = false\n\n protected constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n quitAndInstall(isSilent = false, isForceRunAfter = false): void {\n this._logger.info(`Install on explicit quitAndInstall`)\n // If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app\n const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)\n if (isInstalled) {\n setImmediate(() => {\n // this event is normally emitted when calling quitAndInstall, this emulates that\n require(\"electron\").autoUpdater.emit(\"before-quit-for-update\")\n this.app.quit()\n })\n } else {\n this.quitAndInstallCalled = false\n }\n }\n\n protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n return super.executeDownload({\n ...taskOptions,\n done: event => {\n this.dispatchUpdateDownloaded(event)\n this.addQuitHandler()\n return Promise.resolve()\n },\n })\n }\n\n protected get installerPath(): string | null {\n return this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.file\n }\n\n // must be sync\n protected abstract doInstall(options: InstallOptions): boolean\n\n // must be sync (because quit even handler is not async)\n install(isSilent = false, isForceRunAfter = false): boolean {\n if (this.quitAndInstallCalled) {\n this._logger.warn(\"install call ignored: quitAndInstallCalled is set to true\")\n return false\n }\n\n const downloadedUpdateHelper = this.downloadedUpdateHelper\n const installerPath = this.installerPath\n const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo\n if (installerPath == null || downloadedFileInfo == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\n\n // prevent calling several times\n this.quitAndInstallCalled = true\n\n try {\n this._logger.info(`Install: isSilent: ${isSilent}, isForceRunAfter: ${isForceRunAfter}`)\n return this.doInstall({\n isSilent,\n isForceRunAfter,\n isAdminRightsRequired: downloadedFileInfo.isAdminRightsRequired,\n })\n } catch (e: any) {\n this.dispatchError(e)\n return false\n }\n }\n\n protected addQuitHandler(): void {\n if (this.quitHandlerAdded || !this.autoInstallOnAppQuit) {\n return\n }\n\n this.quitHandlerAdded = true\n\n this.app.onQuit(exitCode => {\n if (this.quitAndInstallCalled) {\n this._logger.info(\"Update installer has already been triggered. Quitting application.\")\n return\n }\n\n if (!this.autoInstallOnAppQuit) {\n this._logger.info(\"Update will not be installed on quit because autoInstallOnAppQuit is set to false.\")\n return\n }\n\n if (exitCode !== 0) {\n this._logger.info(`Update will be not installed on quit because application is quitting with exit code ${exitCode}`)\n return\n }\n\n this._logger.info(\"Auto install update on quit\")\n this.install(true, false)\n })\n }\n\n protected spawnSyncLog(cmd: string, args: string[] = [], env = {}): string {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n const response = spawnSync(cmd, args, {\n env: { ...process.env, ...env },\n encoding: \"utf-8\",\n shell: true,\n })\n\n const { error, status, stdout, stderr } = response\n if (error != null) {\n this._logger.error(stderr)\n throw error\n } else if (status != null && status !== 0) {\n this._logger.error(stderr)\n throw new Error(`Command ${cmd} exited with code ${status}`)\n }\n\n return stdout.trim()\n }\n\n /**\n * This handles both node 8 and node 10 way of emitting error when spawning a process\n * - node 8: Throws the error\n * - node 10: Emit the error(Need to listen with on)\n */\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 protected async spawnLog(cmd: string, args: string[] = [], env: any = undefined, stdio: StdioOptions = \"ignore\"): Promise<boolean> {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n return new Promise<boolean>((resolve, reject) => {\n try {\n const params: SpawnOptions = { stdio, env, detached: true }\n const p = spawn(cmd, args, params)\n p.on(\"error\", error => {\n reject(error)\n })\n p.unref()\n if (p.pid !== undefined) {\n resolve(true)\n }\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\nexport interface InstallOptions {\n readonly isSilent: boolean\n readonly isForceRunAfter: boolean\n readonly isAdminRightsRequired: boolean\n}\n"]}
|
package/out/DebUpdater.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 DebUpdater 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: "dpkg" | "apt", installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger): void;
|
|
11
13
|
}
|
package/out/DebUpdater.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DebUpdater = void 0;
|
|
4
|
-
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
4
|
const Provider_1 = require("./providers/Provider");
|
|
6
5
|
const types_1 = require("./types");
|
|
7
|
-
|
|
6
|
+
const LinuxUpdater_1 = require("./LinuxUpdater");
|
|
7
|
+
class DebUpdater extends LinuxUpdater_1.LinuxUpdater {
|
|
8
8
|
constructor(options, app) {
|
|
9
9
|
super(options, app);
|
|
10
10
|
}
|
|
@@ -24,26 +24,61 @@ class DebUpdater 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
|
+
if (!this.hasCommand("dpkg") && !this.hasCommand("apt")) {
|
|
34
|
+
this.dispatchError(new Error("Neither dpkg nor apt command found. Cannot install .deb package."));
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const priorityList = ["dpkg", "apt"];
|
|
38
|
+
const packageManager = this.detectPackageManager(priorityList);
|
|
39
|
+
try {
|
|
40
|
+
DebUpdater.installWithCommandRunner(packageManager, installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.dispatchError(error);
|
|
38
44
|
return false;
|
|
39
45
|
}
|
|
40
|
-
const cmd = ["dpkg", "-i", installerPath, "||", "apt-get", "install", "-f", "-y"];
|
|
41
|
-
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]);
|
|
42
46
|
if (options.isForceRunAfter) {
|
|
43
47
|
this.app.relaunch();
|
|
44
48
|
}
|
|
45
49
|
return true;
|
|
46
50
|
}
|
|
51
|
+
static installWithCommandRunner(packageManager, installerPath, commandRunner, logger) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (packageManager === "dpkg") {
|
|
54
|
+
try {
|
|
55
|
+
// Primary: Install unsigned .deb directly with dpkg
|
|
56
|
+
commandRunner(["dpkg", "-i", installerPath]);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
// Handle missing dependencies via apt-get
|
|
60
|
+
logger.warn((_a = error.message) !== null && _a !== void 0 ? _a : error);
|
|
61
|
+
logger.warn("dpkg installation failed, trying to fix broken dependencies with apt-get");
|
|
62
|
+
commandRunner(["apt-get", "install", "-f", "-y"]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (packageManager === "apt") {
|
|
66
|
+
// Fallback: Use apt for direct install (less safe for unsigned .deb)
|
|
67
|
+
logger.warn("Using apt to install a local .deb. This may fail for unsigned packages unless properly configured.");
|
|
68
|
+
commandRunner([
|
|
69
|
+
"apt",
|
|
70
|
+
"install",
|
|
71
|
+
"-y",
|
|
72
|
+
"--allow-unauthenticated", // needed for unsigned .debs
|
|
73
|
+
"--allow-downgrades", // allow lower version installs
|
|
74
|
+
"--allow-change-held-packages",
|
|
75
|
+
installerPath,
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw new Error(`Package manager ${packageManager} not supported`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
47
82
|
}
|
|
48
83
|
exports.DebUpdater = DebUpdater;
|
|
49
84
|
//# sourceMappingURL=DebUpdater.js.map
|
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,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;gBAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,yBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB,EAAE,EAAE,CAAC,CAAA;gBACrE,CAAC;gBACD,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,CAAA;YAC7E,CAAC;SACF,CAAC,CAAA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AC,CAAA;YAC9C,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,0CAA0C;gBAC1C,MAAM,CAAC,IAAI,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,CAAA;gBACnC,MAAM,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAA;gBACvF,aAAa,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;YACnD,CAAC;QACH,CAAC;aAAM,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;YACpC,qEAAqE;YACrE,MAAM,CAAC,IAAI,CAAC,oGAAoG,CAAC,CAAA;YACjH,aAAa,CAAC;gBACZ,KAAK;gBACL,SAAS;gBACT,IAAI;gBACJ,yBAAyB,EAAE,4BAA4B;gBACvD,oBAAoB,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,uDAAI,MAAK,CAAC,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,IAAc,aAAa;;QACzB,OAAO,MAAA,MAAA,KAAK,CAAC,aAAa,0CAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,mCAAI,IAAI,CAAA;IACjF,CAAC;IAES,0BAA0B,CAAC,eAAyB;QAC5D,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;YACzD,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QACxE,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,CAAA;QACzB,MAAM,cAAc,GAAG,IAAI,IAAI,wBAAwB,CAAA;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;QAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oDAAoD,IAAI,EA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OAAO,IAAI,CAAA;QACb,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAES,oBAAoB;QAC5B,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QACtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;;OAOG;IACO,oBAAoB,CAAC,GAAa;;QAC1C,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,sCAAsC,0CAAE,IAAI,EAAE,CAAA;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,0BAA0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O,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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+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,SAAQ,2BAAY;IAC7C,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,QAAQ,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAE,CAAA;QACzI,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,QAAQ;YACvB,QAAQ;YACR,qBAAqB;YACrB,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE;gBAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,yBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB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AC,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,EA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AAC;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;AA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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"]}
|