Browse Source

Fixes for elxr use and prompts

master
guest 2 years ago
parent
commit
722dcfd066
2 changed files with 19 additions and 11 deletions
  1. 2
    1
      cliverse.js
  2. 17
    10
      index.js

+ 2
- 1
cliverse.js View File

var prompt = function(choices, label, defaultchoice){ var prompt = function(choices, label, defaultchoice){
// prompt accepts either an array or an object as choices. // prompt accepts either an array or an object as choices.
var choices = choices || []; var choices = choices || [];
defaultchoice = defaultchoice || choices[0] || choices[Object.keys(choices)[0]]
return this.prompter.ask( return this.prompter.ask(
`${label} \n` + Object.keys(choices).map(choice => { return ` ${(+choice) + 1}) ${choices[choice]} `}).join('\n') + `\n default ( <= ${ defaultchoice || choices[0]} ) : `
`${label} \n` + Object.keys(choices).map(choice => { var choice_label = isNaN(+choice) ? choice : choice; return ` ${choice_label}) ${choices[choice]} `}).join('\n') + `\n default ( <= ${ defaultchoice || choices[0]} ) : `
).then(choice => { ).then(choice => {
// propName = promptable.interpret(propValue) // propName = promptable.interpret(propValue)
if(!choice) return defaultchoice || choices[0]; if(!choice) return defaultchoice || choices[0];

+ 17
- 10
index.js View File

env: process.env env: process.env
, cwd: instanceroot + '/' + repo , cwd: instanceroot + '/' + repo
, runas: processedArgs.runas , runas: processedArgs.runas
, title: `'git', ${['config', '--replace-all', 'user.name', username].join(' ')}`
, title: `'git', ${['config', '--replace-all', 'user.name', selectedinstance.username].join(' ')}`
}) })
.then(() => { .then(() => {
if (__isElevated) { if (__isElevated) {
} }


if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${owner}/${configrepo}.git/' not found`))){ if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${owner}/${configrepo}.git/' not found`))){
return cli.prompt( { i : 'install new instance with this name locally'
, f : 'fork a new instance for yourself from another instance'
, o : 'fork a new instance for your organization' // prompt organization name...
, c : 'create a custom personal instance for this node' // prompt hostname as nodename
, p : 'create a custom personal instance'
return cli.prompt( {
t : 'install a new temporary local instance with this name'
, i : 'create a new instance with this name => will fork the default config under your username'
, f : 'fork a new instance with this name for yourself for this node from another instance'
, o : 'fork a new instance with this name for your organization from another instance' // prompt organization name...
, c : 'create a custom config for yourself for this node' // prompt hostname as nodename
, p : 'create a custom config for yourself '
, e : 'exit'} , e : 'exit'}
, 'Config for instance not found. Would you like to ', 'e' ).then(propValue => { , 'Config for instance not found. Would you like to ', 'e' ).then(propValue => {
if(propValue === 'i') return eNotImplemented() // return createLocalChessInsance(selectedinstance)
if(propValue === 'f') return eNotImplemented() // return createChessInstance(selectedinstance)
if(propValue === 't') return eNotImplemented()
if(propValue === 'i') return eNotImplemented()
if(propValue === 'f') return eNotImplemented()
if(propValue === 'o') return eNotImplemented()
if(propValue === 'c') return eNotImplemented() // return createLocalChessInsance(selectedinstance)
if(propValue === 'p') return eNotImplemented() // return createChessInstance(selectedinstance)
// if(propValue === 'o') createChessInstance(selectedinstance, orgname) // if(propValue === 'o') createChessInstance(selectedinstance, orgname)
else process.exit() else process.exit()
}) })


function createLocalChessInstance( cfg ){ function createLocalChessInstance( cfg ){
// return createInstance(cfg) // return createInstance(cfg)
reconfirm = getReconfirmAll()
var inst = {}; var inst = {};
var __new = Object.assign({}, /*__default,*/ cfg)
var __new = Object.assign({}, __default, cfg)
inst[cfg.node_env] = __new; return inst; inst[cfg.node_env] = __new; return inst;
} }



Loading…
Cancel
Save