mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Automatically check next pre-release channel (#3737)
* automatically check next pre-release channel Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * automatically check next pre-release channel Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
a06f0c1ab4
commit
d6b2b0352c
6 files changed
+328
-221
No files matched your search
@@ -26,7 +26,9 @@ import { delay } from "../common/utils";
|
||||
import { areArgsUpdateAvailableToBackchannel, AutoUpdateLogPrefix, broadcastMessage, onceCorrect, UpdateAvailableChannel, UpdateAvailableToBackchannel } from "../common/ipc";
|
||||
import { once } from "lodash";
|
||||
import { ipcMain } from "electron";
|
||||
import { nextUpdateChannel } from "./utils/update-channel";
|
||||
|
||||
const updateChannel = autoUpdater.channel;
|
||||
let installVersion: null | string = null;
|
||||
|
||||
export function isAutoUpdateEnabled() {
|
||||
@@ -100,6 +102,13 @@ export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24
|
||||
logger.error(`${AutoUpdateLogPrefix}: broadcasting failed`, { error });
|
||||
installVersion = undefined;
|
||||
}
|
||||
})
|
||||
.on("update-not-available", () => {
|
||||
const nextChannel = nextUpdateChannel(updateChannel, autoUpdater.channel);
|
||||
|
||||
logger.info(`${AutoUpdateLogPrefix}: update not available from ${autoUpdater.channel}, will check ${nextChannel} channel next`);
|
||||
|
||||
autoUpdater.channel = nextChannel;
|
||||
});
|
||||
|
||||
async function helper() {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { nextUpdateChannel } from "../update-channel";
|
||||
|
||||
describe("nextUpdateChannel", () => {
|
||||
it("returns latest if current channel is latest", () => {
|
||||
expect(nextUpdateChannel("latest", "latest")).toEqual("latest");
|
||||
});
|
||||
|
||||
it("returns beta if current channel is alpha", () => {
|
||||
expect(nextUpdateChannel("alpha", "alpha")).toEqual("beta");
|
||||
expect(nextUpdateChannel("beta", "alpha")).toEqual("beta");
|
||||
expect(nextUpdateChannel("rc", "alpha")).toEqual("beta");
|
||||
expect(nextUpdateChannel("latest", "alpha")).toEqual("beta");
|
||||
});
|
||||
|
||||
it("returns rc if current channel is beta", () => {
|
||||
expect(nextUpdateChannel("alpha", "beta")).toEqual("rc");
|
||||
expect(nextUpdateChannel("beta", "beta")).toEqual("rc");
|
||||
expect(nextUpdateChannel("rc", "beta")).toEqual("rc");
|
||||
expect(nextUpdateChannel("latest", "beta")).toEqual("rc");
|
||||
});
|
||||
|
||||
it("returns latest if current channel is rc", () => {
|
||||
expect(nextUpdateChannel("alpha", "rc")).toEqual("latest");
|
||||
expect(nextUpdateChannel("beta", "rc")).toEqual("latest");
|
||||
expect(nextUpdateChannel("rc", "rc")).toEqual("latest");
|
||||
expect(nextUpdateChannel("latest", "rc")).toEqual("latest");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export function nextUpdateChannel(defaultChannel: string, channel: string): string {
|
||||
if (channel === "alpha") {
|
||||
return "beta";
|
||||
} else if (channel === "beta") {
|
||||
return "rc";
|
||||
} else if (channel === "rc") {
|
||||
return "latest";
|
||||
} else {
|
||||
return defaultChannel;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user