mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
tracker / user-store refactoring, part 1
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
c9fb015bcf
commit
4270ec4240
23 files changed
+247
-225
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import path from "path";
|
||||
import ElectronStore from "electron-store";
|
||||
import Config from "conf";
|
||||
import { isTestEnv } from "../common/vars";
|
||||
|
||||
export interface MigrationOpts {
|
||||
version: string;
|
||||
run(store: ElectronStore, log: (...args: any[]) => void): void;
|
||||
run(storeConfig: Config<any>, log: (...args: any[]) => void): void;
|
||||
}
|
||||
|
||||
function infoLog(...args: any[]) {
|
||||
@@ -12,12 +12,12 @@ function infoLog(...args: any[]) {
|
||||
console.log(...args);
|
||||
}
|
||||
|
||||
export function migration({ version, run }: MigrationOpts) {
|
||||
export function migration<S = any>({ version, run }: MigrationOpts) {
|
||||
return {
|
||||
[version]: (store: ElectronStore) => {
|
||||
const storeName = path.dirname(store.path);
|
||||
infoLog(`STORE MIGRATION (${storeName}): ${version}`, );
|
||||
run(store, infoLog);
|
||||
[version]: (storeConfig: Config<S>) => {
|
||||
const storeName = path.dirname(storeConfig.path);
|
||||
infoLog(`STORE MIGRATION (${storeName}): ${version}`,);
|
||||
run(storeConfig, infoLog);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user