Browse Source

Merge remote-tracking branch 'chess/master'

pull/7/head
aaron 3 years ago
parent
commit
73ebe6243b
8 changed files with 3988 additions and 18293 deletions
  1. 3
    1
      bin/elxr
  2. 4
    2
      cliverse.js
  3. 1720
    16585
      elxr.js
  4. 1983
    1540
      i.js
  5. 263
    75
      index.js
  6. 2
    2
      package.json
  7. 13
    15
      repo-manifest.js
  8. 0
    73
      windowselevate.hta

+ 3
- 1
bin/elxr View File

@@ -3,9 +3,11 @@
var ENV = Object.assign({}, process.env); // Shallow clone it.

const spawn = require('child_process').spawn;
console.dir(process.argv.slice(2))

const child = spawn(
(process.platform === 'win32' ? 'npm.cmd' : 'npm')
, ['run', 'index'].concat(process.argv.slice(2)), { cwd: __dirname });
, ['run', 'index', '--'].concat(process.argv.slice(2)), { cwd: __dirname });

// const child = spawn(
// 'C:\\Program Files\\Git\\bin\\sh.exe'

+ 4
- 2
cliverse.js View File

@@ -58,11 +58,13 @@ function nodeShellExec() {
child.on('close', (code) => {
// console.log('Proper close was fired')
var logEntry = { code, success }
if(+code !== 0 || opts.haserrors) { success = false; logEntry = { result: `${opts.title} exited with code ${code}`, success, code }};
if(+code !== 0 || opts.haserrors) { success = false; logEntry = { messages, result: `${opts.title} exited with code ${code}`, success, code }
if(opts.evaluateResult) logEntry = opts.evaluateResult(false, logEntry);
};
if(opts.stdio !== 'ignore') {
logEntry = { result: `${opts.title} exited with code ${code}`, messages, code }
logEntry.success = success;
if(opts.evaluateResult) logEntry = opts.evaluateResult(success, logEntry);
if(opts.runas){
// success ? logEntry.success = true : null;
fs.writeFileSync('run.log', ', ' + JSON.stringify(logEntry), {'flag':'a+'} )

+ 1720
- 16585
elxr.js
File diff suppressed because it is too large
View File


+ 1983
- 1540
i.js
File diff suppressed because it is too large
View File


+ 263
- 75
index.js View File

@@ -65,13 +65,36 @@ console.dir(processedArgs)
// }
// })

var clioverrides = { }
processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null;
processedArgs.node_env ? clioverrides.node_env = processedArgs.node_env
: (process.env.NODE_ENV && process.env.NODE_ENV.trim())
? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) : null;
var subcommandlabels = {
remote : (`remote ${processedArgs._[1] || ''}`).trim()
}

var interpretrun = function(){

var cmds = {
'remote' : function() {
return { cmd : subcommandlabels['remote'], runchoice : 'c' }
}
}

var cmd = processedArgs._[0];
var clioverrides = { cmd }
processedArgs.node_env ? clioverrides.node_env = processedArgs.node_env
: (process.env.NODE_ENV && process.env.NODE_ENV.trim())
? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) : null;
return cmds[cmd] ? cmds[cmd]() : (function(){

processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null;
return clioverrides
})()
}

Object.keys(clioverrides).forEach( prop => { })

var clioverrides = interpretrun()
console.dir(clioverrides)

// Object.keys(clioverrides).forEach( prop => { })

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

@@ -81,14 +104,14 @@ const { readdir } = require("fs").promises

// Directory shallow walk and do perform on each dir.
const dirs = async (perform, path) => {
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
for (const dir of await readdir(path || selectedinstance.root, { withFileTypes: true })) {
if (dir.isDirectory()) perform(dir)
}
}

var getShellTask = (command, args, options) => {
options = options || {}
var callshell = command === 'rm' ? callgitbashtask : callsheltask;
var callshell = command === 'rm' ? getgitbashtask : getshelltask;
return () => {
var p = callshell( [command, args, Object.assign({
inherit: true, shell: true, env: ENV, title: `${command} ${args}`
@@ -103,9 +126,17 @@ var getShellTask = (command, args, options) => {
}
}

var callsheltask = (args) => {
return args[0] === 'rm' ? callgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } }
var callgitbashtask = (args) => { return () => {
var callshelltask = (args) => {
// console.dir(args)
if( Object.prototype.toString.call(args) === '[object Function]' ) {
return args;
}
return getshelltask(args)()
}

var getshelltask = (args) => {
return args[0] === 'rm' ? getgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } }
var getgitbashtask = (args) => { return () => {
return nodeShellExec( `"${gitbash}"`, ['-c', `"${args[0]} ${args[1].join(' ')}"`], args[2]) }
}

@@ -163,7 +194,7 @@ var gitops = {
var parameters = ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;']
var cmd = [gitbash
, ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;']
, { cwd: instanceroot + '/' + repo, title: 'pull all origins for ' + repo + ' ' + parameters.join(' ') }]
, { cwd: instanceroot + '/' + repo, title: 'discoverbranch for ' + repo + ' ' + parameters.join(' ') }]
return cmd
}
}
@@ -172,22 +203,23 @@ var getPullCmd = (repo, branch) => {
// console.log(useGitPull)var getPullCmd = (repo, branch) => {
// console.log(useGitPull)

var pullCmd = []
if(!branch) {
// console.warn('No branch was specified detecting from working client.')
// First check if working client exists.
// if (existsSync(instanceroot + '/' + repo)) {
pullCmd= gitops.getdiscoverbranchcmd(repo)
// }
// else performpull
}
// var pullCmd = [gitInstallDir
// , ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;']
// , { cwd: instanceroot + '/' + repo, title: 'pull all origins for ' + repo }]
// , { cwd: instanceroot + '/' + repo, title: 'pull all remotes for ' + repo }]
if(branch) {
var parameters = ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;']
var pullCmd = [ gitbash
, ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;']
, { cwd: instanceroot + '/' + repo, title : 'pull all origins for ' + branch + ' ' + repo + ' ' + parameters.join(' ') }]
}
else {
// console.warn('No branch was specified detecting from working client.')
// First check if working client exits.
// if (existsSync(instanceroot + '/' + repo)) {
var pullCmd = gitops.getdiscoverbranchcmd(repo)
// }
// else performpull
, { cwd: instanceroot + '/' + repo, title : 'pull all remotes for ' + branch + ' ' + repo + ' ' + parameters.join(' ') }]
}
// var pullCmd = ['pullall', [], { cwd : repo }]
if (useGitPull) pullCmd = ['git', ['pull'], {
@@ -466,9 +498,10 @@ var op = {
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; })
// PB : TODO -- Convert all the cli args back to string.
var args = [`${selectedinstance.root}/.elxr/run-${runtimestamp}/windowselevate.hta`].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
args.push('--nodepath=' + r[r.length - 1])
if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
// args.push('--nodepath=' + r.messages[r.messages.length - 1])
// if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
// if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
console.dir(processedArgs)

return nodeShellExec('MSHTA', [`"${args.join('" "')}"`]
, {
@@ -577,6 +610,7 @@ var op = {
, 'remote': (args) => {
// Subcommands!
// PB : TODO -- we can now pass in hypehnated args...
if(!processedArgs.v) return false; // Only -v is supported presently..

var serial_perform = (repo) => {
@@ -663,9 +697,132 @@ var op = {

dirs(perform_git_seturl)
}
, 'reset' : ()=>{
// Reset the whole installation pertaining to this elxr folder.
// , 'reset' : ()=>{
// PB : TODO -- Cant have 2 resets !! | There is an npm reset that should be bundled.
// // Reset the whole installation pertaining to this elxr folder.
// }

, 'remote exists': (args) => {
var __args = {
remotename : args.remotename|| processedArgs._[2]
, url : args.url || processedArgs._[3]
, branch : args.branch || processedArgs._[4]
}

var options = args.repo ? { cwd: instanceroot + '/' + args.repo } : {}

// PB : TODO -- We should evaluate a whole list of remotes passed in from args instead of just one.
var commands = [
// 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'], 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) ]
, function(prevserialtaskresult) {
console.log('================================')
var url = __args || prevserialtaskresult.url;
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) ])()
}
]
var mapped = commands.map(callshelltask) //.map( p => p.catch(e => e)) // Handle errors later.
return any(mapped).then( 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 added as a remote and url is accessible.')
: allresolved[0][0] && !allresolved[1][0] ? console.log('was added as a remote but url is currently inaccessible.')
: console.log('was not added as a remote but url is currently accessible.')
return !allresolved[0][0] && !allresolved[1][0] ? [0, 0]
: 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.
: [0, 1] // => was not added and remote and url is accessible.
})
}

, 'remote refresh': (args) => {
var __args = {
remotename : args.remotename|| processedArgs._[2]
, url : args.url || processedArgs._[3]
, branch : args.branch || processedArgs._[4]
}

// use the repo manifest to create missing remotes.
function perform_remote_refresh(dir){
var repo = dir.name
var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo)
try {
var remotes = require(`${selectedinstance.root}/${dir.name}/repo-manifest.js`)( null, selectedinstance).remotes || [];
}
catch(e){
var remotes = []
}
// console.log(`${dir.name}/repo-manifest.js` + '---------------------------')
// console.dir(remotes)

return nodeShellExec.apply(null, dscoverbranchcmd).then(__branch=>{
console.log('Processing : ' + dir.name)
var branch = __branch
__args.repo = repo
__args.branch = __branch
var promises = []

remotes.forEach(remote =>{
Object.keys(remote).forEach(remotename => {
__args.remotename = remotename
__args.url = remote[remotename]
promises.push( op['remote exists']( __args ).then( exists => {
if(!exists[0]) {
if(!exists[1]) { console.error( `Skipping inaccessible remote url ${__args.url}` ) }
else return op['remote add']( { remotename,
// PB : TODO -- use the most accessible remote instead of the first available.
url : (utils.js.isArray(remote[remotename]) ? remote[remotename][0] : remote[remotename]), branch
} )
}
})
)
})
})

return Promise.all(promises)
})
.catch((e) => { console.log('Processing Error : ' + dir.name); console.error(e); return { error: true, message: repo } })
}
return dirs(perform_remote_refresh)
}
, 'remote add': (args) => {
// PB : TODO -- set-upstream-to should be chosen and intentionally switched. Coz we can have multiple upstream remotes.
@@ -870,7 +1027,7 @@ var op = {
// , ['git', ['commit', '-a', '-m', `relocate folder ${args.folder} to ${targetrepo}`], sourcerepooptions ]
]

return any(cmdseq.map(callsheltask))
return any(cmdseq.map(getshelltask))
})
}).catch(e=>{console.error(e)})
}
@@ -904,13 +1061,13 @@ var op = {
var cmdseq = [
// create a temporary working dir in current folder where we started execution.
['mkdir', [ '-p', 'relocate']]
['mkdir', [ '-p', `${instanceroot}/relocate`]]
, ['git', ['clone', `${args.remotebase}${args.sourcerepo}`], options ]
, ['git', ['clone', `${args.sourcerepo}`, `relocate-${args.sourcerepo}-${args.folder}`], options]
, ['git', ['clone', `${args.remotebase}${args.targetrepo}`, `relocate-${args.targetrepo}-${args.folder}`], options]
]
return any(cmdseq.map(callsheltask)).then(() => {
return any(cmdseq.map(getshelltask)).then(() => {
// , ['git', ['subtree', 'split', '-P', `${args.folder}`, '-b', `relocate-${args.sourcerepo}-${args.folder}`], sourcerepooptions]
// split doesnt retain folder structure we need to move and commit ourselves through a branch to retain history...
// , ['git', [`checkout relocate-${args.sourcerepo}-${args.folder}`], sourcerepooptions]
@@ -953,7 +1110,7 @@ var op = {
, targetrepooptions ]
// , ['git', ['push', targetrepooptions ] // manual push for now..
]
return any(cmdseq.map(callsheltask)).catch(e=>{console.error(e)})
return any(cmdseq.map(getshelltask)).catch(e=>{console.error(e)})
}

, 'filter-repo' : function(args){
@@ -975,7 +1132,7 @@ var op = {
// git remote add src-project ../src-project
['git', ['filter-repo', '--path', `${args.folder}`], targetrepooptions ]
]
return any(cmdseq.map(callsheltask)).catch(e=>{console.error(e); throw 'failed' })
return any(cmdseq.map(getshelltask)).catch(e=>{console.error(e); throw 'failed' })
}

, 'filter-branch' : function(preservefolder, repo){
@@ -1109,7 +1266,7 @@ var op = {
) )

var npmbuildrepos = ['loopback-jsonapi-model-serializer']
npmbuildrepos = []
// npmbuildrepos = []
npmbuildrepos.forEach(repo => {
tasks.push(() => {
return nodeShellExec('npm', ['i --force'], {
@@ -1131,9 +1288,9 @@ var op = {
})
})

any(tasks).then(() => {
return any(tasks).then(() => {

gitRepos.push('client/server');
gitRepos.push('chess-server-lib/server');
gitRepos = gitRepos.concat(elevatedRunasRepos);

// gitRepos = [
@@ -1146,17 +1303,16 @@ var op = {
var env = Object.assign({}, process.env)
delete env.NODE_ENV
gitRepos.forEach(repodef => {

rmtasks.push(
// () => {
// console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
// return nodeShellExec(`"${gitbash}"`, ['-c', '"rm package-lock.json"'], {
(callShellTask(['rm', ['package-lock.json'], {
callshelltask(['rm', ['package-lock.json'], {
inherit: true, shell: true
, cwd: instanceroot + '/' + repodef.repo
, env: process.env
, title: `rm 'package-lock.json' for ${repodef.repo}`
}]))()
}])
.then(()=>{
console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
}).catch((e) => { console.error(e) })
@@ -1216,7 +1372,7 @@ var op = {
// console.log('rmtasks.length : ' + rmtasks.length)
return Promise.all(rmtasks).then(() => any(repotasks));
}).catch(e => {
console.error(e)
}).finally(statuslog.finally)

}
@@ -1346,7 +1502,9 @@ var op = {

console.log(`No change detected. Already using requested specs : ${runconfig.NODE_ENV} ${runconfig.use}`)
if (processedArgs.runas) { fs.writeFileSync('run.done', 'success') }
return
if (existsSync('config') && existsSync('data')){
return
}
}

var tasks = [
@@ -1383,7 +1541,7 @@ var op = {
if (!branch) {
var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo)
promise = nodeShellExec.apply(null, dscoverbranchcmd(repo)).then(__branch=>{ branch = __branch})
promise = nodeShellExec.apply(null, dscoverbranchcmd).then(__branch=>{ branch = __branch})
.catch((e) => { console.error(e); return { error: true, message: repo } })
}
@@ -1434,7 +1592,7 @@ var op = {
// Checkout is reduced to pull provided the current branch is the targetbranch
if(branch === mergesource) performCheckout = (def) => {
var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo)
return nodeShellExec.apply(null, dscoverbranchcmd(repo)).then(__branch=>{
return nodeShellExec.apply(null, dscoverbranchcmd).then(__branch=>{
if(branch === __branch) return performCloneAndCheckout(def)
return performPullOrCloneForBranch(def)
@@ -1749,14 +1907,44 @@ var elxr = {
-------------------------------------------------------------------------------
`)
}
, getpulltask(def){
, getpulltask(args){

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

// USAGE
// elxr pull elixir origin master
// elxr pull

// not all remote branches are setup to be tracked locally (respective remotes and branches).
// pull --all is useless. As it fetches all remotes and branches but only merges current branch.
// apart from remote tracking branches We are interested in pulling from all remotes and relavant branches.
// The branch pipline should feed back to master
// master -> test -> stage -> release[nnnn] -> production
// (master) <= git merge [all remotes] production && git merge [all remotes] release[nnnn]
// git merge [all remotes] stage && git merge [all remotes] test && git merge [all remotes] master

def = def || {
var __args = {
remotename : args.remotename|| processedArgs._[2]
, url : args.url || processedArgs._[3]
, branch : args.branch || processedArgs._[4] // If branch not specified opearte on the current branch of each working directorys
}

// var commands = [
// // ['git', ['checkout', __args.branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]]
// ,
// ]

// var parameters = ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;']
// var pullCmd = [ gitbash
// , ['-c', 'for i in `git remote`; do git pull $i ' + branch + '; done;']
// , { cwd: instanceroot + '/' + repo, title : 'pull all remotes for ' + branch + ' ' + repo + ' ' + parameters.join(' ') }]



var def = args || {
repos : selectedinstance.repos,
elevated : selectedinstance.elevated
}
@@ -1845,9 +2033,6 @@ function preworkerconfig(){

// The main elxr cli process
function elxrworker() {
var subcommandlabels = {
remote : (`remote ${processedArgs._[1] || ''}`).trim()
}

var __runcmd = function (label) {
var distinquishedlabel = subcommandlabels[label] || label
@@ -2178,13 +2363,18 @@ var detectinstances = function () {
instanceroot = detected.root
__default.root = root;
clioverrides.root = clioverrides.root || root;
// Resolves empty array when No known instances detected.
return Promise.resolve(instanceoptions)
})

}

if(clioverrides.reconfirm) {
var reconfirm = { 'instanceName' : clioverrides['instanceName'] === 'chess' }
}
else { var reconfirm = {}; }

var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) {
return function(prompts, k, i, a){
@@ -2209,7 +2399,7 @@ var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) {
}
}

var __interactve_promts = function( target, choices ){
var __interactive_prompts = function( target, choices ){

Object.defineProperty(target, 'node_env', { get : function(){ return this.instanceType } });

@@ -2268,6 +2458,7 @@ var __interactve_promts = function( target, choices ){
, instanceName : { label : `Enter Instance Name ( <= ${target.instanceName || 'chess'} ) : `, choices : [], defaultchoice : 'chess'}
, instanceType : { label : `Enter Instance Type ( <= ${target.instanceType || 'development'} ) : `, choices : [], defaultchoice : 'development'}
, reposerver : { label : `Enter Instance Name ( <= ${target.reposerver || 'https://git.bbh.org.in'} ) : `, choices : [], defaultchoice : 'https://git.bbh.org.in'}
, repouser : { label : `Enter User Id for ${target.reposerver} ( <= ${target.repouser || 'chess'} ) : `, choices : [], defaultchoice : 'chess'}
}

var eachPrompt = getBoundEachPrompt( target, promptkeys, interactionpoints, choices)
@@ -2303,7 +2494,7 @@ var prerequisites = [
return any([any(steps), any(prompts)])
}
, installsteps: function () {
return any([this.installcmd].map(callsheltask))
return any([this.installcmd].map(getshelltask))
}
, postinstallsteps: function(){
@@ -2331,7 +2522,7 @@ var prerequisites = [
['git', ['config', '--global', '--add', 'user.name', `${gitUser}`]]
, ['git', ['config', '--global', '--add', 'user.email', `${gitEmail}`]]
]
return any(steps.map(callsheltask)).then(() => {
return any(steps.map(getshelltask)).then(() => {

})
});
@@ -2342,7 +2533,7 @@ var prerequisites = [
, verifyAndInstall : function(){
return getTaskCheckExists(this.shellcmd, { ignorefailures: true })().then((exists) => {
if(exists) {
// return any(['git', ['config', '--global', '-l']].map(callsheltask))
// return any(['git', ['config', '--global', '-l']].map(getshelltask))
return this.getUser(null, this.postinstallsteps.bind(this))
}
return this.install();
@@ -2356,7 +2547,7 @@ var prerequisites = [
if(!repo) globalOrLocal = '--global';
else globalOrLocal = '--local'

return any([['git', ['config', globalOrLocal, '--get-all', 'user.name']]].map(callsheltask)).then((result)=>{
return any([['git', ['config', globalOrLocal, '--get-all', 'user.name']]].map(getshelltask)).then((result)=>{
// not yet configured.
if(!result.success) return onNoResult()
else {
@@ -2383,7 +2574,7 @@ var prerequisites = [
, installcmd: ['MSIEXEC.exe', ['/i'
, path.resolve(downloadsdir + '/' + 'node-v14.16.0-x64.msi')
, 'ACCEPT=YES', '/passive']]
, install : function() { return any([this.installcmd].map(callsheltask)).then(() => { }) }
, install : function() { return any([this.installcmd].map(getshelltask)).then(() => { }) }
}
]

@@ -2649,7 +2840,7 @@ acquireElevationState().then(() => {
chessinstances[instanceName][node_env]
, clioverrides
, selected_overrides
// , __interactve_promts -- Cant just override. Also need selectedinstance to be ready...
// , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready...
);

// chessinstances[instanceName] = chessinstances[instanceName] || {}
@@ -2719,12 +2910,12 @@ acquireElevationState().then(() => {
const retaincount = 2
var min = runtimestamp;
var collect = []
if(noprerequisites[processedArgs._[0]]
|| skipprereqs[processedArgs._[0]]
) {
return elxrworker()
}
// if(noprerequisites[processedArgs._[0]]
// || skipprereqs[processedArgs._[0]]
// ) {
// return elxrworker()
// }

var getchoices = function(detectedinstanceoptions, promptkeys){

@@ -2745,7 +2936,7 @@ acquireElevationState().then(() => {
})
instances = instances.concat(detectedinstanceoptions)

if(promptkeys['instanceName']) instnaceNames.push(selectedinstance['instanceName'])
if(selectedinstance['instanceName']) instnaceNames.push(selectedinstance['instanceName'])
if(promptkeys['instanceName']) instnaceNames.push(promptkeys['instanceName'])
if(selectedinstance['reposervers']) reposervers = reposervers.concat(selectedinstance['reposervers'])
@@ -2759,39 +2950,36 @@ acquireElevationState().then(() => {
}

return detectinstances().then((detectedinstanceoptions)=>{
detectedinstanceoptions.splice(0,0, __default)

// PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!!
selectedinstance = utils.assign( ...detectedinstanceoptions.slice(-2) )
promptkeys = utils.assign(promptkeys, clioverrides)
if(clioverrides.reconfirm) {
var reconfirm = { 'instanceName' : selectedinstance['instanceName'] === 'chess' }
}
else { var reconfirm = {}; }
// promptkeys = utils.assign(promptkeys, clioverrides)
console.dir(selectedinstance)
try {

chessinstances = acquirelocalinstances(selectedinstance);
findlocalinstances(chessinstances, detectedinstanceoptions)
initinstances(selectedinstance) // use the local instances for defaults if at all possible.
var choices = getchoices(detectedinstanceoptions, promptkeys)
var todo = any( __interactve_promts(selectedinstance, choices) ).then(()=>{
var todo = any( __interactive_prompts(selectedinstance, choices) ).then(()=>{
return initinstances(selectedinstance)
})
}
catch (e) {
// PB : TODO -- verbose mode warning.. console.warn(e) // Missing chessinstances is not an error...
var choices = getchoices(detectedinstanceoptions, promptkeys)
var todo = any( __interactve_promts(selectedinstance, choices) ).then(()=>{
var todo = any( __interactive_prompts(selectedinstance, choices) ).then(()=>{
return initinstances(selectedinstance)
})

if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// Weve not been told what to do.
todo = todo.then(() => { return acquireChoices(selectedinstance) })
}
// if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// // Weve not been told what to do.
// todo = todo.then(() => { return acquireChoices(selectedinstance) })
// }
todo = todo.then(() => {
try {

+ 2
- 2
package.json View File

@@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-commented": "rollup index.js --format cjs --file elxr.js",
"build": "rollup -c",
"build-elxr": "rollup index.js --format cjs --file elxr.js",
"build": "rollup -c && rollup index.js --format cjs --file elxr.js",
"index": "SET FORCE_COLOR=true && node index"
},
"keywords": [],

+ 13
- 15
repo-manifest.js View File

@@ -11,19 +11,17 @@ module.exports = ((name, options)=>{
// User can always add more branches and remotes as needed. Mainifest only occupies
// well defined namespaces
, remotes : [
// these are both fetch and push remotes. Use push - remotes to overrid.
{ 'chess' : 'http://git.bbh/chess/elxr.git' }
, { 'public-baptistdev' : 'https://github.com/baptistdev/elxr.git' }
// these are both fetch and push remotes. Use push - remotes to override push.
{ 'chess' : `${options.reposerver}/chess/elxr.git` }
, { 'public-github-baptistdev' : 'https://github.com/baptistdev/elxr.git' }
// Multiple urls as an array doesn't tell us the current origin which may be different in
// different based on currently available/accessible to client.
// This is just a list of possible equivalent options.
, { 'origin' : [
`http://git.bbh/${options.gituser}/elxr.git`
, 'https://git.bbh.org.in/${options.gituser}/elxr.git'
, `//172.16.0.27/repos/${options.gituser}/elxr.git`
]
}
// 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' : `${options.reposerver}/${options.repouser}/elxr.git` }
, { 'origin-public' : `https://git.bbh.org.in/${options.repouser}/elxr.git` }
, { 'origin-unc' : `//172.16.0.27/repos/${options.repouser}/elxr.git` }
]

, 'push-remotes' : [
@@ -41,8 +39,8 @@ module.exports = ((name, options)=>{

// tracking branches.
// We at least need one branch for each remote that we wish to track.
, 'tracking-branches' : [
{ master : ['origin/master', 'chess/master'] }
]
// , 'tracking-branches' : [
// { master : ['origin/master', 'chess/master'] }
// ]
}
})

+ 0
- 73
windowselevate.hta View File

@@ -1,73 +0,0 @@

<html><HTA:APPLICATION ID="windowselevate" icon="#"/>
<script language="vbscript">
document.title = "elxr control panel"
self.ResizeTo 200,600
Sub Window_Onload
self.MoveTo (screen.availWidth - (document.body.clientWidth + 40)),10
End Sub

Set objShell = CreateObject("WScript.Shell")
Set objENV = objShell.Environment("Process")
dim NODE_ENV
NODE_ENV = objENV("NODE_ENV")
</script>

<script language="javascript">
//WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no"
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3);
// alert(args)
var processedArgs = { _ : [] }
var namedArgs = [];
for(var item in args){
if(args[item].charAt(0) === '-'){
namedArgs.push(args[item])
var split = args[item].split('=');
processedArgs[split[0].slice(2)] = split[1] || true;
}
else processedArgs._.push(args[item]);
}
// args = args.forEach(function(item){ })
// alert('processedArgs._ : ' + processedArgs._);
// alert(processedArgs.runas);
// PB : TODO -- Convert all the cli args back to string.
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
// alert(cargs)
var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
shell.ShellExecute('node', cargs, '', 'runas', 1);
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1);
var fso = new ActiveXObject('Scripting.FileSystemObject');
window.onload = function() {
document.body.style.backgroundColor = 'black';
document.body.style.fontFamily = 'arial';
var log = document.createElement('div');
log.innerHTML='Please Wait';
function l(msg){ log.innerHTML+= msg; };
log.style.color = 'blue';
log.style.width = '95%';
log.id = 'log';
document.body.appendChild(log);
l('<Br/>Current config : ')
l('<Br/>NODE_ENV = ' + NODE_ENV)
l('<Br/>cmd = ' + processedArgs._[0])
processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null;
l('<Br/><Br/>')
var timer = function(){
l('.');
if(fso.FileExists("run.done")) close();
else window.setTimeout(timer, 1000);
};
window.setTimeout(timer, 3000);
};
</script>
</html>

Loading…
Cancel
Save