|
|
|
|
|
|
|
|
/* Version: 1.0.0 - August 11, 2021 17:45:09 */ |
|
|
|
|
|
|
|
|
/* Version: 1.0.0 - August 23, 2021 14:13:43 */ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
var path$1 = require('path'); |
|
|
var path$1 = require('path'); |
|
|
|
|
|
|
|
|
return hooks; |
|
|
return hooks; |
|
|
|
|
|
|
|
|
}))); |
|
|
}))); |
|
|
}, "/$$rollup_base$$/node_modules/moment"); |
|
|
|
|
|
|
|
|
}, "E:/elixir/production_A/bbhverse/node_modules/moment"); |
|
|
|
|
|
|
|
|
let array8 = arrayUntyped, |
|
|
let array8 = arrayUntyped, |
|
|
array16 = arrayUntyped, |
|
|
array16 = arrayUntyped, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var v3 = v35('v3', 0x30, md5); |
|
|
var v3 = v35('v3', 0x30, md5); |
|
|
var v3$1 = v3; |
|
|
|
|
|
|
|
|
|
|
|
function v4(options, buf, offset) { |
|
|
function v4(options, buf, offset) { |
|
|
options = options || {}; |
|
|
options = options || {}; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var v5 = v35('v5', 0x50, sha1); |
|
|
var v5 = v35('v5', 0x50, sha1); |
|
|
var v5$1 = v5; |
|
|
|
|
|
|
|
|
|
|
|
var nil = '00000000-0000-0000-0000-000000000000'; |
|
|
var nil = '00000000-0000-0000-0000-000000000000'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var esmBrowser = /*#__PURE__*/Object.freeze({ |
|
|
var esmBrowser = /*#__PURE__*/Object.freeze({ |
|
|
__proto__: null, |
|
|
__proto__: null, |
|
|
v1: v1, |
|
|
v1: v1, |
|
|
v3: v3$1, |
|
|
|
|
|
|
|
|
v3: v3, |
|
|
v4: v4, |
|
|
v4: v4, |
|
|
v5: v5$1, |
|
|
|
|
|
|
|
|
v5: v5, |
|
|
NIL: nil, |
|
|
NIL: nil, |
|
|
version: version$1, |
|
|
version: version$1, |
|
|
validate: validate, |
|
|
validate: validate, |
|
|
|
|
|
|
|
|
parse: parse$1 |
|
|
parse: parse$1 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
var require$$1$1 = /*@__PURE__*/getAugmentedNamespace(esmBrowser); |
|
|
|
|
|
|
|
|
var require$$1 = /*@__PURE__*/getAugmentedNamespace(esmBrowser); |
|
|
|
|
|
|
|
|
// var __g = __G.__g; |
|
|
// var __g = __G.__g; |
|
|
globalThis_1.mediator = mediator.apply({}); |
|
|
globalThis_1.mediator = mediator.apply({}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var uuidv1 = require('uuid/v1'); |
|
|
// var uuidv1 = require('uuid/v1'); |
|
|
const { v1: uuidv1 } = require$$1$1; |
|
|
|
|
|
|
|
|
const { v1: uuidv1 } = require$$1; |
|
|
console.log(uuidv1); |
|
|
console.log(uuidv1); |
|
|
|
|
|
|
|
|
// Mixins. |
|
|
// Mixins. |
|
|
|
|
|
|
|
|
childrenIgnored: childrenIgnored_1 |
|
|
childrenIgnored: childrenIgnored_1 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var require$$1 = glob_1; |
|
|
|
|
|
|
|
|
|
|
|
var sync = globSync; |
|
|
var sync = globSync; |
|
|
globSync.GlobSync = GlobSync$1; |
|
|
globSync.GlobSync = GlobSync$1; |
|
|
require$$1.Glob; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return array |
|
|
return array |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Approach: |
|
|
|
|
|
// |
|
|
|
|
|
// 1. Get the minimatch set |
|
|
|
|
|
// 2. For each pattern in the set, PROCESS(pattern, false) |
|
|
|
|
|
// 3. Store matches per-set, then uniq them |
|
|
|
|
|
// |
|
|
|
|
|
// PROCESS(pattern, inGlobStar) |
|
|
|
|
|
// Get the first [n] items from pattern that are all strings |
|
|
|
|
|
// Join these together. This is PREFIX. |
|
|
|
|
|
// If there is no more remaining, then stat(PREFIX) and |
|
|
|
|
|
// add to matches if it succeeds. END. |
|
|
|
|
|
// |
|
|
|
|
|
// If inGlobStar and PREFIX is symlink and points to dir |
|
|
|
|
|
// set ENTRIES = [] |
|
|
|
|
|
// else readdir(PREFIX) as ENTRIES |
|
|
|
|
|
// If fail, END |
|
|
|
|
|
// |
|
|
|
|
|
// with ENTRIES |
|
|
|
|
|
// If pattern[n] is GLOBSTAR |
|
|
|
|
|
// // handle the case where the globstar match is empty |
|
|
|
|
|
// // by pruning it out, and testing the resulting pattern |
|
|
|
|
|
// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) |
|
|
|
|
|
// // handle other cases. |
|
|
|
|
|
// for ENTRY in ENTRIES (not dotfiles) |
|
|
|
|
|
// // attach globstar + tail onto the entry |
|
|
|
|
|
// // Mark that this entry is a globstar match |
|
|
|
|
|
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) |
|
|
|
|
|
// |
|
|
|
|
|
// else // not globstar |
|
|
|
|
|
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) |
|
|
|
|
|
// Test ENTRY against pattern[n] |
|
|
|
|
|
// If fails, continue |
|
|
|
|
|
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) |
|
|
|
|
|
// |
|
|
|
|
|
// Caveat: |
|
|
|
|
|
// Cache all stats and readdirs results to minimize syscall. Since all |
|
|
|
|
|
// we ever care about is existence and directory-ness, we can just keep |
|
|
|
|
|
// `true` for files, and [children,...] for directories, or `false` for |
|
|
|
|
|
// things that don't exist. |
|
|
|
|
|
|
|
|
|
|
|
var glob_1 = glob; |
|
|
|
|
|
|
|
|
|
|
|
var EE = require$$0__default$1['default'].EventEmitter; |
|
|
var EE = require$$0__default$1['default'].EventEmitter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var childrenIgnored = common.childrenIgnored; |
|
|
var childrenIgnored = common.childrenIgnored; |
|
|
var isIgnored = common.isIgnored; |
|
|
var isIgnored = common.isIgnored; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function glob (pattern, options, cb) { |
|
|
|
|
|
if (typeof options === 'function') cb = options, options = {}; |
|
|
|
|
|
if (!options) options = {}; |
|
|
|
|
|
|
|
|
|
|
|
if (options.sync) { |
|
|
|
|
|
if (cb) |
|
|
|
|
|
throw new TypeError('callback provided to sync glob') |
|
|
|
|
|
return sync(pattern, options) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new Glob(pattern, options, cb) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
glob.sync = sync; |
|
|
|
|
|
var GlobSync = glob.GlobSync = sync.GlobSync; |
|
|
|
|
|
|
|
|
|
|
|
// old api surface |
|
|
|
|
|
glob.glob = glob; |
|
|
|
|
|
|
|
|
|
|
|
function extend (origin, add) { |
|
|
|
|
|
if (add === null || typeof add !== 'object') { |
|
|
|
|
|
return origin |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var keys = Object.keys(add); |
|
|
|
|
|
var i = keys.length; |
|
|
|
|
|
while (i--) { |
|
|
|
|
|
origin[keys[i]] = add[keys[i]]; |
|
|
|
|
|
} |
|
|
|
|
|
return origin |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
glob.hasMagic = function (pattern, options_) { |
|
|
|
|
|
var options = extend({}, options_); |
|
|
|
|
|
options.noprocess = true; |
|
|
|
|
|
|
|
|
|
|
|
var g = new Glob(pattern, options); |
|
|
|
|
|
var set = g.minimatch.set; |
|
|
|
|
|
|
|
|
|
|
|
if (!pattern) |
|
|
|
|
|
return false |
|
|
|
|
|
|
|
|
|
|
|
if (set.length > 1) |
|
|
|
|
|
return true |
|
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < set[0].length; j++) { |
|
|
|
|
|
if (typeof set[0][j] !== 'string') |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
glob.Glob = Glob; |
|
|
|
|
|
|
|
|
var GlobSync = sync.GlobSync; |
|
|
inherits(Glob, EE); |
|
|
inherits(Glob, EE); |
|
|
function Glob (pattern, options, cb) { |
|
|
function Glob (pattern, options, cb) { |
|
|
if (typeof options === 'function') { |
|
|
if (typeof options === 'function') { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const BUILD_VERSION = 'Version: 1.0.0 - built on August 11, 2021 17:45:09'; |
|
|
|
|
|
|
|
|
const BUILD_VERSION = 'Version: 1.0.0 - built on August 23, 2021 14:13:43'; |
|
|
const runtimestamp = (new Date()).getTime(); |
|
|
const runtimestamp = (new Date()).getTime(); |
|
|
function getVersion() { return BUILD_VERSION; } |
|
|
function getVersion() { return BUILD_VERSION; } |
|
|
console.log(getVersion()); |
|
|
console.log(getVersion()); |
|
|
|
|
|
|
|
|
const cliargs = bbhverse.cliargs; |
|
|
const cliargs = bbhverse.cliargs; |
|
|
const processedArgs = cliargs(process.argv.slice(2)); |
|
|
const processedArgs = cliargs(process.argv.slice(2)); |
|
|
console.dir(processedArgs); |
|
|
console.dir(processedArgs); |
|
|
// PB : TODO -- defaults for valuless arguments if passed. |
|
|
|
|
|
// Object.keys(processedArgs).forEach(a=>{ |
|
|
|
|
|
// if(Object.prototype.toString.call(processedArgs[a]) === '[object Undefined]' || !processedArgs[a]) || trim(processedArgs[a])) == '') { |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
require$$1.sync; |
|
|
|
|
|
|
|
|
|
|
|
var ENV = Object.assign({}, process.env); // Shallow clone it. |
|
|
var ENV = Object.assign({}, process.env); // Shallow clone it. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getTaskWithoutElevation = function(tasdef){ |
|
|
var getTaskWithoutElevation = function(tasdef){ |
|
|
return ()=>{ |
|
|
return ()=>{ |
|
|
if(!processedArgs.runas) { return tasdef.regularpulltasks(); } |
|
|
if(!processedArgs.runas) { return tasdef.regularpulltasks(); } |
|
|
else Promise.resolve(true); |
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// git remote equivalents... |
|
|
// git remote equivalents... |
|
|
// git branch --set-upstream-to=elixir-unc/master master |
|
|
// git branch --set-upstream-to=elixir-unc/master master |
|
|
// git push --set-upstream elixir-unc branch.. |
|
|
// git push --set-upstream elixir-unc branch.. |
|
|
|
|
|
, 'remote': (args) => { |
|
|
|
|
|
|
|
|
|
|
|
// Subcommands! |
|
|
|
|
|
if(!processedArgs.v) return false; |
|
|
|
|
|
|
|
|
|
|
|
var serial_perform = (repo) => { |
|
|
|
|
|
var options = { cwd: instanceroot + '/' + repo }; |
|
|
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
['git', ['remote', '-v'], options] |
|
|
|
|
|
] |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var x = (args) => { |
|
|
|
|
|
var tasq = () => { |
|
|
|
|
|
// console.log(args) |
|
|
|
|
|
return nodeShellExec.apply(null, args).catch(e => { |
|
|
|
|
|
// We continue on failure. |
|
|
|
|
|
console.error(tasq.toString()); |
|
|
|
|
|
}) |
|
|
|
|
|
}; |
|
|
|
|
|
tasq.toString = function(){ |
|
|
|
|
|
return JSON.stringify(args) |
|
|
|
|
|
}; |
|
|
|
|
|
return tasq; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var perform = (dir) => { |
|
|
|
|
|
return any(serial_perform(dir.name).map(x)) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
dirs(perform); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
, 'remote set-url': (args) => { |
|
|
, 'remote set-url': (args) => { |
|
|
// git remote set-url elixir-unc //10.10.5.60/gitrepo/chess/bbhverse |
|
|
// git remote set-url elixir-unc //10.10.5.60/gitrepo/chess/bbhverse |
|
|
var __args = { |
|
|
var __args = { |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
var perform_git_seturl = (dir) => { |
|
|
var perform_git_seturl = (dir) => { |
|
|
op['is-git-repo'](dir).then((logEntry) => { |
|
|
op['is-git-repo'](dir).then((logEntry) => { |
|
|
any(serial_perform_git_seturl(dir.name).map(x)); |
|
|
|
|
|
|
|
|
return any(serial_perform_git_seturl(dir.name).map(x)) |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
// console.log('Failed : ' + dir.name) |
|
|
// console.log('Failed : ' + dir.name) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
, getpulltask(def){ |
|
|
, getpulltask(def){ |
|
|
|
|
|
|
|
|
def = (def ? ( |
|
|
|
|
|
def.requiresElevation = true, |
|
|
|
|
|
def.reqularRepos = def.repos, |
|
|
|
|
|
def.elevatedRepos = def.elevatedRunasRepos |
|
|
|
|
|
|
|
|
// def can be an instance config |
|
|
|
|
|
// Or an object with many repos and elevated repos |
|
|
|
|
|
// Or a single repo ( Either Elevated or normal. ) |
|
|
|
|
|
|
|
|
) : false) || { |
|
|
|
|
|
requiresElevation : true, |
|
|
|
|
|
reqularRepos : gitRepos, |
|
|
|
|
|
elevatedRepos : elevatedRunasRepos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def = def || { |
|
|
|
|
|
repos : repomanifest.repos, |
|
|
|
|
|
elevated : repomanifest.elevated |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var elevatedpulltasks = null; |
|
|
|
|
|
if(def.repo) { |
|
|
|
|
|
// Single repo case. |
|
|
|
|
|
if(def.repo.requiresElevation) { |
|
|
|
|
|
elevatedpulltasks = function() { |
|
|
|
|
|
return performPull(def.repo).then(() => { |
|
|
|
|
|
return true; |
|
|
|
|
|
}).catch((e) => { |
|
|
|
|
|
console.error(e); |
|
|
|
|
|
}) |
|
|
|
|
|
}; |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var regularpulltasks = function(){ |
|
|
|
|
|
var pendingpulls = []; |
|
|
|
|
|
pendingpulls.push(performPull(def.repo)); |
|
|
|
|
|
return Promise.all(pendingpulls).finally(Traq.finally) |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
if(elevatedpulltasks) return getTaskWithElevation( { elevatedpulltasks, regularpulltasks} ) |
|
|
|
|
|
else return getTaskWithoutElevation({ regularpulltasks}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
console.log(`-------------------Processing pull for : ${def.repo} ${def.branch}`); |
|
|
|
|
|
|
|
|
// console.log(`-------------------Processing pull for : ${def.repo} ${def.branch}`) |
|
|
console.dir(def); |
|
|
console.dir(def); |
|
|
|
|
|
|
|
|
Object.assign({}, process.env); // Shallow clone it. |
|
|
Object.assign({}, process.env); // Shallow clone it. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processedArgs.useGitPull || false; |
|
|
processedArgs.useGitPull || false; |
|
|
|
|
|
|
|
|
if(def.elevatedRepos || def.reqularRepos) { |
|
|
|
|
|
if(def.elevatedRepos) def.requiresElevation = true; |
|
|
|
|
|
|
|
|
if(def.elevated || def.repos) { |
|
|
|
|
|
if(def.elevated) def.requiresElevation = true; |
|
|
else delete def.requiresElevation; |
|
|
else delete def.requiresElevation; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if(def.requiresElevation) def.elevatedRepos = [def]; |
|
|
|
|
|
else def.reqularRepos = [def]; |
|
|
|
|
|
|
|
|
if(def.requiresElevation) def.elevated = [def]; |
|
|
|
|
|
else def.repos = [def]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var elevatedpulltasks = null; |
|
|
|
|
|
|
|
|
|
|
|
var regularpulltasks = function(){ return Promise.resolve(true) }; |
|
|
var regularpulltasks = function(){ return Promise.resolve(true) }; |
|
|
if(def.elevatedRepos){ |
|
|
|
|
|
|
|
|
if(def.elevated){ |
|
|
elevatedpulltasks = function() { |
|
|
elevatedpulltasks = function() { |
|
|
return any(def.elevatedRepos.map((def) => performPull(def.repo))).then(() => { |
|
|
|
|
|
|
|
|
return any(def.elevated.map((def) => performPull(def.repo))).then(() => { |
|
|
return true; |
|
|
return true; |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
console.error(e); |
|
|
console.error(e); |
|
|
}) |
|
|
}) |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
if(def.reqularRepos) { |
|
|
|
|
|
|
|
|
if(def.repos) { |
|
|
var regularpulltasks = function(){ |
|
|
var regularpulltasks = function(){ |
|
|
var pendingpulls = []; |
|
|
var pendingpulls = []; |
|
|
def.reqularRepos.forEach((def) => { pendingpulls.push(performPull(def.repo)); }); |
|
|
|
|
|
|
|
|
def.repos.forEach((def) => { pendingpulls.push(performPull(def.repo)); }); |
|
|
return Promise.all(pendingpulls).finally(Traq.finally) |
|
|
return Promise.all(pendingpulls).finally(Traq.finally) |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// The main elxr cli process |
|
|
// The main elxr cli process |
|
|
function elxrworker() { |
|
|
function elxrworker() { |
|
|
var subcommandlabels = { |
|
|
var subcommandlabels = { |
|
|
remote : `remote ${processedArgs._[1]}` |
|
|
|
|
|
|
|
|
remote : (`remote ${processedArgs._[1] || ''}`).trim() |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var __runcmd = function (label) { |
|
|
var __runcmd = function (label) { |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var mergeObjByKey = function(arrOfObjs, keyName) { |
|
|
|
|
|
|
|
|
|
|
|
var keyedDistinct = {}; |
|
|
|
|
|
var distinctArrOfObjs = []; |
|
|
|
|
|
|
|
|
|
|
|
arrOfObjs.forEach( o => { |
|
|
|
|
|
if(o) (keyedDistinct[o[keyName]] || (keyedDistinct[o[keyName]] = []) ).push(o); |
|
|
|
|
|
}); |
|
|
|
|
|
Object.keys(keyedDistinct).forEach(key => { |
|
|
|
|
|
distinctArrOfObjs.push( bbhverse.assign( ...keyedDistinct[key] ) ); // PB : TODO -- Shallow use utils.assign |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return distinctArrOfObjs; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var cacheWriteInstanceConfig = function(chessinstances){ |
|
|
|
|
|
var instanceName = chessinstances['current_run'].instanceName; |
|
|
|
|
|
var node_env = chessinstances['current_run'].node_env; |
|
|
|
|
|
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' }); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
var acquireConfig = function (selected, chessinstances) { |
|
|
var acquireConfig = function (selected, chessinstances) { |
|
|
|
|
|
|
|
|
var configrepo = selected.instanceName + '-config-' + selected.node_env; |
|
|
var configrepo = selected.instanceName + '-config-' + selected.node_env; |
|
|
|
|
|
|
|
|
chessinstances[selected.instanceName][selected.node_env] = chessinstances[selected.instanceName][selected.node_env] || {}; |
|
|
chessinstances[selected.instanceName][selected.node_env] = chessinstances[selected.instanceName][selected.node_env] || {}; |
|
|
chessinstances['current_run'] = { instanceName: selected.instanceName, node_env: selected.node_env }; |
|
|
chessinstances['current_run'] = { instanceName: selected.instanceName, node_env: selected.node_env }; |
|
|
// Config from server always override merges into selection ecept for the current selection. |
|
|
// Config from server always override merges into selection ecept for the current selection. |
|
|
|
|
|
// PB : TODO -- utils.assign Array merges are non-distinct... |
|
|
selectedinstance = bbhverse.assign(chessinstances[selected.instanceName][selected.node_env], selected, repomanifest); |
|
|
selectedinstance = bbhverse.assign(chessinstances[selected.instanceName][selected.node_env], selected, repomanifest); |
|
|
// chessinstances[selectedinstance.instanceName][selectedinstance.node_env] = selectedinstance; |
|
|
// chessinstances[selectedinstance.instanceName][selectedinstance.node_env] = selectedinstance; |
|
|
fs.writeFileSync(instanceroot + '/chessinstances.js', 'module.exports = ' + JSON.stringify(chessinstances, null, 2) + '', { 'flag': 'w' }); |
|
|
|
|
|
|
|
|
cacheWriteInstanceConfig(chessinstances); |
|
|
|
|
|
selectedinstance = chessinstances[selected.instanceName][selected.node_env]; |
|
|
// PB : TODO -- We should probably write the new server config also... |
|
|
// 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... |
|
|
selectedinstance.reposerver = selectedinstance.reposerver || selectedinstance.reposervers[0]; // PB : TODO -- Attempt first one that is available and online... |
|
|
ENV.NODE_ENV = selectedinstance.node_env; |
|
|
ENV.NODE_ENV = selectedinstance.node_env; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectedinstance = Object.assign(detectedInstance, clioverrides); |
|
|
selectedinstance = Object.assign(detectedInstance, clioverrides); |
|
|
var todo = Promise.resolve(true); |
|
|
var todo = Promise.resolve(true); |
|
|
|
|
|
var promptkeys = { 'instanceName' : processedArgs._[1] }; |
|
|
|
|
|
|
|
|
|
|
|
var reconfirm = { |
|
|
|
|
|
'instanceName' : selectedinstance['instanceName'] === 'chess' |
|
|
|
|
|
}; |
|
|
|
|
|
var prompts = []; |
|
|
|
|
|
var eachPrompt = function(k, i, a){ |
|
|
|
|
|
|
|
|
|
|
|
// 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. |
|
|
|
|
|
if(promptkeys[k] && selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined && selectedinstance[k] === undefined |
|
|
|
|
|
|| reconfirm[k]) { |
|
|
|
|
|
prompts.push(async ()=>{ |
|
|
|
|
|
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. |
|
|
|
|
|
// We take a snapshot... Shallow.. !! If required deep should be used based on use case. |
|
|
|
|
|
// If latest altered state is required we can reerence this directly. |
|
|
|
|
|
// var asyncthis = Object.assign(this); |
|
|
|
|
|
Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] )); |
|
|
|
|
|
return await selectedinstance[k] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
delete promptkeys[k]; |
|
|
|
|
|
}; |
|
|
try { |
|
|
try { |
|
|
chessinstances = acquirelocalinstances(selectedinstance); |
|
|
chessinstances = acquirelocalinstances(selectedinstance); |
|
|
var promptkeys = { |
|
|
|
|
|
'instanceName' : processedArgs._[1] |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var reconfirm = { |
|
|
|
|
|
'instanceName' : true |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
initinstances(chessinstances, selectedinstance); |
|
|
initinstances(chessinstances, selectedinstance); |
|
|
|
|
|
|
|
|
var instanceNameChoices = new Set(Object.keys( chessinstances) ); |
|
|
var instanceNameChoices = new Set(Object.keys( chessinstances) ); |
|
|
instanceNameChoices.delete('current_run'); |
|
|
instanceNameChoices.delete('current_run'); |
|
|
instanceNameChoices.add(selectedinstance['instanceName']); |
|
|
instanceNameChoices.add(selectedinstance['instanceName']); |
|
|
instanceNameChoices.add(promptkeys['instanceName']); |
|
|
|
|
|
|
|
|
if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName']); |
|
|
|
|
|
|
|
|
var choices = { |
|
|
var choices = { |
|
|
'instanceName' : Array.from(instanceNameChoices) |
|
|
'instanceName' : Array.from(instanceNameChoices) |
|
|
, 'reposerver' : selectedinstance['reposervers'] |
|
|
, 'reposerver' : selectedinstance['reposervers'] |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var prompts = []; |
|
|
|
|
|
var eachPrompt = function(k, i, a){ |
|
|
|
|
|
|
|
|
|
|
|
// 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. |
|
|
|
|
|
if(selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined || reconfirm[k]) { |
|
|
|
|
|
prompts.push(async ()=>{ |
|
|
|
|
|
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. |
|
|
|
|
|
// We take a snapshot... Shallow.. !! If required deep should be used based on use case. |
|
|
|
|
|
// If latest altered state is required we can reerence this directly. |
|
|
|
|
|
// var asyncthis = Object.assign(this); |
|
|
|
|
|
Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] )); |
|
|
|
|
|
return await selectedinstance[k] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
delete promptkeys[k]; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts); |
|
|
Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts); |
|
|
Object.keys(promptkeys).forEach(eachPrompt, promptkeys); |
|
|
Object.keys(promptkeys).forEach(eachPrompt, promptkeys); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (e) { |
|
|
catch (e) { |
|
|
console.error(e); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Basic keys that must be prompted and confirmed if not supplied as cmd line args. |
|
|
|
|
|
// PB: TODO --- This should be cmd specific interpretation of location parameters !!! |
|
|
|
|
|
var promptkeys = { |
|
|
|
|
|
'instanceName' : processedArgs._[1] |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var reconfirm = { |
|
|
|
|
|
'instanceName' : true |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.error(e); // Missing chessinstances is not an error... |
|
|
|
|
|
|
|
|
initinstances(chessinstances, selectedinstance); |
|
|
initinstances(chessinstances, selectedinstance); |
|
|
|
|
|
|
|
|
var instanceNameChoices = new Set(Object.keys( chessinstances) ); |
|
|
var instanceNameChoices = new Set(Object.keys( chessinstances) ); |
|
|
instanceNameChoices.delete('current_run'); |
|
|
instanceNameChoices.delete('current_run'); |
|
|
instanceNameChoices.add(selectedinstance['instanceName']); |
|
|
instanceNameChoices.add(selectedinstance['instanceName']); |
|
|
instanceNameChoices.add(promptkeys['instanceName']); |
|
|
|
|
|
|
|
|
if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName']); |
|
|
|
|
|
|
|
|
var choices = { |
|
|
var choices = { |
|
|
'instanceName' : Array.from(instanceNameChoices) |
|
|
'instanceName' : Array.from(instanceNameChoices) |
|
|
, 'reposerver' : selectedinstance['reposervers'] |
|
|
, 'reposerver' : selectedinstance['reposervers'] |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var prompts = []; |
|
|
|
|
|
var eachPrompt = function(k, i, a){ |
|
|
|
|
|
|
|
|
|
|
|
// 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. |
|
|
|
|
|
if(selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined || reconfirm[k]) { |
|
|
|
|
|
prompts.push(async ()=>{ |
|
|
|
|
|
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. |
|
|
|
|
|
// We take a snapshot... Shallow.. !! If required deep should be used based on use case. |
|
|
|
|
|
// If latest altered state is required we can reerence this directly. |
|
|
|
|
|
// var asyncthis = Object.assign(this); |
|
|
|
|
|
Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] )); |
|
|
|
|
|
return await selectedinstance[k] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
delete promptkeys[k]; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts); |
|
|
Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts); |
|
|
Object.keys(promptkeys).forEach(eachPrompt, promptkeys); |
|
|
Object.keys(promptkeys).forEach(eachPrompt, promptkeys); |
|
|
|
|
|
|