[INIT] Initial Flow
This commit is contained in:
commit
2a191ec913
5 changed files with 641 additions and 0 deletions
42
configurator.js
Normal file
42
configurator.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
import os from "node:os";
|
||||
import fs from "node:fs";
|
||||
import rls from "readline-sync";
|
||||
const configFilePath = `${os.homedir()}/.infisical-env.config.json`;
|
||||
|
||||
const configTemplate = {
|
||||
projects: [],
|
||||
storeTokens: false,
|
||||
infisicalInstance: "https://app.infisical.com"
|
||||
}
|
||||
|
||||
export function loadConfig(){
|
||||
return JSON.parse(fs.readFileSync(configFilePath));
|
||||
}
|
||||
|
||||
export function upsertConfig(){
|
||||
if(fs.existsSync(configFilePath)) return;
|
||||
generateConfig();
|
||||
}
|
||||
|
||||
export function writeConfig(overrides){
|
||||
const config = {...configTemplate, ...overrides};
|
||||
fs.writeFileSync(configFilePath, JSON.stringify(config));
|
||||
}
|
||||
|
||||
export function generateConfig(){
|
||||
const url = rls.question("Infisical Instance: ");
|
||||
const store = rls.keyInYNStrict("Store Tokens? (Will Be Unencrypted)");
|
||||
const projectOptions = ["Add Project", "Exit"];
|
||||
const envOptions = ["Add Environment", "Exit"];
|
||||
const pathOptions = ["Add Path", "Exit"];
|
||||
var opt;
|
||||
projLoop: while(1){
|
||||
opt = rls.keyInSelect(projectOptions, "Select");
|
||||
if(opt !== 1) break projLoop;
|
||||
envLoop: while(1){
|
||||
opt = rls.keyInSelect(projectOptions, "Select");
|
||||
}
|
||||
}
|
||||
console.log({infisicalInstance: url, storeTokens: store});
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue