Browse Source

Fixed legacy instance code.

master
pb 1 year ago
parent
commit
a44862578c
1 changed files with 12 additions and 9 deletions
  1. 12
    9
      index.js

+ 12
- 9
index.js View File

var localinstancesPath = `${instanceroot}/${p}.elxr`; var localinstancesPath = `${instanceroot}/${p}.elxr`;
if(existsSync( localinstancesPath )) { if(existsSync( localinstancesPath )) {
try { try {
var chessinstances = acquirelocalinstances( `${instanceroot}/${p}` )
var chessinstances = acquirelocalinstances( { root : `${instanceroot}/${p}` } )
if(chessinstances.error) delete chessinstances.error if(chessinstances.error) delete chessinstances.error
return Object.keys(chessinstances).earlyreduce( ( reduced, instanceName) => { return Object.keys(chessinstances).earlyreduce( ( reduced, instanceName) => {
return Object.keys(chessinstances[instanceName]).earlyreduce( (reduced, instanceType) => { return Object.keys(chessinstances[instanceName]).earlyreduce( (reduced, instanceType) => {
} }


var cacheWriteInstanceConfig = function(chessinstances, instanceroot, selectedinstance){ var cacheWriteInstanceConfig = function(chessinstances, instanceroot, selectedinstance){
var instanceName = selectedinstance.instanceName ;
var node_env = selectedinstance.node_env;
// PB : TODO -- handle current_run switch...
// console.dir(chessinstances)
// PB : TODO -- We should be able to do simply merge at a higher level using assign
chessinstances[instanceName][node_env].repos = mergeObjByKey(chessinstances[instanceName][node_env].repos || [], 'repo') ;
chessinstances[instanceName][node_env].elevated = mergeObjByKey(chessinstances[instanceName][node_env].elevated || [], 'repo') ;
if(selectedinstance) {

var instanceName = selectedinstance.instanceName ;
var node_env = selectedinstance.node_env;
// PB : TODO -- handle current_run switch...
// console.dir(chessinstances)
// PB : TODO -- We should be able to do simply merge at a higher level using assign
chessinstances[instanceName][node_env].repos = mergeObjByKey(chessinstances[instanceName][node_env].repos || [], 'repo') ;
chessinstances[instanceName][node_env].elevated = mergeObjByKey(chessinstances[instanceName][node_env].elevated || [], 'repo') ;
}
fs.writeFileSync(instanceroot + '/chessinstances.js', 'module.exports = ' + JSON.stringify(chessinstances, null, 2) + '', { 'flag': 'w' }) fs.writeFileSync(instanceroot + '/chessinstances.js', 'module.exports = ' + JSON.stringify(chessinstances, null, 2) + '', { 'flag': 'w' })
} }


, selected, selectedinstance) , selected, selectedinstance)
chessinstances[selected.instanceName][selected.node_env].reposervers = Array.from(new Set(chessinstances[selected.instanceName][selected.node_env].reposervers)) chessinstances[selected.instanceName][selected.node_env].reposervers = Array.from(new Set(chessinstances[selected.instanceName][selected.node_env].reposervers))
selectedinstance.reposerver = selectedinstance.reposerver || selectedinstance.reposervers[0] // PB : TODO -- Attempt first one that is available and online... selectedinstance.reposerver = selectedinstance.reposerver || selectedinstance.reposervers[0] // PB : TODO -- Attempt first one that is available and online...
cacheWriteInstanceConfig(chessinstances, selectedinstance.root)
cacheWriteInstanceConfig(chessinstances, selectedinstance.root, selectedinstance)
// ENV.NODE_ENV = selectedinstance.node_env; // ENV.NODE_ENV = selectedinstance.node_env;
throw e throw e
} }

Loading…
Cancel
Save