electron-updater
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -21,3 +21,3 @@ "use strict"; | ||
function getChannelFilename(channel) { | ||
return `${ channel }.${ getCurrentPlatform() === "darwin" ? "json" : "yml" }`; | ||
return `${channel}.${getCurrentPlatform() === "darwin" ? "json" : "yml"}`; | ||
} | ||
@@ -24,0 +24,0 @@ const DOWNLOAD_PROGRESS = exports.DOWNLOAD_PROGRESS = "download-progress"; |
@@ -22,3 +22,3 @@ "use strict"; | ||
var _ref = (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* () { | ||
return createClient((0, (_jsYaml || _load_jsYaml()).safeLoad)((yield (0, (_fsExtraP || _load_fsExtraP()).readFile)(_path.join(global.__test_resourcesPath || process.resourcesPath, "app-update.yml"), "utf-8")))); | ||
return (0, (_jsYaml || _load_jsYaml()).safeLoad)((yield (0, (_fsExtraP || _load_fsExtraP()).readFile)(_path.join(global.__test_resourcesPath || process.resourcesPath, "app-update.yml"), "utf-8"))); | ||
}); | ||
@@ -115,3 +115,3 @@ | ||
if (this.logger != null) { | ||
this.logger.error(`Error: ${ error.stack || error.message }`); | ||
this.logger.error(`Error: ${error.stack || error.message}`); | ||
} | ||
@@ -148,3 +148,10 @@ }); | ||
setFeedURL(value) { | ||
this.clientPromise = (_bluebirdLstC2 || _load_bluebirdLstC2()).default.resolve(createClient(value)); | ||
// https://github.com/electron-userland/electron-builder/issues/1105 | ||
let client; | ||
if (typeof value === "string") { | ||
client = new (_GenericProvider || _load_GenericProvider()).GenericProvider({ provider: "generic", url: value }); | ||
} else { | ||
client = createClient(value); | ||
} | ||
this.clientPromise = (_bluebirdLstC2 || _load_bluebirdLstC2()).default.resolve(client); | ||
} | ||
@@ -173,3 +180,5 @@ checkForUpdates() { | ||
if (_this.clientPromise == null) { | ||
_this.clientPromise = loadUpdateConfig(); | ||
_this.clientPromise = loadUpdateConfig().then(function (it) { | ||
return createClient(it); | ||
}); | ||
} | ||
@@ -194,7 +203,7 @@ return yield _this.doCheckForUpdates(); | ||
if (latestVersion == null) { | ||
throw new Error(`Latest version (from update server) is not valid semver version: "${ latestVersion }`); | ||
throw new Error(`Latest version (from update server) is not valid semver version: "${latestVersion}`); | ||
} | ||
const currentVersion = (0, (_semver || _load_semver()).valid)(_this2.app.getVersion()); | ||
if (currentVersion == null) { | ||
throw new Error(`App version is not valid semver version: "${ currentVersion }`); | ||
throw new Error(`App version is not valid semver version: "${currentVersion}`); | ||
} | ||
@@ -204,3 +213,3 @@ if (!(0, (_semver || _load_semver()).gt)(latestVersion, currentVersion)) { | ||
if (_this2.logger != null) { | ||
_this2.logger.info(`Update for version ${ versionInfo.version } is not available`); | ||
_this2.logger.info(`Update for version ${versionInfo.version} is not available`); | ||
} | ||
@@ -227,3 +236,3 @@ _this2.emit("update-not-available"); | ||
if (this.logger != null) { | ||
this.logger.info(`Found version ${ versionInfo.version } (url: ${ fileInfo.url })`); | ||
this.logger.info(`Found version ${versionInfo.version} (url: ${fileInfo.url})`); | ||
} | ||
@@ -249,3 +258,3 @@ this.emit("update-available"); | ||
if (_this3.logger != null) { | ||
_this3.logger.info(`Downloading update from ${ fileInfo.url }`); | ||
_this3.logger.info(`Downloading update from ${fileInfo.url}`); | ||
} | ||
@@ -271,5 +280,5 @@ return yield _this3.doDownloadUpdate(versionInfo, fileInfo); | ||
default: | ||
throw new Error(`Unsupported provider: ${ provider }`); | ||
throw new Error(`Unsupported provider: ${provider}`); | ||
} | ||
} | ||
//# sourceMappingURL=AppUpdater.js.map |
@@ -41,3 +41,3 @@ "use strict"; | ||
if ("response" in e && e.response.statusCode === 404) { | ||
throw new Error(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${ e.stack || e.message }`); | ||
throw new Error(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${e.stack || e.message}`); | ||
} | ||
@@ -54,3 +54,3 @@ throw e; | ||
const files = yield _this2.client.getVersionFiles(versionInfo.version); | ||
const suffix = `${ versionInfo.version }.exe`; | ||
const suffix = `${versionInfo.version}.exe`; | ||
for (const file of files) { | ||
@@ -60,3 +60,3 @@ if (file.name.endsWith(suffix) && file.name.indexOf("Setup") !== -1) { | ||
name: file.name, | ||
url: `https://dl.bintray.com/${ _this2.client.owner }/${ _this2.client.repo }/${ file.name }`, | ||
url: `https://dl.bintray.com/${_this2.client.owner}/${_this2.client.repo}/${file.name}`, | ||
sha2: file.sha256 | ||
@@ -67,6 +67,6 @@ }; | ||
//noinspection ExceptionCaughtLocallyJS | ||
throw new Error(`Cannot find suitable file for version ${ versionInfo.version } in: ${ JSON.stringify(files, null, 2) }`); | ||
throw new Error(`Cannot find suitable file for version ${versionInfo.version} in: ${JSON.stringify(files, null, 2)}`); | ||
} catch (e) { | ||
if (e instanceof (_electronBuilderHttp || _load_electronBuilderHttp()).HttpError && e.response.statusCode === 404) { | ||
throw new Error(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${ e.stack || e.message }`); | ||
throw new Error(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${e.stack || e.message}`); | ||
} | ||
@@ -73,0 +73,0 @@ throw e; |
@@ -91,3 +91,3 @@ "use strict"; | ||
if (response.statusCode >= 400) { | ||
callback(new Error(`Cannot download "${ url }", status ${ response.statusCode }: ${ response.statusMessage }`)); | ||
callback(new Error(`Cannot download "${url}", status ${response.statusCode}: ${response.statusMessage}`)); | ||
return; | ||
@@ -100,3 +100,3 @@ } | ||
} else { | ||
callback(new Error(`Too many redirects (> ${ (_electronBuilderHttp || _load_electronBuilderHttp()).maxRedirects })`)); | ||
callback(new Error(`Too many redirects (> ${(_electronBuilderHttp || _load_electronBuilderHttp()).maxRedirects})`)); | ||
} | ||
@@ -116,6 +116,6 @@ return; | ||
if ((_electronBuilderHttp || _load_electronBuilderHttp()).debug.enabled) { | ||
(0, (_electronBuilderHttp || _load_electronBuilderHttp()).debug)(`request: ${ JSON.stringify(requestOptions, null, 2) }`); | ||
(0, (_electronBuilderHttp || _load_electronBuilderHttp()).debug)(`request: ${JSON.stringify(requestOptions, null, 2)}`); | ||
} | ||
if (token != null) { | ||
requestOptions.headers.authorization = token.startsWith("Basic") ? token : `token ${ token }`; | ||
requestOptions.headers.authorization = token.startsWith("Basic") ? token : `token ${token}`; | ||
} | ||
@@ -122,0 +122,0 @@ requestOptions.protocol = options.Protocol || "https:"; |
@@ -50,8 +50,8 @@ "use strict"; | ||
const channelFile = (0, (_api || _load_api()).getChannelFilename)(_this.channel); | ||
const pathname = _path.posix.resolve(_this.baseUrl.pathname || "/", `${ channelFile }`); | ||
const pathname = _path.posix.resolve(_this.baseUrl.pathname || "/", `${channelFile}`); | ||
try { | ||
result = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)({ hostname: _this.baseUrl.hostname, port: _this.baseUrl.port || "443", path: `${ pathname }${ _this.baseUrl.search || "" }`, protocol: _this.baseUrl.protocol }); | ||
result = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)({ hostname: _this.baseUrl.hostname, port: _this.baseUrl.port || "443", path: `${pathname}${_this.baseUrl.search || ""}`, protocol: _this.baseUrl.protocol }); | ||
} catch (e) { | ||
if (e instanceof (_electronBuilderHttp || _load_electronBuilderHttp()).HttpError && e.response.statusCode === 404) { | ||
throw new Error(`Cannot find channel "${ channelFile }" update info: ${ e.stack || e.message }`); | ||
throw new Error(`Cannot find channel "${channelFile}" update info: ${e.stack || e.message}`); | ||
} | ||
@@ -92,8 +92,8 @@ throw e; | ||
if (info.sha2 == null) { | ||
throw new Error(`Update info doesn't contain sha2 checksum: ${ JSON.stringify(info, null, 2) }`); | ||
throw new Error(`Update info doesn't contain sha2 checksum: ${JSON.stringify(info, null, 2)}`); | ||
} | ||
if (info.path == null) { | ||
throw new Error(`Update info doesn't contain file path: ${ JSON.stringify(info, null, 2) }`); | ||
throw new Error(`Update info doesn't contain file path: ${JSON.stringify(info, null, 2)}`); | ||
} | ||
} | ||
//# sourceMappingURL=GenericProvider.js.map |
@@ -48,10 +48,10 @@ "use strict"; | ||
// do not use API to avoid limit | ||
const releaseInfo = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)({ hostname: "github.com", path: `${ basePath }/latest` }, null, null, { Accept: "application/json" }); | ||
const releaseInfo = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)({ hostname: "github.com", path: `${basePath}/latest` }, null, null, { Accept: "application/json" }); | ||
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 }`); | ||
throw new Error(`Unable to find latest version on github, please ensure a production release exists: ${e.stack || e.message}`); | ||
} | ||
let result; | ||
const channelFile = (0, (_api || _load_api()).getChannelFilename)((0, (_api || _load_api()).getDefaultChannelName)()); | ||
const channelFileUrlPath = `${ basePath }/download/v${ version }/${ channelFile }`; | ||
const channelFileUrlPath = `${basePath}/download/v${version}/${channelFile}`; | ||
try { | ||
@@ -61,3 +61,3 @@ result = yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).request)({ hostname: "github.com", path: channelFileUrlPath }); | ||
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: ${e.stack || e.message}`); | ||
} | ||
@@ -68,3 +68,3 @@ throw e; | ||
if ((0, (_api || _load_api()).getCurrentPlatform)() === "darwin") { | ||
result.releaseJsonUrl = `https://github.com${ channelFileUrlPath }`; | ||
result.releaseJsonUrl = `https://github.com${channelFileUrlPath}`; | ||
} | ||
@@ -75,3 +75,3 @@ return result; | ||
getBasePath() { | ||
return `/${ this.options.owner }/${ this.options.repo }/releases`; | ||
return `/${this.options.owner}/${this.options.repo}/releases`; | ||
} | ||
@@ -90,3 +90,3 @@ getUpdateFile(versionInfo) { | ||
name: name, | ||
url: `https://github.com${ basePath }/download/v${ versionInfo.version }/${ name }`, | ||
url: `https://github.com${basePath}/download/v${versionInfo.version}/${name}`, | ||
sha2: versionInfo.sha2 | ||
@@ -93,0 +93,0 @@ }; |
@@ -35,3 +35,3 @@ "use strict"; | ||
if (this.logger != null) { | ||
this.logger.info(`New version ${ version } has been downloaded`); | ||
this.logger.info(`New version ${version} has been downloaded`); | ||
} | ||
@@ -38,0 +38,0 @@ this.emit("update-downloaded", this.versionInfo); |
@@ -81,3 +81,3 @@ "use strict"; | ||
} | ||
return (0, (_fsExtraP || _load_fsExtraP()).mkdtemp)(`${ _path.join((0, (_os || _load_os()).tmpdir)(), "up") }-`).then(function (it) { | ||
return (0, (_fsExtraP || _load_fsExtraP()).mkdtemp)(`${_path.join((0, (_os || _load_os()).tmpdir)(), "up")}-`).then(function (it) { | ||
return (0, (_electronBuilderHttp || _load_electronBuilderHttp()).download)(fileInfo.url, _path.join(it, fileInfo.name), downloadOptions); | ||
@@ -89,3 +89,3 @@ }).then(function (it) { | ||
if (_this.logger != null) { | ||
_this.logger.info(`New version ${ version } has been downloaded`); | ||
_this.logger.info(`New version ${version} has been downloaded`); | ||
} | ||
@@ -92,0 +92,0 @@ _this.emit("update-downloaded", _this.versionInfo, null, version, null, null, function () { |
{ | ||
"name": "electron-updater", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "NSIS Auto Updater", | ||
@@ -22,3 +22,3 @@ "main": "out/main.js", | ||
}, | ||
"typings": "./out/electron-auto-updater.d.ts" | ||
"typings": "./out/electron-updater.d.ts" | ||
} |
@@ -1,3 +0,24 @@ | ||
# electron-auto-updater | ||
# electron-updater | ||
[Auto Update](https://github.com/electron-userland/electron-builder/wiki/Auto-Update). | ||
This module allows to automatically update your application. You only need to install this module and write two lines of code! | ||
To publish your updates you just need a simple file hosting, it does not require a dedicated server. | ||
See the [Auto Update](https://github.com/electron-userland/electron-builder/wiki/Auto-Update) section | ||
of the [Wiki](https://github.com/electron-userland/electron-builder/wiki) for more information. | ||
Supported OS: | ||
- macOS ([Squirrel.Mac](https://github.com/Squirrel/Squirrel.Mac)). | ||
- Windows (NSIS). | ||
Linux support is [planned](https://github.com/electron-userland/electron-builder/issues/1138). | ||
## Differences between electron-updater and built-in autoUpdater | ||
* Actually, autoUpdater is used inside (on macOS). | ||
* It doesn't require a dedicated release server. | ||
* You need only 2 lines of code to make it work. | ||
* [electron-builder](https://github.com/electron-userland/electron-builder) produces and published all required metadata files and artifacts. | ||
## Credits | ||
Thanks to [Evolve Labs](https://www.evolvehq.com) for donating the npm package name. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
96987
22
1102
24
1