Browse Source

Merge branch 'master' of https://git.bbh.org.in/chess/elxr

production
pb 2 years ago
parent
commit
b8c7deb573
6 changed files with 3528 additions and 3100 deletions
  1. 1
    1
      cliverse.js
  2. 27
    23
      i.win.js
  3. 3433
    3037
      index.js
  4. 10
    3
      lin_verse.js
  5. 42
    29
      repo-manifest.js
  6. 15
    7
      win_verse.js

+ 1
- 1
cliverse.js View File

} }
else { else {
// console.log( messages.join('') ) // console.log( messages.join('') )
process.stdout.write( messages.join('') )
// process.stdout.write( JSON.stringify(logEntry) )
} }
} }
else if(opts.evaluateResult) { else if(opts.evaluateResult) {

+ 27
- 23
i.win.js View File

a.WriteLine("set PATH=%PATH%;" + python2path ) a.WriteLine("set PATH=%PATH%;" + python2path )
// a.WriteLine("set LAUNCHEDWITHENV=YES" ) // a.WriteLine("set LAUNCHEDWITHENV=YES" )
var __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b'
var __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b'
var currentIsExlr = function() { var currentIsExlr = function() {
if(fs.FileExists('./' + __ALIAS__STAMP__)) return true if(fs.FileExists('./' + __ALIAS__STAMP__)) return true
} }
var runningInExlr = currentIsExlr() var runningInExlr = currentIsExlr()
if(cfn === sfn && runningInExlr) { if(cfn === sfn && runningInExlr) {
a.WriteLine("cd ..");
a.WriteLine("SET LAUNCHEDWITHENV=YES && cscript "+cfn+" /all:true") // PB : TODO -- Retain all script args...
a.WriteLine("cd ..");
a.WriteLine("SET LAUNCHEDWITHENV=YES && cscript "+cfn+" /all:true") // PB : TODO -- Retain all script args...
} }
else { else {
var guesselxr = fs.FileExists(cd + './elxr/' + __ALIAS__STAMP__) var guesselxr = fs.FileExists(cd + './elxr/' + __ALIAS__STAMP__)
return any(steps) return any(steps)
// return any([any(steps), any(prompts)]) // return any([any(steps), any(prompts)])
} }
, install : install
, postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') }
, exists : exists
, install : install
, postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') }
, exists : exists
} }
, { , {
shellcmd: 'code' shellcmd: 'code'
url: 'https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.30.0.msi' //'https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.29.0.msi' url: 'https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.30.0.msi' //'https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.29.0.msi'
, installer: 'mysql-installer-community-8.0.30.0.msi' , installer: 'mysql-installer-community-8.0.30.0.msi'
, installcmd: ['MSIEXEC.exe', ['/i' , installcmd: ['MSIEXEC.exe', ['/i'
, path.normalize(downloadsdir + '/' + 'mysql-installer-community-8.0.30.0.msi')
, path.normalize(downloadsdir + '/' + 'mysql-installer-community-8.0.30.0.msi')
//, 'ACCEPT=YES', '/passive' //, 'ACCEPT=YES', '/passive'
]]
]]
, install : install , install : install
, exists : exists , exists : exists
, preinstallsteps: function() { , preinstallsteps: function() {
['git', ['clone', chessRepo + '/chess/elxr'] ] ['git', ['clone', chessRepo + '/chess/elxr'] ]
] ]
if(existsSyncFolder( selectedinstance.root + '\\elxr')) {
if(existsSyncFolder( selectedinstance.root + '\\elxr\\.git')) {
// PB : TODO -- use a elxr guid signature to detect more reliably folders named the same that is not us.
ifns = [ ['git', ['pull'], { cwd : selectedinstance.root + '\\elxr' } ] ]
}
else {
throw 'elxr subfolder not recognized as a git repository. Please cleanup and continue.'
}
if(existsSyncFolder( selectedinstance.root + '\\elxr')) {
if(existsSyncFolder( selectedinstance.root + '\\elxr\\.git')) {
// PB : TODO -- use a elxr guid signature to detect more reliably folders named the same that is not us.
ifns = [ ['git', ['pull'], { cwd : selectedinstance.root + '\\elxr' } ] ]
} }
else console.log(selectedinstance.root + '\\elxr' + ' NOT FOUND ')
else {
throw 'elxr subfolder not recognized as a git repository. Please cleanup and continue.'
}
}
else console.log(selectedinstance.root + '\\elxr' + ' NOT FOUND ')
ifns.push(['npm', ['i'], { cwd : '.\\elxr' } ]) ifns.push(['npm', ['i'], { cwd : '.\\elxr' } ])
if(!ifns.map) ifns.map = map;
return any(ifns.map(callsheltask))['catch'](function(e){
if(e.code === 1602) {
console.warn("Installation was probably cancelled.")
}
else throw e
if(!ifns.map) ifns.map = map;
return any(ifns.map(callsheltask))['catch'](function(e){
if(e.code === 1602) {
console.warn("Installation was probably cancelled.")
}
else throw e
}) })
}) })
} }
, nodeShellExec('start', ['""', '"C:\\Program Files\\Git\\bin\\sh.exe"', '-c', '"node ' + (selectedinstance.root + '\\elxr\\index.js').replace(/\\/g, '/') + ' i elixir"']) , nodeShellExec('start', ['""', '"C:\\Program Files\\Git\\bin\\sh.exe"', '-c', '"node ' + (selectedinstance.root + '\\elxr\\index.js').replace(/\\/g, '/') + ' i elixir"'])
// , nodeShellExec('node', [selectedinstance.root + 'elxr\\index.js']) // , nodeShellExec('node', [selectedinstance.root + 'elxr\\index.js'])
]) ])
// return any([ /*self.preinstallsteps,*/ function(){ return self.installsteps() }
// , nodeShellExec('node', [selectedinstance.root + '\\elxr\\index.js', 'init'])
// // , nodeShellExec('node', [selectedinstance.root + 'elxr\\index.js'])
// ])
} }
// , exists : function(){ // , exists : function(){
// console.log('Elxr PreInstallsteps called') // console.log('Elxr PreInstallsteps called')

+ 3433
- 3037
index.js
File diff suppressed because it is too large
View File


+ 10
- 3
lin_verse.js View File

return Promise.resolve(false).then(( elevationstate ) => { return Promise.resolve(false).then(( elevationstate ) => {
__isElevated ? console.log('Elevated') : console.log('Not Elevated') __isElevated ? console.log('Elevated') : console.log('Not Elevated')
__isElevated = elevationstate; __isElevated = elevationstate;
shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated);
shell_verse.isElevated = () => { return Promise.resolve(__isElevated)}
return __isElevated
}).catch(() => { }).catch(() => {
__isElevated = false; __isElevated = false;
console.log('Not Elevated');
}).finally(()=>{
shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated); shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated);
shell_verse.isElevated = () => { return Promise.resolve(__isElevated)} shell_verse.isElevated = () => { return Promise.resolve(__isElevated)}
return __isElevated;
console.log('Not Elevated');
return __isElevated
}) })
// .finally(()=>{
// shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated);
// shell_verse.isElevated = () => { return Promise.resolve(__isElevated)}
// return __isElevated; // Value returned from finally is not supported by node.
// })
} }


, getTaskCheckExists : cli.createTask('getTaskCheckExists', 'which') , getTaskCheckExists : cli.createTask('getTaskCheckExists', 'which')

+ 42
- 29
repo-manifest.js View File

module.exports = ((name, options)=>{ module.exports = ((name, options)=>{


options = options || { username : ``, reposerver : `https://git.bbh.org.in` }
options = options || { username : `guest`, reposerver : `https://git.bbh.org.in`, password : `noneforguest` }
utils = options.utils utils = options.utils


// Default set of users in main repos. // Default set of users in main repos.
'chess' : { 'chess' : {
priority : 0, priority : 0,
// PB : TODO -- Handle cases where a repository url can be accessed by multiple users... // PB : TODO -- Handle cases where a repository url can be accessed by multiple users...
server : `${options.reposerver}`, user : options.username || '', path : ``
, get url(){ return `${this.server}/chess/${this.path}`} // fetch
server : `${options.reposerver}`, user : { username : options.username || ''}, path : ``
, get url(){ return `${this.server}/${this.owner}`} // fetch
, push : 'no-pushing' , push : 'no-pushing'
, title : 'chess' , title : 'chess'
, get username(){ return this.user.username }
, owner : 'chess'
} }
, 'chess-public' : { priority : 1, , 'chess-public' : { priority : 1,
server : `https://git.bbh.org.in`, user : options.username || '', path : ``
, get url(){ return `${this.server}/chess/${this.path}`}
server : `https://git.bbh.org.in`, user : { username : options.username || ''}, path : ``
, get url(){ return `${this.server}/${this.owner}`}
, title : 'chess-public' // PB : TODO -- rename... , title : 'chess-public' // PB : TODO -- rename...
, accessibility : ['public'] , accessibility : ['public']
, push : 'no-pushing' , push : 'no-pushing'
, get username(){ return this.user.username }
, owner : 'chess'
} }
// PB : TODO -- Load private repositories from private config... // PB : TODO -- Load private repositories from private config...
, 'chess-private' : { priority : 2, , 'chess-private' : { priority : 2,
server : `http://git.bbh`, user : options.username || '', path : ``
, get url(){ return `${this.server}/chess/${this.path}`}
server : `http://git.bbh`, user : { username : options.username || ''}, path : ``
, get url(){ return `${this.server}/${this.owner}`}
, title : 'chess-private' , title : 'chess-private'
, accessibility : ['private'] , accessibility : ['private']
, push : 'no-pushing', private : true , push : 'no-pushing', private : true
}
, get username(){ return this.user.username }
, owner : 'chess'
}
, 'chess-github' : { priority : 3, , 'chess-github' : { priority : 3,
server : `https://github.com`, user : 'baptistdev', path : ``
, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
server : `https://github.com`, user : { username : 'baptistdev'}, path : ``
, get url(){ return `${this.server}/${this.owner}`} // fetch
, title : 'chess-github' , title : 'chess-github'
, accessibility : ['public'] , accessibility : ['public']
, push : 'no-pushing' //, external : true, public : true
, push : 'no-pushing' //, external : true, public : true
, get username(){ return this.user.username }
, owner : 'chess'
} }
} }
utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION } utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }
, remotes , remotes
, { 'userfork' : { , { 'userfork' : {
priority : 1,
server : `${options.reposerver}`, user : `${options.username}`, path : ``
, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
, title : 'userfork'
priority : 1,
server : `${options.reposerver}`, user : { username : `${options.username}`}, path : ``
, get url(){ return `${this.server}/${this.user.username}`} // fetch
, title : 'userfork'
, get username(){ return this.user.username }
, get owner(){ return this.username }
, pushable : true
} }
, 'userfork-public' : { , 'userfork-public' : {
priority : 1, priority : 1,
server : `https://git.bbh.org.in`, user : `${options.username}`, path : ``
, get url(){ return `${this.server}/${this.user}/${this.path}`}
server : `https://git.bbh.org.in`, user : {username : `${options.username}`}, path : ``
, get url(){ return `${this.server}/${this.user.username}`}
// PB : TODO - Other users may have access to this users repo. However that needs to be defined as a new remote // PB : TODO - Other users may have access to this users repo. However that needs to be defined as a new remote
, title : 'userfork-public' , title : 'userfork-public'
, accessibility : ['public'] /*public : true, external: true */ , accessibility : ['public'] /*public : true, external: true */
, get username(){ return this.user.username }
, get owner(){ return this.username }
, pushable : true
} }
// PB : TODO -- Load private repositories from private config... // PB : TODO -- Load private repositories from private config...
, 'userfork-private' : { priority : 2, , 'userfork-private' : { priority : 2,
server : `http://git.bbh`, user : options.username || '', path : ``
, get url(){ return `${this.server}/${options.username}/${this.path}`}
server : `http://git.bbh`, user : { username : options.username || ''}, path : ``
, get url(){ return `${this.server}/${this.user.username}`}
, title : 'userfork-private' , title : 'userfork-private'
, accessibility : ['private'] , accessibility : ['private']
}
, get username(){ return this.user.username }
, get owner(){ return this.username }
}
, 'userfork-unc' : { , 'userfork-unc' : {
priority : 3, priority : 3,
server : `//172.16.0.27/repos`, user : `${options.username}`, path : ``
, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
server : `//172.16.0.27/repos`, user : { username : `${options.username}`}, path : ``
, get url(){ return `${this.server}/${this.user.username}`} // fetch
, title : 'userfork-unc' , title : 'userfork-unc'
, accessibility : ['unc'] , accessibility : ['unc']
// , unc : true, private : true // , unc : true, private : true
}
, get username(){ return this.user.username }
, get owner(){ return this.username }
, pushable : true
}
} }
) )
} }
reposervers : Object.keys(reposerverinstances) reposervers : Object.keys(reposerverinstances)
, reposerverinstances , reposerverinstances
, remotes , remotes
, get reposindexed(){
// PB : TODO -- Implement -- One time gettor and then cached...
var indexed = {}
this.repos.forEach(r => { indexed[r.repo] = r })
return indexed;
}
, repos : [ , repos : [
{ repo : 'elxr' } { repo : 'elxr' }
] ]

+ 15
- 7
win_verse.js View File

const { any } = require('bbhverse'); const { any } = require('bbhverse');
const fs = require('fs') const fs = require('fs')
var path = require('path');


var cli = require('./cliverse') var cli = require('./cliverse')
var nodeShellExec = cli.nodeShellExec; var nodeShellExec = cli.nodeShellExec;
var __runasresult = null; var __runasresult = null;
return taskToRun().then((r)=>{ return taskToRun().then((r)=>{
// PB : TODO -- Every elevation should have its own messaging file. Async writes from multiple processes are a problem here... // PB : TODO -- Every elevation should have its own messaging file. Async writes from multiple processes are a problem here...
elevatedRunIPCWriteMessage( runlogjson, { info : taskToRun.info, success: true } )
elevatedRunIPCWriteMessage( runlogjson, ', ' + JSON.stringify( { info : taskToRun.info, success: true }) )
if(!inBatch) fs.writeFileSync('run.done', 'success') // PB : TODO -- This should be done conditionally if we are running inproc. if(!inBatch) fs.writeFileSync('run.done', 'success') // PB : TODO -- This should be done conditionally if we are running inproc.
return __runasresult = r; return __runasresult = r;
}) })
.catch((e) => { .catch((e) => {
elevatedRunIPCWriteMessage( runlogjson, e )
elevatedRunIPCWriteMessage( runlogjson, ', ' + JSON.stringify(e ) )
if(!inBatch)fs.writeFileSync('run.done', 'failure') if(!inBatch)fs.writeFileSync('run.done', 'failure')
console.error(e) console.error(e)
}) })
}).then((exitcode) => { }).then((exitcode) => {
console.log('Elevated') console.log('Elevated')
__isElevated = true; __isElevated = true;
}).catch(() => {
shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated);
shell_verse.isElevated = () => { return Promise.resolve(__isElevated)}
return __isElevated
}).catch((e) => {
__isElevated = false; __isElevated = false;
console.log('Not Elevated');
}).finally(()=>{
shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated); shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated);
shell_verse.isElevated = () => { return Promise.resolve(__isElevated)} shell_verse.isElevated = () => { return Promise.resolve(__isElevated)}
return __isElevated;
console.log('Not Elevated');
return __isElevated
}) })
// .finally(()=>{
// shell_verse.acquireElevationState = ()=> Promise.resolve(__isElevated);
// shell_verse.isElevated = () => { return Promise.resolve(__isElevated)}
// // return __isElevated; // Value returned from finally is not supported by node.
// })
} }
, getTaskCheckExists : cli.createTask('getTaskCheckExists', 'where') , getTaskCheckExists : cli.createTask('getTaskCheckExists', 'where')
console.log('result : ' + JSON.stringify(r)) console.log('result : ' + JSON.stringify(r))
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; }) Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; })
// PB : TODO -- Convert all the cli args back to string. // PB : TODO -- Convert all the cli args back to string.
var args = [`${selectedinstance.root}/.elxr/run-${taskToRun.runtimestamp}/windowselevate.hta`].concat(processedArgs._)
var args = [ path.normalize(`${selectedinstance.root}/.elxr/run-${taskToRun.runtimestamp}/windowselevate.hta`) ].concat(processedArgs._)
namedArgs.length > 0 ? args = args.concat(namedArgs.join(' ')) : null; namedArgs.length > 0 ? args = args.concat(namedArgs.join(' ')) : null;
args.push('--runas=self'); args.push('--runas=self');
var elevatedruntimestamp = (new Date()).getTime() var elevatedruntimestamp = (new Date()).getTime()

Loading…
Cancel
Save