1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Use BuildSemanticVersion

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-09-15 10:09:41 -04:00
parent ea70e7decc
commit 7a687dbe09
6 changed files with 17 additions and 17 deletions

View File

@ -5,13 +5,13 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import { action, computed, observable } from "mobx"; import { action, computed, observable } from "mobx";
import type { UpdateChannel, UpdateChannelId } from "../update-channels"; import type { UpdateChannel, ReleaseChannel } from "../update-channels";
import { updateChannels } from "../update-channels"; import { updateChannels } from "../update-channels";
import defaultUpdateChannelInjectable from "./default-update-channel.injectable"; import defaultUpdateChannelInjectable from "./default-update-channel.injectable";
export interface SelectedUpdateChannel { export interface SelectedUpdateChannel {
value: IComputedValue<UpdateChannel>; value: IComputedValue<UpdateChannel>;
setValue: (channelId?: UpdateChannelId) => void; setValue: (channelId?: ReleaseChannel) => void;
} }
const selectedUpdateChannelInjectable = getInjectable({ const selectedUpdateChannelInjectable = getInjectable({

View File

@ -4,7 +4,7 @@
*/ */
export type UpdateChannelId = "alpha" | "beta" | "latest"; export type ReleaseChannel = "alpha" | "beta" | "latest";
const latestChannel: UpdateChannel = { const latestChannel: UpdateChannel = {
id: "latest", id: "latest",
@ -31,7 +31,7 @@ export const updateChannels = {
}; };
export interface UpdateChannel { export interface UpdateChannel {
readonly id: UpdateChannelId; readonly id: ReleaseChannel;
readonly label: string; readonly label: string;
readonly moreStableUpdateChannel: UpdateChannel | null; readonly moreStableUpdateChannel: UpdateChannel | null;
} }

View File

@ -13,7 +13,7 @@ import { DESCRIPTORS } from "./preferences-helpers";
import type { UserPreferencesModel, StoreType } from "./preferences-helpers"; import type { UserPreferencesModel, StoreType } from "./preferences-helpers";
import logger from "../../main/logger"; import logger from "../../main/logger";
import type { SelectedUpdateChannel } from "../application-update/selected-update-channel/selected-update-channel.injectable"; import type { SelectedUpdateChannel } from "../application-update/selected-update-channel/selected-update-channel.injectable";
import type { UpdateChannelId } from "../application-update/update-channels"; import type { ReleaseChannel } from "../application-update/update-channels";
export interface UserStoreModel { export interface UserStoreModel {
lastSeenAppVersion: string; lastSeenAppVersion: string;
@ -167,7 +167,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
// TODO: Switch to action-based saving instead saving stores by reaction // TODO: Switch to action-based saving instead saving stores by reaction
if (preferences?.updateChannel) { if (preferences?.updateChannel) {
this.dependencies.selectedUpdateChannel.setValue(preferences?.updateChannel as UpdateChannelId); this.dependencies.selectedUpdateChannel.setValue(preferences?.updateChannel as ReleaseChannel);
} }
} }

View File

@ -3,14 +3,14 @@
* 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 type { UpdateChannelId } from "../application-update/update-channels"; import type { ReleaseChannel } from "../application-update/update-channels";
import appSemanticVersionInjectable from "./app-semantic-version.injectable"; import buildSemanticVersionInjectable from "./build-semantic-version.injectable";
const releaseChannelInjectable = getInjectable({ const releaseChannelInjectable = getInjectable({
id: "release-channel", id: "release-channel",
instantiate: (di): UpdateChannelId => { instantiate: (di): ReleaseChannel => {
const appSemanticVersion = di.inject(appSemanticVersionInjectable); const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
const currentReleaseChannel = appSemanticVersion.prerelease[0]; const currentReleaseChannel = buildSemanticVersion.get().prerelease[0];
switch (currentReleaseChannel) { switch (currentReleaseChannel) {
case "latest": case "latest":

View File

@ -12,7 +12,7 @@ import type { CheckForPlatformUpdates } from "../../main/application-update/chec
import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable";
import type { AsyncFnMock } from "@async-fn/jest"; import type { AsyncFnMock } from "@async-fn/jest";
import asyncFn from "@async-fn/jest"; import asyncFn from "@async-fn/jest";
import type { UpdateChannel, UpdateChannelId } from "../../common/application-update/update-channels"; import type { UpdateChannel, ReleaseChannel } from "../../common/application-update/update-channels";
import { updateChannels } from "../../common/application-update/update-channels"; import { updateChannels } from "../../common/application-update/update-channels";
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable"; import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable"; import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
@ -89,7 +89,7 @@ describe("selection of update stability", () => {
describe('given update channel "alpha" is selected, when checking for updates', () => { describe('given update channel "alpha" is selected, when checking for updates', () => {
let selectedUpdateChannel: { let selectedUpdateChannel: {
value: IComputedValue<UpdateChannel>; value: IComputedValue<UpdateChannel>;
setValue: (channelId: UpdateChannelId) => void; setValue: (channelId: ReleaseChannel) => void;
}; };
beforeEach(() => { beforeEach(() => {
@ -180,7 +180,7 @@ describe("selection of update stability", () => {
describe('given update channel "beta" is selected', () => { describe('given update channel "beta" is selected', () => {
let selectedUpdateChannel: { let selectedUpdateChannel: {
value: IComputedValue<UpdateChannel>; value: IComputedValue<UpdateChannel>;
setValue: (channelId: UpdateChannelId) => void; setValue: (channelId: ReleaseChannel) => void;
}; };
beforeEach(() => { beforeEach(() => {
@ -254,7 +254,7 @@ describe("selection of update stability", () => {
// TODO: UserStore is currently responsible for getting and setting initial value // TODO: UserStore is currently responsible for getting and setting initial value
const selectedUpdateChannel = mainDi.inject(selectedUpdateChannelInjectable); const selectedUpdateChannel = mainDi.inject(selectedUpdateChannelInjectable);
selectedUpdateChannel.setValue("something-invalid" as UpdateChannelId); selectedUpdateChannel.setValue("something-invalid" as ReleaseChannel);
}); });
await builder.render(); await builder.render();

View File

@ -9,7 +9,7 @@ import asyncFn from "@async-fn/jest";
import type { AppUpdater, UpdateCheckResult } from "electron-updater"; import type { AppUpdater, UpdateCheckResult } from "electron-updater";
import type { CheckForPlatformUpdates } from "./check-for-platform-updates.injectable"; import type { CheckForPlatformUpdates } from "./check-for-platform-updates.injectable";
import checkForPlatformUpdatesInjectable from "./check-for-platform-updates.injectable"; import checkForPlatformUpdatesInjectable from "./check-for-platform-updates.injectable";
import type { UpdateChannel, UpdateChannelId } from "../../../common/application-update/update-channels"; import type { UpdateChannel, ReleaseChannel } from "../../../common/application-update/update-channels";
import { getPromiseStatus } from "../../../common/test-utils/get-promise-status"; import { getPromiseStatus } from "../../../common/test-utils/get-promise-status";
import loggerInjectable from "../../../common/logger.injectable"; import loggerInjectable from "../../../common/logger.injectable";
import type { Logger } from "../../../common/logger"; import type { Logger } from "../../../common/logger";
@ -47,7 +47,7 @@ describe("check-for-platform-updates", () => {
beforeEach(() => { beforeEach(() => {
const testUpdateChannel: UpdateChannel = { const testUpdateChannel: UpdateChannel = {
id: "some-update-channel" as UpdateChannelId, id: "some-update-channel" as ReleaseChannel,
label: "Some update channel", label: "Some update channel",
moreStableUpdateChannel: null, moreStableUpdateChannel: null,
}; };