|  |  | @@ -65,13 +65,36 @@ console.dir(processedArgs) | 
		
	
		
			
			|  |  |  | //   } | 
		
	
		
			
			|  |  |  | // }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var clioverrides = { } | 
		
	
		
			
			|  |  |  | processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null; | 
		
	
		
			
			|  |  |  | processedArgs.node_env ? clioverrides.node_env = processedArgs.node_env | 
		
	
		
			
			|  |  |  | : (process.env.NODE_ENV && process.env.NODE_ENV.trim()) | 
		
	
		
			
			|  |  |  | ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) : null; | 
		
	
		
			
			|  |  |  | var subcommandlabels = { | 
		
	
		
			
			|  |  |  | remote : (`remote ${processedArgs._[1] || ''}`).trim() | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var interpretrun = function(){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var cmds = { | 
		
	
		
			
			|  |  |  | 'remote' : function() { | 
		
	
		
			
			|  |  |  | return { cmd : subcommandlabels['remote'], runchoice : 'c' } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var cmd = processedArgs._[0]; | 
		
	
		
			
			|  |  |  | var clioverrides = { cmd } | 
		
	
		
			
			|  |  |  | processedArgs.node_env ? clioverrides.node_env = processedArgs.node_env | 
		
	
		
			
			|  |  |  | : (process.env.NODE_ENV && process.env.NODE_ENV.trim()) | 
		
	
		
			
			|  |  |  | ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) : null; | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | return cmds[cmd] ? cmds[cmd]() : (function(){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null; | 
		
	
		
			
			|  |  |  | return clioverrides | 
		
	
		
			
			|  |  |  | })() | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | Object.keys(clioverrides).forEach( prop => { }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var clioverrides = interpretrun() | 
		
	
		
			
			|  |  |  | console.dir(clioverrides) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // Object.keys(clioverrides).forEach( prop => { }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var globSync = require('glob').sync; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
			|  |  | @@ -81,14 +104,14 @@ const { readdir } = require("fs").promises | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // Directory shallow walk and do perform on each dir. | 
		
	
		
			
			|  |  |  | const dirs = async (perform, path) => { | 
		
	
		
			
			|  |  |  | for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) { | 
		
	
		
			
			|  |  |  | for (const dir of await readdir(path || selectedinstance.root, { withFileTypes: true })) { | 
		
	
		
			
			|  |  |  | if (dir.isDirectory()) perform(dir) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var getShellTask = (command, args, options) => { | 
		
	
		
			
			|  |  |  | options = options || {} | 
		
	
		
			
			|  |  |  | var callshell = command === 'rm' ? callgitbashtask : callsheltask; | 
		
	
		
			
			|  |  |  | var callshell = command === 'rm' ? getgitbashtask : getshelltask; | 
		
	
		
			
			|  |  |  | return () => { | 
		
	
		
			
			|  |  |  | var p = callshell( [command, args, Object.assign({ | 
		
	
		
			
			|  |  |  | inherit: true, shell: true, env: ENV, title: `${command} ${args}` | 
		
	
	
		
			
			|  |  | @@ -103,9 +126,17 @@ var getShellTask = (command, args, options) => { | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var callsheltask = (args) => { | 
		
	
		
			
			|  |  |  | return args[0] === 'rm' ? callgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } } | 
		
	
		
			
			|  |  |  | var callgitbashtask = (args) => { return () => { | 
		
	
		
			
			|  |  |  | var callshelltask = (args) => { | 
		
	
		
			
			|  |  |  | // console.dir(args) | 
		
	
		
			
			|  |  |  | if( Object.prototype.toString.call(args) === '[object Function]' ) { | 
		
	
		
			
			|  |  |  | return args; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | return  getshelltask(args)() | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var getshelltask = (args) => { | 
		
	
		
			
			|  |  |  | return args[0] === 'rm' ? getgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } } | 
		
	
		
			
			|  |  |  | var getgitbashtask = (args) => { return () => { | 
		
	
		
			
			|  |  |  | return nodeShellExec( `"${gitbash}"`, ['-c', `"${args[0]} ${args[1].join(' ')}"`], args[2]) } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
			|  |  | @@ -163,7 +194,7 @@ var gitops = { | 
		
	
		
			
			|  |  |  | var parameters = ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;'] | 
		
	
		
			
			|  |  |  | var cmd = [gitbash | 
		
	
		
			
			|  |  |  | , ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;'] | 
		
	
		
			
			|  |  |  | , { cwd: instanceroot + '/' + repo, title: 'pull all origins for ' + repo + ' ' + parameters.join(' ') }] | 
		
	
		
			
			|  |  |  | , { cwd: instanceroot + '/' + repo, title: 'discoverbranch for ' + repo + ' ' + parameters.join(' ') }] | 
		
	
		
			
			|  |  |  | return cmd | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
			|  |  | @@ -172,22 +203,23 @@ var getPullCmd = (repo, branch) => { | 
		
	
		
			
			|  |  |  | // console.log(useGitPull)var getPullCmd = (repo, branch) => { | 
		
	
		
			
			|  |  |  | // console.log(useGitPull) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var pullCmd = [] | 
		
	
		
			
			|  |  |  | if(!branch) { | 
		
	
		
			
			|  |  |  | // console.warn('No branch was specified detecting from working client.') | 
		
	
		
			
			|  |  |  | // First check if working client exists. | 
		
	
		
			
			|  |  |  | // if (existsSync(instanceroot + '/' + repo)) { | 
		
	
		
			
			|  |  |  | pullCmd= gitops.getdiscoverbranchcmd(repo) | 
		
	
		
			
			|  |  |  | // } | 
		
	
		
			
			|  |  |  | // else performpull | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // var pullCmd = [gitInstallDir | 
		
	
		
			
			|  |  |  | //   , ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;'] | 
		
	
		
			
			|  |  |  | //   , { cwd: instanceroot + '/' + repo, title: 'pull all origins for ' + repo }] | 
		
	
		
			
			|  |  |  | //   , { cwd: instanceroot + '/' + repo, title: 'pull all remotes for ' + repo }] | 
		
	
		
			
			|  |  |  | if(branch) { | 
		
	
		
			
			|  |  |  | var parameters = ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;'] | 
		
	
		
			
			|  |  |  | var pullCmd = [ gitbash | 
		
	
		
			
			|  |  |  | , ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;'] | 
		
	
		
			
			|  |  |  | , { cwd: instanceroot + '/' + repo, title : 'pull all origins for ' + branch + '  ' + repo + ' ' + parameters.join(' ') }] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | else { | 
		
	
		
			
			|  |  |  | // console.warn('No branch was specified detecting from working client.') | 
		
	
		
			
			|  |  |  | // First check if working client exits. | 
		
	
		
			
			|  |  |  | // if (existsSync(instanceroot + '/' + repo)) { | 
		
	
		
			
			|  |  |  | var pullCmd = gitops.getdiscoverbranchcmd(repo) | 
		
	
		
			
			|  |  |  | // } | 
		
	
		
			
			|  |  |  | // else performpull | 
		
	
		
			
			|  |  |  | , { cwd: instanceroot + '/' + repo, title : 'pull all remotes for ' + branch + '  ' + repo + ' ' + parameters.join(' ') }] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // var pullCmd = ['pullall', [], { cwd : repo }] | 
		
	
		
			
			|  |  |  | if (useGitPull) pullCmd = ['git', ['pull'], { | 
		
	
	
		
			
			|  |  | @@ -466,9 +498,10 @@ var op = { | 
		
	
		
			
			|  |  |  | Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; }) | 
		
	
		
			
			|  |  |  | // PB : TODO -- Convert all the cli args back to string. | 
		
	
		
			
			|  |  |  | var args = [`${selectedinstance.root}/.elxr/run-${runtimestamp}/windowselevate.hta`].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self'); | 
		
	
		
			
			|  |  |  | args.push('--nodepath=' + r[r.length - 1]) | 
		
	
		
			
			|  |  |  | if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV) | 
		
	
		
			
			|  |  |  | if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated.. | 
		
	
		
			
			|  |  |  | // args.push('--nodepath=' + r.messages[r.messages.length - 1]) | 
		
	
		
			
			|  |  |  | // if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV) | 
		
	
		
			
			|  |  |  | // if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated.. | 
		
	
		
			
			|  |  |  | console.dir(processedArgs) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return nodeShellExec('MSHTA', [`"${args.join('" "')}"`] | 
		
	
		
			
			|  |  |  | , { | 
		
	
	
		
			
			|  |  | @@ -577,6 +610,7 @@ var op = { | 
		
	
		
			
			|  |  |  | , 'remote': (args) => { | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // Subcommands! | 
		
	
		
			
			|  |  |  | // PB : TODO -- we can now pass in hypehnated args... | 
		
	
		
			
			|  |  |  | if(!processedArgs.v) return false; // Only -v is supported presently.. | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var serial_perform = (repo) => { | 
		
	
	
		
			
			|  |  | @@ -663,9 +697,132 @@ var op = { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | dirs(perform_git_seturl) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | , 'reset' : ()=>{ | 
		
	
		
			
			|  |  |  | // Reset the whole installation pertaining to this elxr folder. | 
		
	
		
			
			|  |  |  | // , 'reset' : ()=>{ | 
		
	
		
			
			|  |  |  | // PB : TODO -- Cant have 2 resets !! | There is an npm reset that should be bundled. | 
		
	
		
			
			|  |  |  | //   // Reset the whole installation pertaining to this elxr folder. | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | , 'remote exists': (args) => { | 
		
	
		
			
			|  |  |  | var __args = { | 
		
	
		
			
			|  |  |  | remotename : args.remotename|| processedArgs._[2] | 
		
	
		
			
			|  |  |  | , url : args.url || processedArgs._[3] | 
		
	
		
			
			|  |  |  | , branch : args.branch || processedArgs._[4] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var options = args.repo ? { cwd: instanceroot + '/' + args.repo } : {} | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // PB : TODO -- We should evaluate a whole list of remotes passed in from args instead of just one. | 
		
	
		
			
			|  |  |  | var commands = [ | 
		
	
		
			
			|  |  |  | // git remote -v| while read remote; do "${remote#origin/}" "$remote"; done | 
		
	
		
			
			|  |  |  | // ['git', ['remote', '-v', '| while read remote; do "${remote#origin/}" "$remote"; done'], utils.assign( { | 
		
	
		
			
			|  |  |  | ['git', ['remote', '-v'], utils.assign( { | 
		
	
		
			
			|  |  |  | evaluateResult : function(err, result){ | 
		
	
		
			
			|  |  |  | // var found = result.messages.find( (r)=> { return r.includes( __args.remotename )  }) | 
		
	
		
			
			|  |  |  | var remotes = [] | 
		
	
		
			
			|  |  |  | var found = false; | 
		
	
		
			
			|  |  |  | console.dir(result.messages) | 
		
	
		
			
			|  |  |  | console.log(result + '---------------') | 
		
	
		
			
			|  |  |  | result.messages.forEach( (line)=> { | 
		
	
		
			
			|  |  |  | console.log(line + '$$$$$$$$$$$$$$$$$$$$') | 
		
	
		
			
			|  |  |  | var matches = line.match(/(.*)?\s\s([^\(]*)?\s?\(?([^\)]*)\)?/); | 
		
	
		
			
			|  |  |  | if(matches) { | 
		
	
		
			
			|  |  |  | var remote = {}; | 
		
	
		
			
			|  |  |  | remote[matches[1]] = matches[2]; | 
		
	
		
			
			|  |  |  | if( (!matches[3].trim() ||  matches[3].trim() === 'fetch') && matches[1].trim() === remotename.trim()) { | 
		
	
		
			
			|  |  |  | found = true; | 
		
	
		
			
			|  |  |  | result.url = remote[remotename]; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | console.dir(remotes) | 
		
	
		
			
			|  |  |  | return [ | 
		
	
		
			
			|  |  |  | found | 
		
	
		
			
			|  |  |  | , result | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } , options) ] | 
		
	
		
			
			|  |  |  | , function(prevserialtaskresult) { | 
		
	
		
			
			|  |  |  | console.log('================================') | 
		
	
		
			
			|  |  |  | var url = __args || prevserialtaskresult.url; | 
		
	
		
			
			|  |  |  | console.dir(prevserialtaskresult) | 
		
	
		
			
			|  |  |  | return getshelltask(['git', ['ls-remote', url], utils.assign( { | 
		
	
		
			
			|  |  |  | evaluateResult : function(err, result){ | 
		
	
		
			
			|  |  |  | // fatal: unable to access '${__args.url}/': Failed to connect to git.bbh port 80 after 21025 ms: Timed out | 
		
	
		
			
			|  |  |  | // `fatal: repository '${__args.url}/' not found` | 
		
	
		
			
			|  |  |  | var hasfailed = /^fatal: .*/.test(result.messages.join(' ')) | 
		
	
		
			
			|  |  |  | return [ | 
		
	
		
			
			|  |  |  | !hasfailed, result | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } , options) ])() | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | var mapped = commands.map(callshelltask)  //.map( p => p.catch(e => e)) // Handle errors later. | 
		
	
		
			
			|  |  |  | return any(mapped).then( allresolved =>{ | 
		
	
		
			
			|  |  |  | console.dir(allresolved) | 
		
	
		
			
			|  |  |  | !allresolved[0][0] && !allresolved[1][0] ? console.log('was not added as a remote and url is currently inaccessible.') | 
		
	
		
			
			|  |  |  | : allresolved[0][0] && allresolved[1][0] ? console.log('was added as a remote and url is accessible.') | 
		
	
		
			
			|  |  |  | : allresolved[0][0] && !allresolved[1][0] ? console.log('was added as a remote but url is currently inaccessible.') | 
		
	
		
			
			|  |  |  | : console.log('was not added as a remote but url is currently accessible.') | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | return !allresolved[0][0] && !allresolved[1][0] ? [0, 0] | 
		
	
		
			
			|  |  |  | : allresolved[0][0] && allresolved[1][0] ? [1, 1]   // => was added as a remote and url is accessible. | 
		
	
		
			
			|  |  |  | : allresolved[0][0] && !allresolved[1][0] ? [1, 0]  // => was added as a remote but url is currently inaccessible. | 
		
	
		
			
			|  |  |  | : [0, 1]  // => was not added and remote and url is accessible. | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | , 'remote refresh': (args) => { | 
		
	
		
			
			|  |  |  | var __args = { | 
		
	
		
			
			|  |  |  | remotename : args.remotename|| processedArgs._[2] | 
		
	
		
			
			|  |  |  | , url : args.url || processedArgs._[3] | 
		
	
		
			
			|  |  |  | , branch : args.branch || processedArgs._[4] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // use the repo manifest to create missing remotes. | 
		
	
		
			
			|  |  |  | function perform_remote_refresh(dir){ | 
		
	
		
			
			|  |  |  | var repo = dir.name | 
		
	
		
			
			|  |  |  | var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo) | 
		
	
		
			
			|  |  |  | try { | 
		
	
		
			
			|  |  |  | var remotes = require(`${selectedinstance.root}/${dir.name}/repo-manifest.js`)( null, selectedinstance).remotes || []; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | catch(e){ | 
		
	
		
			
			|  |  |  | var remotes = [] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // console.log(`${dir.name}/repo-manifest.js` + '---------------------------') | 
		
	
		
			
			|  |  |  | // console.dir(remotes) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return nodeShellExec.apply(null, dscoverbranchcmd).then(__branch=>{ | 
		
	
		
			
			|  |  |  | console.log('Processing : ' + dir.name) | 
		
	
		
			
			|  |  |  | var branch = __branch | 
		
	
		
			
			|  |  |  | __args.repo = repo | 
		
	
		
			
			|  |  |  | __args.branch = __branch | 
		
	
		
			
			|  |  |  | var promises = [] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | remotes.forEach(remote =>{ | 
		
	
		
			
			|  |  |  | Object.keys(remote).forEach(remotename => { | 
		
	
		
			
			|  |  |  | __args.remotename = remotename | 
		
	
		
			
			|  |  |  | __args.url = remote[remotename] | 
		
	
		
			
			|  |  |  | promises.push( op['remote exists']( __args ).then( exists => { | 
		
	
		
			
			|  |  |  | if(!exists[0]) { | 
		
	
		
			
			|  |  |  | if(!exists[1]) { console.error( `Skipping inaccessible remote url ${__args.url}` ) } | 
		
	
		
			
			|  |  |  | else return op['remote add']( { remotename, | 
		
	
		
			
			|  |  |  | // PB : TODO -- use the most accessible remote instead of the first available. | 
		
	
		
			
			|  |  |  | url : (utils.js.isArray(remote[remotename]) ? remote[remotename][0] : remote[remotename]), branch | 
		
	
		
			
			|  |  |  | } ) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | ) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return Promise.all(promises) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .catch((e) => { console.log('Processing Error : ' + dir.name); console.error(e); return { error: true, message: repo } }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | return dirs(perform_remote_refresh) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | , 'remote add': (args) => { | 
		
	
		
			
			|  |  |  | // PB : TODO -- set-upstream-to should be chosen and intentionally switched. Coz we can have multiple upstream remotes. | 
		
	
	
		
			
			|  |  | @@ -870,7 +1027,7 @@ var op = { | 
		
	
		
			
			|  |  |  | // , ['git', ['commit', '-a', '-m', `relocate folder ${args.folder} to ${targetrepo}`], sourcerepooptions ] | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(callsheltask)) | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(getshelltask)) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }).catch(e=>{console.error(e)}) | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
			|  |  | @@ -904,13 +1061,13 @@ var op = { | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | var cmdseq = [ | 
		
	
		
			
			|  |  |  | // create a temporary working dir in current folder where we started execution. | 
		
	
		
			
			|  |  |  | ['mkdir', [ '-p', 'relocate']] | 
		
	
		
			
			|  |  |  | ['mkdir', [ '-p', `${instanceroot}/relocate`]] | 
		
	
		
			
			|  |  |  | , ['git', ['clone', `${args.remotebase}${args.sourcerepo}`], options ] | 
		
	
		
			
			|  |  |  | , ['git', ['clone', `${args.sourcerepo}`, `relocate-${args.sourcerepo}-${args.folder}`], options] | 
		
	
		
			
			|  |  |  | , ['git', ['clone', `${args.remotebase}${args.targetrepo}`, `relocate-${args.targetrepo}-${args.folder}`], options] | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(callsheltask)).then(() => { | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(getshelltask)).then(() => { | 
		
	
		
			
			|  |  |  | // , ['git', ['subtree', 'split', '-P', `${args.folder}`, '-b', `relocate-${args.sourcerepo}-${args.folder}`], sourcerepooptions] | 
		
	
		
			
			|  |  |  | // split doesnt retain folder structure we need to move and commit ourselves through a branch to retain history... | 
		
	
		
			
			|  |  |  | // , ['git', [`checkout relocate-${args.sourcerepo}-${args.folder}`], sourcerepooptions] | 
		
	
	
		
			
			|  |  | @@ -953,7 +1110,7 @@ var op = { | 
		
	
		
			
			|  |  |  | , targetrepooptions ] | 
		
	
		
			
			|  |  |  | // , ['git', ['push', targetrepooptions ] // manual push for now.. | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(callsheltask)).catch(e=>{console.error(e)}) | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(getshelltask)).catch(e=>{console.error(e)}) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | , 'filter-repo' : function(args){ | 
		
	
	
		
			
			|  |  | @@ -975,7 +1132,7 @@ var op = { | 
		
	
		
			
			|  |  |  | // git remote add src-project ../src-project | 
		
	
		
			
			|  |  |  | ['git', ['filter-repo', '--path', `${args.folder}`], targetrepooptions ] | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(callsheltask)).catch(e=>{console.error(e); throw 'failed' }) | 
		
	
		
			
			|  |  |  | return any(cmdseq.map(getshelltask)).catch(e=>{console.error(e); throw 'failed' }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | , 'filter-branch' : function(preservefolder, repo){ | 
		
	
	
		
			
			|  |  | @@ -1109,7 +1266,7 @@ var op = { | 
		
	
		
			
			|  |  |  | ) ) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var npmbuildrepos = ['loopback-jsonapi-model-serializer'] | 
		
	
		
			
			|  |  |  | npmbuildrepos = [] | 
		
	
		
			
			|  |  |  | // npmbuildrepos = [] | 
		
	
		
			
			|  |  |  | npmbuildrepos.forEach(repo => { | 
		
	
		
			
			|  |  |  | tasks.push(() => { | 
		
	
		
			
			|  |  |  | return nodeShellExec('npm', ['i --force'], { | 
		
	
	
		
			
			|  |  | @@ -1131,9 +1288,9 @@ var op = { | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | any(tasks).then(() => { | 
		
	
		
			
			|  |  |  | return any(tasks).then(() => { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | gitRepos.push('client/server'); | 
		
	
		
			
			|  |  |  | gitRepos.push('chess-server-lib/server'); | 
		
	
		
			
			|  |  |  | gitRepos = gitRepos.concat(elevatedRunasRepos); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // gitRepos = [ | 
		
	
	
		
			
			|  |  | @@ -1146,17 +1303,16 @@ var op = { | 
		
	
		
			
			|  |  |  | var env = Object.assign({}, process.env) | 
		
	
		
			
			|  |  |  | delete env.NODE_ENV | 
		
	
		
			
			|  |  |  | gitRepos.forEach(repodef => { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | rmtasks.push( | 
		
	
		
			
			|  |  |  | // () => { | 
		
	
		
			
			|  |  |  | // console.log(`--rm package-lock.json for ${repodef.repo}--------------------`) | 
		
	
		
			
			|  |  |  | // return nodeShellExec(`"${gitbash}"`, ['-c', '"rm  package-lock.json"'], { | 
		
	
		
			
			|  |  |  | (callShellTask(['rm', ['package-lock.json'], { | 
		
	
		
			
			|  |  |  | callshelltask(['rm', ['package-lock.json'], { | 
		
	
		
			
			|  |  |  | inherit: true, shell: true | 
		
	
		
			
			|  |  |  | , cwd: instanceroot + '/' + repodef.repo | 
		
	
		
			
			|  |  |  | , env: process.env | 
		
	
		
			
			|  |  |  | , title: `rm 'package-lock.json' for ${repodef.repo}` | 
		
	
		
			
			|  |  |  | }]))() | 
		
	
		
			
			|  |  |  | }]) | 
		
	
		
			
			|  |  |  | .then(()=>{ | 
		
	
		
			
			|  |  |  | console.log(`--rm package-lock.json for ${repodef.repo}--------------------`) | 
		
	
		
			
			|  |  |  | }).catch((e) => { console.error(e) }) | 
		
	
	
		
			
			|  |  | @@ -1216,7 +1372,7 @@ var op = { | 
		
	
		
			
			|  |  |  | // console.log('rmtasks.length : ' + rmtasks.length) | 
		
	
		
			
			|  |  |  | return Promise.all(rmtasks).then(() => any(repotasks)); | 
		
	
		
			
			|  |  |  | }).catch(e => { | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | console.error(e) | 
		
	
		
			
			|  |  |  | }).finally(statuslog.finally) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
			|  |  | @@ -1346,7 +1502,9 @@ var op = { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | console.log(`No change detected. Already using requested specs : ${runconfig.NODE_ENV} ${runconfig.use}`) | 
		
	
		
			
			|  |  |  | if (processedArgs.runas) { fs.writeFileSync('run.done', 'success') } | 
		
	
		
			
			|  |  |  | return | 
		
	
		
			
			|  |  |  | if (existsSync('config') && existsSync('data')){ | 
		
	
		
			
			|  |  |  | return | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var tasks = [ | 
		
	
	
		
			
			|  |  | @@ -1383,7 +1541,7 @@ var op = { | 
		
	
		
			
			|  |  |  | if (!branch) { | 
		
	
		
			
			|  |  |  | var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | promise = nodeShellExec.apply(null, dscoverbranchcmd(repo)).then(__branch=>{ branch = __branch}) | 
		
	
		
			
			|  |  |  | promise = nodeShellExec.apply(null, dscoverbranchcmd).then(__branch=>{ branch = __branch}) | 
		
	
		
			
			|  |  |  | .catch((e) => { console.error(e); return { error: true, message: repo } }) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
			|  |  | @@ -1434,7 +1592,7 @@ var op = { | 
		
	
		
			
			|  |  |  | // Checkout is reduced to pull provided the current branch is the targetbranch | 
		
	
		
			
			|  |  |  | if(branch === mergesource) performCheckout = (def) => { | 
		
	
		
			
			|  |  |  | var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo) | 
		
	
		
			
			|  |  |  | return nodeShellExec.apply(null, dscoverbranchcmd(repo)).then(__branch=>{ | 
		
	
		
			
			|  |  |  | return nodeShellExec.apply(null, dscoverbranchcmd).then(__branch=>{ | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | if(branch === __branch) return performCloneAndCheckout(def) | 
		
	
		
			
			|  |  |  | return performPullOrCloneForBranch(def) | 
		
	
	
		
			
			|  |  | @@ -1749,14 +1907,44 @@ var elxr = { | 
		
	
		
			
			|  |  |  | ------------------------------------------------------------------------------- | 
		
	
		
			
			|  |  |  | `) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | , getpulltask(def){ | 
		
	
		
			
			|  |  |  | , getpulltask(args){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // def can be an instance config | 
		
	
		
			
			|  |  |  | // Or an object with many repos and elevated repos | 
		
	
		
			
			|  |  |  | // Or a single repo ( Either Elevated or normal. ) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // USAGE | 
		
	
		
			
			|  |  |  | // elxr pull elixir origin master | 
		
	
		
			
			|  |  |  | // elxr pull | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // not all remote branches are setup to be tracked locally (respective remotes and branches). | 
		
	
		
			
			|  |  |  | // pull --all is useless. As it fetches all remotes and branches but only merges current branch. | 
		
	
		
			
			|  |  |  | // apart from remote tracking branches We are interested in pulling from all remotes and relavant branches. | 
		
	
		
			
			|  |  |  | // The branch pipline should feed back to master | 
		
	
		
			
			|  |  |  | //   master -> test -> stage -> release[nnnn] -> production | 
		
	
		
			
			|  |  |  | //   (master) <= git merge [all remotes] production && git merge [all remotes] release[nnnn] | 
		
	
		
			
			|  |  |  | // git merge [all remotes] stage && git merge [all remotes] test  && git merge [all remotes] master | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | def = def || { | 
		
	
		
			
			|  |  |  | var __args = { | 
		
	
		
			
			|  |  |  | remotename : args.remotename|| processedArgs._[2] | 
		
	
		
			
			|  |  |  | , url : args.url || processedArgs._[3] | 
		
	
		
			
			|  |  |  | , branch : args.branch || processedArgs._[4]  // If branch not specified opearte on the current branch of each working directorys | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // var commands = [ | 
		
	
		
			
			|  |  |  | //     // ['git', ['checkout', __args.branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]] | 
		
	
		
			
			|  |  |  | //   , | 
		
	
		
			
			|  |  |  | // ] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // var parameters = ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;'] | 
		
	
		
			
			|  |  |  | // var pullCmd = [ gitbash | 
		
	
		
			
			|  |  |  | //   , ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;'] | 
		
	
		
			
			|  |  |  | //   , { cwd: instanceroot + '/' + repo, title : 'pull all remotes for ' + branch + '  ' + repo + ' ' + parameters.join(' ') }] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var def = args || { | 
		
	
		
			
			|  |  |  | repos : selectedinstance.repos, | 
		
	
		
			
			|  |  |  | elevated : selectedinstance.elevated | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
			|  |  | @@ -1845,9 +2033,6 @@ function preworkerconfig(){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // The main elxr cli process | 
		
	
		
			
			|  |  |  | function elxrworker() { | 
		
	
		
			
			|  |  |  | var subcommandlabels = { | 
		
	
		
			
			|  |  |  | remote : (`remote ${processedArgs._[1] || ''}`).trim() | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var __runcmd = function (label) { | 
		
	
		
			
			|  |  |  | var distinquishedlabel = subcommandlabels[label] || label | 
		
	
	
		
			
			|  |  | @@ -2178,13 +2363,18 @@ var detectinstances = function () { | 
		
	
		
			
			|  |  |  | instanceroot = detected.root | 
		
	
		
			
			|  |  |  | __default.root = root; | 
		
	
		
			
			|  |  |  | clioverrides.root = clioverrides.root || root; | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // Resolves empty array when No known instances detected. | 
		
	
		
			
			|  |  |  | return Promise.resolve(instanceoptions) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if(clioverrides.reconfirm) { | 
		
	
		
			
			|  |  |  | var reconfirm = { 'instanceName' : clioverrides['instanceName'] === 'chess' } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | else { var reconfirm = {}; } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) { | 
		
	
		
			
			|  |  |  | return function(prompts, k, i, a){ | 
		
	
		
			
			|  |  |  |  | 
		
	
	
		
			
			|  |  | @@ -2209,7 +2399,7 @@ var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) { | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var __interactve_promts = function( target, choices ){ | 
		
	
		
			
			|  |  |  | var __interactive_prompts = function( target, choices ){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | Object.defineProperty(target, 'node_env', { get : function(){ return this.instanceType } }); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
			|  |  | @@ -2268,6 +2458,7 @@ var __interactve_promts = function( target, choices ){ | 
		
	
		
			
			|  |  |  | , instanceName : { label : `Enter Instance Name ( <= ${target.instanceName || 'chess'} ) : `, choices : [], defaultchoice : 'chess'} | 
		
	
		
			
			|  |  |  | , instanceType : { label : `Enter Instance Type ( <= ${target.instanceType || 'development'} ) : `, choices : [], defaultchoice : 'development'} | 
		
	
		
			
			|  |  |  | , reposerver   : { label : `Enter Instance Name ( <= ${target.reposerver || 'https://git.bbh.org.in'} ) : `, choices : [], defaultchoice : 'https://git.bbh.org.in'} | 
		
	
		
			
			|  |  |  | , repouser   : { label : `Enter User Id for ${target.reposerver} ( <= ${target.repouser || 'chess'} ) : `, choices : [], defaultchoice : 'chess'} | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var eachPrompt = getBoundEachPrompt( target, promptkeys, interactionpoints, choices) | 
		
	
	
		
			
			|  |  | @@ -2303,7 +2494,7 @@ var prerequisites = [ | 
		
	
		
			
			|  |  |  | return any([any(steps), any(prompts)]) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | , installsteps: function () { | 
		
	
		
			
			|  |  |  | return any([this.installcmd].map(callsheltask)) | 
		
	
		
			
			|  |  |  | return any([this.installcmd].map(getshelltask)) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | , postinstallsteps: function(){ | 
		
	
		
			
			|  |  |  |  | 
		
	
	
		
			
			|  |  | @@ -2331,7 +2522,7 @@ var prerequisites = [ | 
		
	
		
			
			|  |  |  | ['git', ['config', '--global', '--add', 'user.name', `${gitUser}`]] | 
		
	
		
			
			|  |  |  | , ['git', ['config', '--global', '--add', 'user.email', `${gitEmail}`]] | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | return any(steps.map(callsheltask)).then(() => { | 
		
	
		
			
			|  |  |  | return any(steps.map(getshelltask)).then(() => { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }); | 
		
	
	
		
			
			|  |  | @@ -2342,7 +2533,7 @@ var prerequisites = [ | 
		
	
		
			
			|  |  |  | , verifyAndInstall : function(){ | 
		
	
		
			
			|  |  |  | return getTaskCheckExists(this.shellcmd, { ignorefailures: true })().then((exists) => { | 
		
	
		
			
			|  |  |  | if(exists) { | 
		
	
		
			
			|  |  |  | // return any(['git', ['config', '--global', '-l']].map(callsheltask)) | 
		
	
		
			
			|  |  |  | // return any(['git', ['config', '--global', '-l']].map(getshelltask)) | 
		
	
		
			
			|  |  |  | return this.getUser(null, this.postinstallsteps.bind(this)) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | return this.install(); | 
		
	
	
		
			
			|  |  | @@ -2356,7 +2547,7 @@ var prerequisites = [ | 
		
	
		
			
			|  |  |  | if(!repo) globalOrLocal = '--global'; | 
		
	
		
			
			|  |  |  | else globalOrLocal = '--local' | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return any([['git', ['config', globalOrLocal, '--get-all', 'user.name']]].map(callsheltask)).then((result)=>{ | 
		
	
		
			
			|  |  |  | return any([['git', ['config', globalOrLocal, '--get-all', 'user.name']]].map(getshelltask)).then((result)=>{ | 
		
	
		
			
			|  |  |  | // not yet configured. | 
		
	
		
			
			|  |  |  | if(!result.success) return onNoResult() | 
		
	
		
			
			|  |  |  | else { | 
		
	
	
		
			
			|  |  | @@ -2383,7 +2574,7 @@ var prerequisites = [ | 
		
	
		
			
			|  |  |  | , installcmd: ['MSIEXEC.exe', ['/i' | 
		
	
		
			
			|  |  |  | , path.resolve(downloadsdir + '/' + 'node-v14.16.0-x64.msi') | 
		
	
		
			
			|  |  |  | , 'ACCEPT=YES', '/passive']] | 
		
	
		
			
			|  |  |  | , install : function() { return any([this.installcmd].map(callsheltask)).then(() => { }) } | 
		
	
		
			
			|  |  |  | , install : function() { return any([this.installcmd].map(getshelltask)).then(() => { }) } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
			|  |  | @@ -2649,7 +2840,7 @@ acquireElevationState().then(() => { | 
		
	
		
			
			|  |  |  | chessinstances[instanceName][node_env] | 
		
	
		
			
			|  |  |  | , clioverrides | 
		
	
		
			
			|  |  |  | , selected_overrides | 
		
	
		
			
			|  |  |  | // , __interactve_promts -- Cant just override. Also need selectedinstance to be ready... | 
		
	
		
			
			|  |  |  | // , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready... | 
		
	
		
			
			|  |  |  | ); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // chessinstances[instanceName] = chessinstances[instanceName] || {} | 
		
	
	
		
			
			|  |  | @@ -2719,12 +2910,12 @@ acquireElevationState().then(() => { | 
		
	
		
			
			|  |  |  | const retaincount = 2 | 
		
	
		
			
			|  |  |  | var min = runtimestamp; | 
		
	
		
			
			|  |  |  | var collect = [] | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | if(noprerequisites[processedArgs._[0]] | 
		
	
		
			
			|  |  |  | || skipprereqs[processedArgs._[0]] | 
		
	
		
			
			|  |  |  | ) { | 
		
	
		
			
			|  |  |  | return elxrworker() | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // if(noprerequisites[processedArgs._[0]] | 
		
	
		
			
			|  |  |  | //   || skipprereqs[processedArgs._[0]] | 
		
	
		
			
			|  |  |  | // ) { | 
		
	
		
			
			|  |  |  | //   return elxrworker() | 
		
	
		
			
			|  |  |  | // } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | var getchoices = function(detectedinstanceoptions, promptkeys){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
			|  |  | @@ -2745,7 +2936,7 @@ acquireElevationState().then(() => { | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | instances = instances.concat(detectedinstanceoptions) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if(promptkeys['instanceName']) instnaceNames.push(selectedinstance['instanceName']) | 
		
	
		
			
			|  |  |  | if(selectedinstance['instanceName']) instnaceNames.push(selectedinstance['instanceName']) | 
		
	
		
			
			|  |  |  | if(promptkeys['instanceName']) instnaceNames.push(promptkeys['instanceName']) | 
		
	
		
			
			|  |  |  | if(selectedinstance['reposervers'])  reposervers = reposervers.concat(selectedinstance['reposervers']) | 
		
	
		
			
			|  |  |  |  | 
		
	
	
		
			
			|  |  | @@ -2759,39 +2950,36 @@ acquireElevationState().then(() => { | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | return detectinstances().then((detectedinstanceoptions)=>{ | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | detectedinstanceoptions.splice(0,0, __default) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!! | 
		
	
		
			
			|  |  |  | selectedinstance = utils.assign( ...detectedinstanceoptions.slice(-2) ) | 
		
	
		
			
			|  |  |  | promptkeys = utils.assign(promptkeys, clioverrides) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | if(clioverrides.reconfirm) { | 
		
	
		
			
			|  |  |  | var reconfirm = { 'instanceName' : selectedinstance['instanceName'] === 'chess' } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | else { var reconfirm = {}; } | 
		
	
		
			
			|  |  |  | // promptkeys = utils.assign(promptkeys, clioverrides) | 
		
	
		
			
			|  |  |  | console.dir(selectedinstance) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | try { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | chessinstances = acquirelocalinstances(selectedinstance); | 
		
	
		
			
			|  |  |  | findlocalinstances(chessinstances, detectedinstanceoptions) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | initinstances(selectedinstance) // use the local instances for defaults if at all possible. | 
		
	
		
			
			|  |  |  | var choices = getchoices(detectedinstanceoptions, promptkeys) | 
		
	
		
			
			|  |  |  | var todo = any( __interactve_promts(selectedinstance, choices)  ).then(()=>{ | 
		
	
		
			
			|  |  |  | var todo = any( __interactive_prompts(selectedinstance, choices)  ).then(()=>{ | 
		
	
		
			
			|  |  |  | return initinstances(selectedinstance) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | catch (e) { | 
		
	
		
			
			|  |  |  | // PB : TODO -- verbose mode warning.. console.warn(e) // Missing chessinstances is not an error... | 
		
	
		
			
			|  |  |  | var choices = getchoices(detectedinstanceoptions, promptkeys) | 
		
	
		
			
			|  |  |  | var todo = any( __interactve_promts(selectedinstance, choices)  ).then(()=>{ | 
		
	
		
			
			|  |  |  | var todo = any( __interactive_prompts(selectedinstance, choices)  ).then(()=>{ | 
		
	
		
			
			|  |  |  | return initinstances(selectedinstance) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){ | 
		
	
		
			
			|  |  |  | // Weve not been told what to do. | 
		
	
		
			
			|  |  |  | todo = todo.then(() => { return acquireChoices(selectedinstance) }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){ | 
		
	
		
			
			|  |  |  | //   // Weve not been told what to do. | 
		
	
		
			
			|  |  |  | //   todo = todo.then(() => { return acquireChoices(selectedinstance) }) | 
		
	
		
			
			|  |  |  | // } | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | todo = todo.then(() => { | 
		
	
		
			
			|  |  |  | try { |