store migrations refactoring

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2020-07-03 14:15:35 +03:00
1 parent c15aa7972c
commit d7cffeb7a8
13 files changed
+164 -145

No files matched your search

+4 -21
View File
@@ -1,32 +1,16 @@
import ElectronStore from "electron-store"
import migrations from "../migrations/cluster-store"
import { Cluster, ClusterBaseInfo } from "../main/cluster";
import * as version200Beta2 from "../migrations/cluster-store/2.0.0-beta.2"
import * as version241 from "../migrations/cluster-store/2.4.1"
import * as version260Beta2 from "../migrations/cluster-store/2.6.0-beta.2"
import * as version260Beta3 from "../migrations/cluster-store/2.6.0-beta.3"
import * as version270Beta0 from "../migrations/cluster-store/2.7.0-beta.0"
import * as version270Beta1 from "../migrations/cluster-store/2.7.0-beta.1"
import { getAppVersion } from "./utils/app-version";
export class ClusterStore {
private static instance: ClusterStore;
public store: ElectronStore;
private store: ElectronStore;
private constructor() {
this.store = new ElectronStore({
// @ts-ignore
// fixme: tests are failed without "projectVersion"
projectVersion: getAppVersion(),
name: "lens-cluster-store",
accessPropertiesByDotNotation: false, // To make dots safe in cluster context names
migrations: {
"2.0.0-beta.2": version200Beta2.migration,
"2.4.1": version241.migration,
"2.6.0-beta.2": version260Beta2.migration,
"2.6.0-beta.3": version260Beta3.migration,
"2.7.0-beta.0": version270Beta0.migration,
"2.7.0-beta.1": version270Beta1.migration
}
migrations: migrations,
})
}
@@ -78,8 +62,7 @@ export class ClusterStore {
}
if (index === -1) {
clusters.push(storable)
}
else {
} else {
clusters[index] = storable
}
this.store.set("clusters", clusters)
+3 -15
View File
@@ -1,10 +1,5 @@
import ElectronStore from "electron-store"
import * as version210Beta4 from "../migrations/user-store/2.1.0-beta.4"
import { getAppVersion } from "./utils/app-version";
export interface User {
id?: string;
}
import migrations from "../migrations/user-store"
export interface UserPreferences {
httpsProxy?: string;
@@ -20,12 +15,7 @@ export class UserStore {
private constructor() {
this.store = new ElectronStore({
// @ts-ignore
// fixme: tests are failed without "projectVersion"
projectVersion: getAppVersion(),
migrations: {
"2.1.0-beta.4": version210Beta4.migration,
}
migrations: migrations,
});
}
@@ -81,6 +71,4 @@ export class UserStore {
}
}
const userStore: UserStore = UserStore.getInstance();
export { userStore };
export const userStore: UserStore = UserStore.getInstance();
+1 -1
View File
@@ -20,7 +20,7 @@ export class Workspace implements WorkspaceData {
export class WorkspaceStore {
public static defaultId = "default"
private static instance: WorkspaceStore;
public store: ElectronStore;
private store: ElectronStore;
private constructor() {
this.store = new ElectronStore({