Skip to content

Commit

Permalink
fix(auto-update): patch GitHub provider for electron-updater to make …
Browse files Browse the repository at this point in the history
…it backward compatible with pre-release withou channels

Changes in electron-updater library broke our Github flow with pre-release status without channels (-beta/-alba). We are not able to start using -beta tags without publishing two separate builds with different versions (one for EAP, second for general public release). This patch basically reverts the changes for apps without channel tag in version.

(cherry picked from commit 4a5c69f)
  • Loading branch information
matejkriz committed Jul 12, 2022
1 parent 51a6998 commit 20ef59a
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions patches/electron-updater+5.0.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff --git a/node_modules/electron-updater/out/providers/GitHubProvider.js b/node_modules/electron-updater/out/providers/GitHubProvider.js
index 8f15cd3..c719b66 100644
--- a/node_modules/electron-updater/out/providers/GitHubProvider.js
+++ b/node_modules/electron-updater/out/providers/GitHubProvider.js
@@ -45,28 +45,32 @@ class GitHubProvider extends BaseGitHubProvider {
try {
if (this.updater.allowPrerelease) {
const currentChannel = ((_a = this.updater) === null || _a === void 0 ? void 0 : _a.channel) || ((_b = semver.prerelease(this.updater.currentVersion)) === null || _b === void 0 ? void 0 : _b[0]) || null;
- for (const element of feed.getElements("entry")) {
- // noinspection TypeScriptValidateJSTypes
- const hrefElement = hrefRegExp.exec(element.element("link").attribute("href"));
- // If this is null then something is wrong and skip this release
- if (hrefElement === null)
- continue;
- // This Release's Tag
- const hrefTag = hrefElement[1];
- //Get Channel from this release's tag
- const hrefChannel = ((_c = semver.prerelease(hrefTag)) === null || _c === void 0 ? void 0 : _c[0]) || null;
- const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel);
- const isCustomChannel = !["alpha", "beta"].includes(String(hrefChannel));
- // Allow moving from alpha to beta but not down
- const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha";
- if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {
- tag = hrefTag;
- break;
- }
- const isNextPreRelease = hrefChannel && hrefChannel === currentChannel;
- if (isNextPreRelease) {
- tag = hrefTag;
- break;
+ if (currentChannel === null) {
+ tag = hrefRegExp.exec(latestRelease.element("link").attribute("href"))[1]
+ } else {
+ for (const element of feed.getElements("entry")) {
+ // noinspection TypeScriptValidateJSTypes
+ const hrefElement = hrefRegExp.exec(element.element("link").attribute("href"));
+ // If this is null then something is wrong and skip this release
+ if (hrefElement === null)
+ continue;
+ // This Release's Tag
+ const hrefTag = hrefElement[1];
+ //Get Channel from this release's tag
+ const hrefChannel = ((_c = semver.prerelease(hrefTag)) === null || _c === void 0 ? void 0 : _c[0]) || null;
+ const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel);
+ const isCustomChannel = !["alpha", "beta"].includes(String(hrefChannel));
+ // Allow moving from alpha to beta but not down
+ const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha";
+ if (shouldFetchVersion && !isCustomChannel && !channelMismatch) {
+ tag = hrefTag;
+ break;
+ }
+ const isNextPreRelease = hrefChannel && hrefChannel === currentChannel;
+ if (isNextPreRelease) {
+ tag = hrefTag;
+ break;
+ }
}
}
}

0 comments on commit 20ef59a

Please sign in to comment.