Browse Source

Updated Elevated shell ops culled out by OS

production
pb 2 years ago
parent
commit
f86b4c5e61
2 changed files with 44 additions and 18 deletions
  1. 42
    16
      index.js
  2. 2
    2
      win_verse.js

+ 42
- 16
index.js View File

etask.statuslog = statuslog etask.statuslog = statuslog
etask.selectedinstance = selectedinstance etask.selectedinstance = selectedinstance
etask.processedArgs = processedArgs etask.processedArgs = processedArgs
etask.runtimestamp = runtimestamp
etask.ENV = ENV
return shell_verse.runElevated(etask) return shell_verse.runElevated(etask)
return pullCmd return pullCmd
} }


var performPull = (repo, branch, repoowner, errHandler) => {
// PB : TODO -- Use queueing with async tasks..
var performPull = (repodef, branch, repoowner, errHandler) => {
// PB : TODO -- Handle no branch passed in case. // PB : TODO -- Handle no branch passed in case.
// if(!branch) { throw 'No branch specified' } // if(!branch) { throw 'No branch specified' }
var repo = repodef.repo;
try{ try{
var exists = existsSync(instanceroot + '/' + repo) var exists = existsSync(instanceroot + '/' + repo)
} }
task.info = { repo } task.info = { repo }
task.errHandler = errHandler task.errHandler = errHandler
task.statuslog = statuslog task.statuslog = statuslog
return shell_verse.runTask( task )
task.processedArgs = processedArgs
task.selectedinstance = selectedinstance
task.runtimestamp = runtimestamp
task.ENV = ENV
if(repodef.requiresElevation) return shell_verse.runElevated( task )
else return shell_verse.runTask( task )
} }
else { else {
console.log('cloning ' + repo) console.log('cloning ' + repo)
task.info = { repo } task.info = { repo }
task.errHandler = errHandler task.errHandler = errHandler
task.statuslog = statuslog task.statuslog = statuslog
return shell_verse.runTask( task )
task.processedArgs = processedArgs
task.selectedinstance = selectedinstance
task.runtimestamp = runtimestamp
task.ENV = ENV
if(repodef.requiresElevation) return shell_verse.runElevated( task )
else return shell_verse.runTask( task )
}) })
} }
task.info = { repo } task.info = { repo }
task.errHandler = errHandler task.errHandler = errHandler
task.statuslog = statuslog task.statuslog = statuslog
return shell_verse.runTask( task )
task.processedArgs = processedArgs
task.selectedinstance = selectedinstance
task.runtimestamp = runtimestamp
task.ENV = ENV
if(repodef.requiresElevation) return shell_verse.runElevated( task )
else return shell_verse.runTask( task )
} }
} }


// console.dir(env) // console.dir(env)
console.log('Running exlr pull : ' + path.dirname(__dirname)) console.log('Running exlr pull : ' + path.dirname(__dirname))


if (!processedArgs.runas) gitRepos.map((def) => performPull(def.repo, def.branch || 'master'))
if (!processedArgs.runas) gitRepos.map((def) => performPull(def, def.branch || 'master'))
var etask = ()=>{ var etask = ()=>{
return any(elevatedRunasRepos.map((def) => performPull(def.repo, def.branch || 'master'))).then(() => {
return any(elevatedRunasRepos.map((def) => performPull(def, def.branch || 'master'))).then(() => {
fs.writeFileSync('run.done', 'success') fs.writeFileSync('run.done', 'success')
}).catch(() => { }).catch(() => {
fs.writeFileSync('run.done', 'error') fs.writeFileSync('run.done', 'error')
etask.statuslog = statuslog etask.statuslog = statuslog
etask.selectedinstance = selectedinstance etask.selectedinstance = selectedinstance
etask.processedArgs = processedArgs etask.processedArgs = processedArgs
etask.runtimestamp = runtimestamp
etask.ENV = ENV
return shell_verse.runElevated(etask) return shell_verse.runElevated(etask)
} }


etask.statuslog = statuslog etask.statuslog = statuslog
etask.selectedinstance = selectedinstance etask.selectedinstance = selectedinstance
etask.processedArgs = processedArgs etask.processedArgs = processedArgs
etask.runtimestamp = runtimestamp
etask.ENV = ENV
return shell_verse.runElevated(etask) return shell_verse.runElevated(etask)
} }


etask.statuslog = statuslog etask.statuslog = statuslog
etask.selectedinstance = selectedinstance etask.selectedinstance = selectedinstance
etask.processedArgs = processedArgs etask.processedArgs = processedArgs
etask.runtimestamp = runtimestamp
etask.ENV = ENV
return shell_verse.runElevated(etask) return shell_verse.runElevated(etask)
} }
, noprerequisites : true , noprerequisites : true
if(def.repo) { if(def.repo) {
// Single repo case. // Single repo case.
if(def.repo.requiresElevation) { if(def.repo.requiresElevation) {
getElevatedTask
var t1 = function() { var t1 = function() {
return performPull(def.repo).then(() => {
return performPull(def).then(() => {
return true; return true;
}).catch((e) => { }).catch((e) => {
console.error(e) console.error(e)
} }
else { else {
var t2 = function(){ var t2 = function(){
return performPull(def.repo).then(() => {
return performPull(def).then(() => {
return true; return true;
}).catch((e) => { }).catch((e) => {
console.error(e) console.error(e)
var regularpulltasks = function(){ return Promise.resolve(true) } var regularpulltasks = function(){ return Promise.resolve(true) }
if(def.elevated){ if(def.elevated){
elevatedpulltasks = function() { elevatedpulltasks = function() {
return any(def.elevated.map((def) => performPull(def.repo))).then(() => {
// shell_verse.getElevatedTask( t1 )
return any(def.elevated.map((def) => performPull(def))).then(() => {
return true; return true;
}).catch((e) => { }).catch((e) => {
console.error(e) console.error(e)
if(def.repos) { if(def.repos) {
var regularpulltasks = function(){ var regularpulltasks = function(){
var pendingpulls = []; var pendingpulls = [];
def.repos.forEach((def) => { pendingpulls.push(performPull(def.repo)) })
def.repos.forEach((def) => { pendingpulls.push(performPull(def)) })
return Promise.all(pendingpulls).finally(Traq.finally) return Promise.all(pendingpulls).finally(Traq.finally)
} }
regularpulltasks.statuslog = statuslog regularpulltasks.statuslog = statuslog
// git config --edit --system // git config --edit --system
// git config --global credential.helper "store --file ~/gitcredentials" // git config --global credential.helper "store --file ~/gitcredentials"
// git credential fill // git credential fill
// git credential-store --file ~/git.store store
// git credential-store --file ~/git.store store
// Find system git config // Find system git config
// git config --global --edit // git config --global --edit
ENV.NODE_ENV = selectedinstance.node_env; ENV.NODE_ENV = selectedinstance.node_env;
} }


return performPull(configrepo, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler )
return performPull({repo : configrepo}, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler )
.catch( (e)=>{ .catch( (e)=>{
// if(e){ // if(e){
if(Promise.resolve(e) === e) return e; if(Promise.resolve(e) === e) return e;


} }


return performPull(datarepo, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler )
return performPull({ repo : datarepo }, null, owner, errHandler || errorHandler || ((e)=>{ throw e })).then( successHandler )
.catch( (e)=>{ .catch( (e)=>{
// if(e){ // if(e){
if(Promise.resolve(e) === e) return e; if(Promise.resolve(e) === e) return e;
, { repo : 'ember-sw-client-route' } , { repo : 'ember-sw-client-route' }
, { repo : 'global-this' } , { repo : 'global-this' }
] ]
, elevated : [ { repo : 'chess-server-lib' } ]
// Requires elevation only in windows
, elevated : [ { repo : 'chess-server-lib', requiresElevation : true } ]
, exludeMergeRepos : { } , exludeMergeRepos : { }
} }



+ 2
- 2
win_verse.js View File

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-${runtimestamp}/windowselevate.hta`].concat(processedArgs._)
var args = [`${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');
// args.push('--nodepath=' + r.messages[r.messages.length - 1]) // args.push('--nodepath=' + r.messages[r.messages.length - 1])
, { , {
inherit: true inherit: true
, shell: true , shell: true
, env: ENV
, env: taskToRun.ENV
, runas: 'self' , runas: 'self'
, title: `runas` , title: `runas`
} }

Loading…
Cancel
Save