electron-updater
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -81,2 +81,3 @@ declare module "electron-updater/out/api" { | ||
getLatestVersion(): Promise<UpdateInfo> | ||
private getLatestVersionString(basePath, cancellationToken) | ||
private getBasePath() | ||
@@ -83,0 +84,0 @@ getUpdateFile(versionInfo: UpdateInfo): Promise<FileInfo> |
@@ -70,22 +70,12 @@ "use strict"; | ||
const basePath = _this.getBasePath(); | ||
let version; | ||
const cancellationToken = new (_CancellationToken || _load_CancellationToken()).CancellationToken(); | ||
try { | ||
// do not use API to avoid limit | ||
const releaseInfo = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)(Object.assign({ | ||
path: `${basePath}/latest`, | ||
headers: Object.assign({ Accept: "application/json" }, _this.requestHeaders) | ||
}, _this.baseUrl), cancellationToken); | ||
version = releaseInfo.tag_name.startsWith("v") ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name; | ||
} catch (e) { | ||
throw new Error(`Unable to find latest version on github, please ensure a production release exists: ${e.stack || e.message}`); | ||
} | ||
const version = yield _this.getLatestVersionString(basePath, cancellationToken); | ||
let result; | ||
const channelFile = (0, (_api || _load_api()).getChannelFilename)((0, (_api || _load_api()).getDefaultChannelName)()); | ||
const channelFileUrlPath = `${basePath}/download/v${version}/${channelFile}`; | ||
const requestOptions = Object.assign({ path: `${basePath}/download/v${version}/${channelFile}`, headers: _this.requestHeaders || undefined }, _this.baseUrl); | ||
try { | ||
result = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)(Object.assign({ path: channelFileUrlPath, headers: _this.requestHeaders || undefined }, _this.baseUrl), cancellationToken); | ||
result = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)(requestOptions, cancellationToken); | ||
} catch (e) { | ||
if (e instanceof (_electronBuilderHttp || _load_electronBuilderHttp()).HttpError && e.response.statusCode === 404) { | ||
throw new Error(`Cannot find ${channelFile} in the latest release artifacts: ${e.stack || e.message}`); | ||
throw new Error(`Cannot find ${channelFile} in the latest release artifacts (${(_url || _load_url()).format(requestOptions)}): ${e.stack || e.message}`); | ||
} | ||
@@ -96,3 +86,3 @@ throw e; | ||
if ((0, (_api || _load_api()).getCurrentPlatform)() === "darwin") { | ||
result.releaseJsonUrl = `${(0, (_publishOptions || _load_publishOptions()).githubUrl)(_this.options)}/${channelFileUrlPath}`; | ||
result.releaseJsonUrl = `${(0, (_publishOptions || _load_publishOptions()).githubUrl)(_this.options)}/${requestOptions.path}`; | ||
} | ||
@@ -102,2 +92,19 @@ return result; | ||
} | ||
getLatestVersionString(basePath, cancellationToken) { | ||
var _this2 = this; | ||
return (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* () { | ||
const requestOptions = Object.assign({ | ||
path: `${basePath}/latest`, | ||
headers: Object.assign({ Accept: "application/json" }, _this2.requestHeaders) | ||
}, _this2.baseUrl); | ||
try { | ||
// do not use API to avoid limit | ||
const releaseInfo = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)(requestOptions, cancellationToken); | ||
return releaseInfo.tag_name.startsWith("v") ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name; | ||
} catch (e) { | ||
throw new Error(`Unable to find latest version on GitHub (${(_url || _load_url()).format(requestOptions)}), please ensure a production release exists: ${e.stack || e.message}`); | ||
} | ||
})(); | ||
} | ||
getBasePath() { | ||
@@ -107,3 +114,3 @@ return `/${this.options.owner}/${this.options.repo}/releases`; | ||
getUpdateFile(versionInfo) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -114,3 +121,3 @@ return (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* () { | ||
} | ||
const basePath = _this2.getBasePath(); | ||
const basePath = _this3.getBasePath(); | ||
// space is not supported on GitHub | ||
@@ -120,3 +127,3 @@ const name = versionInfo.githubArtifactName || _path.posix.basename(versionInfo.path).replace(/ /g, "-"); | ||
name: name, | ||
url: (_url || _load_url()).format(Object.assign({ pathname: `${basePath}/download/v${versionInfo.version}/${name}` }, _this2.baseUrl)), | ||
url: (_url || _load_url()).format(Object.assign({ pathname: `${basePath}/download/v${versionInfo.version}/${name}` }, _this3.baseUrl)), | ||
sha2: versionInfo.sha2 | ||
@@ -123,0 +130,0 @@ }; |
{ | ||
"name": "electron-updater", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "Cross platform updater for electron applications", | ||
@@ -20,5 +20,5 @@ "main": "out/main.js", | ||
"source-map-support": "^0.4.11", | ||
"electron-builder-http": "13.4.0" | ||
"electron-builder-http": "13.6.0" | ||
}, | ||
"typings": "./out/electron-updater.d.ts" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105347
1193
+ Addeddebug@2.6.1(transitive)
+ Addedelectron-builder-http@13.6.0(transitive)
- Removeddebug@2.6.0(transitive)
- Removedelectron-builder-http@13.4.0(transitive)
Updatedelectron-builder-http@13.6.0