electron-updater 6.8.9 → 7.0.0-alpha.1

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.
Files changed (173) hide show
  1. package/{out → dist}/AppAdapter.d.ts +1 -0
  2. package/dist/AppAdapter.d.ts.map +1 -0
  3. package/{out → dist}/AppAdapter.js +4 -7
  4. package/dist/AppAdapter.js.map +1 -0
  5. package/{out → dist}/AppImageUpdater.d.ts +3 -2
  6. package/dist/AppImageUpdater.d.ts.map +1 -0
  7. package/{out → dist}/AppImageUpdater.js +21 -25
  8. package/dist/AppImageUpdater.js.map +1 -0
  9. package/{out → dist}/AppUpdater.d.ts +8 -7
  10. package/dist/AppUpdater.d.ts.map +1 -0
  11. package/{out → dist}/AppUpdater.js +75 -78
  12. package/dist/AppUpdater.js.map +1 -0
  13. package/{out → dist}/BaseUpdater.d.ts +3 -2
  14. package/dist/BaseUpdater.d.ts.map +1 -0
  15. package/{out → dist}/BaseUpdater.js +9 -12
  16. package/dist/BaseUpdater.js.map +1 -0
  17. package/{out → dist}/DebUpdater.d.ts +6 -5
  18. package/dist/DebUpdater.d.ts.map +1 -0
  19. package/{out → dist}/DebUpdater.js +8 -13
  20. package/dist/DebUpdater.js.map +1 -0
  21. package/{out → dist}/DownloadedUpdateHelper.d.ts +3 -2
  22. package/dist/DownloadedUpdateHelper.d.ts.map +1 -0
  23. package/{out → dist}/DownloadedUpdateHelper.js +17 -23
  24. package/dist/DownloadedUpdateHelper.js.map +1 -0
  25. package/{out → dist}/ElectronAppAdapter.d.ts +2 -1
  26. package/dist/ElectronAppAdapter.d.ts.map +1 -0
  27. package/{out → dist}/ElectronAppAdapter.js +6 -8
  28. package/dist/ElectronAppAdapter.js.map +1 -0
  29. package/{out → dist}/LinuxUpdater.d.ts +3 -2
  30. package/dist/LinuxUpdater.d.ts.map +1 -0
  31. package/{out → dist}/LinuxUpdater.js +4 -10
  32. package/dist/LinuxUpdater.js.map +1 -0
  33. package/{out → dist}/MacUpdater.d.ts +4 -3
  34. package/dist/MacUpdater.d.ts.map +1 -0
  35. package/{out → dist}/MacUpdater.js +25 -28
  36. package/dist/MacUpdater.js.map +1 -0
  37. package/{out → dist}/NsisUpdater.d.ts +5 -4
  38. package/dist/NsisUpdater.d.ts.map +1 -0
  39. package/{out → dist}/NsisUpdater.js +24 -26
  40. package/dist/NsisUpdater.js.map +1 -0
  41. package/{out → dist}/PacmanUpdater.d.ts +6 -5
  42. package/dist/PacmanUpdater.d.ts.map +1 -0
  43. package/{out → dist}/PacmanUpdater.js +8 -13
  44. package/dist/PacmanUpdater.js.map +1 -0
  45. package/{out → dist}/RpmUpdater.d.ts +6 -5
  46. package/dist/RpmUpdater.d.ts.map +1 -0
  47. package/{out → dist}/RpmUpdater.js +7 -11
  48. package/dist/RpmUpdater.js.map +1 -0
  49. package/{out → dist}/differentialDownloader/DataSplitter.d.ts +6 -3
  50. package/dist/differentialDownloader/DataSplitter.d.ts.map +1 -0
  51. package/{out → dist}/differentialDownloader/DataSplitter.js +21 -22
  52. package/dist/differentialDownloader/DataSplitter.js.map +1 -0
  53. package/{out → dist}/differentialDownloader/DifferentialDownloader.d.ts +4 -3
  54. package/dist/differentialDownloader/DifferentialDownloader.d.ts.map +1 -0
  55. package/{out → dist}/differentialDownloader/DifferentialDownloader.js +27 -32
  56. package/dist/differentialDownloader/DifferentialDownloader.js.map +1 -0
  57. package/{out → dist}/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.d.ts +2 -1
  58. package/dist/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.d.ts.map +1 -0
  59. package/dist/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js +33 -0
  60. package/dist/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js.map +1 -0
  61. package/{out → dist}/differentialDownloader/GenericDifferentialDownloader.d.ts +3 -2
  62. package/dist/differentialDownloader/GenericDifferentialDownloader.d.ts.map +1 -0
  63. package/dist/differentialDownloader/GenericDifferentialDownloader.js +7 -0
  64. package/dist/differentialDownloader/GenericDifferentialDownloader.js.map +1 -0
  65. package/{out → dist}/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.d.ts +1 -0
  66. package/dist/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.d.ts.map +1 -0
  67. package/{out → dist}/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js +2 -6
  68. package/dist/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +1 -0
  69. package/{out → dist}/differentialDownloader/downloadPlanBuilder.d.ts +3 -2
  70. package/dist/differentialDownloader/downloadPlanBuilder.d.ts.map +1 -0
  71. package/{out → dist}/differentialDownloader/downloadPlanBuilder.js +3 -7
  72. package/dist/differentialDownloader/downloadPlanBuilder.js.map +1 -0
  73. package/{out → dist}/differentialDownloader/multipleRangeDownloader.d.ts +3 -2
  74. package/dist/differentialDownloader/multipleRangeDownloader.d.ts.map +1 -0
  75. package/{out → dist}/differentialDownloader/multipleRangeDownloader.js +12 -16
  76. package/dist/differentialDownloader/multipleRangeDownloader.js.map +1 -0
  77. package/{out → dist}/electronHttpExecutor.d.ts +4 -2
  78. package/dist/electronHttpExecutor.d.ts.map +1 -0
  79. package/{out → dist}/electronHttpExecutor.js +10 -13
  80. package/dist/electronHttpExecutor.js.map +1 -0
  81. package/dist/index.d.ts +27 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +74 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/indexInternal.d.ts +6 -0
  86. package/dist/indexInternal.d.ts.map +1 -0
  87. package/dist/indexInternal.js +5 -0
  88. package/dist/indexInternal.js.map +1 -0
  89. package/{out → dist}/providerFactory.d.ts +3 -2
  90. package/dist/providerFactory.d.ts.map +1 -0
  91. package/dist/providerFactory.js +64 -0
  92. package/dist/providerFactory.js.map +1 -0
  93. package/{out → dist}/providers/BitbucketProvider.d.ts +4 -3
  94. package/dist/providers/BitbucketProvider.d.ts.map +1 -0
  95. package/dist/providers/BitbucketProvider.js +38 -0
  96. package/dist/providers/BitbucketProvider.js.map +1 -0
  97. package/{out → dist}/providers/GenericProvider.d.ts +4 -3
  98. package/dist/providers/GenericProvider.d.ts.map +1 -0
  99. package/{out → dist}/providers/GenericProvider.js +11 -15
  100. package/dist/providers/GenericProvider.js.map +1 -0
  101. package/{out → dist}/providers/GitHubProvider.d.ts +4 -3
  102. package/dist/providers/GitHubProvider.d.ts.map +1 -0
  103. package/{out → dist}/providers/GitHubProvider.js +28 -35
  104. package/dist/providers/GitHubProvider.js.map +1 -0
  105. package/{out → dist}/providers/GitLabProvider.d.ts +4 -3
  106. package/dist/providers/GitLabProvider.d.ts.map +1 -0
  107. package/{out → dist}/providers/GitLabProvider.js +32 -37
  108. package/dist/providers/GitLabProvider.js.map +1 -0
  109. package/{out → dist}/providers/KeygenProvider.d.ts +4 -3
  110. package/dist/providers/KeygenProvider.d.ts.map +1 -0
  111. package/dist/providers/KeygenProvider.js +42 -0
  112. package/dist/providers/KeygenProvider.js.map +1 -0
  113. package/{out → dist}/providers/PrivateGitHubProvider.d.ts +5 -4
  114. package/dist/providers/PrivateGitHubProvider.d.ts.map +1 -0
  115. package/{out → dist}/providers/PrivateGitHubProvider.js +20 -24
  116. package/dist/providers/PrivateGitHubProvider.js.map +1 -0
  117. package/{out → dist}/providers/Provider.d.ts +3 -2
  118. package/dist/providers/Provider.d.ts.map +1 -0
  119. package/{out → dist}/providers/Provider.js +22 -32
  120. package/dist/providers/Provider.js.map +1 -0
  121. package/{out → dist}/types.d.ts +2 -1
  122. package/dist/types.d.ts.map +1 -0
  123. package/dist/types.js +28 -0
  124. package/dist/types.js.map +1 -0
  125. package/{out → dist}/util.d.ts +1 -0
  126. package/dist/util.d.ts.map +1 -0
  127. package/{out → dist}/util.js +6 -11
  128. package/dist/util.js.map +1 -0
  129. package/{out → dist}/windowsExecutableCodeSignatureVerifier.d.ts +2 -1
  130. package/dist/windowsExecutableCodeSignatureVerifier.d.ts.map +1 -0
  131. package/{out → dist}/windowsExecutableCodeSignatureVerifier.js +10 -14
  132. package/dist/windowsExecutableCodeSignatureVerifier.js.map +1 -0
  133. package/package.json +26 -6
  134. package/out/AppAdapter.js.map +0 -1
  135. package/out/AppImageUpdater.js.map +0 -1
  136. package/out/AppUpdater.js.map +0 -1
  137. package/out/BaseUpdater.js.map +0 -1
  138. package/out/DebUpdater.js.map +0 -1
  139. package/out/DownloadedUpdateHelper.js.map +0 -1
  140. package/out/ElectronAppAdapter.js.map +0 -1
  141. package/out/LinuxUpdater.js.map +0 -1
  142. package/out/MacUpdater.js.map +0 -1
  143. package/out/NsisUpdater.js.map +0 -1
  144. package/out/PacmanUpdater.js.map +0 -1
  145. package/out/RpmUpdater.js.map +0 -1
  146. package/out/differentialDownloader/DataSplitter.js.map +0 -1
  147. package/out/differentialDownloader/DifferentialDownloader.js.map +0 -1
  148. package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js +0 -37
  149. package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js.map +0 -1
  150. package/out/differentialDownloader/GenericDifferentialDownloader.js +0 -11
  151. package/out/differentialDownloader/GenericDifferentialDownloader.js.map +0 -1
  152. package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +0 -1
  153. package/out/differentialDownloader/downloadPlanBuilder.js.map +0 -1
  154. package/out/differentialDownloader/multipleRangeDownloader.js.map +0 -1
  155. package/out/electronHttpExecutor.js.map +0 -1
  156. package/out/main.d.ts +0 -19
  157. package/out/main.js +0 -84
  158. package/out/main.js.map +0 -1
  159. package/out/providerFactory.js +0 -68
  160. package/out/providerFactory.js.map +0 -1
  161. package/out/providers/BitbucketProvider.js +0 -42
  162. package/out/providers/BitbucketProvider.js.map +0 -1
  163. package/out/providers/GenericProvider.js.map +0 -1
  164. package/out/providers/GitHubProvider.js.map +0 -1
  165. package/out/providers/GitLabProvider.js.map +0 -1
  166. package/out/providers/KeygenProvider.js +0 -46
  167. package/out/providers/KeygenProvider.js.map +0 -1
  168. package/out/providers/PrivateGitHubProvider.js.map +0 -1
  169. package/out/providers/Provider.js.map +0 -1
  170. package/out/types.js +0 -42
  171. package/out/types.js.map +0 -1
  172. package/out/util.js.map +0 -1
  173. package/out/windowsExecutableCodeSignatureVerifier.js.map +0 -1
@@ -20,3 +20,4 @@ export interface AppAdapter {
20
20
  onQuit(handler: (exitCode: number) => void): void;
21
21
  }
22
22
  export declare function getAppCacheDir(): string;
23
+ //# sourceMappingURL=AppAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppAdapter.d.ts","sourceRoot":"","sources":["../src/AppAdapter.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAE5B;;OAEG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IAEpC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAE7B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAE9B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAE1B,QAAQ,IAAI,IAAI,CAAA;IAEhB,IAAI,IAAI,IAAI,CAAA;IAEZ,MAAM,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAA;CAClD;AAED,wBAAgB,cAAc,WAY7B"}
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppCacheDir = getAppCacheDir;
4
- const path = require("path");
5
- const os_1 = require("os");
6
- function getAppCacheDir() {
7
- const homedir = (0, os_1.homedir)();
1
+ import * as path from "path";
2
+ import { homedir as getHomedir } from "os";
3
+ export function getAppCacheDir() {
4
+ const homedir = getHomedir();
8
5
  // https://github.com/electron/electron/issues/1404#issuecomment-194391247
9
6
  let result;
10
7
  if (process.platform === "win32") {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppAdapter.js","sourceRoot":"","sources":["../src/AppAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,IAAI,CAAA;AAgC1C,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;IAC5B,0EAA0E;IAC1E,IAAI,MAAc,CAAA;IAClB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAChF,CAAC;SAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;IAClD,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACxE,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import * as path from \"path\"\nimport { homedir as getHomedir } from \"os\"\n\nexport interface AppAdapter {\n readonly version: string\n readonly name: string\n\n readonly isPackaged: boolean\n\n /**\n * Path to update metadata file.\n */\n readonly appUpdateConfigPath: string\n\n /**\n * Path to user data directory.\n */\n readonly userDataPath: string\n\n /**\n * Path to cache directory.\n */\n readonly baseCachePath: string\n\n whenReady(): Promise<void>\n\n relaunch(): void\n\n quit(): void\n\n onQuit(handler: (exitCode: number) => void): void\n}\n\nexport function getAppCacheDir() {\n const homedir = getHomedir()\n // https://github.com/electron/electron/issues/1404#issuecomment-194391247\n let result: string\n if (process.platform === \"win32\") {\n result = process.env[\"LOCALAPPDATA\"] || path.join(homedir, \"AppData\", \"Local\")\n } else if (process.platform === \"darwin\") {\n result = path.join(homedir, \"Library\", \"Caches\")\n } else {\n result = process.env[\"XDG_CACHE_HOME\"] || path.join(homedir, \".cache\")\n }\n return result\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { AllPublishOptions } from "builder-util-runtime";
2
- import { DownloadUpdateOptions } from "./AppUpdater";
3
- import { BaseUpdater, InstallOptions } from "./BaseUpdater";
2
+ import { DownloadUpdateOptions } from "./AppUpdater.js";
3
+ import { BaseUpdater, InstallOptions } from "./BaseUpdater.js";
4
4
  export declare class AppImageUpdater extends BaseUpdater {
5
5
  constructor(options?: AllPublishOptions | null, app?: any);
6
6
  isUpdaterActive(): boolean;
@@ -9,3 +9,4 @@ export declare class AppImageUpdater extends BaseUpdater {
9
9
  private downloadDifferential;
10
10
  protected doInstall(options: InstallOptions): boolean;
11
11
  }
12
+ //# sourceMappingURL=AppImageUpdater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppImageUpdater.d.ts","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,sBAAsB,CAAA;AAKlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAM9D,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG;IAIlD,eAAe,IAAI,OAAO;IAYjC,gBAAgB;IAChB,SAAS,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAsBlF,oBAAoB;IAyBlC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;CA+CtD"}
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppImageUpdater = void 0;
4
- const builder_util_runtime_1 = require("builder-util-runtime");
5
- const child_process_1 = require("child_process");
6
- const fs_extra_1 = require("fs-extra");
7
- const fs_1 = require("fs");
8
- const path = require("path");
9
- const BaseUpdater_1 = require("./BaseUpdater");
10
- const FileWithEmbeddedBlockMapDifferentialDownloader_1 = require("./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader");
11
- const Provider_1 = require("./providers/Provider");
12
- const types_1 = require("./types");
13
- class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
1
+ import { newError } from "builder-util-runtime";
2
+ import { execFileSync } from "child_process";
3
+ import fsExtra from "fs-extra";
4
+ import { unlinkSync } from "fs";
5
+ import * as path from "path";
6
+ import { BaseUpdater } from "./BaseUpdater.js";
7
+ import { FileWithEmbeddedBlockMapDifferentialDownloader } from "./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js";
8
+ import { findFile } from "./providers/Provider.js";
9
+ import { DOWNLOAD_PROGRESS } from "./types.js";
10
+ export class AppImageUpdater extends BaseUpdater {
14
11
  constructor(options, app) {
15
12
  super(options, app);
16
13
  }
@@ -29,7 +26,7 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
29
26
  /*** @private */
30
27
  doDownloadUpdate(downloadUpdateOptions) {
31
28
  const provider = downloadUpdateOptions.updateInfoAndProvider.provider;
32
- const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "AppImage", ["rpm", "deb", "pacman"]);
29
+ const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "AppImage", ["rpm", "deb", "pacman"]);
33
30
  return this.executeDownload({
34
31
  fileExtension: "AppImage",
35
32
  fileInfo,
@@ -37,12 +34,12 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
37
34
  task: async (updateFile, downloadOptions) => {
38
35
  const oldFile = process.env["APPIMAGE"];
39
36
  if (oldFile == null) {
40
- throw (0, builder_util_runtime_1.newError)("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND");
37
+ throw newError("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND");
41
38
  }
42
39
  if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {
43
40
  await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
44
41
  }
45
- await (0, fs_extra_1.chmod)(updateFile, 0o755);
42
+ await fsExtra.chmod(updateFile, 0o755);
46
43
  },
47
44
  });
48
45
  }
@@ -57,10 +54,10 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
57
54
  requestHeaders: downloadUpdateOptions.requestHeaders,
58
55
  cancellationToken: downloadUpdateOptions.cancellationToken,
59
56
  };
60
- if (this.listenerCount(types_1.DOWNLOAD_PROGRESS) > 0) {
61
- downloadOptions.onProgress = it => this.emit(types_1.DOWNLOAD_PROGRESS, it);
57
+ if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {
58
+ downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it);
62
59
  }
63
- await new FileWithEmbeddedBlockMapDifferentialDownloader_1.FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download();
60
+ await new FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download();
64
61
  return false;
65
62
  }
66
63
  catch (e) {
@@ -72,13 +69,13 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
72
69
  doInstall(options) {
73
70
  const appImageFile = process.env["APPIMAGE"];
74
71
  if (appImageFile == null) {
75
- throw (0, builder_util_runtime_1.newError)("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND");
72
+ throw newError("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND");
76
73
  }
77
74
  if (!path.isAbsolute(appImageFile) || appImageFile.includes("\0")) {
78
- throw (0, builder_util_runtime_1.newError)(`APPIMAGE env is not a valid absolute path: "${appImageFile}"`, "ERR_UPDATER_OLD_FILE_NOT_FOUND");
75
+ throw newError(`APPIMAGE env is not a valid absolute path: "${appImageFile}"`, "ERR_UPDATER_OLD_FILE_NOT_FOUND");
79
76
  }
80
77
  // https://stackoverflow.com/a/1712051/1910191
81
- (0, fs_1.unlinkSync)(appImageFile);
78
+ unlinkSync(appImageFile);
82
79
  let destination;
83
80
  const existingBaseName = path.basename(appImageFile);
84
81
  const installerPath = this.installerPath;
@@ -95,7 +92,7 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
95
92
  else {
96
93
  destination = path.join(path.dirname(appImageFile), path.basename(installerPath));
97
94
  }
98
- (0, child_process_1.execFileSync)("mv", ["-f", installerPath, destination]);
95
+ execFileSync("mv", ["-f", installerPath, destination]);
99
96
  if (destination !== appImageFile) {
100
97
  this.emit("appimage-filename-updated", destination);
101
98
  }
@@ -109,10 +106,9 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
109
106
  }
110
107
  else {
111
108
  env.APPIMAGE_EXIT_AFTER_INSTALL = "true";
112
- (0, child_process_1.execFileSync)(destination, [], { env });
109
+ execFileSync(destination, [], { env });
113
110
  }
114
111
  return true;
115
112
  }
116
113
  }
117
- exports.AppImageUpdater = AppImageUpdater;
118
114
  //# sourceMappingURL=AppImageUpdater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OA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AAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACjG,kDAAkD;YAClD,WAAW,GAAG,YAAY,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAA;QACnF,CAAC;QAED,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;QACtD,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA;QACrD,CAAC;QAED,MAAM,GAAG,GAAsB;YAC7B,GAAG,OAAO,CAAC,GAAG;YACd,uBAAuB,EAAE,MAAM;SAChC,CAAA;QAED,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,mEAAmE;YACnE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAA;YACxC,YAAY,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { AllPublishOptions, newError } from \"builder-util-runtime\"\nimport { execFileSync } from \"child_process\"\nimport fsExtra from \"fs-extra\"\nimport { unlinkSync } from \"fs\"\nimport * as path from \"path\"\nimport { DownloadUpdateOptions } from \"./AppUpdater.js\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater.js\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader.js\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js\"\nimport { findFile, Provider } from \"./providers/Provider.js\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./types.js\"\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 fsExtra.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 if (!path.isAbsolute(appImageFile) || appImageFile.includes(\"\\0\")) {\n throw newError(`APPIMAGE env is not a valid absolute path: \"${appImageFile}\"`, \"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"]}
@@ -2,15 +2,15 @@ import { AllPublishOptions, CancellationToken, PublishConfiguration, UpdateInfo,
2
2
  import { OutgoingHttpHeaders } from "http";
3
3
  import { Lazy } from "lazy-val";
4
4
  import { SemVer } from "semver";
5
- import { AppAdapter } from "./AppAdapter";
6
- import { DownloadedUpdateHelper } from "./DownloadedUpdateHelper";
7
- import { LoginCallback } from "./electronHttpExecutor";
8
- import { Provider, ProviderPlatform } from "./providers/Provider";
5
+ import { AppAdapter } from "./AppAdapter.js";
6
+ import { DownloadedUpdateHelper } from "./DownloadedUpdateHelper.js";
7
+ import { LoginCallback } from "./electronHttpExecutor.js";
8
+ import { Provider, ProviderPlatform } from "./providers/Provider.js";
9
9
  import type { TypedEmitter } from "tiny-typed-emitter";
10
- import Session = Electron.Session;
10
+ type Session = Electron.Session;
11
11
  import type { AuthInfo } from "electron";
12
- import { Logger, ResolvedUpdateFileInfo, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from "./types";
13
- import { VerifyUpdateSupport } from "./main";
12
+ import { Logger, ResolvedUpdateFileInfo, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from "./types.js";
13
+ import { VerifyUpdateSupport } from "./index.js";
14
14
  export type AppUpdaterEvents = {
15
15
  error: (error: Error, message?: string) => void;
16
16
  login: (info: AuthInfo, callback: LoginCallback) => void;
@@ -239,3 +239,4 @@ export interface TestOnlyUpdaterOptions {
239
239
  isUseDifferentialDownload?: boolean;
240
240
  }
241
241
  export {};
242
+ //# sourceMappingURL=AppUpdater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppUpdater.d.ts","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,EAEjB,oBAAoB,EACpB,UAAU,EAEV,eAAe,EAEf,YAAY,EAGb,MAAM,sBAAsB,CAAA;AAK7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAE1C,OAAO,EAAE,IAAI,EAAE,M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IAAI,CAAC,OAAO,CAAC,EAAE,GAAG;IAKlB,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG;IAKlB,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG;CAGpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAA;IACzC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAA;IACrD,QAAQ,CAAC,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAE9J,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CAC/D;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,eAAe;AACf,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,gBAAgB,CAAA;IAE1B,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC"}
@@ -1,24 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoOpLogger = exports.AppUpdater = void 0;
4
- const builder_util_runtime_1 = require("builder-util-runtime");
5
- const crypto_1 = require("crypto");
6
- const os_1 = require("os");
7
- const events_1 = require("events");
8
- const fs_extra_1 = require("fs-extra");
9
- const js_yaml_1 = require("js-yaml");
10
- const lazy_val_1 = require("lazy-val");
11
- const path = require("path");
12
- const semver_1 = require("semver");
13
- const DownloadedUpdateHelper_1 = require("./DownloadedUpdateHelper");
14
- const ElectronAppAdapter_1 = require("./ElectronAppAdapter");
15
- const electronHttpExecutor_1 = require("./electronHttpExecutor");
16
- const GenericProvider_1 = require("./providers/GenericProvider");
17
- const providerFactory_1 = require("./providerFactory");
18
- const zlib_1 = require("zlib");
19
- const GenericDifferentialDownloader_1 = require("./differentialDownloader/GenericDifferentialDownloader");
20
- const types_1 = require("./types");
21
- class AppUpdater extends events_1.EventEmitter {
1
+ import { createRequire } from "node:module";
2
+ import { asArray, CancellationToken, newError, UUID, CancellationError, retry, } from "builder-util-runtime";
3
+ import { randomBytes } from "crypto";
4
+ import { release } from "os";
5
+ import { EventEmitter } from "events";
6
+ import fsExtra from "fs-extra";
7
+ import { load } from "js-yaml";
8
+ import { Lazy } from "lazy-val";
9
+ import * as path from "path";
10
+ import { eq as isVersionsEqual, gt as isVersionGreaterThan, lt as isVersionLessThan, parse as parseVersion, prerelease as getVersionPreleaseComponents } from "semver";
11
+ import { createTempUpdateFile, DownloadedUpdateHelper } from "./DownloadedUpdateHelper.js";
12
+ import { ElectronAppAdapter } from "./ElectronAppAdapter.js";
13
+ import { ElectronHttpExecutor, getNetSession } from "./electronHttpExecutor.js";
14
+ import { GenericProvider } from "./providers/GenericProvider.js";
15
+ import { createClient, isUrlProbablySupportMultiRangeRequests } from "./providerFactory.js";
16
+ import { gunzipSync, gzipSync } from "zlib";
17
+ import { GenericDifferentialDownloader } from "./differentialDownloader/GenericDifferentialDownloader.js";
18
+ import { DOWNLOAD_PROGRESS, UPDATE_DOWNLOADED, UpdaterSignal } from "./types.js";
19
+ const require = createRequire(import.meta.url);
20
+ export class AppUpdater extends EventEmitter {
22
21
  /**
23
22
  * Get the update channel. Doesn't return `channel` from the update configuration, only if was previously set.
24
23
  */
@@ -34,10 +33,10 @@ class AppUpdater extends events_1.EventEmitter {
34
33
  if (this._channel != null) {
35
34
  // noinspection SuspiciousTypeOfGuard
36
35
  if (typeof value !== "string") {
37
- throw (0, builder_util_runtime_1.newError)(`Channel must be a string, but got: ${value}`, "ERR_UPDATER_INVALID_CHANNEL");
36
+ throw newError(`Channel must be a string, but got: ${value}`, "ERR_UPDATER_INVALID_CHANNEL");
38
37
  }
39
38
  else if (value.length === 0) {
40
- throw (0, builder_util_runtime_1.newError)(`Channel must be not an empty string`, "ERR_UPDATER_INVALID_CHANNEL");
39
+ throw newError(`Channel must be not an empty string`, "ERR_UPDATER_INVALID_CHANNEL");
41
40
  }
42
41
  }
43
42
  this._channel = value;
@@ -53,7 +52,7 @@ class AppUpdater extends events_1.EventEmitter {
53
52
  }
54
53
  // noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
55
54
  get netSession() {
56
- return (0, electronHttpExecutor_1.getNetSession)();
55
+ return getNetSession();
57
56
  }
58
57
  /**
59
58
  * The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.
@@ -73,7 +72,7 @@ class AppUpdater extends events_1.EventEmitter {
73
72
  set updateConfigPath(value) {
74
73
  this.clientPromise = null;
75
74
  this._appUpdateConfigPath = value;
76
- this.configOnDisk = new lazy_val_1.Lazy(() => this.loadUpdateConfig());
75
+ this.configOnDisk = new Lazy(() => this.loadUpdateConfig());
77
76
  }
78
77
  /**
79
78
  * Allows developer to override default logic for determining if an update is supported.
@@ -181,15 +180,15 @@ class AppUpdater extends events_1.EventEmitter {
181
180
  /**
182
181
  * For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})`
183
182
  */
184
- this.signals = new types_1.UpdaterSignal(this);
183
+ this.signals = new UpdaterSignal(this);
185
184
  this._appUpdateConfigPath = null;
186
185
  this._isUpdateSupported = updateInfo => this.checkIfUpdateSupported(updateInfo);
187
186
  this._isUserWithinRollout = updateInfo => this.isStagingMatch(updateInfo);
188
187
  this.clientPromise = null;
189
- this.stagingUserIdPromise = new lazy_val_1.Lazy(() => this.getOrCreateStagingUserId());
188
+ this.stagingUserIdPromise = new Lazy(() => this.getOrCreateStagingUserId());
190
189
  // public, allow to read old config for anyone
191
190
  /** @internal */
192
- this.configOnDisk = new lazy_val_1.Lazy(() => this.loadUpdateConfig());
191
+ this.configOnDisk = new Lazy(() => this.loadUpdateConfig());
193
192
  this.checkForUpdatesPromise = null;
194
193
  this.downloadPromise = null;
195
194
  this.updateInfoAndProvider = null;
@@ -202,17 +201,17 @@ class AppUpdater extends events_1.EventEmitter {
202
201
  this._logger.error(`Error: ${error.stack || error.message}`);
203
202
  });
204
203
  if (app == null) {
205
- this.app = new ElectronAppAdapter_1.ElectronAppAdapter();
206
- this.httpExecutor = new electronHttpExecutor_1.ElectronHttpExecutor((authInfo, callback) => this.emit("login", authInfo, callback));
204
+ this.app = new ElectronAppAdapter();
205
+ this.httpExecutor = new ElectronHttpExecutor((authInfo, callback) => this.emit("login", authInfo, callback));
207
206
  }
208
207
  else {
209
208
  this.app = app;
210
209
  this.httpExecutor = null;
211
210
  }
212
211
  const currentVersionString = this.app.version;
213
- const currentVersion = (0, semver_1.parse)(currentVersionString);
212
+ const currentVersion = parseVersion(currentVersionString);
214
213
  if (currentVersion == null) {
215
- throw (0, builder_util_runtime_1.newError)(`App version is not a valid semver version: "${currentVersionString}"`, "ERR_UPDATER_INVALID_VERSION");
214
+ throw newError(`App version is not a valid semver version: "${currentVersionString}"`, "ERR_UPDATER_INVALID_VERSION");
216
215
  }
217
216
  this.currentVersion = currentVersion;
218
217
  this.allowPrerelease = hasPrereleaseComponents(currentVersion);
@@ -236,13 +235,13 @@ class AppUpdater extends events_1.EventEmitter {
236
235
  // https://github.com/electron-userland/electron-builder/issues/1105
237
236
  let provider;
238
237
  if (typeof options === "string") {
239
- provider = new GenericProvider_1.GenericProvider({ provider: "generic", url: options }, this, {
238
+ provider = new GenericProvider({ provider: "generic", url: options }, this, {
240
239
  ...runtimeOptions,
241
- isUseMultipleRangeRequest: (0, providerFactory_1.isUrlProbablySupportMultiRangeRequests)(options),
240
+ isUseMultipleRangeRequest: isUrlProbablySupportMultiRangeRequests(options),
242
241
  });
243
242
  }
244
243
  else {
245
- provider = (0, providerFactory_1.createClient)(options, this, runtimeOptions);
244
+ provider = createClient(options, this, runtimeOptions);
246
245
  }
247
246
  this.clientPromise = Promise.resolve(provider);
248
247
  }
@@ -285,7 +284,7 @@ class AppUpdater extends events_1.EventEmitter {
285
284
  // noinspection JSUnusedGlobalSymbols
286
285
  checkForUpdatesAndNotify(downloadNotification) {
287
286
  return this.checkForUpdates().then(it => {
288
- if (!(it === null || it === void 0 ? void 0 : it.downloadPromise)) {
287
+ if (!it?.downloadPromise) {
289
288
  if (this._logger.debug != null) {
290
289
  this._logger.debug("checkForUpdatesAndNotify called, downloadPromise is null");
291
290
  }
@@ -325,7 +324,7 @@ class AppUpdater extends events_1.EventEmitter {
325
324
  // convert from user 0-100 to internal 0-1
326
325
  stagingPercentage = stagingPercentage / 100;
327
326
  const stagingUserId = await this.stagingUserIdPromise.value;
328
- const val = builder_util_runtime_1.UUID.parse(stagingUserId).readUInt32BE(12);
327
+ const val = UUID.parse(stagingUserId).readUInt32BE(12);
329
328
  const percentage = val / 0xffffffff;
330
329
  this._logger.info(`Staging percentage: ${stagingPercentage}, percentage: ${percentage}, user id: ${stagingUserId}`);
331
330
  return percentage < stagingPercentage;
@@ -337,12 +336,12 @@ class AppUpdater extends events_1.EventEmitter {
337
336
  return headers;
338
337
  }
339
338
  async isUpdateAvailable(updateInfo) {
340
- const latestVersion = (0, semver_1.parse)(updateInfo.version);
339
+ const latestVersion = parseVersion(updateInfo.version);
341
340
  if (latestVersion == null) {
342
- throw (0, builder_util_runtime_1.newError)(`This file could not be downloaded, or the latest version (from update server) does not have a valid semver version: "${updateInfo.version}"`, "ERR_UPDATER_INVALID_VERSION");
341
+ throw newError(`This file could not be downloaded, or the latest version (from update server) does not have a valid semver version: "${updateInfo.version}"`, "ERR_UPDATER_INVALID_VERSION");
343
342
  }
344
343
  const currentVersion = this.currentVersion;
345
- if ((0, semver_1.eq)(latestVersion, currentVersion)) {
344
+ if (isVersionsEqual(latestVersion, currentVersion)) {
346
345
  return false;
347
346
  }
348
347
  if (!(await Promise.resolve(this.isUpdateSupported(updateInfo)))) {
@@ -354,19 +353,19 @@ class AppUpdater extends events_1.EventEmitter {
354
353
  }
355
354
  // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405033227
356
355
  // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405030797
357
- const isLatestVersionNewer = (0, semver_1.gt)(latestVersion, currentVersion);
358
- const isLatestVersionOlder = (0, semver_1.lt)(latestVersion, currentVersion);
356
+ const isLatestVersionNewer = isVersionGreaterThan(latestVersion, currentVersion);
357
+ const isLatestVersionOlder = isVersionLessThan(latestVersion, currentVersion);
359
358
  if (isLatestVersionNewer) {
360
359
  return true;
361
360
  }
362
361
  return this.allowDowngrade && isLatestVersionOlder;
363
362
  }
364
363
  checkIfUpdateSupported(updateInfo) {
365
- const minimumSystemVersion = updateInfo === null || updateInfo === void 0 ? void 0 : updateInfo.minimumSystemVersion;
366
- const currentOSVersion = (0, os_1.release)();
364
+ const minimumSystemVersion = updateInfo?.minimumSystemVersion;
365
+ const currentOSVersion = release();
367
366
  if (minimumSystemVersion) {
368
367
  try {
369
- if ((0, semver_1.lt)(currentOSVersion, minimumSystemVersion)) {
368
+ if (isVersionLessThan(currentOSVersion, minimumSystemVersion)) {
370
369
  this._logger.info(`Current OS version ${currentOSVersion} is less than the minimum OS version required ${minimumSystemVersion} for version ${currentOSVersion}`);
371
370
  return false;
372
371
  }
@@ -380,7 +379,7 @@ class AppUpdater extends events_1.EventEmitter {
380
379
  async getUpdateInfoAndProvider() {
381
380
  await this.app.whenReady();
382
381
  if (this.clientPromise == null) {
383
- this.clientPromise = this.configOnDisk.value.then(it => (0, providerFactory_1.createClient)(it, this, this.createProviderRuntimeOptions()));
382
+ this.clientPromise = this.configOnDisk.value.then(it => createClient(it, this, this.createProviderRuntimeOptions()));
384
383
  }
385
384
  const client = await this.clientPromise;
386
385
  const stagingUserId = await this.stagingUserIdPromise.value;
@@ -412,7 +411,7 @@ class AppUpdater extends events_1.EventEmitter {
412
411
  }
413
412
  this.updateInfoAndProvider = result;
414
413
  this.onUpdateAvailable(updateInfo);
415
- const cancellationToken = new builder_util_runtime_1.CancellationToken();
414
+ const cancellationToken = new CancellationToken();
416
415
  //noinspection ES6MissingAwait
417
416
  return {
418
417
  isUpdateAvailable: true,
@@ -423,7 +422,7 @@ class AppUpdater extends events_1.EventEmitter {
423
422
  };
424
423
  }
425
424
  onUpdateAvailable(updateInfo) {
426
- this._logger.info(`Found version ${updateInfo.version} (url: ${(0, builder_util_runtime_1.asArray)(updateInfo.files)
425
+ this._logger.info(`Found version ${updateInfo.version} (url: ${asArray(updateInfo.files)
427
426
  .map(it => it.url)
428
427
  .join(", ")})`);
429
428
  this.emit("update-available", updateInfo);
@@ -432,7 +431,7 @@ class AppUpdater extends events_1.EventEmitter {
432
431
  * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.
433
432
  * @returns {Promise<Array<string>>} Paths to downloaded files.
434
433
  */
435
- downloadUpdate(cancellationToken = new builder_util_runtime_1.CancellationToken()) {
434
+ downloadUpdate(cancellationToken = new CancellationToken()) {
436
435
  const updateInfoAndProvider = this.updateInfoAndProvider;
437
436
  if (updateInfoAndProvider == null) {
438
437
  const error = new Error("Please check update first");
@@ -443,12 +442,12 @@ class AppUpdater extends events_1.EventEmitter {
443
442
  this._logger.info("Downloading update (already in progress)");
444
443
  return this.downloadPromise;
445
444
  }
446
- this._logger.info(`Downloading update from ${(0, builder_util_runtime_1.asArray)(updateInfoAndProvider.info.files)
445
+ this._logger.info(`Downloading update from ${asArray(updateInfoAndProvider.info.files)
447
446
  .map(it => it.url)
448
447
  .join(", ")}`);
449
448
  const errorHandler = (e) => {
450
449
  // https://github.com/electron-userland/electron-builder/issues/1150#issuecomment-436891159
451
- if (!(e instanceof builder_util_runtime_1.CancellationError)) {
450
+ if (!(e instanceof CancellationError)) {
452
451
  try {
453
452
  this.dispatchError(e);
454
453
  }
@@ -477,13 +476,13 @@ class AppUpdater extends events_1.EventEmitter {
477
476
  this.emit("error", e, (e.stack || e).toString());
478
477
  }
479
478
  dispatchUpdateDownloaded(event) {
480
- this.emit(types_1.UPDATE_DOWNLOADED, event);
479
+ this.emit(UPDATE_DOWNLOADED, event);
481
480
  }
482
481
  async loadUpdateConfig() {
483
482
  if (this._appUpdateConfigPath == null) {
484
483
  this._appUpdateConfigPath = this.app.appUpdateConfigPath;
485
484
  }
486
- return (0, js_yaml_1.load)(await (0, fs_extra_1.readFile)(this._appUpdateConfigPath, "utf-8"));
485
+ return load(await fsExtra.readFile(this._appUpdateConfigPath, "utf-8"));
487
486
  }
488
487
  computeRequestHeaders(provider) {
489
488
  const fileExtraDownloadHeaders = provider.fileExtraDownloadHeaders;
@@ -501,8 +500,8 @@ class AppUpdater extends events_1.EventEmitter {
501
500
  async getOrCreateStagingUserId() {
502
501
  const file = path.join(this.app.userDataPath, ".updaterId");
503
502
  try {
504
- const id = await (0, fs_extra_1.readFile)(file, "utf-8");
505
- if (builder_util_runtime_1.UUID.check(id)) {
503
+ const id = await fsExtra.readFile(file, "utf-8");
504
+ if (UUID.check(id)) {
506
505
  return id;
507
506
  }
508
507
  else {
@@ -514,10 +513,10 @@ class AppUpdater extends events_1.EventEmitter {
514
513
  this._logger.warn(`Couldn't read staging user ID, creating a blank one: ${e}`);
515
514
  }
516
515
  }
517
- const id = builder_util_runtime_1.UUID.v5((0, crypto_1.randomBytes)(4096), builder_util_runtime_1.UUID.OID);
516
+ const id = UUID.v5(randomBytes(4096), UUID.OID);
518
517
  this._logger.info(`Generated new staging user ID: ${id}`);
519
518
  try {
520
- await (0, fs_extra_1.outputFile)(file, id);
519
+ await fsExtra.outputFile(file, id);
521
520
  }
522
521
  catch (e) {
523
522
  this._logger.warn(`Couldn't write out staging user ID: ${e}`);
@@ -551,7 +550,7 @@ class AppUpdater extends events_1.EventEmitter {
551
550
  if (logger.debug != null) {
552
551
  logger.debug(`updater cache dir: ${cacheDir}`);
553
552
  }
554
- result = new DownloadedUpdateHelper_1.DownloadedUpdateHelper(cacheDir);
553
+ result = new DownloadedUpdateHelper(cacheDir);
555
554
  this.downloadedUpdateHelper = result;
556
555
  }
557
556
  return result;
@@ -564,8 +563,8 @@ class AppUpdater extends events_1.EventEmitter {
564
563
  sha2: fileInfo.info.sha2,
565
564
  sha512: fileInfo.info.sha512,
566
565
  };
567
- if (this.listenerCount(types_1.DOWNLOAD_PROGRESS) > 0) {
568
- downloadOptions.onProgress = it => this.emit(types_1.DOWNLOAD_PROGRESS, it);
566
+ if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {
567
+ downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it);
569
568
  }
570
569
  const updateInfo = taskOptions.downloadUpdateOptions.updateInfoAndProvider.info;
571
570
  const version = updateInfo.version;
@@ -584,7 +583,7 @@ class AppUpdater extends events_1.EventEmitter {
584
583
  }
585
584
  const downloadedUpdateHelper = await this.getOrCreateDownloadHelper();
586
585
  const cacheDir = downloadedUpdateHelper.cacheDirForPendingUpdate;
587
- await (0, fs_extra_1.mkdir)(cacheDir, { recursive: true });
586
+ await fsExtra.mkdir(cacheDir, { recursive: true });
588
587
  const updateFileName = getCacheUpdateFileName();
589
588
  let updateFile = path.join(cacheDir, updateFileName);
590
589
  const packageFile = packageInfo == null ? null : path.join(cacheDir, `package-${version}${path.extname(packageInfo.path) || ".7z"}`);
@@ -595,8 +594,8 @@ class AppUpdater extends events_1.EventEmitter {
595
594
  downloadedFile: updateFile,
596
595
  });
597
596
  const currentBlockMapFile = path.join(cacheDir, "current.blockmap");
598
- if (await (0, fs_extra_1.pathExists)(currentBlockMapFile)) {
599
- await (0, fs_extra_1.copyFile)(currentBlockMapFile, path.join(downloadedUpdateHelper.cacheDir, "current.blockmap"));
597
+ if (await fsExtra.pathExists(currentBlockMapFile)) {
598
+ await fsExtra.copyFile(currentBlockMapFile, path.join(downloadedUpdateHelper.cacheDir, "current.blockmap"));
600
599
  }
601
600
  return packageFile == null ? [updateFile] : [updateFile, packageFile];
602
601
  };
@@ -610,14 +609,14 @@ class AppUpdater extends events_1.EventEmitter {
610
609
  await downloadedUpdateHelper.clear().catch(() => {
611
610
  // ignore
612
611
  });
613
- return await (0, fs_extra_1.unlink)(updateFile).catch(() => {
612
+ return await fsExtra.unlink(updateFile).catch(() => {
614
613
  // ignore
615
614
  });
616
615
  };
617
- const tempUpdateFile = await (0, DownloadedUpdateHelper_1.createTempUpdateFile)(`temp-${updateFileName}`, cacheDir, log);
616
+ const tempUpdateFile = await createTempUpdateFile(`temp-${updateFileName}`, cacheDir, log);
618
617
  try {
619
618
  await taskOptions.task(tempUpdateFile, downloadOptions, packageFile, removeFileIfAny);
620
- await (0, builder_util_runtime_1.retry)(() => (0, fs_extra_1.rename)(tempUpdateFile, updateFile), {
619
+ await retry(() => fsExtra.rename(tempUpdateFile, updateFile), {
621
620
  retries: 60,
622
621
  interval: 500,
623
622
  shouldRetry: (error) => {
@@ -631,7 +630,7 @@ class AppUpdater extends events_1.EventEmitter {
631
630
  }
632
631
  catch (e) {
633
632
  await removeFileIfAny();
634
- if (e instanceof builder_util_runtime_1.CancellationError) {
633
+ if (e instanceof CancellationError) {
635
634
  log.info("cancelled");
636
635
  this.emit("update-cancelled", updateInfo);
637
636
  }
@@ -657,7 +656,7 @@ class AppUpdater extends events_1.EventEmitter {
657
656
  throw new Error(`Blockmap "${url.href}" is empty`);
658
657
  }
659
658
  try {
660
- return JSON.parse((0, zlib_1.gunzipSync)(data).toString());
659
+ return JSON.parse(gunzipSync(data).toString());
661
660
  }
662
661
  catch (e) {
663
662
  throw new Error(`Cannot parse blockmap "${url.href}", error: ${e}`);
@@ -672,18 +671,18 @@ class AppUpdater extends events_1.EventEmitter {
672
671
  requestHeaders: downloadUpdateOptions.requestHeaders,
673
672
  cancellationToken: downloadUpdateOptions.cancellationToken,
674
673
  };
675
- if (this.listenerCount(types_1.DOWNLOAD_PROGRESS) > 0) {
676
- downloadOptions.onProgress = it => this.emit(types_1.DOWNLOAD_PROGRESS, it);
674
+ if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {
675
+ downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it);
677
676
  }
678
677
  const saveBlockMapToCacheDir = async (blockMapData, cacheDir) => {
679
678
  const blockMapFile = path.join(cacheDir, "current.blockmap");
680
- await (0, fs_extra_1.outputFile)(blockMapFile, (0, zlib_1.gzipSync)(JSON.stringify(blockMapData)));
679
+ await fsExtra.outputFile(blockMapFile, gzipSync(JSON.stringify(blockMapData)));
681
680
  };
682
681
  const getBlockMapFromCacheDir = async (cacheDir) => {
683
682
  const blockMapFile = path.join(cacheDir, "current.blockmap");
684
683
  try {
685
- if (await (0, fs_extra_1.pathExists)(blockMapFile)) {
686
- return JSON.parse((0, zlib_1.gunzipSync)(await (0, fs_extra_1.readFile)(blockMapFile)).toString());
684
+ if (await fsExtra.pathExists(blockMapFile)) {
685
+ return JSON.parse(gunzipSync(await fsExtra.readFile(blockMapFile)).toString());
687
686
  }
688
687
  }
689
688
  catch (e) {
@@ -698,7 +697,7 @@ class AppUpdater extends events_1.EventEmitter {
698
697
  if (oldBlockMapData == null) {
699
698
  oldBlockMapData = await downloadBlockMap(blockmapFileUrls[0]);
700
699
  }
701
- await new GenericDifferentialDownloader_1.GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(oldBlockMapData, newBlockMapData);
700
+ await new GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(oldBlockMapData, newBlockMapData);
702
701
  return false;
703
702
  }
704
703
  catch (e) {
@@ -711,13 +710,12 @@ class AppUpdater extends events_1.EventEmitter {
711
710
  }
712
711
  }
713
712
  }
714
- exports.AppUpdater = AppUpdater;
715
713
  function hasPrereleaseComponents(version) {
716
- const versionPrereleaseComponent = (0, semver_1.prerelease)(version);
714
+ const versionPrereleaseComponent = getVersionPreleaseComponents(version);
717
715
  return versionPrereleaseComponent != null && versionPrereleaseComponent.length > 0;
718
716
  }
719
717
  /** @private */
720
- class NoOpLogger {
718
+ export class NoOpLogger {
721
719
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
722
720
  info(message) {
723
721
  // ignore
@@ -731,5 +729,4 @@ class NoOpLogger {
731
729
  // ignore
732
730
  }
733
731
  }
734
- exports.NoOpLogger = NoOpLogger;
735
732
  //# sourceMappingURL=AppUpdater.js.map