mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com> Co-authored-by: Sebastian Malton <sebastian@malton.name> Co-authored-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Lauri Nevala <lauri.nevala@gmail.com> Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
22 lines
525 B
TypeScript
22 lines
525 B
TypeScript
import Config from "conf";
|
|
import { isTestEnv } from "../common/vars";
|
|
|
|
export interface MigrationOpts {
|
|
version: string;
|
|
run(storeConfig: Config<any>, log: (...args: any[]) => void): void;
|
|
}
|
|
|
|
function infoLog(...args: any[]) {
|
|
if (isTestEnv) return;
|
|
console.log(...args);
|
|
}
|
|
|
|
export function migration<S = any>({ version, run }: MigrationOpts) {
|
|
return {
|
|
[version]: (storeConfig: Config<S>) => {
|
|
infoLog(`STORE MIGRATION (${storeConfig.path}): ${version}`,);
|
|
run(storeConfig, infoLog);
|
|
}
|
|
};
|
|
}
|