[FEATURE] Working Prototype
This commit is contained in:
parent
2a191ec913
commit
70168074dc
2 changed files with 94 additions and 47 deletions
|
@ -4,39 +4,49 @@ import rls from "readline-sync";
|
|||
const configFilePath = `${os.homedir()}/.infisical-env.config.json`;
|
||||
|
||||
const configTemplate = {
|
||||
projects: [],
|
||||
storeTokens: false,
|
||||
infisicalInstance: "https://app.infisical.com"
|
||||
projects: [
|
||||
{
|
||||
name: "proj1",
|
||||
environments: [
|
||||
{
|
||||
slug: "prod",
|
||||
envar: "INFISICAL_PROJ1_PROD_READ_TOKEN",
|
||||
paths: ["/", "/database"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
storeTokens: false,
|
||||
infisicalInstance: "https://app.infisical.com",
|
||||
};
|
||||
|
||||
export function loadConfig() {
|
||||
return JSON.parse(fs.readFileSync(configFilePath));
|
||||
}
|
||||
|
||||
export function loadConfig(){
|
||||
return JSON.parse(fs.readFileSync(configFilePath));
|
||||
export function upsertConfig() {
|
||||
if (fs.existsSync(configFilePath)) return;
|
||||
generateConfig();
|
||||
}
|
||||
|
||||
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 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){
|
||||
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");
|
||||
}
|
||||
}
|
||||
console.log({infisicalInstance: url, storeTokens: store});
|
||||
|
||||
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