Browse Source

Merge branch 'master' of http://git.bbh/chess/elxr

production^2^2
Aaron 3 years ago
parent
commit
77953dce2f
6 changed files with 3030 additions and 630 deletions
  1. 12
    6
      cliverse.js
  2. 2440
    227
      i.js
  3. 390
    0
      i.win.js
  4. 187
    69
      index.js
  5. 0
    328
      package-lock.json
  6. 1
    0
      package.json

+ 12
- 6
cliverse.js View File

@@ -76,13 +76,19 @@ const readline = require("readline");
var cli = {
nodeShellExec
, get prompter() {
const clii = readline.createInterface({ input: process.stdin, output: process.stdout });
clii.ask = function(q){
return new Promise((resolve, reject)=>{
clii.question(q, (answer)=>{ resolve(answer) })
})
var prompt_interface = {
ask : function(q){
// Needs to be serialized. Parallel asks are not possible.
const clii = readline.createInterface({ input: process.stdin, output: process.stdout });
return new Promise((resolve, reject)=>{
clii.question(q, (answer)=>{
clii.close();
resolve(answer)
})
})
}
}
return clii
return prompt_interface
}
, prompt
}

+ 2440
- 227
i.js
File diff suppressed because it is too large
View File


+ 390
- 0
i.win.js View File

@@ -0,0 +1,390 @@

var BUILD_VERSION = '[VI]Version: {version} - built on {date}[/VI]';
var runtimestamp = (new Date()).getTime();
function getVersion() { return BUILD_VERSION; }
WScript.echo(getVersion())

var fso = new ActiveXObject('Scripting.FileSystemObject');
var shell = new ActiveXObject('shell.application');
function forEach(eachFn){
for(var i=0; i<this.length; i++) eachFn(this[i])
}

var console = { log : function(m) {WScript.Echo(m)}, error : function(m) {WScript.Echo(m)} }
var Promise = function(fn){

// Detect error
var state = Promise.PENDING;
var chain = [];
chain.forEach = forEach;

function reject(e){
if(state !== Promise.PENDING) { console.error ('Error : Promise Rejection can only be called once')}
var __i = 0;
var __e = e;
do {
for(var i = __i; i < chain.length; i++, __i = i) if(chain[i].isCatch) break;
try {
for(var i = __i; i < chain.length; i++, __i = i) if(chain[i].isCatch) { chain[i](__e); break; }
__e = null;
}
catch(e){ __e = e}
} while(__e)
do {
try { for(var i = __i; i < chain.length; i++, __i = i) if(!chain[i].isCatch) { p.result = chain[i](p.result); } }
catch(e){
do {
try {
for(var i = __i; i < chain.length; i++, __i = i) if(chain[i].isCatch) { chain[i](__e); break; }
__e = null;
}
catch(e){ __e = e}
} while(__e)
}
} while ( __i < chain.length )
state = Promise.REJECTED;
}

function resolve(result){
if(state !== Promise.PENDING) { console.error ('Error : Promise Rejection can only be called once')}
// console.log('main promise resolve... ' + chain.length )
p.result = result;
var __i = 0;
do {
try { for(var i = __i; i < chain.length; i++, __i = i) if(!chain[i].isCatch) { p.result = chain[i](p.result); } }
catch(e){
var __e = e;
do {
try {
for(var i = __i; i < chain.length; i++, __i = i) if(chain[i].isCatch) { chain[i](__e); break; }
__e = null;
}
catch(e){ __e = e}
} while(__e)
}
} while ( __i < chain.length )
state = Promise.FULFILLED;
};
var p = {
then : function(thenfn){
thenfn.isThen = true
chain.push(thenfn)
return p;
}
, pcatch : function(catchfn) {
catchfn.isCatch = true
chain.push(catchfn)
return p;
}
, start : function(){
try { fn(resolve, reject) }
catch(e){ reject(e) }
}
}
return p
}

Promise.all = function(arr){
arr.forEach = forEach;
var results = [];
return new Promise(function(resolve, reject){
arr.forEach(function(p){ results.push(waitForResult(p))} )
resolve(results)
});
}

any = function(arr){
arr.forEach = forEach;
var results = [];
return new Promise(function(resolve, reject){
arr.forEach(function(p){ results.push(waitForResult(p))} )
resolve(results)
});
}

Promise.PENDING = 1
Promise.FULFILLED = 2
Promise.REJECTED = 3


function waitForResult(p){
while(p.state === Promise.PENDING) WScript.Sleep(500)
return true
}

var stampedFilePfx = function(date) {
return date.getFullYear() +
('0' + (date.getMonth() + 1)).slice(-2) +
('0' + date.getDate()).slice(-2) +
('0' + date.getHours()).slice(-2) +
('0' + date.getMinutes()).slice(-2) +
('0' + date.getSeconds()).slice(-2);
}
function nodeShellExec(cmd, cargs){
var p = new Promise(function(resolve, reject){
var runFile = selectedinstance.root + '\\' + stampedFilePfx(new Date()) + cmd + cargs + "out.txt";
// console.log(runFile)
shell.ShellExecute('cmd', '/c ' + cmd + ' ' + cargs + " > " + runFile , "", "", 1);
// var WshFinished = 1
// var WshFailed = 2
// var strOutput = 'Did not work'
// switch(shell.Status){
// case WshFinished :
// strOutput = oShell.StdOut.ReadAll;
// break;
// case WshFailed :
// strOutput = oShell.StdErr.ReadAll;
// break;
// }
// WScript.Echo(strOutput)

while(!fso.FileExists(runFile)) {
WScript.Sleep(500)
}

var objFileToRead = fso.OpenTextFile(runFile,1)
var strFileText = objFileToRead.ReadAll()
objFileToRead.Close()

fso.DeleteFile(runFile)
resolve(strFileText)
})
return p;
}

// Detect or specify install directory.
var selectedinstance = {
root : fso.GetAbsolutePathName(".")
}

var downloadsdir = selectedinstance.root + '/Downloads';

var fs = {
writeFileSync : function(filepath, text) {
WScript.echo(filepath)
var fh = fso.CreateTextFile(filepath, true);
fh.WriteLine(text);
fh.Close();
},
existsSync : function(path){
// fso.FileExists(path)
return fso.FolderExists(path)
}
, mkdirSync : function(path) {
fso.CreateFolder(path)
}
}

var path = {
dirname : function(filepath) {
var normalized = filepath.replace(/\//g,'\\');
var li = normalized.lastIndexOf("\\")
if( li > -1) {
return normalized.substring(0, li)
}
}
}

function ensureDirectoryExistence(filePath) {
var dirname = path.dirname(filePath);
if (fs.existsSync(dirname)) {
return filePath;
}
ensureDirectoryExistence(dirname);
fs.mkdirSync(dirname);
return filePath;
}

var getTaskCheckExists = function(command, options) {
options = options || {}
return function() {
var p = nodeShellExec.apply(null, ['where', [command]])
if (options.ignorefailures) {
return p.then(function(v) {
// WScript.Echo('firstThen ' + v);
return v }).pcatch( function(e) { // Ignore. Not a major error.
return false;
})
}
else return p.then(function() {
// WScript.Echo('firstThen ddd');
return v });
}
}

function verifyAndInstallPrerequisites() {
fs.writeFileSync(ensureDirectoryExistence(downloadsdir + '/readme.txt'), getVersion() + ' Your local downloads for this instance');
var downloadbatch =
"::************************************************************************** \
:Download_ <url> <File> \
Powershell.exe ^ \
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'; ^ \
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols; ^ \
(New-Object System.Net.WebClient).DownloadFile('%1','%2') \
exit /b \
::**************************************************************************";
fs.writeFileSync('download.bat', downloadbatch);

var downloadtasks = [];
var installtasks = [];
prerequisites.forEach(function(preq) {
var p = null;
downloadtasks.push(
p = preq.exists().then(function(exists) {
if (exists) console.log( preq.shellcmd + ' exists');
else {
console.log(preq.shellcmd + ' is not installed');
return preq.preinstallsteps().then(function(){
installtasks.push(task.install);
})
}
}
));
p.start()
});
return Promise.all(downloadtasks).then(function(){ return any(installtasks) })
}


var prerequisites = [
{
shellcmd: 'git',
url: 'https://github.com/git-for-windows/git/releases/download/v2.31.0.windows.1/Git-2.31.0-64-bit.exe'
, installer: 'Git-2.31.0-64-bit.exe'
, installcmd: ['cmd', ['/c', 'start',
'/WAIT', downloadsdir + '/' + 'Git-2.31.0-64-bit.exe'
, '/VERYSILENT'
// , '/MERGETASKS=!runcode' // This is required only for vscode...
]]
, preinstallsteps: function() {
var prompt = cli.prompter;
var steps = [
function(){
if (!existsSync(downloadsdir + '/' + this.installer)) {
return nodeShellExec(selectedinstance.root + '/.elxr/run-${runtimestamp}/download.bat', [this.url, downloadsdir + '/' + this.installer])
}
else return Promise.resolve(true)
}
]
var prompts = [
function() {prompt.ask('git user name : ( <= ' + gitUser + ' )').then( function(user){ gitUser = user; })}
, function() { prompt.ask('git email : ( <= ' + gitEmail + ' )').then(function(email) { gitEmail = email; })}
]
return any([any(steps), any(prompts)])
}
, installsteps: function () {
return any([this.installcmd].map(callsheltask))
}
, postinstallsteps: function(){
var prompt = cli.prompter;
var gitUser = 'guest';
var gitEmail = 'guest@bbh.org.in';
var prompts = [];
prompts.push(
function(){
var choices = { 0 : 'guest', 1 : 'chessdemo' }
return cli.prompt(choices, 'git user name').then(function(gituser) { gitUser = gituser})
}
)

prompts.push(
function(){
var choices = { 0 : 'guest@bbh.org.in', 1 : 'chessdemo@bbh.org.in' }
return cli.prompt(choices, 'git user email').then(function(gitemail) { gitEmail = gitemail})
}
)

return any(prompts).then(function(){
var steps = [
['git', ['config', '--global', '--add', 'user.name', gitUser]]
, ['git', ['config', '--global', '--add', 'user.email', gitEmail]]
]
return any(steps.map(callsheltask)).then(function(){

})
});
}
, install: function () {
return any([ /*this.preinstallsteps,*/ this.installsteps.bind(this), this.postinstallsteps.bind(this)])
}
, verifyAndInstall : function(){
var self = this;
return self.exists().then( function(exits) {
if(exists) return self.getUser(null, self.postinstallsteps.bind(self))
else return self.install();
})
}
, exists : function(next){
var self = this;
return getTaskCheckExists(this.shellcmd, { ignorefailures: true })().then(function(exists) {
if(exists && exists.indexOf(self.shellcmd) > -1 ) {
// console.log(exists + ' git exists')
return true;
}
else return false
})
}
, getUser : function(repo, onNoResult){
onNoResult = onNoResult || function(){return false}
var globalOrLocal = '--global';
if(!repo) globalOrLocal = '--global';
else globalOrLocal = '--local'

return any([['git', ['config', globalOrLocal, '--get-all', 'user.name']]].map(callsheltask)).then(function(result){
// not yet configured.
if(!result.success) return onNoResult()
else {
var users = result.messages[0].trim().split('\n');
if(users.length === 0 ||
users.length === 1 && users[0] === 'guest') {
return onNoResult()
}
else return users[0]; // PB : TODO == We should probably prompt with all the users available for selection !
}
})
.pcatch(function(e){
console.log(e)
return onNoResult()
})
}
}
,
{
shellcmd: 'node',
url: 'https://nodejs.org/dist/v14.16.0/node-v14.16.0-x64.msi'
, installer: 'node-v14.16.0-x64.msi'
, installcmd: ['MSIEXEC.exe', ['/i'
, downloadsdir + '/' + 'node-v14.16.0-x64.msi'
, 'ACCEPT=YES', '/passive']]
, install : function() { return any([this.installcmd].map(callsheltask)) }
, exists : function(next){
var self = this;
return getTaskCheckExists(this.shellcmd, { ignorefailures: true })().then(function(exists) {
if(exists && exists.indexOf(self.shellcmd) > -1 ) {
// console.log(self.shellcmd + ' ' + exists + ' node exists')
return true
}
else {
// console.log(self.shellcmd + ' ' + exists + ' node doesnt exist')
return false
}
})
}
, preinstallsteps : function(){
return true;
}
}
]

prerequisites.forEach = forEach;

verifyAndInstallPrerequisites()

+ 187
- 69
index.js View File

@@ -33,6 +33,13 @@ const fs = require('fs')
const cliargs = utils.cliargs;
const processedArgs = cliargs(process.argv.slice(2));
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])) == '') {

// }
// })

var globSync = require('glob').sync;

var ENV = Object.assign({}, process.env); // Shallow clone it.
@@ -93,12 +100,15 @@ var getTaskWithElevation = function(tasdef){
}
else {
// PB : TODO -- Rename op['runas'] to 'elevate'
return op['runas']().then(() => { return true; })

var __runasresult = null;

return op['runas']().then((r) => { return __runasresult = r; })
.catch((e) => {
console.error(e)
})
.finally(() => {
fs.unlinkSync('run.done')
if(__runasresult && !__runasresult.skipped) fs.unlinkSync('run.done')
if (!processedArgs.runas) { return tasdef.regularpulltasks(); }
})
}
@@ -139,7 +149,11 @@ var getPullCmd = (repo, branch) => {
}
else {
console.warn('No branch was specified detecting from working client.')
var pullCmd = gitops.getdiscoverbranchcmd(repo)
// First check if working client exits.
// if (existsSync(instanceroot + '/' + repo)) {
var pullCmd = gitops.getdiscoverbranchcmd(repo)
// }
// else performpull
}
// var pullCmd = ['pullall', [], { cwd : repo }]
if (useGitPull) pullCmd = ['git', ['pull'], {
@@ -388,6 +402,9 @@ var op = {
})
}
, 'runas': () => {

if(processedArgs.skipelevated) return Promise.resolve({ skipped : true });

console.log('Testing Elevation')

if (__isElevated) {
@@ -525,6 +542,40 @@ var op = {
// git remote equivalents...
// git branch --set-upstream-to=elixir-unc/master master
// 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) => {
// git remote set-url elixir-unc //10.10.5.60/gitrepo/chess/bbhverse
var __args = {
@@ -572,7 +623,7 @@ var op = {
}
var perform_git_seturl = (dir) => {
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) => {
// console.log('Failed : ' + dir.name)
})
@@ -959,7 +1010,7 @@ var op = {
// Usage :
// elxr pull -- Defaults to run config

return elxr.getpulltask()()
return elxr.getpulltask(selectedinstance)()
}
, 'isInstalled': () => {
return nodeShellExec('where', [processedArgs._[1]], { inherit: true }).then(() => {
@@ -1642,12 +1693,41 @@ var elxr = {
}
, getpulltask(def){

// def can be an instance config
// Or an object with many repos and elevated repos
// Or a single repo ( Either Elevated or normal. )


def = def || {
requiresElevation : true,
reqularRepos : gitRepos,
elevatedRepos : elevatedRunasRepos
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)

var env = Object.assign({}, process.env); // Shallow clone it.
@@ -1655,30 +1735,30 @@ var elxr = {

var useGitPull = 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 {
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) }
if(def.elevatedRepos){
if(def.elevated){
elevatedpulltasks = function() {
return any(def.elevatedRepos.map((def) => performPull(def.repo))).then(() => {
return any(def.elevated.map((def) => performPull(def.repo))).then(() => {
return true;
}).catch((e) => {
console.error(e)
})
}
}
if(def.reqularRepos) {
if(def.repos) {
var regularpulltasks = function(){
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)
}
}
@@ -1708,7 +1788,7 @@ function preworkerconfig(){
// The main elxr cli process
function elxrworker() {
var subcommandlabels = {
remote : `remote ${processedArgs._[1]}`
remote : (`remote ${processedArgs._[1] || ''}`).trim()
}

var __runcmd = function (label) {
@@ -1741,16 +1821,16 @@ function acquireChoices(selectedinstance) {
Warning : Cannot locate your preferred configuration since it was not specified
You should fork the default chess configuration to customize and make it
your own instance with a named config as
{{yourowninstancename}}-config-{{yourcurrentenvironment}}
{{yourowninstancename}}-config-{{yourchosenenvironment}}
And then run this tool as follows
NODE_ENV={{yourenvironment}} elxr i {{yourowninstancename}}
NODE_ENV={{yourchosenenvironment}} elxr i {{yourowninstancename}}
OR
Run this tool with the following command to use a quick start default.
node elxr --default
elxr --default
OR
Choose the the option to create a new instance for you interactively.
Choose one of the options below to run interactively.

We will run your choice of default or create your own at the next prompt.
We will run your choice at the next prompt.
-------------------------------------------------------------------------------
`))
var prompt = cli.prompter;
@@ -1767,7 +1847,6 @@ We will run your choice of default or create your own at the next prompt.
q) Quit
Default <= d
: `).then((choice) => {
prompt.close();
if (choice && choice === 'd' || !choice) {
processedArgs._[0] = 'i'
selectedinstance.instanceName = processedArgs._[1] = processedArgs._[1] || 'chess'
@@ -1796,7 +1875,6 @@ We will run your choice of default or create your own at the next prompt.
}

return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposerver || selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
p1.close()
selectedinstance.reposerver = reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in'
})
})
@@ -1817,7 +1895,6 @@ We will run your choice of default or create your own at the next prompt.
else processedArgs._[0] = cmd
return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposerver || selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
selectedinstance.reposerver = reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in'
p1.close()
})
})
})
@@ -1831,6 +1908,29 @@ We will run your choice of default or create your own at the next prompt.
})
}

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( utils.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 configrepo = selected.instanceName + '-config-' + selected.node_env;
@@ -1843,8 +1943,11 @@ var acquireConfig = function (selected, chessinstances) {
chessinstances[selected.instanceName][selected.node_env] = chessinstances[selected.instanceName][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.
// PB : TODO -- utils.assign Array merges are non-distinct...
selectedinstance = utils.assign(chessinstances[selected.instanceName][selected.node_env], selected, repomanifest)
fs.writeFileSync(instanceroot + '/chessinstances.js', 'module.exports = ' + JSON.stringify(chessinstances, null, 2) + '', { 'flag': 'w' })
// chessinstances[selectedinstance.instanceName][selectedinstance.node_env] = selectedinstance;
cacheWriteInstanceConfig(chessinstances)
selectedinstance = chessinstances[selected.instanceName][selected.node_env]
// 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...
ENV.NODE_ENV = selectedinstance.node_env;
@@ -1929,7 +2032,8 @@ var __interactve_promts = {
Object.defineProperty(this, 'reposerver', {
value: reposerver,
writable: false,
configurable : true
configurable : true,
enumerable : true
});
return reposerver
})
@@ -1938,7 +2042,8 @@ var __interactve_promts = {
Object.defineProperty(this, 'reposerver', {
value: reposerver,
writable: false,
configurable : true
configurable : true,
enumerable : true
});
return reposerver
}
@@ -1969,7 +2074,7 @@ var prerequisites = [
() => prompt.ask(`git user name : ( <= ${gitUser} )`).then((user) => { gitUser = user; })
, () => prompt.ask(`git email : ( <= ${gitEmail} )`).then((email) => { gitEmail = email; })
]
return any([any(steps), any(prompts)]).then(() => { prompt.close() })
return any([any(steps), any(prompts)])
}
, installsteps: function () {
return any([this.installcmd].map(callsheltask))
@@ -2186,7 +2291,8 @@ var getPromptableAsyncPropDescriptor = function(propName, choices, defaultchoise
Object.defineProperty(this, propName, {
value: propValue,
writable: false,
configurable : true
configurable : true,
enumerable : true
});
return propValue
})
@@ -2195,11 +2301,13 @@ var getPromptableAsyncPropDescriptor = function(propName, choices, defaultchoise
// Object.defineProperty(this, propName, {
// value: propValue,
// writable: false,
// configurable : true
// configurable : true,
// enumerable : true
// })
// return propValue;
// }
, configurable : true
, enumerable : true
}
}

@@ -2285,56 +2393,66 @@ acquireElevationState().then(() => {
selectedinstance = Object.assign(detectedInstance, clioverrides);
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 {
chessinstances = acquirelocalinstances(selectedinstance);
initinstances(chessinstances, selectedinstance)
}
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
var instanceNameChoices = new Set(Object.keys( chessinstances) )
instanceNameChoices.delete('current_run')
instanceNameChoices.add(selectedinstance['instanceName'])
if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName'])
var choices = {
'instanceName' : Array.from(instanceNameChoices)
, 'reposerver' : selectedinstance['reposervers']
}

Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts)
Object.keys(promptkeys).forEach(eachPrompt, promptkeys)
todo = any(prompts).then(()=>{ return selectedinstance })
}
catch (e) {
console.error(e) // Missing chessinstances is not an error...
// 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.
initinstances(chessinstances, selectedinstance)
var instanceNameChoices = new Set(Object.keys( chessinstances) )
instanceNameChoices.delete('current_run')
instanceNameChoices.add(selectedinstance['instanceName'])
instanceNameChoices.add(promptkeys['instanceName'])
if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName'])
var choices = {
'instanceName' : Array.from(instanceNameChoices)
, 'reposerver' : selectedinstance['reposervers']
}

var prompts = [];
var eachPrompt = function(k, i, a){
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(promptkeys).forEach(eachPrompt, promptkeys)
@@ -2342,7 +2460,7 @@ acquireElevationState().then(() => {
if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// Weve been told what to do.
todo = acquireChoices(selectedinstance)
todo = todo.then(() => { return acquireChoices(selectedinstance) })
}
todo = todo.then(() => {
@@ -2400,7 +2518,7 @@ acquireElevationState().then(() => {
// Currently it retains 2*n when proc needs to be relaunched in elevated mode !!!
ensureDirectoryExistence(`${selectedinstance.root}/.elxr/run-${runtimestamp}/download.bat`)
if (!skipprerequisites && !__isElevated) mainTasks.push(verifyAndInstallPrerequisites);
if (!skipprerequisites && !__isElevated || processedArgs.forceprereqs && !__isElevated ) mainTasks.push(verifyAndInstallPrerequisites);
mainTasks.push(maintask)
return any(mainTasks);
})

+ 0
- 328
package-lock.json View File

@@ -1,328 +0,0 @@
{
"name": "elxr",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@rollup/plugin-commonjs": {
"version": "17.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz",
"integrity": "sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.1.0",
"commondir": "^1.0.1",
"estree-walker": "^2.0.1",
"glob": "^7.1.6",
"is-reference": "^1.2.1",
"magic-string": "^0.25.7",
"resolve": "^1.17.0"
}
},
"@rollup/plugin-node-resolve": {
"version": "11.2.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz",
"integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.1.0",
"@types/resolve": "1.17.1",
"builtin-modules": "^3.1.0",
"deepmerge": "^4.2.2",
"is-module": "^1.0.0",
"resolve": "^1.19.0"
}
},
"@rollup/pluginutils": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
"integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
"dev": true,
"requires": {
"@types/estree": "0.0.39",
"estree-walker": "^1.0.1",
"picomatch": "^2.2.2"
},
"dependencies": {
"estree-walker": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
"integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
"dev": true
}
}
},
"@types/estree": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
"dev": true
},
"@types/node": {
"version": "15.0.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz",
"integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==",
"dev": true
},
"@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
"integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"bbhverse": {
"version": "file:../bbhverse"
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"builtin-modules": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz",
"integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==",
"dev": true
},
"chalk": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
"integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"dateformat": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.5.1.tgz",
"integrity": "sha512-OD0TZ+B7yP7ZgpJf5K2DIbj3FZvFvxgFUuaqA/V5zTjAtAAXZ1E8bktHxmAGs4x5b7PflqA9LeQ84Og7wYtF7Q==",
"dev": true
},
"deepmerge": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==",
"dev": true
},
"estree-walker": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
"dev": true
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"is-core-module": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.3.0.tgz",
"integrity": "sha512-xSphU2KG9867tsYdLD4RWQ1VqdFl4HTO9Thf3I/3dLEfr0dbPTWKsuCKrgqMljg4nPE+Gq0VCnzT3gr0CyBmsw==",
"dev": true,
"requires": {
"has": "^1.0.3"
}
},
"is-module": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
"integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=",
"dev": true
},
"is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
"dev": true,
"requires": {
"@types/estree": "*"
}
},
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"magic-string": {
"version": "0.25.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
"integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==",
"dev": true,
"requires": {
"sourcemap-codec": "^1.4.4"
}
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"dev": true
},
"picomatch": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz",
"integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==",
"dev": true
},
"resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"dev": true,
"requires": {
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
}
},
"rollup-plugin-version-injector": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/rollup-plugin-version-injector/-/rollup-plugin-version-injector-1.3.3.tgz",
"integrity": "sha512-+Rrf0xIFHkwFGuMfphVlAOtd9FlhHFh3vrDwamJ6+YR3IxebRHGVT879qwWzZ1CpWMCLlngb2MmHW5wC5EJqvg==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
"dateformat": "^4.2.1",
"lodash": "^4.17.20"
}
},
"sourcemap-codec": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
"dev": true
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"requires": {
"has-flag": "^4.0.0"
}
},
"tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
}
}
}

+ 1
- 0
package.json View File

@@ -19,6 +19,7 @@
"crossfilter2": "^1.5.4",
"chalk": "^4.1.0",
"glob": "^7.1.2",
"uuid": "^8.3.2",
"tree-kill": "^1.2.2"
},
"bin": {

Loading…
Cancel
Save