|
|
@@ -2332,7 +2332,8 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
interpret() { |
|
|
|
var interpreted = {} |
|
|
|
// Non custom command has universal positiona args. |
|
|
|
processedArgs._[1] ? interpreted.instanceName = processedArgs._[1]: null; |
|
|
|
interpreted.instanceName = processedArgs._[1] ? processedArgs._[1] : null; |
|
|
|
interpreted.runchoice = processedArgs._[0] || selectedinstance.runchoice; |
|
|
|
// return clioverrides |
|
|
|
// cmds[cmd] = { |
|
|
|
// interpret() { |
|
|
@@ -2348,7 +2349,9 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
, getPossiblePrompts(){ return { username : true, password : true, instanceName : true, instanceType : true, reposerver : true } } |
|
|
|
, cmdFn : ()=>{ throw "Elxr Unknown command."} |
|
|
|
, finalized : true |
|
|
|
, toArgs : function( o ){ return o } |
|
|
|
, toArgs : function( o ){ |
|
|
|
// PB : TODO -- need to call this before selectedinstance is built. The instanceName is dependent on the specific cmd. |
|
|
|
return o } |
|
|
|
} |
|
|
|
|
|
|
|
function __createO(o){ |
|
|
@@ -2383,6 +2386,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
return cmds[cmd].interpret() |
|
|
|
} |
|
|
|
|
|
|
|
var chessinstances = { current_run : {} }; |
|
|
|
var clioverrides = interpretrun() |
|
|
|
clioverrides = utils.assign( { cmd : processedArgs._[0], node_env : ENV.NODE_ENV, root : ENV.wd, instanceType : ENV.NODE_ENV } |
|
|
|
, clioverrides, cmds[clioverrides.cmd].toArgs(processedArgs), { root : ENV.wd } ) |
|
|
@@ -2396,7 +2400,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
var existinglocalinstances = { current_run : {}, error : true } |
|
|
|
} |
|
|
|
|
|
|
|
var chessinstances = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }, existinglocalinstances); |
|
|
|
chessinstances = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }, existinglocalinstances); |
|
|
|
// console.dir(chessinstances) |
|
|
|
return chessinstances |
|
|
|
} |
|
|
@@ -2408,7 +2412,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
var localinstancesPath = `${instanceroot}/${p}.elxr`; |
|
|
|
if(existsSync( localinstancesPath )) { |
|
|
|
try { |
|
|
|
var chessinstances = acquirelocalinstances( { root : `${instanceroot}/${p}` } ) |
|
|
|
acquirelocalinstances( { root : `${instanceroot}/${p}` } ) |
|
|
|
if(chessinstances.error) { |
|
|
|
delete chessinstances.error; delete chessinstances.e |
|
|
|
return {} |
|
|
@@ -2477,34 +2481,46 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
return utils.assign_core( { keycase : true, arraymergetype : utils.assign_core.DISTINCT_UNION }, { error : true, e }, moverrides) |
|
|
|
} |
|
|
|
} |
|
|
|
var getReconfirmAll = ()=>{return { instanceName : true, instanceType : true, reposerver : true, username : true, password : true } } |
|
|
|
|
|
|
|
var selectedinstance = (function() { |
|
|
|
|
|
|
|
// PB : TODO -- Override cli prefs and call with undefined selectedinstance only if there is no cli overide or selection. |
|
|
|
var chessinstances = acquirelocalinstances( { root : ENV.wd } ) |
|
|
|
acquirelocalinstances( { root : ENV.wd } ) |
|
|
|
|
|
|
|
if(chessinstances.error) { |
|
|
|
delete chessinstances.error |
|
|
|
// use installchoices only when we don't find chessinstances. |
|
|
|
try { var installchoices = require(path.normalize(ENV.wd + '/installchoices.js')) |
|
|
|
chessinstances[installchoices.instanceName] = chessinstances[installchoices.instanceName] || {} |
|
|
|
chessinstances[installchoices.instanceName][installchoices.node_env || clioverrides.node_env] = installchoices |
|
|
|
installchoices.username = installchoices.gitUser |
|
|
|
installchoices.email = installchoices.gitEmail |
|
|
|
var instanceName = installchoices.instanceName; |
|
|
|
var reposerver = installchoices.reposerver |
|
|
|
var node_env = clioverrides.node_env || installchoices.node_env |
|
|
|
var __instance = (chessinstances[instanceName] = chessinstances[instanceName] || createLocalChessInstance( { |
|
|
|
instanceName, node_env, root, reposerver /* promptkeys['reposerver'] */ } ))[node_env]; |
|
|
|
chessinstances['current_run'] = { instanceName, node_env, reposerver, root } |
|
|
|
|
|
|
|
// if(path.normalize(selectedinstance.root) !== path.normalize(chessinstances[selectedinstance.instanceName][selectedinstance.node_env].root)) { |
|
|
|
// throw "instanceName and instanceType specified doesn't match whats already present do you want to continue " + chessinstances[instanceName][node_env].root + ' does not match ' + selectedinstance.root |
|
|
|
// } |
|
|
|
// chessinstances[installchoices.instanceName] = chessinstances[installchoices.instanceName] || {} |
|
|
|
// chessinstances[installchoices.instanceName][installchoices.node_env || clioverrides.node_env] = installchoices |
|
|
|
__instance.username = installchoices.username = installchoices.gitUser |
|
|
|
__instance.email = installchoices.email = installchoices.gitEmail |
|
|
|
} |
|
|
|
catch(e){ |
|
|
|
console.warn(e) |
|
|
|
console.warn( 'Install choices not found. WIll prompt for choices' ) // This is not an error. A new fresh instance is probably being setup. |
|
|
|
throw 'PROMPT FOR INSTLL CHOICES TO BE IMPLEMENTED' |
|
|
|
chessinstances[installchoices.instanceName] = chessinstances[installchoices.instanceName] || {} |
|
|
|
chessinstances[installchoices.instanceName][installchoices.node_env || clioverrides.node_env] = installchoices |
|
|
|
// chessinstances[installchoices.instanceName] = chessinstances[installchoices.instanceName] || {} |
|
|
|
// chessinstances[installchoices.instanceName][installchoices.node_env || clioverrides.node_env] = installchoices |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// PB : chessinstances.js update if we are switching repo servers, username etc... Myabe always refresh on each run. |
|
|
|
// root location for instance swithc ?? should not be allowd... |
|
|
|
var selectedInstanceName = chessinstances[clioverrides.instanceName || chessinstances.current_run.instanceName]; |
|
|
|
var instance = selectedInstanceName ? selectedInstanceName[clioverrides.node_env || (selectedinstance && selectedinstance.node_env) || [chessinstances.current_run.node_env] ] |
|
|
|
: clioverrides |
|
|
|
var selectedInstaneTypes = chessinstances[clioverrides.instanceName || chessinstances.current_run.instanceName]; |
|
|
|
var instance = selectedInstaneTypes ? selectedInstaneTypes[clioverrides.node_env || [chessinstances.current_run.node_env] ] |
|
|
|
: utils.assign(chessinstances['current_run'], clioverrides) |
|
|
|
// PB : TODO -- Handle instance not found cases. and prompt cases.. |
|
|
|
|
|
|
|
// PB : TODO -- Embed defaults in the build instead of inlining here... |
|
|
@@ -2584,9 +2600,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
var __pub = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }, {}, __pvt |
|
|
|
// Finalized immutables. |
|
|
|
// We don't need pub to prevent immutability. |
|
|
|
, { get root(){ |
|
|
|
return __pvt.root |
|
|
|
} |
|
|
|
, { get root(){ return __pvt.root } |
|
|
|
, get node_env(){ return __pvt.node_env } |
|
|
|
, get instanceName() { return __pvt.instanceName } |
|
|
|
, get reposindexed(){ |
|
|
@@ -2611,6 +2625,26 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
|
|
|
|
chessinstances[__pub.instanceName] = chessinstances[__pub.instanceName] || {} |
|
|
|
chessinstances[__pub.instanceName][__pub.instanceType] = __pub |
|
|
|
// PB : TODO initinstances is now obselete relocated here |
|
|
|
// Upgrade old formats.. |
|
|
|
if(__pub?.repos && !__pub?.repos[0]?.repo) { |
|
|
|
console.warn('repo manifest has obsolete format. Attempting upgrade.') |
|
|
|
__pub.repos = __pub.repos.map(function(repo){ return { repo } }) |
|
|
|
} |
|
|
|
if(__pub?.elevated && !__pub?.elevated[0]?.repo) { |
|
|
|
console.warn('elevated repo manifest has obsolete format. Attempting upgrade.') |
|
|
|
__pub.elevated = __pub.elevated.map(function(repo){ return { repo } }) |
|
|
|
} |
|
|
|
|
|
|
|
// Config from server always override merges into selection except for the current selection. |
|
|
|
// PB : TODO -- utils.assign Array merges are non-distinct... |
|
|
|
// chessinstances[instanceName][node_env] = selectedinstance; |
|
|
|
// chessinstances[selectedinstance.instanceName][selectedinstance.node_env] = selectedinstance; |
|
|
|
// cacheWriteInstanceConfig(chessinstances, __pub.root, __pub) |
|
|
|
|
|
|
|
// PB : TODO -- We should probably write the new server config also... |
|
|
|
__pub.reposerver = __pub.reposerver || __pub.reposervers[0] // PB : TODO -- Attempt first one that is available and online... |
|
|
|
|
|
|
|
cacheWriteInstanceConfig(chessinstances, __pub.root, __pub ) |
|
|
|
|
|
|
|
Object.defineProperty(__g, 'selectedinstance', { |
|
|
@@ -2624,8 +2658,6 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
|
|
|
|
var __default = selectedinstance; // PB : TODO -- Eliminate __default references. |
|
|
|
|
|
|
|
// initinstances(selectedinstance) |
|
|
|
|
|
|
|
var any = utils.any; |
|
|
|
var Tasq = utils.Tasq |
|
|
|
var statuslog = utils.Traq |
|
|
@@ -3470,7 +3502,8 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
return true; |
|
|
|
}).catch((e) => { |
|
|
|
console.error(e) |
|
|
|
}).finally(Traq.finally) |
|
|
|
}) |
|
|
|
// .finally(Traq.finally) |
|
|
|
} |
|
|
|
t2.statuslog = statuslog |
|
|
|
var regularpulltasks = shell_verse.getNonElevatedTask( t2 ) |
|
|
@@ -4072,7 +4105,6 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
// We first load the default and then override with a runconfig if it exists else we override with the interactive prompts. |
|
|
|
// Then acquire and reload and replace this default. |
|
|
|
|
|
|
|
var getReconfirmAll = ()=>{return { instanceName : true, instanceType : true, reposerver : true, username : true, password : true } } |
|
|
|
if(clioverrides.reconfirm) { |
|
|
|
var reconfirm = getReconfirmAll() |
|
|
|
} |
|
|
@@ -4376,7 +4408,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
var email = 'guest@bbh.org.in'; |
|
|
|
var password = '***'; |
|
|
|
|
|
|
|
return any( getInteractionPoints(selectedinstance, promptkeys, { username, password, email}) ).then(()=>{ |
|
|
|
return any( getInteractionPoints([selectedinstance], promptkeys, { username, password, email}) ).then(()=>{ |
|
|
|
if(!data.find(e => e === selectedinstance.username)) { |
|
|
|
var steps = [ |
|
|
|
['git', ['config', '--global', '--add', 'user.name', `${username}`]] |
|
|
@@ -4526,7 +4558,6 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
// function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
|
var runconfig = null; |
|
|
|
|
|
|
|
var chessinstances = { current_run : {} }; |
|
|
|
var promptkeys = { |
|
|
|
cmd : processedArgs._[0] || 'pull' |
|
|
|
// Try not to prompt anything unless absolutely necessary or reconfirm is forced. |
|
|
@@ -4909,60 +4940,64 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
} |
|
|
|
|
|
|
|
var skipprerequisites = false; |
|
|
|
function initinstances(selected_overrides) { |
|
|
|
var root = selected_overrides.root // We should always have this coz we are running at some place which is fixed by . |
|
|
|
function initinstances() { |
|
|
|
// var root = selectedinstance.root |
|
|
|
|
|
|
|
var instanceName = selectedinstance.instanceName |
|
|
|
var node_env = selectedinstance.node_env |
|
|
|
var reposerver = selectedinstance.reposerver |
|
|
|
|
|
|
|
var instanceName = selected_overrides.instanceName |
|
|
|
|| clioverrides.instanceName |
|
|
|
// || processedArgs._[1] |
|
|
|
|| chessinstances.current_run.instanceName |
|
|
|
// var instanceName = selectedinstance.instanceName |
|
|
|
// || clioverrides.instanceName |
|
|
|
// // || processedArgs._[1] |
|
|
|
// || chessinstances.current_run.instanceName |
|
|
|
|
|
|
|
var node_env = selected_overrides.node_env |
|
|
|
|| clioverrides.node_env |
|
|
|
// || processedArgs.node_env |
|
|
|
|| chessinstances.current_run.node_env |
|
|
|
|
|
|
|
var reposerver = selected_overrides.reposerver |
|
|
|
|| clioverrides.reposerver |
|
|
|
// || processedArgs.node_env |
|
|
|
|| chessinstances.current_run.reposerver |
|
|
|
// var node_env = selectedinstance.node_env |
|
|
|
// || clioverrides.node_env |
|
|
|
// // || processedArgs.node_env |
|
|
|
// || chessinstances.current_run.node_env |
|
|
|
|
|
|
|
// var reposerver = selectedinstance.reposerver |
|
|
|
// || clioverrides.reposerver |
|
|
|
// // || processedArgs.node_env |
|
|
|
// || chessinstances.current_run.reposerver |
|
|
|
|
|
|
|
if(!instanceName) { |
|
|
|
promptkeys['instanceName'] = instanceName = chessinstances.current_run.instanceName = promptkeys['instanceName'] || __default.instanceName; |
|
|
|
promptkeys['node_env'] = node_env = chessinstances.current_run.node_env = promptkeys['node_env'] || __default.node_env; |
|
|
|
promptkeys['reposerver'] = reposerver = chessinstances.current_run.reposerver = promptkeys['reposerver'] || __default.reposervers[0]; |
|
|
|
} |
|
|
|
// if(!instanceName) { |
|
|
|
// promptkeys['instanceName'] = instanceName = chessinstances.current_run.instanceName = promptkeys['instanceName'] || __default.instanceName; |
|
|
|
// promptkeys['node_env'] = node_env = chessinstances.current_run.node_env = promptkeys['node_env'] || __default.node_env; |
|
|
|
// promptkeys['reposerver'] = reposerver = chessinstances.current_run.reposerver = promptkeys['reposerver'] || __default.reposervers[0]; |
|
|
|
// } |
|
|
|
|
|
|
|
if(!node_env) { |
|
|
|
promptkeys['node_env'] = node_env = chessinstances.current_run.node_env = promptkeys['node_env'] || __default.node_env; |
|
|
|
promptkeys['reposerver'] = reposerver = chessinstances.current_run.reposerver = promptkeys['reposerver'] || __default.reposervers[0]; |
|
|
|
} |
|
|
|
// if(!node_env) { |
|
|
|
// promptkeys['node_env'] = node_env = chessinstances.current_run.node_env = promptkeys['node_env'] || __default.node_env; |
|
|
|
// promptkeys['reposerver'] = reposerver = chessinstances.current_run.reposerver = promptkeys['reposerver'] || __default.reposervers[0]; |
|
|
|
// } |
|
|
|
|
|
|
|
if(!reposerver) { |
|
|
|
promptkeys['reposerver'] = reposerver = chessinstances.current_run.reposerver = promptkeys['reposerver'] || __default.reposervers[0]; |
|
|
|
} |
|
|
|
// if(!reposerver) { |
|
|
|
// promptkeys['reposerver'] = reposerver = chessinstances.current_run.reposerver = promptkeys['reposerver'] || __default.reposervers[0]; |
|
|
|
// } |
|
|
|
|
|
|
|
chessinstances[instanceName] = chessinstances[instanceName] || createLocalChessInstance( { |
|
|
|
instanceName, node_env, root : selected_overrides.root, reposerver : selected_overrides.reposerver /* promptkeys['reposerver'] */ } ); |
|
|
|
chessinstances['current_run'] = { instanceName: instanceName, node_env, reposerver, root } |
|
|
|
// chessinstances[instanceName] = chessinstances[instanceName] || createLocalChessInstance( { |
|
|
|
// instanceName, node_env, root : selectedinstance.root, reposerver : selectedinstance.reposerver /* promptkeys['reposerver'] */ } ); |
|
|
|
// chessinstances['current_run'] = { instanceName: selectedinstance.instanceName, node_env : selectedinstance.node_env, reposerver : selectedinstance.reposerver, root } |
|
|
|
|
|
|
|
if(path.normalize(selected_overrides.root) !== path.normalize(chessinstances[instanceName][node_env].root)) { |
|
|
|
throw "instanceName and instanceType specified doesn't match whats already present do you want to continue " + chessinstances[instanceName][node_env].root + ' does not match ' + selected_overrides.root |
|
|
|
} |
|
|
|
// if(path.normalize(selectedinstance.root) !== path.normalize(chessinstances[selectedinstance.instanceName][selectedinstance.node_env].root)) { |
|
|
|
// throw "instanceName and instanceType specified doesn't match whats already present do you want to continue " + chessinstances[instanceName][node_env].root + ' does not match ' + selectedinstance.root |
|
|
|
// } |
|
|
|
// Override sequence. |
|
|
|
// __default, chessinstances[current_run], instanceName-config-development, cliargs, interactve_promts |
|
|
|
// PB : TODO -- Undefined keys are overriding and deleting values. We should not allow that. |
|
|
|
// This is ordinary utils.assign behavior. The key should not exist as undefined in the override. |
|
|
|
// PB : TODO -- We now have options that can be passed into assign_core to control this behavior. |
|
|
|
if(selected_overrides.node_env === undefined) delete selected_overrides.node_env |
|
|
|
if(selectedinstance.node_env === undefined) delete selectedinstance.node_env |
|
|
|
|
|
|
|
selectedinstance = __g.selectedinstance = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
, __default |
|
|
|
, chessinstances[instanceName][node_env] |
|
|
|
, clioverrides |
|
|
|
, selected_overrides |
|
|
|
// , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready... |
|
|
|
); |
|
|
|
// selectedinstance = __g.selectedinstance = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
// , __default |
|
|
|
// , chessinstances[instanceName][node_env] |
|
|
|
// , clioverrides |
|
|
|
// , selectedinstance |
|
|
|
// // , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready... |
|
|
|
// ); |
|
|
|
|
|
|
|
// chessinstances[instanceName] = chessinstances[instanceName] || {} |
|
|
|
// chessinstances[instanceName][node_env] = chessinstances[instanceName][node_env] || {} |
|
|
@@ -4972,6 +5007,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
// selectedinstance = Object.assign( __default, selectedinstance ) |
|
|
|
// } |
|
|
|
|
|
|
|
// Upgrade old formats.. |
|
|
|
if(selectedinstance?.repos && !selectedinstance?.repos[0]?.repo) { |
|
|
|
console.warn('repo manifest has obsolete format. Attempting upgrade.') |
|
|
|
selectedinstance.repos = selectedinstance.repos.map(function(repo){ return { repo } }) |
|
|
@@ -4983,9 +5019,10 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
|
|
|
|
// Config from server always override merges into selection except for the current selection. |
|
|
|
// PB : TODO -- utils.assign Array merges are non-distinct... |
|
|
|
chessinstances[instanceName][node_env] = selectedinstance; |
|
|
|
// chessinstances[instanceName][node_env] = selectedinstance; |
|
|
|
// chessinstances[selectedinstance.instanceName][selectedinstance.node_env] = selectedinstance; |
|
|
|
cacheWriteInstanceConfig(chessinstances, selectedinstance.root) |
|
|
|
|
|
|
|
// PB : TODO -- We should probably write the new server config also... |
|
|
|
selectedinstance.reposerver = selectedinstance.reposerver || selectedinstance.reposervers[0] // PB : TODO -- Attempt first one that is available and online... |
|
|
|
|
|
|
@@ -5178,7 +5215,7 @@ shell_verse.acquireElevationState().then((isElevated) => { |
|
|
|
// chessinstances = acquirelocalinstances(selectedinstance); |
|
|
|
// findlocalinstances(chessinstances, detectedinstanceoptions) |
|
|
|
initinstances(selectedinstance) // use the local instances for defaults if at all possible. |
|
|
|
var todo = any( getInteractionPoints([selectedinstance], promptkeys) ).then(()=>{ |
|
|
|
var todo = any( getInteractionPoints(detectedinstanceoptions, promptkeys) ).then(()=>{ |
|
|
|
var inst = initinstances(selectedinstance) |
|
|
|
detection_state.localInstanceDetected = true; |
|
|
|
return inst; |