mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 11:29:42 +00:00
Feat: Standalone migration mode
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { logger } from "../logger";
|
||||
|
||||
export const isMigrationMode = () => {
|
||||
try {
|
||||
const args = process.argv.slice(2);
|
||||
const migrationFlag = args.find((arg) => arg.startsWith("--migration-mode"));
|
||||
|
||||
if (!migrationFlag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Covers the case where the flag is --migration-mode [true|false|...]
|
||||
if (migrationFlag === "--migration-mode") {
|
||||
const nextArg = args[args.indexOf(migrationFlag) + 1];
|
||||
if (nextArg === "false") {
|
||||
return false;
|
||||
}
|
||||
// --migration-mode without a value defaults to true
|
||||
return nextArg === undefined || nextArg.toLowerCase() === "true";
|
||||
}
|
||||
|
||||
// Covers the case where the flag is --migration-mode=[...]
|
||||
const [, value] = migrationFlag.split("=");
|
||||
if (value === undefined) {
|
||||
const nextArg = args[args.indexOf(migrationFlag) + 1];
|
||||
return nextArg === "true";
|
||||
}
|
||||
|
||||
return value.toLowerCase() === "true";
|
||||
} catch (err) {
|
||||
logger.error(err, `Failed to check migration mode`);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
// Some of the functions are taken from https://github.com/rayepps/radash
|
||||
// Full credits goes to https://github.com/rayapps to those functions
|
||||
// Code taken to keep in in house and to adjust somethings for our needs
|
||||
export * from "./argv";
|
||||
export * from "./array";
|
||||
export * from "./dates";
|
||||
export * from "./object";
|
||||
|
||||
Reference in New Issue
Block a user