electron-updater 4.5.1 → 4.6.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  ## 4.3.0
2
2
 
3
+ ## 4.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#6390](https://github.com/electron-userland/electron-builder/pull/6390) [`a5e8073e`](https://github.com/electron-userland/electron-builder/commit/a5e8073e21b1ff791905cdb4ab011a724533d8c1) Thanks [@Nokel81](https://github.com/Nokel81)! - Fix updating only on demand not working on macOS
8
+
9
+ - Updated dependencies [[`66ca625f`](https://github.com/electron-userland/electron-builder/commit/66ca625f892329fd7bedf52fddc6659ec83b7cd3)]:
10
+ - builder-util-runtime@8.9.2
11
+
12
+ ## 4.6.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`54ee4e72`](https://github.com/electron-userland/electron-builder/commit/54ee4e72c5db859b9a00104179786567a0e977ff)]:
17
+ - builder-util-runtime@8.9.1
18
+
19
+ ## 4.6.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#6228](https://github.com/electron-userland/electron-builder/pull/6228) [`a9453216`](https://github.com/electron-userland/electron-builder/commit/a94532164709a545c0f6551fdc336dbc5377bda8) Thanks [@mmaietta](https://github.com/mmaietta)! - feat: adding Bitbucket publisher and autoupdater
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [[`a9453216`](https://github.com/electron-userland/electron-builder/commit/a94532164709a545c0f6551fdc336dbc5377bda8)]:
28
+ - builder-util-runtime@8.9.0
29
+
30
+ ## 4.5.2
31
+
32
+ ### Patch Changes
33
+
34
+ - [#6212](https://github.com/electron-userland/electron-builder/pull/6212) [`0c21cd69`](https://github.com/electron-userland/electron-builder/commit/0c21cd69663a7eebe0687eaba9eea851cc2fea9e) Thanks [@johnnyopao](https://github.com/johnnyopao)! - Fix upgrade flows on intel mac when both x64 and arm64 versions published
35
+
3
36
  ## 4.5.1
4
37
 
5
38
  ### Patch Changes
package/out/MacUpdater.js CHANGED
@@ -31,7 +31,7 @@ class MacUpdater extends AppUpdater_1.AppUpdater {
31
31
  const log = this._logger;
32
32
  // detect if we are running inside Rosetta emulation
33
33
  const sysctlRosettaInfoKey = "sysctl.proc_translated";
34
- let isRosetta;
34
+ let isRosetta = false;
35
35
  try {
36
36
  this.debug("Checking for macOS Rosetta environment");
37
37
  const result = child_process_1.execFileSync("sysctl", [sysctlRosettaInfoKey], { encoding: "utf8" });
@@ -41,10 +41,14 @@ class MacUpdater extends AppUpdater_1.AppUpdater {
41
41
  catch (e) {
42
42
  log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`);
43
43
  }
44
+ const isArm64Mac = process.arch === "arm64" || isRosetta;
44
45
  // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524
45
46
  const isArm64 = (file) => { var _a; return file.url.pathname.includes("arm64") || ((_a = file.info.url) === null || _a === void 0 ? void 0 : _a.includes("arm64")); };
46
- if (files.some(isArm64)) {
47
- files = files.filter(file => (process.arch === "arm64" || isRosetta) === isArm64(file));
47
+ if (isArm64Mac && files.some(isArm64)) {
48
+ files = files.filter(file => isArm64Mac === isArm64(file));
49
+ }
50
+ else {
51
+ files = files.filter(file => !isArm64(file));
48
52
  }
49
53
  const zipFileInfo = Provider_1.findFile(files, "zip", ["pkg", "dmg"]);
50
54
  if (zipFileInfo == null) {
@@ -152,10 +156,17 @@ class MacUpdater extends AppUpdater_1.AppUpdater {
152
156
  this.nativeUpdater.quitAndInstall();
153
157
  }
154
158
  else {
155
- // quit and install as soon as Squirrel get the update
159
+ // Quit and install as soon as Squirrel get the update
156
160
  this.nativeUpdater.on("update-downloaded", () => {
157
161
  this.nativeUpdater.quitAndInstall();
158
162
  });
163
+ if (!this.autoInstallOnAppQuit) {
164
+ /**
165
+ * If this was not `true` previously then MacUpdater.doDownloadUpdate()
166
+ * would not actually initiate the downloading by electron's autoUpdater
167
+ */
168
+ this.nativeUpdater.checkForUpdates();
169
+ }
159
170
  }
160
171
  }
161
172
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAA+B;AAC/B,2BAAqC;AACrC,+BAAoE;AAGpE,6CAAgE;AAEhE,mDAA+C;AAE/C,iDAA4C;AAE5C,MAAa,UAAW,SAAQ,uBAAU;IAKxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QALJ,kBAAa,GAAgB,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAA;QAErE,6BAAwB,GAAG,KAAK,CAAA;QAKtC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC9C,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,OAAe;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;YAC9B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;SAC5B;IACH,CAAC;IAES,KAAK,CAAC,gBAAgB,CAAC,qBAA4C;QAC3E,IAAI,KAAK,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QAE/H,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAA;QAExB,oDAAoD;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A;gBAEF,uEAAuE;gBACvE,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAA;gBAEpC,IAAI,IAAI,CAAC,oBAAoB,EAAE;oBAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;oBACxC,sEAAsE;oBACtE,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;iBACrC;qBAAM;oBACL,OAAO,CAAC,EAAE,CAAC,CAAA;iBACZ;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,wBAAwB,EAAE;YACjC,4DAA4D;YAC5D,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;SACpC;aAAM;YACL,sDAAsD;YACtD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;gBAC9C,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;YACrC,CAAC,CAAC,CAAA;SACH;IACH,CAAC;CACF;AAvKD,gCAuKC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { stat } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport { createServer, IncomingMessage, ServerResponse } from \"http\"\nimport { AddressInfo } from \"net\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo, UpdateDownloadedEvent } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\nimport { execFileSync } from \"child_process\"\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n })\n }\n\n private debug(message: string): void {\n if (this._logger.debug != null) {\n this._logger.debug(message)\n }\n }\n\n protected async doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n const log = this._logger\n\n // detect if we are running inside Rosetta emulation\n const sysctlRosettaInfoKey = \"sysctl.proc_translated\"\n let isRosetta: boolean\n try {\n this.debug(\"Checking for macOS Rosetta environment\")\n const result = execFileSync(\"sysctl\", [sysctlRosettaInfoKey], { encoding: \"utf8\" })\n isRosetta = result.includes(`${sysctlRosettaInfoKey}: 1`)\n log.info(`Checked for macOS Rosetta environment (isRosetta=${isRosetta})`)\n } catch (e) {\n log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`)\n }\n\n // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\") || file.info.url?.includes(\"arm64\")\n if (files.some(isArm64)) {\n files = files.filter(file => (process.arch === \"arm64\" || isRosetta) === isArm64(file))\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: (destinationFile, downloadOptions) => {\n return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n },\n done: event => this.updateDownloaded(zipFileInfo, event),\n })\n }\n\n private async updateDownloaded(zipFileInfo: ResolvedUpdateFileInfo, event: UpdateDownloadedEvent): Promise<Array<string>> {\n const downloadedFile = event.downloadedFile\n const updateFileSize = zipFileInfo.info.size ?? (await stat(downloadedFile)).size\n\n const log = this._logger\n const logContext = `fileToProxy=${zipFileInfo.url.href}`\n this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`)\n const server = createServer()\n this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`)\n server.on(\"close\", () => {\n log.info(`Proxy server for native Squirrel.Mac is closed (${logContext})`)\n })\n\n // must be called after server is listening, otherwise address is null\n function getServerUrl(): string {\n const address = server.address() as AddressInfo\n return `http://127.0.0.1:${address.port}`\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n // insecure random is ok\n const fileUrl = `/${Date.now().toString(16)}-${Math.floor(Math.random() * 9999).toString(16)}.zip`\n server.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n log.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n const data = Buffer.from(`{ \"url\": \"${getServerUrl()}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n log.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n log.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n try {\n setImmediate(() => server.close())\n } finally {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e) {\n log.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n\n this.debug(`Proxy server for native Squirrel.Mac is starting to listen (${logContext})`)\n server.listen(0, \"127.0.0.1\", () => {\n this.debug(`Proxy server for native Squirrel.Mac is listening (address=${getServerUrl()}, ${logContext})`)\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(),\n headers: { \"Cache-Control\": \"no-cache\" },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // update already fetched by Squirrel, it's ready to install\n this.nativeUpdater.quitAndInstall()\n } else {\n // quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.nativeUpdater.quitAndInstall()\n })\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAA+B;AAC/B,2BAAqC;AACrC,+BAAoE;AAGpE,6CAAgE;AAEhE,mDAA+C;AAE/C,iDAA4C;AAE5C,MAAa,UAAW,SAAQ,uBAAU;IAKxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QALJ,kBAAa,GAAgB,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAA;QAErE,6BAAwB,GAAG,KAAK,CAAA;QAKtC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC9C,IAAI,CAAC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,cAAc,EAAE,CAAA;YACrC,CAAC,CAAC,CAAA;YAEF,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;gBAC9B;;;mBAGG;gBACH,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;aACrC;SACF;IACH,CAAC;CACF;AApLD,gCAoLC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { stat } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport { createServer, IncomingMessage, ServerResponse } from \"http\"\nimport { AddressInfo } from \"net\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo, UpdateDownloadedEvent } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\nimport { execFileSync } from \"child_process\"\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n })\n }\n\n private debug(message: string): void {\n if (this._logger.debug != null) {\n this._logger.debug(message)\n }\n }\n\n protected async doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n const log = this._logger\n\n // detect if we are running inside Rosetta emulation\n const sysctlRosettaInfoKey = \"sysctl.proc_translated\"\n let isRosetta = false\n try {\n this.debug(\"Checking for macOS Rosetta environment\")\n const result = execFileSync(\"sysctl\", [sysctlRosettaInfoKey], { encoding: \"utf8\" })\n isRosetta = result.includes(`${sysctlRosettaInfoKey}: 1`)\n log.info(`Checked for macOS Rosetta environment (isRosetta=${isRosetta})`)\n } catch (e) {\n log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`)\n }\n\n const isArm64Mac = process.arch === \"arm64\" || isRosetta\n\n // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\") || file.info.url?.includes(\"arm64\")\n if (isArm64Mac && files.some(isArm64)) {\n files = files.filter(file => isArm64Mac === isArm64(file))\n } else {\n files = files.filter(file => !isArm64(file))\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: (destinationFile, downloadOptions) => {\n return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n },\n done: event => this.updateDownloaded(zipFileInfo, event),\n })\n }\n\n private async updateDownloaded(zipFileInfo: ResolvedUpdateFileInfo, event: UpdateDownloadedEvent): Promise<Array<string>> {\n const downloadedFile = event.downloadedFile\n const updateFileSize = zipFileInfo.info.size ?? (await stat(downloadedFile)).size\n\n const log = this._logger\n const logContext = `fileToProxy=${zipFileInfo.url.href}`\n this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`)\n const server = createServer()\n this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`)\n server.on(\"close\", () => {\n log.info(`Proxy server for native Squirrel.Mac is closed (${logContext})`)\n })\n\n // must be called after server is listening, otherwise address is null\n function getServerUrl(): string {\n const address = server.address() as AddressInfo\n return `http://127.0.0.1:${address.port}`\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n // insecure random is ok\n const fileUrl = `/${Date.now().toString(16)}-${Math.floor(Math.random() * 9999).toString(16)}.zip`\n server.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n log.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n const data = Buffer.from(`{ \"url\": \"${getServerUrl()}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n log.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n log.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n try {\n setImmediate(() => server.close())\n } finally {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e) {\n log.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n\n this.debug(`Proxy server for native Squirrel.Mac is starting to listen (${logContext})`)\n server.listen(0, \"127.0.0.1\", () => {\n this.debug(`Proxy server for native Squirrel.Mac is listening (address=${getServerUrl()}, ${logContext})`)\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(),\n headers: { \"Cache-Control\": \"no-cache\" },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // update already fetched by Squirrel, it's ready to install\n this.nativeUpdater.quitAndInstall()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.nativeUpdater.quitAndInstall()\n })\n\n if (!this.autoInstallOnAppQuit) {\n /**\n * If this was not `true` previously then MacUpdater.doDownloadUpdate()\n * would not actually initiate the downloading by electron's autoUpdater\n */\n this.nativeUpdater.checkForUpdates()\n }\n }\n }\n}\n"]}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createClient = exports.isUrlProbablySupportMultiRangeRequests = void 0;
4
4
  const builder_util_runtime_1 = require("builder-util-runtime");
5
5
  const BintrayProvider_1 = require("./providers/BintrayProvider");
6
+ const BitbucketProvider_1 = require("./providers/BitbucketProvider");
6
7
  const GenericProvider_1 = require("./providers/GenericProvider");
7
8
  const GitHubProvider_1 = require("./providers/GitHubProvider");
8
9
  const KeygenProvider_1 = require("./providers/KeygenProvider");
@@ -28,6 +29,8 @@ function createClient(data, updater, runtimeOptions) {
28
29
  return new PrivateGitHubProvider_1.PrivateGitHubProvider(githubOptions, updater, token, runtimeOptions);
29
30
  }
30
31
  }
32
+ case "bitbucket":
33
+ return new BitbucketProvider_1.BitbucketProvider(data, updater, runtimeOptions);
31
34
  case "keygen":
32
35
  return new KeygenProvider_1.KeygenProvider(data, updater, runtimeOptions);
33
36
  case "s3":
@@ -1 +1 @@
1
- {"version":3,"file":"providerFactory.js","sourceRoot":"","sources":["../src/providerFactory.ts"],"names":[],"mappings":";;;AAAA,+DAW6B;AAE7B,iEAA6D;AAC7D,iEAA6D;AAC7D,+DAA2D;AAC3D,+DAA2D;AAC3D,6EAAyE;AAGzE,SAAgB,sCAAsC,CAAC,GAAW;IAChE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;AAC1C,CAAC;AAFD,wFAEC;AAED,SAAgB,YAAY,CAAC,IAA8C,EAAE,OAAmB,EAAE,cAAsC;IACtI,qCAAqC;IACrC,IAAI,OAAO,IAAI,KAAK,QA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AK,IAAI,sCAAsC,CAAC,OAAO,CAAC,GAAG,CAAC;aAC5H,CAAC,CAAA;SACH;QAED,KAAK,SAAS;YACZ,OAAO,IAAI,iCAAe,CAAC,IAAsB,EAAE,cAAc,CAAC,CAAA;QAEpE,KAAK,QAAQ,CAAC,CAAC;YACb,MAAM,OAAO,GAAG,IAA4B,CAAA;YAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAA;YAC1C,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,+BAAQ,CAAC,+BAA+B,EAAE,4CAA4C,CAAC,CAAA;aAC9F;YACD,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;SACzD;QAED;YACE,MAAM,+BAAQ,CAAC,yBAAyB,QAAQ,EAAE,EAAE,kCAAkC,CAAC,CAAA;KAC1F;AACH,CAAC;AA5DD,oCA4DC","sourcesContent":["import {\n AllPublishOptions,\n BaseS3Options,\n BintrayOptions,\n CustomPublishOptions,\n GenericServerOptions,\n getS3LikeProviderBaseUrl,\n GithubOptions,\n KeygenOptions,\n newError,\n PublishConfiguration,\n} from \"builder-util-runtime\"\nimport { AppUpdater } from \"./AppUpdater\"\nimport { BintrayProvider } from \"./providers/BintrayProvider\"\nimport { GenericProvider } from \"./providers/GenericProvider\"\nimport { GitHubProvider } from \"./providers/GitHubProvider\"\nimport { KeygenProvider } from \"./providers/KeygenProvider\"\nimport { PrivateGitHubProvider } from \"./providers/PrivateGitHubProvider\"\nimport { Provider, ProviderRuntimeOptions } from \"./providers/Provider\"\n\nexport function isUrlProbablySupportMultiRangeRequests(url: string): boolean {\n return !url.includes(\"s3.amazonaws.com\")\n}\n\nexport function createClient(data: PublishConfiguration | AllPublishOptions, updater: AppUpdater, runtimeOptions: ProviderRuntimeOptions): Provider<any> {\n // noinspection SuspiciousTypeOfGuard\n if (typeof data === \"string\") {\n throw newError(\"Please pass PublishConfiguration object\", \"ERR_UPDATER_INVALID_PROVIDER_CONFIGURATION\")\n }\n\n const provider = data.provider\n switch (provider) {\n case \"github\": {\n const githubOptions = data as GithubOptions\n const token = (githubOptions.private ? process.env[\"GH_TOKEN\"] || process.env[\"GITHUB_TOKEN\"] : null) || githubOptions.token\n if (token == null) {\n return new GitHubProvider(githubOptions, updater, runtimeOptions)\n } else {\n return new PrivateGitHubProvider(githubOptions, updater, token, runtimeOptions)\n }\n }\n\n case \"keygen\":\n return new KeygenProvider(data as KeygenOptions, updater, runtimeOptions)\n\n case \"s3\":\n case \"spaces\":\n return new GenericProvider(\n {\n provider: \"generic\",\n url: getS3LikeProviderBaseUrl(data),\n channel: (data as BaseS3Options).channel || null,\n },\n updater,\n {\n ...runtimeOptions,\n // https://github.com/minio/minio/issues/5285#issuecomment-350428955\n isUseMultipleRangeRequest: false,\n }\n )\n\n case \"generic\": {\n const options = data as GenericServerOptions\n return new GenericProvider(options, updater, {\n ...runtimeOptions,\n isUseMultipleRangeRequest: options.useMultipleRangeRequest !== false && isUrlProbablySupportMultiRangeRequests(options.url),\n })\n }\n\n case \"bintray\":\n return new BintrayProvider(data as BintrayOptions, runtimeOptions)\n\n case \"custom\": {\n const options = data as CustomPublishOptions\n const constructor = options.updateProvider\n if (!constructor) {\n throw newError(\"Custom provider not specified\", \"ERR_UPDATER_INVALID_PROVIDER_CONFIGURATION\")\n }\n return new constructor(options, updater, runtimeOptions)\n }\n\n default:\n throw newError(`Unsupported provider: ${provider}`, \"ERR_UPDATER_UNSUPPORTED_PROVIDER\")\n }\n}\n"]}
1
+ {"version":3,"file":"providerFactory.js","sourceRoot":"","sources":["../src/providerFactory.ts"],"names":[],"mappings":";;;AAAA,+DAY6B;AAE7B,iEAA6D;AAC7D,qEAAiE;AACjE,iEAA6D;AAC7D,+DAA2D;AAC3D,+DAA2D;AAC3D,6EAAyE;AAGzE,SAAgB,sCAAsC,CAAC,GAAW;IAChE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;AAC1C,CAAC;A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aACjC,CACF,CAAA;QAEH,KAAK,SAAS,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,IAA4B,CAAA;YAC5C,OAAO,IAAI,iCAAe,CAAC,OAAO,EAAE,OAAO,EAAE;gBAC3C,GAAG,cAAc;gBACjB,yBAAyB,EAAE,OAAO,CAAC,uBAAuB,KAAK,KAAK,IAAI,sCAAsC,CAAC,OAAO,CAAC,GAAG,CAAC;aAC5H,CAAC,CAAA;SACH;QAED,KAAK,SAAS;YACZ,OAAO,IAAI,iCAAe,CAAC,IAAsB,EAAE,cAAc,CAAC,CAAA;QAEpE,KAAK,QAAQ,CAAC,CAAC;YACb,MAAM,OAAO,GAAG,IAA4B,CAAA;YAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAA;YAC1C,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,+BAAQ,CAAC,+BAA+B,EAAE,4CAA4C,CAAC,CAAA;aAC9F;YACD,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;SACzD;QAED;YACE,MAAM,+BAAQ,CAAC,yBAAyB,QAAQ,EAAE,EAAE,kCAAkC,CAAC,CAAA;KAC1F;AACH,CAAC;AA/DD,oCA+DC","sourcesContent":["import {\n AllPublishOptions,\n BaseS3Options,\n BintrayOptions,\n BitbucketOptions,\n CustomPublishOptions,\n GenericServerOptions,\n getS3LikeProviderBaseUrl,\n GithubOptions,\n KeygenOptions,\n newError,\n PublishConfiguration,\n} from \"builder-util-runtime\"\nimport { AppUpdater } from \"./AppUpdater\"\nimport { BintrayProvider } from \"./providers/BintrayProvider\"\nimport { BitbucketProvider } from \"./providers/BitbucketProvider\"\nimport { GenericProvider } from \"./providers/GenericProvider\"\nimport { GitHubProvider } from \"./providers/GitHubProvider\"\nimport { KeygenProvider } from \"./providers/KeygenProvider\"\nimport { PrivateGitHubProvider } from \"./providers/PrivateGitHubProvider\"\nimport { Provider, ProviderRuntimeOptions } from \"./providers/Provider\"\n\nexport function isUrlProbablySupportMultiRangeRequests(url: string): boolean {\n return !url.includes(\"s3.amazonaws.com\")\n}\n\nexport function createClient(data: PublishConfiguration | AllPublishOptions, updater: AppUpdater, runtimeOptions: ProviderRuntimeOptions): Provider<any> {\n // noinspection SuspiciousTypeOfGuard\n if (typeof data === \"string\") {\n throw newError(\"Please pass PublishConfiguration object\", \"ERR_UPDATER_INVALID_PROVIDER_CONFIGURATION\")\n }\n\n const provider = data.provider\n switch (provider) {\n case \"github\": {\n const githubOptions = data as GithubOptions\n const token = (githubOptions.private ? process.env[\"GH_TOKEN\"] || process.env[\"GITHUB_TOKEN\"] : null) || githubOptions.token\n if (token == null) {\n return new GitHubProvider(githubOptions, updater, runtimeOptions)\n } else {\n return new PrivateGitHubProvider(githubOptions, updater, token, runtimeOptions)\n }\n }\n\n case \"bitbucket\":\n return new BitbucketProvider(data as BitbucketOptions, updater, runtimeOptions)\n\n case \"keygen\":\n return new KeygenProvider(data as KeygenOptions, updater, runtimeOptions)\n\n case \"s3\":\n case \"spaces\":\n return new GenericProvider(\n {\n provider: \"generic\",\n url: getS3LikeProviderBaseUrl(data),\n channel: (data as BaseS3Options).channel || null,\n },\n updater,\n {\n ...runtimeOptions,\n // https://github.com/minio/minio/issues/5285#issuecomment-350428955\n isUseMultipleRangeRequest: false,\n }\n )\n\n case \"generic\": {\n const options = data as GenericServerOptions\n return new GenericProvider(options, updater, {\n ...runtimeOptions,\n isUseMultipleRangeRequest: options.useMultipleRangeRequest !== false && isUrlProbablySupportMultiRangeRequests(options.url),\n })\n }\n\n case \"bintray\":\n return new BintrayProvider(data as BintrayOptions, runtimeOptions)\n\n case \"custom\": {\n const options = data as CustomPublishOptions\n const constructor = options.updateProvider\n if (!constructor) {\n throw newError(\"Custom provider not specified\", \"ERR_UPDATER_INVALID_PROVIDER_CONFIGURATION\")\n }\n return new constructor(options, updater, runtimeOptions)\n }\n\n default:\n throw newError(`Unsupported provider: ${provider}`, \"ERR_UPDATER_UNSUPPORTED_PROVIDER\")\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { BitbucketOptions, UpdateInfo } from "builder-util-runtime";
2
+ import { AppUpdater } from "../AppUpdater";
3
+ import { ResolvedUpdateFileInfo } from "../main";
4
+ import { Provider, ProviderRuntimeOptions } from "./Provider";
5
+ export declare class BitbucketProvider extends Provider<UpdateInfo> {
6
+ private readonly configuration;
7
+ private readonly updater;
8
+ private readonly baseUrl;
9
+ constructor(configuration: BitbucketOptions, updater: AppUpdater, runtimeOptions: ProviderRuntimeOptions);
10
+ private get channel();
11
+ getLatestVersion(): Promise<UpdateInfo>;
12
+ resolveFiles(updateInfo: UpdateInfo): Array<ResolvedUpdateFileInfo>;
13
+ toString(): string;
14
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitbucketProvider = void 0;
4
+ const builder_util_runtime_1 = require("builder-util-runtime");
5
+ const util_1 = require("../util");
6
+ const Provider_1 = require("./Provider");
7
+ class BitbucketProvider extends Provider_1.Provider {
8
+ constructor(configuration, updater, runtimeOptions) {
9
+ super({
10
+ ...runtimeOptions,
11
+ isUseMultipleRangeRequest: false,
12
+ });
13
+ this.configuration = configuration;
14
+ this.updater = updater;
15
+ const { owner, slug } = configuration;
16
+ this.baseUrl = util_1.newBaseUrl(`https://api.bitbucket.org/2.0/repositories/${owner}/${slug}/downloads`);
17
+ }
18
+ get channel() {
19
+ return this.updater.channel || this.configuration.channel || "latest";
20
+ }
21
+ async getLatestVersion() {
22
+ const cancellationToken = new builder_util_runtime_1.CancellationToken();
23
+ const channelFile = util_1.getChannelFilename(this.getCustomChannelName(this.channel));
24
+ const channelUrl = util_1.newUrlFromBase(channelFile, this.baseUrl, this.updater.isAddNoCacheQuery);
25
+ try {
26
+ const updateInfo = await this.httpRequest(channelUrl, undefined, cancellationToken);
27
+ return Provider_1.parseUpdateInfo(updateInfo, channelFile, channelUrl);
28
+ }
29
+ catch (e) {
30
+ throw builder_util_runtime_1.newError(`Unable to find latest version on ${this.toString()}, please ensure release exists: ${e.stack || e.message}`, "ERR_UPDATER_LATEST_VERSION_NOT_FOUND");
31
+ }
32
+ }
33
+ resolveFiles(updateInfo) {
34
+ return Provider_1.resolveFiles(updateInfo, this.baseUrl);
35
+ }
36
+ toString() {
37
+ const { owner, slug } = this.configuration;
38
+ return `Bitbucket (owner: ${owner}, slug: ${slug}, channel: ${this.channel})`;
39
+ }
40
+ }
41
+ exports.BitbucketProvider = BitbucketProvider;
42
+ //# sourceMappingURL=BitbucketProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitbucketProvider.js","sourceRoot":"","sources":["../../src/providers/BitbucketProvider.ts"],"names":[],"mappings":";;;AAAA,+DAAgG;AAGhG,kCAAwE;AACxE,yCAA4F;AAE5F,MAAa,iBAAkB,SAAQ,mBAAoB;IAGzD,YAA6B,aAA+B,EAAmB,OAAmB,EAAE,cAAsC;QACxI,KAAK,CAAC;YACJ,GAAG,cAAc;YACjB,yBAAyB,EAAE,KAAK;SACjC,CAAC,CAAA;QAJyB,kBAAa,GAAb,aAAa,CAAkB;QAAmB,YAAO,GAAP,OAAO,CAAY;QAKhG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,aAAa,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,iBAAU,CAAC,8CAA8C,KAAK,IAAI,IAAI,YAAY,CAAC,CAAA;IACpG,CAAC;IAED,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,QAAQ,CAAA;IACvE,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,iBAAiB,GAAG,IAAI,wCAAiB,EAAE,CAAA;QACjD,MAAM,WAAW,GAAG,yBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAC/E,MAAM,UAAU,GAAG,qBAAc,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QAC5F,IAAI;YACF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;YACnF,OAAO,0BAAe,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAA;SAC5D;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,+BAAQ,CAAC,oCAAoC,IAAI,CAAC,QAAQ,EAAE,mCAAmC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,sCAAsC,CAAC,CAAA;SACrK;IACH,CAAC;IAED,YAAY,CAAC,UAAsB;QACjC,OAAO,uBAAY,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;IAED,QAAQ;QACN,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,aAAa,CAAA;QAC1C,OAAO,qBAAqB,KAAK,WAAW,IAAI,cAAc,IAAI,CAAC,OAAO,GAAG,CAAA;IAC/E,CAAC;CACF;AApCD,8CAoCC","sourcesContent":["import { CancellationToken, BitbucketOptions, newError, UpdateInfo } from \"builder-util-runtime\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"../main\"\nimport { getChannelFilename, newBaseUrl, newUrlFromBase } from \"../util\"\nimport { parseUpdateInfo, Provider, ProviderRuntimeOptions, resolveFiles } from \"./Provider\"\n\nexport class BitbucketProvider extends Provider<UpdateInfo> {\n private readonly baseUrl: URL\n\n constructor(private readonly configuration: BitbucketOptions, private readonly updater: AppUpdater, runtimeOptions: ProviderRuntimeOptions) {\n super({\n ...runtimeOptions,\n isUseMultipleRangeRequest: false,\n })\n const { owner, slug } = configuration\n this.baseUrl = newBaseUrl(`https://api.bitbucket.org/2.0/repositories/${owner}/${slug}/downloads`)\n }\n\n private get channel(): string {\n return this.updater.channel || this.configuration.channel || \"latest\"\n }\n\n async getLatestVersion(): Promise<UpdateInfo> {\n const cancellationToken = new CancellationToken()\n const channelFile = getChannelFilename(this.getCustomChannelName(this.channel))\n const channelUrl = newUrlFromBase(channelFile, this.baseUrl, this.updater.isAddNoCacheQuery)\n try {\n const updateInfo = await this.httpRequest(channelUrl, undefined, cancellationToken)\n return parseUpdateInfo(updateInfo, channelFile, channelUrl)\n } catch (e) {\n throw newError(`Unable to find latest version on ${this.toString()}, please ensure release exists: ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n }\n\n resolveFiles(updateInfo: UpdateInfo): Array<ResolvedUpdateFileInfo> {\n return resolveFiles(updateInfo, this.baseUrl)\n }\n\n toString() {\n const { owner, slug } = this.configuration\n return `Bitbucket (owner: ${owner}, slug: ${slug}, channel: ${this.channel})`\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-updater",
3
- "version": "4.5.1",
3
+ "version": "4.6.2",
4
4
  "description": "Cross platform updater for electron applications",
5
5
  "main": "out/main.js",
6
6
  "author": "Vladimir Krivosheev",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "@types/semver": "^7.3.6",
20
- "builder-util-runtime": "8.8.1",
20
+ "builder-util-runtime": "8.9.2",
21
21
  "fs-extra": "^10.0.0",
22
22
  "js-yaml": "^4.1.0",
23
23
  "lazy-val": "^1.0.5",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/fs-extra": "9.0.12",
30
- "@types/js-yaml": "4.0.2",
30
+ "@types/js-yaml": "4.0.3",
31
31
  "@types/lodash.escaperegexp": "4.1.6",
32
32
  "@types/lodash.isequal": "4.5.5"
33
33
  },