mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix beta->latest->beta upgrade loop (#6189)
This commit is contained in:
parent
b428518857
commit
a784ca70b1
@ -3,23 +3,12 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import appSemanticVersionInjectable from "../../vars/app-semantic-version.injectable";
|
import releaseChannelInjectable from "../../vars/release-channel.injectable";
|
||||||
import type { UpdateChannelId } from "../update-channels";
|
|
||||||
import { updateChannels } from "../update-channels";
|
import { updateChannels } from "../update-channels";
|
||||||
|
|
||||||
const defaultUpdateChannelInjectable = getInjectable({
|
const defaultUpdateChannelInjectable = getInjectable({
|
||||||
id: "default-update-channel",
|
id: "default-update-channel",
|
||||||
|
instantiate: (di) => updateChannels[di.inject(releaseChannelInjectable)],
|
||||||
instantiate: (di) => {
|
|
||||||
const appSemanticVersion = di.inject(appSemanticVersionInjectable);
|
|
||||||
const currentReleaseChannel = appSemanticVersion.prerelease[0]?.toString();
|
|
||||||
|
|
||||||
if (currentReleaseChannel in updateChannels) {
|
|
||||||
return updateChannels[currentReleaseChannel as UpdateChannelId];
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateChannels.latest;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default defaultUpdateChannelInjectable;
|
export default defaultUpdateChannelInjectable;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ const alphaChannel: UpdateChannel = {
|
|||||||
moreStableUpdateChannel: betaChannel,
|
moreStableUpdateChannel: betaChannel,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateChannels: Record<UpdateChannelId, UpdateChannel> = {
|
export const updateChannels = {
|
||||||
latest: latestChannel,
|
latest: latestChannel,
|
||||||
beta: betaChannel,
|
beta: betaChannel,
|
||||||
alpha: alphaChannel,
|
alpha: alphaChannel,
|
||||||
|
|||||||
26
src/common/vars/release-channel.injectable.ts
Normal file
26
src/common/vars/release-channel.injectable.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import type { UpdateChannelId } from "../application-update/update-channels";
|
||||||
|
import appSemanticVersionInjectable from "./app-semantic-version.injectable";
|
||||||
|
|
||||||
|
const releaseChannelInjectable = getInjectable({
|
||||||
|
id: "release-channel",
|
||||||
|
instantiate: (di): UpdateChannelId => {
|
||||||
|
const appSemanticVersion = di.inject(appSemanticVersionInjectable);
|
||||||
|
const currentReleaseChannel = appSemanticVersion.prerelease[0];
|
||||||
|
|
||||||
|
switch (currentReleaseChannel) {
|
||||||
|
case "latest":
|
||||||
|
case "beta":
|
||||||
|
case "alpha":
|
||||||
|
return currentReleaseChannel;
|
||||||
|
default:
|
||||||
|
return "latest";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default releaseChannelInjectable;
|
||||||
@ -40,6 +40,36 @@ describe("downgrading version update", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.latest,
|
||||||
|
appVersion: "4.0.0",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.beta,
|
||||||
|
appVersion: "4.0.0",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.alpha,
|
||||||
|
appVersion: "4.0.0",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.latest,
|
||||||
|
appVersion: "4.0.0-latest",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.beta,
|
||||||
|
appVersion: "4.0.0-latest",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.alpha,
|
||||||
|
appVersion: "4.0.0-latest",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
updateChannel: updateChannels.latest,
|
updateChannel: updateChannels.latest,
|
||||||
appVersion: "4.0.0-beta",
|
appVersion: "4.0.0-beta",
|
||||||
@ -50,16 +80,21 @@ describe("downgrading version update", () => {
|
|||||||
appVersion: "4.0.0-beta",
|
appVersion: "4.0.0-beta",
|
||||||
downgradeIsAllowed: false,
|
downgradeIsAllowed: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
updateChannel: updateChannels.beta,
|
|
||||||
appVersion: "4.0.0-beta.1",
|
|
||||||
downgradeIsAllowed: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
updateChannel: updateChannels.alpha,
|
updateChannel: updateChannels.alpha,
|
||||||
appVersion: "4.0.0-beta",
|
appVersion: "4.0.0-beta",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.latest,
|
||||||
|
appVersion: "4.0.0-alpha",
|
||||||
downgradeIsAllowed: true,
|
downgradeIsAllowed: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
updateChannel: updateChannels.beta,
|
||||||
|
appVersion: "4.0.0-alpha",
|
||||||
|
downgradeIsAllowed: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
updateChannel: updateChannels.alpha,
|
updateChannel: updateChannels.alpha,
|
||||||
appVersion: "4.0.0-alpha",
|
appVersion: "4.0.0-alpha",
|
||||||
|
|||||||
@ -91,7 +91,7 @@ describe("installing update", () => {
|
|||||||
it("checks for updates", () => {
|
it("checks for updates", () => {
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
||||||
expect.any(Object),
|
expect.any(Object),
|
||||||
{ allowDowngrade: true },
|
{ allowDowngrade: false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ describe("selection of update stability", () => {
|
|||||||
it('checks updates from update channel "alpha"', () => {
|
it('checks updates from update channel "alpha"', () => {
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
||||||
updateChannels.alpha,
|
updateChannels.alpha,
|
||||||
{ allowDowngrade: true },
|
{ allowDowngrade: false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ describe("selection of update stability", () => {
|
|||||||
it('checks updates from update channel "beta"', () => {
|
it('checks updates from update channel "beta"', () => {
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
||||||
updateChannels.beta,
|
updateChannels.beta,
|
||||||
{ allowDowngrade: true },
|
{ allowDowngrade: false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ describe("selection of update stability", () => {
|
|||||||
it('finally checks updates from update channel "latest"', () => {
|
it('finally checks updates from update channel "latest"', () => {
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
||||||
updateChannels.latest,
|
updateChannels.latest,
|
||||||
{ allowDowngrade: true },
|
{ allowDowngrade: false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ describe("selection of update stability", () => {
|
|||||||
|
|
||||||
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(
|
||||||
updateChannels.latest,
|
updateChannels.latest,
|
||||||
{ allowDowngrade: true },
|
{ allowDowngrade: false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -19,10 +19,7 @@ const checkForUpdatesStartingFromChannelInjectable = getInjectable({
|
|||||||
id: "check-for-updates-starting-from-channel",
|
id: "check-for-updates-starting-from-channel",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const checkForPlatformUpdates = di.inject(
|
const checkForPlatformUpdates = di.inject(checkForPlatformUpdatesInjectable);
|
||||||
checkForPlatformUpdatesInjectable,
|
|
||||||
);
|
|
||||||
|
|
||||||
const updateCanBeDowngraded = di.inject(updateCanBeDowngradedInjectable);
|
const updateCanBeDowngraded = di.inject(updateCanBeDowngradedInjectable);
|
||||||
|
|
||||||
const _recursiveCheck = async (
|
const _recursiveCheck = async (
|
||||||
|
|||||||
@ -5,24 +5,19 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import selectedUpdateChannelInjectable from "../../../common/application-update/selected-update-channel/selected-update-channel.injectable";
|
import selectedUpdateChannelInjectable from "../../../common/application-update/selected-update-channel/selected-update-channel.injectable";
|
||||||
import appVersionInjectable from "../../../common/vars/app-version.injectable";
|
import releaseChannelInjectable from "../../../common/vars/release-channel.injectable";
|
||||||
import { SemVer } from "semver";
|
|
||||||
|
|
||||||
const updateCanBeDowngradedInjectable = getInjectable({
|
const updateCanBeDowngradedInjectable = getInjectable({
|
||||||
id: "update-can-be-downgraded",
|
id: "update-can-be-downgraded",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const selectedUpdateChannel = di.inject(selectedUpdateChannelInjectable);
|
const selectedUpdateChannel = di.inject(selectedUpdateChannelInjectable);
|
||||||
const appVersion = di.inject(appVersionInjectable);
|
const releaseChannel = di.inject(releaseChannelInjectable);
|
||||||
|
|
||||||
return computed(() => {
|
return computed(() => (
|
||||||
const semVer = new SemVer(appVersion);
|
selectedUpdateChannel.value.get().id === "latest"
|
||||||
|
&& releaseChannel !== "latest"
|
||||||
return (
|
));
|
||||||
semVer.prerelease[0] !==
|
|
||||||
selectedUpdateChannel.value.get().id
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user