mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add user-store file name migration
specify the new name Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
parent
41e012d83f
commit
daa68d96b9
@ -10,6 +10,7 @@ import { kubeConfigDefaultPath, loadConfig } from "./kube-helpers";
|
||||
import { appEventBus } from "./event-bus";
|
||||
import logger from "../main/logger";
|
||||
import path from "path";
|
||||
import { fileNameMigration } from "../migrations/user-store";
|
||||
|
||||
export interface UserStoreModel {
|
||||
kubeConfigPath: string;
|
||||
@ -36,7 +37,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
|
||||
private constructor() {
|
||||
super({
|
||||
// configName: "lens-user-store", // todo: migrate from default "config.json"
|
||||
configName: "lens-user-store",
|
||||
migrations,
|
||||
});
|
||||
|
||||
@ -80,6 +81,12 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
}
|
||||
}
|
||||
|
||||
async load(): Promise<void> {
|
||||
await fileNameMigration();
|
||||
|
||||
return super.load();
|
||||
}
|
||||
|
||||
get isNewVersion() {
|
||||
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
||||
}
|
||||
|
||||
17
src/migrations/user-store/file-name-migration.ts
Normal file
17
src/migrations/user-store/file-name-migration.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import fse from "fs-extra";
|
||||
import { app, remote } from "electron";
|
||||
import path from "path";
|
||||
|
||||
export async function fileNameMigration() {
|
||||
const userDataPath = (app || remote.app).getPath("userData");
|
||||
const configJsonPath = path.join(userDataPath, "config.json");
|
||||
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
|
||||
const [configJsonExists, lensUserStoreJsonExists] = await Promise.all([
|
||||
fse.pathExists(configJsonPath),
|
||||
fse.pathExists(lensUserStoreJsonPath),
|
||||
]);
|
||||
|
||||
if (configJsonExists && !lensUserStoreJsonExists) {
|
||||
await fse.move(configJsonPath, lensUserStoreJsonPath);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,11 @@
|
||||
// User store migrations
|
||||
|
||||
import version210Beta4 from "./2.1.0-beta.4";
|
||||
import { fileNameMigration } from "./file-name-migration";
|
||||
|
||||
export {
|
||||
fileNameMigration
|
||||
};
|
||||
|
||||
export default {
|
||||
...version210Beta4,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user