|
|
|
|
|
|
|
|
var getCmdString = function(args){ return `"${args[0]} ${args[1].join(' ')}"` } |
|
|
var getCmdString = function(args){ return `"${args[0]} ${args[1].join(' ')}"` } |
|
|
|
|
|
|
|
|
var getshelltask = (args) => { |
|
|
var getshelltask = (args) => { |
|
|
return args[0] === 'rm' ? getgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } } |
|
|
|
|
|
|
|
|
return args[0] === 'rm' ? getgitbashtask(args) : () => { |
|
|
|
|
|
return nodeShellExec.apply(null, args).catch(function(e){ e.benign = args[2].benign; if(!e.benign) {console.error(e); throw e} }) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
var getgitbashtask = (args, onEachError) => { return () => { |
|
|
var getgitbashtask = (args, onEachError) => { return () => { |
|
|
return nodeShellExec( `"${gitbash}"`, ['-c', getCmdString(args)], args[2]).catch( onEachError || function(e){ console.error(e) }) } |
|
|
return nodeShellExec( `"${gitbash}"`, ['-c', getCmdString(args)], args[2]).catch( onEachError || function(e){ console.error(e) }) } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var getPullCmd = (repo, branch) => { |
|
|
|
|
|
|
|
|
var getPullCmd = (repodef, branch) => { |
|
|
// console.log(useGitPull)var getPullCmd = (repo, branch) => { |
|
|
// console.log(useGitPull)var getPullCmd = (repo, branch) => { |
|
|
// console.log(useGitPull) |
|
|
// console.log(useGitPull) |
|
|
|
|
|
|
|
|
|
|
|
var repo = repodef.repo |
|
|
var pullCmd = [] |
|
|
var pullCmd = [] |
|
|
if(!branch) { |
|
|
if(!branch) { |
|
|
// console.warn('No branch was specified detecting from working client.') |
|
|
// console.warn('No branch was specified detecting from working client.') |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (exists) { |
|
|
if (exists) { |
|
|
|
|
|
|
|
|
|
|
|
// Add the remotes |
|
|
|
|
|
var tasks = [] |
|
|
|
|
|
var selectedremotes = Array.from( new Set(selectedinstance.selectedremotes.concat(Object.keys(repodef.remotes || {})))); |
|
|
|
|
|
var repoRemotes = Object.assign( {}, selectedinstance.remotes, repodef.remotes ); |
|
|
|
|
|
selectedremotes.forEach((remotename)=>{ |
|
|
|
|
|
var ai_RemoteAddNeeded = (info)=>{ return true }; // ai prefix for all apis that require an answer if choice is needed. |
|
|
|
|
|
tasks.push( |
|
|
|
|
|
()=>{ |
|
|
|
|
|
|
|
|
|
|
|
return op['remote exists']({ |
|
|
|
|
|
remotename, repo, benign : true, ignorefailures : true |
|
|
|
|
|
, url : repoRemotes[remotename].url || processedArgs._[3] |
|
|
|
|
|
, branch : processedArgs._[4] |
|
|
|
|
|
}).then( (r) => { |
|
|
|
|
|
if(!r[1]) return false; // PB : TODO -- Not accessible skip for now probably should remove. |
|
|
|
|
|
else if(r[0]) return true; // Already added nothing to do |
|
|
|
|
|
else if(ai_RemoteAddNeeded()) return op['remote add']( { remotename, |
|
|
|
|
|
'set-upstream' : remotename === selectedinstance['upstream-remote'] //remote.upstream ??? when url accessible... in order of highest priority |
|
|
|
|
|
, url : remote.url, branch : checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV |
|
|
|
|
|
}) |
|
|
|
|
|
// else skipped as remote is not relevant for this repo... |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
var branchprint = branch ? ' branch :' + branch : ''; |
|
|
var branchprint = branch ? ' branch :' + branch : ''; |
|
|
var task = ()=>{ |
|
|
var task = ()=>{ |
|
|
console.log('pulling ' + instanceroot + '/' + repo + branchprint ) |
|
|
console.log('pulling ' + instanceroot + '/' + repo + branchprint ) |
|
|
return nodeShellExec.apply(null, getPullCmd(repo, branch)).then(() => { |
|
|
|
|
|
return true; |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
return any(tasks).then( ()=>{ |
|
|
|
|
|
return nodeShellExec.apply(null, getPullCmd(repodef, branch)).then(() => { |
|
|
|
|
|
return true; |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
initTask(task) |
|
|
initTask(task) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dbsForLabel[label] || 'mysql' |
|
|
return dbsForLabel[label] || 'mysql' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Maps an environment to a branch. Not required if the branch is appropriately named. |
|
|
|
|
|
var checkoutMap = { 'development': 'master' } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SAM : TODO Use nodeshellexec where to detect git installation dir |
|
|
// SAM : TODO Use nodeshellexec where to detect git installation dir |
|
|
var gitbash = shell_verse.getbash() |
|
|
var gitbash = shell_verse.getbash() |
|
|
// var gitbash = "G:\\Installed\\Git\\bin\\sh.exe" |
|
|
// var gitbash = "G:\\Installed\\Git\\bin\\sh.exe" |
|
|
|
|
|
|
|
|
// git push origin master |
|
|
// git push origin master |
|
|
|
|
|
|
|
|
var repo = processedArgs._[1]; |
|
|
var repo = processedArgs._[1]; |
|
|
|
|
|
var remote = 'origin' |
|
|
|
|
|
|
|
|
var sequentialTaskShellCommands = []; |
|
|
var sequentialTaskShellCommands = []; |
|
|
if (!existsSync(`Z:/${repo}.git`)) { |
|
|
if (!existsSync(`Z:/${repo}.git`)) { |
|
|
|
|
|
|
|
|
, env: process.env |
|
|
, env: process.env |
|
|
}] |
|
|
}] |
|
|
// PB : TODO -- Do this conditionally only... |
|
|
// PB : TODO -- Do this conditionally only... |
|
|
, ['git', ['remote', 'rename', 'origin', 'githubclone'], { cwd: `${instanceroot + '/' + repo}` }, (err) => { |
|
|
|
|
|
console.log('Ignoring origin rename error : ' + err); return true; //return true to continue. |
|
|
|
|
|
|
|
|
, ['git', ['remote', 'rename', remote, 'githubclone'], { cwd: `${instanceroot + '/' + repo}` }, (err) => { |
|
|
|
|
|
console.log(`Ignoring ${remote} rename error : ` + err); return true; //return true to continue. |
|
|
}] // PB ; Todo -- new repositories created locally will not have origin. Handle this failure. |
|
|
}] // PB ; Todo -- new repositories created locally will not have origin. Handle this failure. |
|
|
, ['git', ['remote', 'add', 'origin', `${selectedinstance.reposerver}/${repo}.git`], { cwd: `${instanceroot + '/' + repo}` }] |
|
|
|
|
|
|
|
|
, ['git', ['remote', 'add', remote, `${selectedinstance.reposerver}/${repo}.git`], { cwd: `${instanceroot + '/' + repo}` }] |
|
|
// PB : TODO -- If threre is a gitbubclone origin |
|
|
// PB : TODO -- If threre is a gitbubclone origin |
|
|
// Set the master to pull from the local repo. |
|
|
// Set the master to pull from the local repo. |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sequentialTaskShellCommands.push(['git', ['push', 'origin', 'master'], { cwd: `${instanceroot + '/' + repo}` }]) |
|
|
|
|
|
|
|
|
sequentialTaskShellCommands.push(['git', ['push', remote, 'master'], { cwd: `${instanceroot + '/' + repo}` }]) |
|
|
// console.dir(sequentialTaskShellCommands); |
|
|
// console.dir(sequentialTaskShellCommands); |
|
|
|
|
|
|
|
|
var tasks = []; |
|
|
var tasks = []; |
|
|
|
|
|
|
|
|
var commands = [ |
|
|
var commands = [ |
|
|
// git remote -v| while read remote; do "${remote#origin/}" "$remote"; done |
|
|
// 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', '| 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) ] |
|
|
|
|
|
|
|
|
[ |
|
|
|
|
|
// 'git', ['remote', '-v'] |
|
|
|
|
|
'git', ['config', `remote.${__args.remotename}.url`] |
|
|
|
|
|
, utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, { |
|
|
|
|
|
benign : args.benign, ignorefailures : args.ignorefailures, |
|
|
|
|
|
evaluateResult : function(err, result){ |
|
|
|
|
|
// var found = result.messages.find( (r)=> { return r.includes( __args.remotename ) }) |
|
|
|
|
|
console.log(__args.remotename) |
|
|
|
|
|
var remotes = [] |
|
|
|
|
|
var found = false; |
|
|
|
|
|
if(+result.code === 0) found = true; |
|
|
|
|
|
// 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) { |
|
|
, function(prevserialtaskresult) { |
|
|
|
|
|
if(!prevserialtaskresult) return [[ false, null], [ false, null]] |
|
|
|
|
|
|
|
|
|
|
|
if(!prevserialtaskresult) return [[ false, null], [ false, null]] |
|
|
console.log('================================') |
|
|
console.log('================================') |
|
|
var url = __args || prevserialtaskresult.url; |
|
|
var url = __args || prevserialtaskresult.url; |
|
|
console.dir(prevserialtaskresult) |
|
|
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) ])() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return getshelltask(['git', ['ls-remote', url], utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, { |
|
|
|
|
|
benign : args.benign, |
|
|
|
|
|
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) ])().catch( e => { |
|
|
|
|
|
console.error(e) |
|
|
|
|
|
return [[ false, null], [ false, null]] |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
] |
|
|
] |
|
|
var mapped = commands.map(callshelltask) //.map( p => p.catch(e => e)) // Handle errors later. |
|
|
var mapped = commands.map(callshelltask) //.map( p => p.catch(e => e)) // Handle errors later. |
|
|
return any(mapped).then( allresolved =>{ |
|
|
|
|
|
|
|
|
return any(mapped, true).then( allresolved =>{ |
|
|
|
|
|
|
|
|
console.dir(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 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 and url is accessible.') |
|
|
|
|
|
|
|
|
: allresolved[0][0] && allresolved[1][0] ? [1, 1] // => was added as a remote and url is accessible. |
|
|
: 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. |
|
|
: 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. |
|
|
: [0, 1] // => was not added and remote and url is accessible. |
|
|
|
|
|
}).catch(e => { |
|
|
|
|
|
console.log(e) |
|
|
|
|
|
return [0, 0] |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(remote).forEach(remotename => { |
|
|
Object.keys(remote).forEach(remotename => { |
|
|
__args.remotename = remotename |
|
|
__args.remotename = remotename |
|
|
__args.url = remote[remotename] |
|
|
__args.url = remote[remotename] |
|
|
|
|
|
__args.benign = true |
|
|
|
|
|
__args.ignorefailures = true |
|
|
promises.push( op['remote exists']( __args ).then( exists => { |
|
|
promises.push( op['remote exists']( __args ).then( exists => { |
|
|
if(!exists[0]) { |
|
|
if(!exists[0]) { |
|
|
if(!exists[1]) { console.error( `Skipping inaccessible remote url ${__args.url}` ) } |
|
|
if(!exists[1]) { console.error( `Skipping inaccessible remote url ${__args.url}` ) } |
|
|
|
|
|
|
|
|
// alias pullall='for i in `git remote`; do git pull $i; done;' |
|
|
// alias pullall='for i in `git remote`; do git pull $i; done;' |
|
|
// args === processedArgs ? args = {} : null; |
|
|
// args === processedArgs ? args = {} : null; |
|
|
var __args = { |
|
|
var __args = { |
|
|
remotename : args.remotename|| processedArgs._[2] |
|
|
|
|
|
|
|
|
remotename : args.remotename|| processedArgs._[2] |
|
|
, url : args.url || processedArgs._[3] |
|
|
, url : args.url || processedArgs._[3] |
|
|
, branch : args.branch || processedArgs._[4] |
|
|
, branch : args.branch || processedArgs._[4] |
|
|
|
|
|
, 'set-upstream' : args['set-upstream'] || processedArgs._[5] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var remotename = __args.remotename |
|
|
var remotename = __args.remotename |
|
|
|
|
|
|
|
|
var options = { cwd: instanceroot + '/' + repo } |
|
|
var options = { cwd: instanceroot + '/' + repo } |
|
|
// console.log(repo) |
|
|
// console.log(repo) |
|
|
if (pushable) { |
|
|
if (pushable) { |
|
|
return [ |
|
|
|
|
|
|
|
|
var gacmds = [ |
|
|
['git', ['remote', 'add', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }] |
|
|
['git', ['remote', 'add', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['pull', remotename, branch], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['pull', remotename, branch], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }] |
|
|
|
|
|
|
|
|
// , ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }] |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
|
var gacmds = [ |
|
|
['git', ['remote', 'add', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }] |
|
|
['git', ['remote', 'add', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['remote', `set-url`, '--push', remotename, 'no-pushing'], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['remote', `set-url`, '--push', remotename, 'no-pushing'], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['pull', remotename, branch], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['pull', remotename, branch], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }] |
|
|
|
|
|
|
|
|
// When we add a remote it should not automatically become the upstream. The upstream should be a chosen remote else we do not change |
|
|
|
|
|
// , ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }] |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(args['set-upstream']) gacmds.push(['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }]) |
|
|
} |
|
|
} |
|
|
var x = (args) => { |
|
|
var x = (args) => { |
|
|
return () => { |
|
|
return () => { |
|
|
|
|
|
|
|
|
var options = { cwd: instanceroot + '/' + repo } |
|
|
var options = { cwd: instanceroot + '/' + repo } |
|
|
// console.log(repo) |
|
|
// console.log(repo) |
|
|
return [ |
|
|
return [ |
|
|
['git', ['remote', 'add', 'chess', `${selectedinstance.reposerver}/${user}/${repo}.git`], { cwd: instanceroot + '/' + repo }] |
|
|
|
|
|
|
|
|
['git', ['remote', 'add', 'chess', `${selectedinstance.reposerver}/${user}/${repo}.git`], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['remote', 'set-url', '--push', 'chess', 'no-pushing'], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['remote', 'set-url', '--push', 'chess', 'no-pushing'], { cwd: instanceroot + '/' + repo }] |
|
|
, ['git', ['remote', 'set-url', 'origin', `${selectedinstance.reposerver}/${user}/${repo}.git`], { cwd: instanceroot + '/' + repo }] |
|
|
|
|
|
|
|
|
, ['git', ['remote', 'set-url', 'userfork', `${selectedinstance.reposerver}/${user}/${repo}.git`], { cwd: instanceroot + '/' + repo }] |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
var x = (args) => { |
|
|
var x = (args) => { |
|
|
|
|
|
|
|
|
4) Iterates all repos and checkout to the ENV specified. 'git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV] |
|
|
4) Iterates all repos and checkout to the ENV specified. 'git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV] |
|
|
5) Iterates all repos and merge from source configured in mergesource. 'git', ['merge', mergesource], |
|
|
5) Iterates all repos and merge from source configured in mergesource. 'git', ['merge', mergesource], |
|
|
*/ |
|
|
*/ |
|
|
var runconfig = { NODE_ENV: selectedinstance.node_env } |
|
|
|
|
|
try { runconfig = Object.assign(runconfig, require(instanceroot + '/run.js')) } catch (e) { } |
|
|
|
|
|
// We no longer need to check ruans.. ??? if we were initiated from self invoked privileged shell ? |
|
|
// We no longer need to check ruans.. ??? if we were initiated from self invoked privileged shell ? |
|
|
if (( /*processedArgs.runas && processedArgs.runas !== 'self' &&*/ !processedArgs.force) && |
|
|
if (( /*processedArgs.runas && processedArgs.runas !== 'self' &&*/ !processedArgs.force) && |
|
|
runconfig.NODE_ENV && runconfig.NODE_ENV === (selectedinstance.node_env || runconfig.NODE_ENV) && |
|
|
runconfig.NODE_ENV && runconfig.NODE_ENV === (selectedinstance.node_env || runconfig.NODE_ENV) && |
|
|
|
|
|
|
|
|
// console.log(process.env.cwd) |
|
|
// console.log(process.env.cwd) |
|
|
fs.writeFileSync(instanceroot + '/run.js', 'module.exports = ' + JSON.stringify(runconfig)) |
|
|
fs.writeFileSync(instanceroot + '/run.js', 'module.exports = ' + JSON.stringify(runconfig)) |
|
|
|
|
|
|
|
|
// Maps an environment to a branch. Not required if the branch is appropriately named. |
|
|
|
|
|
var checkoutMap = { 'development': 'master' } |
|
|
|
|
|
|
|
|
|
|
|
var branch = checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV |
|
|
var branch = checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV |
|
|
|
|
|
|
|
|
var performPullOrCloneForBranch = (def)=>{ |
|
|
var performPullOrCloneForBranch = (def)=>{ |
|
|
|
|
|
|
|
|
// console.log(o) |
|
|
// console.log(o) |
|
|
subs.forEach(sub=>elxrcmd.create( cmds[subcommandlabelFor(o.cmd, sub)] )) |
|
|
subs.forEach(sub=>elxrcmd.create( cmds[subcommandlabelFor(o.cmd, sub)] )) |
|
|
|
|
|
|
|
|
var created = utils.assign_strict({}, __cmd, cmds[o.cmd], o) |
|
|
|
|
|
|
|
|
var created = utils.assign_core( { keycase: true, arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, {}, __cmd, cmds[o.cmd], o) |
|
|
cmds[o.cmd] = created; |
|
|
cmds[o.cmd] = created; |
|
|
op[o.cmd] = created.cmdFn; |
|
|
op[o.cmd] = created.cmdFn; |
|
|
noprerequisites[o.cmd] = created.noprerequisites |
|
|
noprerequisites[o.cmd] = created.noprerequisites |
|
|
|
|
|
|
|
|
if(o) (keyedDistinct[o[keyName]] || (keyedDistinct[o[keyName]] = []) ).push(o) |
|
|
if(o) (keyedDistinct[o[keyName]] || (keyedDistinct[o[keyName]] = []) ).push(o) |
|
|
}) |
|
|
}) |
|
|
Object.keys(keyedDistinct).forEach(key => { |
|
|
Object.keys(keyedDistinct).forEach(key => { |
|
|
distinctArrOfObjs.push( utils.assign( ...keyedDistinct[key] ) ) // PB : TODO -- Shallow use utils.assign |
|
|
|
|
|
|
|
|
distinctArrOfObjs.push( utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, ...keyedDistinct[key] ) ) // PB : TODO -- Shallow use utils.assign |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
return distinctArrOfObjs; |
|
|
return distinctArrOfObjs; |
|
|
|
|
|
|
|
|
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' }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var os = require("os"); |
|
|
|
|
|
var hostname = os.hostname(); |
|
|
|
|
|
var clustername = null; // PB : TODO -- Prompt to acquire. |
|
|
var configs = (function(){ |
|
|
var configs = (function(){ |
|
|
return { |
|
|
|
|
|
clusterNodeInstance(selected) { var clusternodename = 'node01' |
|
|
|
|
|
return __acquireConfig(selected, selected.username, clusternodename |
|
|
|
|
|
|
|
|
// We need to discover and use the most specialized config available. |
|
|
|
|
|
// Two passes are required as the config currently cloned may be switched by the discovery. |
|
|
|
|
|
// If the repo name is the same but has different remotes the newly acquired config from multiple remotes may |
|
|
|
|
|
// iteself redefine the remotes, repos and servers for the config which we need to honor.. |
|
|
|
|
|
return { |
|
|
|
|
|
ownerClusterNodeConfig(selected) { |
|
|
|
|
|
// Hostname and therefore clusternodename can be anything and can participate in many clusters. |
|
|
|
|
|
// Also many cluster node instance can be running as a set of services on the same host on the same port with ( specific domain names ) |
|
|
|
|
|
var clusternodename = hostname || `CHESS0001${selected.username}`; // Cluster node names need to be unique accross all clusters to avoid collitions. |
|
|
|
|
|
clustername = clustername || `${selected.username}-CHESS-${selected.node_env}`; |
|
|
|
|
|
return __acquireConfig(selected, { remote : 'userfork' } // PB : TODO -- accessiblity state should switch to public etc.. |
|
|
, selected.instanceName + '-config-' + selected.node_env + `-${clusternodename}` |
|
|
, selected.instanceName + '-config-' + selected.node_env + `-${clusternodename}` |
|
|
, function(e){ console.info('Customized node level config not found. This is not an Error. Will attempt with owner level config.'); |
|
|
, function(e){ console.info('Customized node level config not found. This is not an Error. Will attempt with owner level config.'); |
|
|
return e; } |
|
|
return e; } |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
, ownerInstnace(selected) { return __acquireConfig(selected, selected.username, null, null |
|
|
|
|
|
|
|
|
, ownerInstnace(selected) { return __acquireConfig(selected, { remote : 'userfork' } |
|
|
|
|
|
, selected.instanceName + '-config-' + selected.node_env |
|
|
, function(e){ console.info('Customized user level config not found. This is not an Error. Will attempt global common instance config.'); |
|
|
, function(e){ console.info('Customized user level config not found. This is not an Error. Will attempt global common instance config.'); |
|
|
return e } |
|
|
return e } |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
, commonInstance(selected) { return __acquireConfig(selected, defaultRepoOwner |
|
|
|
|
|
|
|
|
, commonInstance(selected) { return __acquireConfig(selected, { defaultRepoOwner } |
|
|
// , function(e){ console.info('This is probably an error unless the user is asking to create a new instance with this name.') } |
|
|
// , function(e){ console.info('This is probably an error unless the user is asking to create a new instance with this name.') } |
|
|
) } |
|
|
) } |
|
|
, genericChessInstance(selected) { return __acquireConfig(selected) } |
|
|
, genericChessInstance(selected) { return __acquireConfig(selected) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PB : TODO -- accept additional arg - an array specifying custom configPriority. |
|
|
// PB : TODO -- accept additional arg - an array specifying custom configPriority. |
|
|
var acquireConfig = function(slections){ |
|
|
var acquireConfig = function(slections){ |
|
|
var configPriority = [ 'clusterNodeInstance', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] |
|
|
|
|
|
|
|
|
var configPriority = [ 'ownerClusterNodeConfig', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] |
|
|
return any(configPriority.map(cfg => { return function() { return configs[cfg](slections) } } ), true, true).then(()=>{ |
|
|
return any(configPriority.map(cfg => { return function() { return configs[cfg](slections) } } ), true, true).then(()=>{ |
|
|
return acquireData(slections) |
|
|
return acquireData(slections) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var instanceData = (function(){ |
|
|
var instanceData = (function(){ |
|
|
return { |
|
|
return { |
|
|
clusterNodeInstance(selected) { var clusternodename = 'node01' |
|
|
|
|
|
return __acquireData(selected, selected.username, clusternodename |
|
|
|
|
|
|
|
|
ownerClusterNodeData(selected) { |
|
|
|
|
|
var clusternodename = hostname || `CHESS0001${selected.username}`; // Cluster node names need to be unique accross all clusters to avoid collitions. |
|
|
|
|
|
clustername = clustername || `${selected.username}-CHESS-${selected.node_env}`; |
|
|
|
|
|
return __acquireData(selected, { remote : 'userfork' } |
|
|
, selected.instanceName + '-data-' + selected.node_env + `-${clusternodename}` |
|
|
, selected.instanceName + '-data-' + selected.node_env + `-${clusternodename}` |
|
|
, function(e){ console.info('Customized node level config not found. This is not an Error. Will attempt with owner level config.'); |
|
|
, function(e){ console.info('Customized node level config not found. This is not an Error. Will attempt with owner level config.'); |
|
|
return e; } |
|
|
return e; } |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
, ownerInstnace(selected) { return __acquireData(selected, selected.username, null |
|
|
|
|
|
|
|
|
, ownerInstnace(selected) { return __acquireData(selected, { remote : 'userfork' } |
|
|
, selected.instanceName + '-data-' + selected.node_env |
|
|
, selected.instanceName + '-data-' + selected.node_env |
|
|
, function(e){ console.info('Customized user level config not found. This is not an Error. Will attempt global common instance config.'); |
|
|
, function(e){ console.info('Customized user level config not found. This is not an Error. Will attempt global common instance config.'); |
|
|
return e } |
|
|
return e } |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
// PB : TODO -- Use the ORG level instance before falling back to common Instance coz common instance may not exist for certain orgs. |
|
|
, commonInstance(selected) { return __acquireData(selected, defaultRepoOwner |
|
|
|
|
|
|
|
|
, commonInstance(selected) { return __acquireData(selected, { defaultRepoOwner } |
|
|
|
|
|
|
|
|
// , function(e){ console.info('This is probably an error unless the user is asking to create a new instance with this name.') } |
|
|
// , function(e){ console.info('This is probably an error unless the user is asking to create a new instance with this name.') } |
|
|
) } |
|
|
) } |
|
|
, genericChessInstance(selected) { return __acquireData(selected) } |
|
|
, genericChessInstance(selected) { return __acquireData(selected) } |
|
|
|
|
|
|
|
|
})() |
|
|
})() |
|
|
|
|
|
|
|
|
var acquireData = function(slections){ |
|
|
var acquireData = function(slections){ |
|
|
var configPriority = [ 'clusterNodeInstance', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] |
|
|
|
|
|
|
|
|
var configPriority = [ 'ownerClusterNodeData', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] |
|
|
return any(configPriority.map(cfg => { return function() { return instanceData[cfg](slections) } } ), true, true) |
|
|
return any(configPriority.map(cfg => { return function() { return instanceData[cfg](slections) } } ), true, true) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var execonce = function(taskArgs, task){ return any([task[1].push.apply(task[1], taskArgs)].map(createTasq)) } |
|
|
var execonce = function(taskArgs, task){ return any([task[1].push.apply(task[1], taskArgs)].map(createTasq)) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var __acquireConfig = function (selected, owner, clusternodename, configrepo, errHandler) { |
|
|
|
|
|
|
|
|
var __acquireConfig = function (selected, options, configrepo, errHandler) { |
|
|
|
|
|
|
|
|
configrepo = configrepo || selected.instanceName + '-config-' + selected.node_env; |
|
|
configrepo = configrepo || selected.instanceName + '-config-' + selected.node_env; |
|
|
|
|
|
|
|
|
var errorHandler = (e) => { |
|
|
var errorHandler = (e) => { |
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${owner}/${configrepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${configrepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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}/${selected.username || options.defaultRepoOwner}/${configrepo}.git/' not found`))){ |
|
|
var choices = { |
|
|
var choices = { |
|
|
t : `install a new temporary local instance with this name ( will not persist ). |
|
|
t : `install a new temporary local instance with this name ( will not persist ). |
|
|
Use your own username for additional options. You can request for a username at chess@bbh.org.in )` |
|
|
Use your own username for additional options. You can request for a username at chess@bbh.org.in )` |
|
|
, e : 'exit' } |
|
|
, e : 'exit' } |
|
|
|
|
|
|
|
|
if(selectedinstance.username !== 'guest' && selectedinstance.username !== 'demo') { |
|
|
if(selectedinstance.username !== 'guest' && selectedinstance.username !== 'demo') { |
|
|
choices = utils.assign({ |
|
|
|
|
|
|
|
|
choices = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, { |
|
|
i : 'create a new instance with this name => will fork the default config under your username' |
|
|
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' |
|
|
, 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... |
|
|
, o : 'fork a new instance with this name for your organization from another instance' // prompt organization name... |
|
|
|
|
|
|
|
|
var successHandler = () => { |
|
|
var successHandler = () => { |
|
|
|
|
|
|
|
|
var manifestpath = path.normalize(selected.root + '/' + selected.instanceName + '-config-' + selected.node_env + '/repo-manifest'); |
|
|
var manifestpath = path.normalize(selected.root + '/' + selected.instanceName + '-config-' + selected.node_env + '/repo-manifest'); |
|
|
utils.assign_strict(selectedinstance, require(manifestpath)( null, selectedinstance)) |
|
|
|
|
|
|
|
|
utils.assign_core( { keycase : true, arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, selectedinstance, require(manifestpath)( null, selectedinstance)) |
|
|
console.dir(selectedinstance.repos) |
|
|
console.dir(selectedinstance.repos) |
|
|
// Config from server always override merges into selection except for the current selection. |
|
|
// Config from server always override merges into selection except for the current selection. |
|
|
// PB : TODO -- utils.assign Array merges are non-distinct... |
|
|
// PB : TODO -- utils.assign Array merges are non-distinct... |
|
|
|
|
|
|
|
|
console.warn('elevated repo manifest has obsolete format. Attempting upgrade.') |
|
|
console.warn('elevated repo manifest has obsolete format. Attempting upgrade.') |
|
|
selectedinstance.elevated = selectedinstance.elevated.map(function(repo){ return { repo } }) |
|
|
selectedinstance.elevated = selectedinstance.elevated.map(function(repo){ return { repo } }) |
|
|
} |
|
|
} |
|
|
chessinstances[selected.instanceName][selected.node_env] = selectedinstance = utils.assign(selected, selectedinstance) |
|
|
|
|
|
|
|
|
chessinstances[selected.instanceName][selected.node_env] = selectedinstance = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, 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) |
|
|
cacheWriteInstanceConfig(chessinstances) |
|
|
ENV.NODE_ENV = selectedinstance.node_env; |
|
|
ENV.NODE_ENV = selectedinstance.node_env; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return performPull({repo : configrepo}, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
|
|
|
|
|
|
var selectedremotes = {}; |
|
|
|
|
|
if(options.remote) selectedremotes[options.remote] = selected.reposerverinstances[selected.reposerver].remotes[options.remote]; |
|
|
|
|
|
// else known remotes preselected from UI pref. |
|
|
|
|
|
return performPull({repo : configrepo, remotes : Object.assign(selectedremotes |
|
|
|
|
|
, selected.repos[configrepo]?.remotes || {} ) } |
|
|
|
|
|
, null, selected.username || options.defaultRepoOwner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
.catch( (e)=>{ |
|
|
.catch( (e)=>{ |
|
|
// if(e){ |
|
|
// if(e){ |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var __acquireData = function (selected, owner, clusternodename, datarepo, errHandler) { |
|
|
|
|
|
|
|
|
var __acquireData = function (selected, options, datarepo, errHandler) { |
|
|
|
|
|
|
|
|
datarepo = datarepo || selected.instanceName + '-data'; |
|
|
datarepo = datarepo || selected.instanceName + '-data'; |
|
|
|
|
|
|
|
|
var errorHandler = (e) => { |
|
|
var errorHandler = (e) => { |
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${owner}/${datarepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: unable to access '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${datarepo}.git/': Failed to connect to .*? port .*? after .*? ms: Timed out`))){ |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
// console.error('Could not connect to repo server. Timed Out') |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
return cli.prompt( ['(y)es', '(n)o', '(r)etry'], 'Could not connect to repo server. Timed Out. Would you like to switch server ? (y/n) ', 'y' ).then(propValue => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${owner}/${datarepo}.git/' not found`))){ |
|
|
|
|
|
|
|
|
if(e.messages.join(' ').match(new RegExp (`fatal: repository '${selectedinstance.reposerver}/${selected.username || options.defaultRepoOwner}/${datarepo}.git/' not found`))){ |
|
|
var choices = { |
|
|
var choices = { |
|
|
t : `install a temporary local data folder. |
|
|
t : `install a temporary local data folder. |
|
|
For more options. Request and use a personal username at chess@bbh.org.in )` |
|
|
For more options. Request and use a personal username at chess@bbh.org.in )` |
|
|
, e : 'exit' } |
|
|
, e : 'exit' } |
|
|
|
|
|
|
|
|
if(selectedinstance.username !== 'guest' && selectedinstance.username !== 'demo') { |
|
|
if(selectedinstance.username !== 'guest' && selectedinstance.username !== 'demo') { |
|
|
choices = utils.assign({ |
|
|
|
|
|
|
|
|
choices = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, { |
|
|
i : 'create a new instance with this name => will fork the default config under your username' |
|
|
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' |
|
|
, 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... |
|
|
, o : 'fork a new instance with this name for your organization from another instance' // prompt organization name... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return performPull({ repo : datarepo }, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
|
|
|
|
|
|
var selectedremotes = {}; |
|
|
|
|
|
if(options.remote) selectedremotes[options.remote] = selected.reposerverinstances[selected.reposerver].remotes[options.remote] |
|
|
|
|
|
// else ... |
|
|
|
|
|
return performPull({ repo : datarepo |
|
|
|
|
|
, remotes : Object.assign(selectedremotes |
|
|
|
|
|
, selected.repos[datarepo]?.remotes || {} ) } |
|
|
|
|
|
, null, selected.username || options.defaultRepoOwner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler ) |
|
|
.catch( (e)=>{ |
|
|
.catch( (e)=>{ |
|
|
// if(e){ |
|
|
// if(e){ |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
if(Promise.resolve(e) === e) return e; |
|
|
|
|
|
|
|
|
instanceroot = path.normalize(thisscriptdir) === path.normalize(launchpath) ? path.normalize(thisscriptdir + '/..') : launchpath ; |
|
|
instanceroot = path.normalize(thisscriptdir) === path.normalize(launchpath) ? path.normalize(thisscriptdir + '/..') : launchpath ; |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PB : TODO -- Embed this in the build instead of inlining it. |
|
|
|
|
|
// Also attepmt to load from ../chess-config/... |
|
|
|
|
|
var __default = ((name, options)=>{ |
|
|
|
|
|
|
|
|
|
|
|
// Default set of users in main repos. |
|
|
|
|
|
var users = [ |
|
|
|
|
|
{ username : `${options.username}`, password : `${options.password}` } |
|
|
|
|
|
, { username : `chess` } |
|
|
|
|
|
// , { username : `baptistdev`, password : 'encrypted' } |
|
|
|
|
|
// , { username : `guest`, password : 'encrypted' } |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
// ${options.reposerver} should be used to lookup current config. |
|
|
|
|
|
|
|
|
|
|
|
// User can always add more branches and remotes as needed. Mainifest only occupies |
|
|
|
|
|
// well defined namespaces |
|
|
|
|
|
var remotes = { |
|
|
|
|
|
// these are both fetch and push remotes. Use push - remotes to override push. |
|
|
|
|
|
'chess' : { |
|
|
|
|
|
server : `${options.reposerver}`, user : 'chess', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch |
|
|
|
|
|
, push : 'no-pushing' } |
|
|
|
|
|
, 'baptistdev-public' : { |
|
|
|
|
|
server : `https://github.com`, user : 'baptistdev', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch |
|
|
|
|
|
, push : 'no-pushing' } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Multiple urls dont tell us the current origin which may be |
|
|
|
|
|
// different based on currently available/accessible based on device and client. |
|
|
|
|
|
// We just treat them as different remotes and merge as needed. |
|
|
|
|
|
// |
|
|
|
|
|
, 'origin' : { |
|
|
|
|
|
server : `${options.reposerver}`, user : '${options.username}', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch |
|
|
|
|
|
} |
|
|
|
|
|
, 'origin-public' : { |
|
|
|
|
|
// export GIT_SSL_NO_VERIFY=true |
|
|
|
|
|
server : `https://git.bbh.org.in`, user : 'chess', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch |
|
|
|
|
|
, push : { |
|
|
|
|
|
server : `${options.reposerver}`, user : `${options.username}`, path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
, 'origin-unc' : { |
|
|
|
|
|
server : `//172.16.0.27/repos`, user : '${options.username}', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch |
|
|
|
|
|
} |
|
|
|
|
|
// , { `${options.username}` : `https://git.bbh.org.in/${options.username}/elxr.git` } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// , 'fetch-remotes' : [] // Multiple fetch remotes are not supported by git. |
|
|
|
|
|
// We therefore need to use |
|
|
|
|
|
// - a pullall |
|
|
|
|
|
// - or branch alias for multiple remote branch tracking branch strategy. |
|
|
|
|
|
// -- This is however limited to corresponding branch names |
|
|
|
|
|
|
|
|
|
|
|
// tracking branches. |
|
|
|
|
|
// We at least need one branch for each remote that we wish to track. |
|
|
|
|
|
// , 'tracking-branches' : [ |
|
|
|
|
|
// { master : ['origin/master', 'chess/master'] } |
|
|
|
|
|
// ] |
|
|
|
|
|
|
|
|
|
|
|
var reposerverinstances = { |
|
|
|
|
|
'http://git.bbh' : { users, remotes } |
|
|
|
|
|
, 'https://git.bbh.org.in' : { users, remotes, external : true } |
|
|
|
|
|
, '//172.16.0.27/repos' : { users, remotes } |
|
|
|
|
|
, 'https://github.com' : { |
|
|
|
|
|
// We host a miniaml set of repositories in github. |
|
|
|
|
|
get users() { return [{ username : `${this.username}` }]}, username : `baptistdev` |
|
|
|
|
|
, remotes : { |
|
|
|
|
|
'baptistdev-public' : { |
|
|
|
|
|
server : `https://github.com`, user : 'baptistdev', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch |
|
|
|
|
|
, push : 'no-pushing' } |
|
|
|
|
|
// , Add other remotes here. |
|
|
|
|
|
} |
|
|
|
|
|
, external : true, public : true |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return { |
|
|
|
|
|
reposervers : Object.keys(reposerverinstances) |
|
|
|
|
|
, reposerverinstances |
|
|
|
|
|
|
|
|
|
|
|
// Common baseline repos for all chess instances. |
|
|
|
|
|
, repos : [ |
|
|
|
|
|
{ repo : 'ember-masonry-grid' /*, branch : master*/ } // Default need not be specified. |
|
|
|
|
|
, { repo : 'bbhverse' } |
|
|
|
|
|
, { repo : 'clientverse' } |
|
|
|
|
|
, { repo : 'serververse' } |
|
|
|
|
|
, { repo : 'elxr' } |
|
|
|
|
|
, { repo : 'ember-searchable-select' } |
|
|
|
|
|
, { repo : 'loopback-component-jsonapi' } |
|
|
|
|
|
, { repo : 'loopback-jsonapi-model-serializer' } |
|
|
|
|
|
, { repo : 'loopback-connector-mysql' } |
|
|
|
|
|
, { repo : 'loopback-connector-ds' } |
|
|
|
|
|
|
|
|
|
|
|
, { repo : 'ember-service-worker' } |
|
|
|
|
|
, { repo : 'ember-service-worker-asset-cache' } |
|
|
|
|
|
, { repo : 'ember-service-worker-cache-fallback' } |
|
|
|
|
|
, { repo : 'ember-service-worker-index' } |
|
|
|
|
|
, { repo : 'ember-sw-client-route' } |
|
|
|
|
|
, { repo : 'global-this' } |
|
|
|
|
|
] |
|
|
|
|
|
// Requires elevation only in windows |
|
|
|
|
|
, elevated : [ { repo : 'chess-server-lib', requiresElevation : true } ] |
|
|
|
|
|
, exludeMergeRepos : { } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
})( |
|
|
|
|
|
'__default' // name |
|
|
|
|
|
, { username : 'guest', instanceName : 'chess', node_env : 'development', reposerver : 'https://git.bbh.org.in' } // options |
|
|
|
|
|
) |
|
|
|
|
|
// We first load the default and then override with a runconfig if it exists else we override with the interactive prompts. |
|
|
// 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. |
|
|
// Then acquire and reload and replace this default. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var hasElxr = function(path, options, cb) { |
|
|
var hasElxr = function(path, options, cb) { |
|
|
// PB : TOOD -- Navigate up the folder chain to discover the relevant .elxr directory. |
|
|
// PB : TOOD -- Navigate up the folder chain to discover the relevant .elxr directory. |
|
|
options = options || {}; |
|
|
options = options || {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getBoundEachPrompt = function(target, possiblePrompts, promptables, choices, promptsfilter) { |
|
|
var getBoundEachPrompt = function(target, possiblePrompts, promptables, choices, promptsfilter) { |
|
|
return function(prompts, k, i, a){ |
|
|
return function(prompts, k, i, a){ |
|
|
|
|
|
|
|
|
|
|
|
// Reducer for all prompts on targets. |
|
|
|
|
|
|
|
|
// No local instances config found. We use a default initialized instance available in selectedinstance |
|
|
// No local instances config found. We use a default initialized instance available in selectedinstance |
|
|
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. |
|
|
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. |
|
|
// PB : TODO -- selectedinstance === __default check to prompt everything... |
|
|
// PB : TODO -- selectedinstance === __default check to prompt everything... |
|
|
if( shouldPrompt(k, possiblePrompts, target) ) { |
|
|
|
|
|
|
|
|
if( shouldPrompt(k, possiblePrompts, target) ) { |
|
|
delete reconfirm[k]; |
|
|
delete reconfirm[k]; |
|
|
// console.log(k) |
|
|
// console.log(k) |
|
|
// console.dir(possiblePrompts); //console.dir(target) |
|
|
// console.dir(possiblePrompts); //console.dir(target) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
, instanceType : { label : `Enter Instance Type ( <= ${target.instanceType || 'development'} ) : ` |
|
|
, instanceType : { label : `Enter Instance Type ( <= ${target.instanceType || 'development'} ) : ` |
|
|
, choices : choices['instanceType'], defaultchoice : 'development' |
|
|
, choices : choices['instanceType'], defaultchoice : 'development' |
|
|
, selectedchoice : target.instanceType |
|
|
|
|
|
|
|
|
, selectedchoice : target.instanceType || 'development' |
|
|
} |
|
|
} |
|
|
, reposerver : { label : `Enter Repo Url ( <= ${target.reposerver || 'https://git.bbh.org.in'} ) : ` |
|
|
|
|
|
, choices : choices['reposerver'], defaultchoice : 'https://git.bbh.org.in' |
|
|
|
|
|
|
|
|
, reposerver : { label : `Enter Repo Server Base Url ( <= ${target.reposerver || 'https://git.bbh.org.in'} ) : ` |
|
|
|
|
|
, get choices() { |
|
|
|
|
|
choices['reposerver'].forEach( rs => { |
|
|
|
|
|
var __rs = new URL(rs); |
|
|
|
|
|
__rs.hostname = __rs.host; |
|
|
|
|
|
__rs.path = '/' |
|
|
|
|
|
__rs.method = 'GET' |
|
|
|
|
|
RESTAPI.get(__rs, function(data){ rs.accessibility = 'unaccessible' } |
|
|
|
|
|
, function(error){ rs.accessibility = 'unaccessible' } ) |
|
|
|
|
|
}) |
|
|
|
|
|
return choices['reposerver'] |
|
|
|
|
|
} |
|
|
|
|
|
, defaultchoice : 'https://git.bbh.org.in' |
|
|
, selectedchoice : target.reposerver |
|
|
, selectedchoice : target.reposerver |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
, 'upstream-remote' : { label : `Enter Remote Name ( <= ${target['upstream-remote'] || 'chess'} ) : ` |
|
|
|
|
|
, get choices() { |
|
|
|
|
|
var reposerver = target['reposerver'] |
|
|
|
|
|
var remotes = [] |
|
|
|
|
|
target.reposervers.forEach(rs => { |
|
|
|
|
|
if(rs.server === reposerver){ |
|
|
|
|
|
remotes.push(remote) |
|
|
|
|
|
// PB : TODO -- Sort and display highest priority target.remotes.sort( ) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
return remotes |
|
|
|
|
|
} |
|
|
|
|
|
, defaultchoice : 'userfork' |
|
|
|
|
|
, selectedchoice : target['upstream-remote'] || 'userfork' |
|
|
|
|
|
// Just using getters resolves dependencies..., dependencies : [ ()=>{ return target['reposerver'] } ] |
|
|
|
|
|
} |
|
|
|
|
|
, 'selectedremotes' : { label : `Chose Remote Names ( <= ${target['selectedremotes'] || 'chess'} ) : ` |
|
|
|
|
|
, get choices() { |
|
|
|
|
|
var reposerver = target['reposerver'] // PB : TODO -- We need options to work with multiple selected reposervers at the same time.. |
|
|
|
|
|
var remotenames = [] |
|
|
|
|
|
Object.entries(target.remotes).forEach( ([rname, r]) => { |
|
|
|
|
|
if(r.server === reposerver){ |
|
|
|
|
|
remotes.push(rname) |
|
|
|
|
|
// PB : TODO -- Sort and display highest priority target.remotes.sort( ) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// PB : TODO -- Need to generate all possible permuted choices nP( 1 -> n ) |
|
|
|
|
|
// Currenty handles all combinations without any priority order. |
|
|
|
|
|
var _remotechoices = [] // Array of arrays of choices. |
|
|
|
|
|
remotenames.forEach( r => { |
|
|
|
|
|
var __rcs = [] |
|
|
|
|
|
_remotechoices.forEach(rc => { |
|
|
|
|
|
__rcs.push( rc.concat(r) ) |
|
|
|
|
|
}) |
|
|
|
|
|
Array.prototype.push.apply( _remotechoices, __rcs) |
|
|
|
|
|
_remotechoices.push(r) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return _remotechoices |
|
|
|
|
|
} |
|
|
|
|
|
, defaultchoice : ['userfork-public', 'chess-public'] |
|
|
|
|
|
, selectedchoice : target['selectedremotes'] || ['userfork-public', 'chess-public'] |
|
|
|
|
|
// , defaultchoice : { 'userfork-public' : target.remotes['userfork-public'] , 'chess-public' : target.remotes['chess-public'] } |
|
|
|
|
|
// , selectedchoice : target['selectedremotes'] || { 'userfork-public' : target.remotes['userfork-public'] , 'chess-public' : target.remotes['chess-public'] } |
|
|
|
|
|
|
|
|
|
|
|
// Info : Just using getters resolves dependencies..., dependencies : [ ()=>{ return target['reposerver'] } ] |
|
|
|
|
|
} |
|
|
, get username() { return { label : `Enter User Id for ${target.reposerver} ( <= ${target.username || 'chess'} ) : ` |
|
|
, get username() { return { label : `Enter User Id for ${target.reposerver} ( <= ${target.username || 'chess'} ) : ` |
|
|
, choices : choices['username'], defaultchoice : 'chess', selectedchoice : target.username } } |
|
|
, choices : choices['username'], defaultchoice : 'chess', selectedchoice : target.username } } |
|
|
, get password() { return { label : `Enter Password for ${target.username} @ ${target.reposerver} ( <= ${target.password || ''} ) : ` |
|
|
, get password() { return { label : `Enter Password for ${target.username} @ ${target.reposerver} ( <= ${target.password || ''} ) : ` |
|
|
|
|
|
|
|
|
var getPromptableAsyncPropDescriptor = function(propName, promptable){ |
|
|
var getPromptableAsyncPropDescriptor = function(propName, promptable){ |
|
|
return { |
|
|
return { |
|
|
get (){ |
|
|
get (){ |
|
|
return cli.prompt( promptable.choices, promptable.label, promptable.defaultchoice, promptable.selectedchoice ).then(propValue => { |
|
|
|
|
|
|
|
|
|
|
|
var asyncprop = Promise.resolve(propValue) |
|
|
|
|
|
if(promptable.interpret){ |
|
|
|
|
|
asyncprop = promptable.interpret(propValue) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return any( promptable.dependencies || [] ).then(()=>{ |
|
|
|
|
|
|
|
|
return asyncprop.then( |
|
|
|
|
|
()=>{ |
|
|
|
|
|
Object.defineProperty(this, propName, { |
|
|
|
|
|
value: propValue, |
|
|
|
|
|
writable: true, |
|
|
|
|
|
configurable : true, |
|
|
|
|
|
enumerable : true |
|
|
|
|
|
}); |
|
|
|
|
|
return propValue |
|
|
|
|
|
|
|
|
return cli.prompt( promptable.choices, promptable.label, promptable.defaultchoice, promptable.selectedchoice ).then(propValue => { |
|
|
|
|
|
|
|
|
|
|
|
var asyncprop = Promise.resolve(propValue) |
|
|
|
|
|
if(promptable.interpret){ |
|
|
|
|
|
asyncprop = promptable.interpret(propValue) |
|
|
} |
|
|
} |
|
|
) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return asyncprop.then( |
|
|
|
|
|
()=>{ |
|
|
|
|
|
Object.defineProperty(this, propName, { |
|
|
|
|
|
value: propValue, |
|
|
|
|
|
writable: true, |
|
|
|
|
|
configurable : true, |
|
|
|
|
|
enumerable : true |
|
|
|
|
|
}); |
|
|
|
|
|
return propValue |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
}) |
|
|
|
|
|
} ) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
// , set (propValue){ |
|
|
// , set (propValue){ |
|
|
// Object.defineProperty(this, propName, { |
|
|
// Object.defineProperty(this, propName, { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function acquirelocalinstances(selected){ |
|
|
function acquirelocalinstances(selected){ |
|
|
// utils.assign is used to cleanup duplicates... |
|
|
|
|
|
var chessinstances = utils.assign(require(path.normalize(selected.root + '/chessinstances.js'))); |
|
|
|
|
|
|
|
|
// utils.assign is used to cleanup duplicates... assuming chessinstances.js is probably not clean. |
|
|
|
|
|
var chessinstances = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, require(path.normalize(selected.root + '/chessinstances.js'))); |
|
|
return chessinstances |
|
|
return chessinstances |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
// function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
var selectedinstance = { root : process.env.wd }; |
|
|
var selectedinstance = { root : process.env.wd }; |
|
|
|
|
|
var runconfig = null; |
|
|
|
|
|
|
|
|
var chessinstances = { current_run : {} }; |
|
|
var chessinstances = { current_run : {} }; |
|
|
var promptkeys = { |
|
|
var promptkeys = { |
|
|
cmd : processedArgs._[0] || 'pull' |
|
|
cmd : processedArgs._[0] || 'pull' |
|
|
|
|
|
|
|
|
inst[cfg.node_env] = __new; return inst; |
|
|
inst[cfg.node_env] = __new; return inst; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var choices = { |
|
|
var choices = { |
|
|
'instanceName' : [] |
|
|
'instanceName' : [] |
|
|
, 'reposerver' : [] |
|
|
, 'reposerver' : [] |
|
|
|
|
|
, 'upstream-remote' : [] |
|
|
, 'instanceType' : [] |
|
|
, 'instanceType' : [] |
|
|
, username : ['guest', 'chessdemo', 'demo'] |
|
|
, username : ['guest', 'chessdemo', 'demo'] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var instances = [] |
|
|
var instances = [] |
|
|
var reposervers = []; |
|
|
var reposervers = []; |
|
|
|
|
|
var remotes = []; |
|
|
var instanceNames = [] |
|
|
var instanceNames = [] |
|
|
var instanceTypes = ['development', 'production']; |
|
|
var instanceTypes = ['development', 'production']; |
|
|
Object.keys( chessinstances).forEach(instanceName => { |
|
|
Object.keys( chessinstances).forEach(instanceName => { |
|
|
|
|
|
|
|
|
instances.push(instance) |
|
|
instances.push(instance) |
|
|
instanceTypes.push(instance.node_env) |
|
|
instanceTypes.push(instance.node_env) |
|
|
instanceNames.push(instance.instanceName) |
|
|
instanceNames.push(instance.instanceName) |
|
|
|
|
|
Array.prototype.push.apply(remotes, Object.keys(instance.reposerverinstances[instance.reposerver].remotes)) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
instances = instances.concat(detectedinstanceoptions) |
|
|
instances = instances.concat(detectedinstanceoptions) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
choices['instanceName'] = Array.from( new Set(instanceNames.concat(choices['instanceName'])) ) |
|
|
choices['instanceName'] = Array.from( new Set(instanceNames.concat(choices['instanceName'])) ) |
|
|
choices['reposerver'] = Array.from( new Set(reposervers.concat(choices['reposerver'])) ) |
|
|
choices['reposerver'] = Array.from( new Set(reposervers.concat(choices['reposerver'])) ) |
|
|
|
|
|
// choices['upstream-remote'] = Array.from( new Set(remotes.concat(choices['upstream-remote'])) ) |
|
|
choices['instanceType'] = Array.from( new Set(instanceTypes.concat(choices['instanceType'])) ) |
|
|
choices['instanceType'] = Array.from( new Set(instanceTypes.concat(choices['instanceType'])) ) |
|
|
|
|
|
|
|
|
return __interactive_prompts(selectedinstance, choices, promptsfilter) |
|
|
return __interactive_prompts(selectedinstance, choices, promptsfilter) |
|
|
|
|
|
|
|
|
const https = require('https') |
|
|
const https = require('https') |
|
|
const http = require('http'); |
|
|
const http = require('http'); |
|
|
const { resolve } = require('path'); |
|
|
const { resolve } = require('path'); |
|
|
|
|
|
const { Console } = require('console'); |
|
|
const RESTAPI = (function(){ |
|
|
const RESTAPI = (function(){ |
|
|
|
|
|
|
|
|
// Singleton |
|
|
// Singleton |
|
|
|
|
|
|
|
|
// __default, chessinstances[current_run], instanceName-config-development, cliargs, interactve_promts |
|
|
// __default, chessinstances[current_run], instanceName-config-development, cliargs, interactve_promts |
|
|
// PB : TODO -- Undefined keys are overriding and deleting values. We should not allow that. |
|
|
// 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. |
|
|
// 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(selected_overrides.node_env === undefined) delete selected_overrides.node_env |
|
|
|
|
|
|
|
|
selectedinstance = utils.assign( |
|
|
|
|
|
chessinstances[instanceName][node_env] |
|
|
|
|
|
|
|
|
selectedinstance = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, __default |
|
|
|
|
|
, chessinstances[instanceName][node_env] |
|
|
, clioverrides |
|
|
, clioverrides |
|
|
, selected_overrides |
|
|
, selected_overrides |
|
|
// , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready... |
|
|
// , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready... |
|
|
|
|
|
|
|
|
var cmdprompts = cmdinstance.getPossiblePrompts() |
|
|
var cmdprompts = cmdinstance.getPossiblePrompts() |
|
|
selectedinstance.node_env ? selectedinstance.node_env : selectedinstance.node_env = clioverrides.node_env |
|
|
selectedinstance.node_env ? selectedinstance.node_env : selectedinstance.node_env = clioverrides.node_env |
|
|
// PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!! |
|
|
// PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!! |
|
|
selectedinstance = utils.assign( ...detectedinstanceoptions.slice(-2), promptkeys ) |
|
|
|
|
|
|
|
|
selectedinstance = utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } |
|
|
|
|
|
, ...detectedinstanceoptions.slice(-2), promptkeys ) |
|
|
// promptkeys = utils.assign(promptkeys, clioverrides) |
|
|
// promptkeys = utils.assign(promptkeys, clioverrides) |
|
|
|
|
|
|
|
|
if(cmdprompts.instanceName) { |
|
|
if(cmdprompts.instanceName) { |
|
|
|
|
|
|
|
|
else return Promise.resolve(true) |
|
|
else return Promise.resolve(true) |
|
|
}) |
|
|
}) |
|
|
.then(()=>{ |
|
|
.then(()=>{ |
|
|
|
|
|
|
|
|
|
|
|
runconfig = { NODE_ENV: selectedinstance.node_env } |
|
|
|
|
|
try { runconfig = Object.assign(runconfig, require(instanceroot + '/run.js')) } catch (e) { } |
|
|
generateDependencies(); |
|
|
generateDependencies(); |
|
|
if(noprerequisites[processedArgs._[0]] |
|
|
if(noprerequisites[processedArgs._[0]] |
|
|
|| skipprereqs[processedArgs._[0]] |
|
|
|| skipprereqs[processedArgs._[0]] |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var __default = null; // PB : TODO -- Use initialized instance instead of default everywhere. |
|
|
// PB : TODO -- In windows if we are run from an elevated shell we never move forward and simply exits !?. |
|
|
// PB : TODO -- In windows if we are run from an elevated shell we never move forward and simply exits !?. |
|
|
// -- Currently workaround in windows is to always run from a non-elevated shell. |
|
|
// -- Currently workaround in windows is to always run from a non-elevated shell. |
|
|
shell_verse.acquireElevationState().then((elevationstate) => { |
|
|
shell_verse.acquireElevationState().then((elevationstate) => { |
|
|
return detectInstanceRoot.then(()=>{ |
|
|
return detectInstanceRoot.then(()=>{ |
|
|
|
|
|
|
|
|
|
|
|
// PB : TODO -- Embed this in the build instead of inlining it. |
|
|
|
|
|
// Also attepmt to load from ../chess-config/... |
|
|
|
|
|
var __repo_manifest = (require(path.normalize(instanceroot + '/elxr/repo-manifest.js')))( |
|
|
|
|
|
'__default' // name |
|
|
|
|
|
, { utils, username : 'guest', instanceName : 'chess', node_env : 'development', reposerver : 'https://git.bbh.org.in' } // options |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
__default = Object.assign(__repo_manifest, { |
|
|
|
|
|
// Common baseline repos for all chess instances. |
|
|
|
|
|
repos : (()=> { |
|
|
|
|
|
var __repos = [ |
|
|
|
|
|
{ repo : 'ember-masonry-grid' /*, branch : master*/ } // Default need not be specified. |
|
|
|
|
|
, { repo : 'bbhverse' } |
|
|
|
|
|
, { repo : 'clientverse' } |
|
|
|
|
|
, { repo : 'serververse' } |
|
|
|
|
|
, { repo : 'elxr' } |
|
|
|
|
|
, { repo : 'ember-searchable-select' } |
|
|
|
|
|
, { repo : 'loopback-component-jsonapi' } |
|
|
|
|
|
, { repo : 'loopback-jsonapi-model-serializer' } |
|
|
|
|
|
, { repo : 'loopback-connector-mysql' } |
|
|
|
|
|
, { repo : 'loopback-connector-ds' } |
|
|
|
|
|
|
|
|
|
|
|
, { repo : 'ember-service-worker' } |
|
|
|
|
|
, { repo : 'ember-service-worker-asset-cache' } |
|
|
|
|
|
, { repo : 'ember-service-worker-cache-fallback' } |
|
|
|
|
|
, { repo : 'ember-service-worker-index' } |
|
|
|
|
|
, { repo : 'ember-sw-client-route' } |
|
|
|
|
|
, { repo : 'global-this' } |
|
|
|
|
|
] |
|
|
|
|
|
Array.prototype.push.apply( __repos, __repo_manifest.repos) |
|
|
|
|
|
return __repos; |
|
|
|
|
|
})() |
|
|
|
|
|
// Requires elevation only in windows |
|
|
|
|
|
, elevated : [ { repo : 'chess-server-lib', requiresElevation : true } ] |
|
|
|
|
|
, exludeMergeRepos : { } |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cmdobj = cmds[clioverrides.cmd] |
|
|
var cmdobj = cmds[clioverrides.cmd] |
|
|
return Promise.all((cmdobj.requires || []).map( (r) => utils.promisify(null, r) ) ).then(()=>{ |
|
|
return Promise.all((cmdobj.requires || []).map( (r) => utils.promisify(null, r) ) ).then(()=>{ |
|
|
if(cmdobj.independentcmd) { |
|
|
if(cmdobj.independentcmd) { |