|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exists) { |
|
|
if (exists) { |
|
|
var branchprint = branch ? ' branch :' + branch : ''; |
|
|
var branchprint = branch ? ' branch :' + branch : ''; |
|
|
console.log('pulling ' + instanceroot + '/' + repo + branchprint ) |
|
|
|
|
|
var task = ()=>{ |
|
|
var task = ()=>{ |
|
|
|
|
|
console.log('pulling ' + instanceroot + '/' + repo + branchprint ) |
|
|
return nodeShellExec.apply(null, getPullCmd(repo, branch)).then(() => { |
|
|
return nodeShellExec.apply(null, getPullCmd(repo, branch)).then(() => { |
|
|
return true; |
|
|
return true; |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
initTask(task) |
|
|
initTask(task) |
|
|
|
|
|
|
|
|
if(repodef.requiresElevation) { |
|
|
if(repodef.requiresElevation) { |
|
|
|
|
|
if(elevatedBatch.length === 1) { initTask(elevatedBatch[0]) } // PB : TDOO -- Make sure first task also has run context. May need to be moved to win_verse |
|
|
elevatedBatch.push(shell_verse.getElevatedTask( task )); |
|
|
elevatedBatch.push(shell_verse.getElevatedTask( task )); |
|
|
return elevatedBatch[elevatedBatch.length-1] |
|
|
return elevatedBatch[elevatedBatch.length-1] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// shell_verse.getElevatedTask( t1 ) |
|
|
// shell_verse.getElevatedTask( t1 ) |
|
|
var eBatch = [] |
|
|
var eBatch = [] |
|
|
def.elevated.map((def) => getPullTask(def, null, null, null, eBatch)) |
|
|
def.elevated.map((def) => getPullTask(def, null, null, null, eBatch)) |
|
|
return any(shell_verse.runElevatedBatch(eBatch)).then(() => { |
|
|
|
|
|
|
|
|
return shell_verse.runElevatedBatch(eBatch).then(() => { |
|
|
return true; |
|
|
return true; |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
console.error(e) |
|
|
console.error(e) |
|
|
|
|
|
|
|
|
// --runas |
|
|
// --runas |
|
|
if (processedArgs.runas) { |
|
|
if (processedArgs.runas) { |
|
|
// Weve been asked to run in priviledged mode. Check if we already are privileged. |
|
|
// Weve been asked to run in priviledged mode. Check if we already are privileged. |
|
|
return __runcmd('runas') |
|
|
|
|
|
|
|
|
// return __runcmd('runas') |
|
|
|
|
|
// we no longer have a runas function. This has been moved to shellverse.requestElevation... |
|
|
|
|
|
// Each task has knowledge of requiring elevation and will handle elevation requests as needed. Preferably the task will participate in a batch and queue itself. |
|
|
|
|
|
// |
|
|
|
|
|
return __runcmd(processedArgs.label || processedArgs._[0] || 'undefined'); |
|
|
} |
|
|
} |
|
|
else return __runcmd(processedArgs.label || processedArgs._[0] || 'undefined'); |
|
|
else return __runcmd(processedArgs.label || processedArgs._[0] || 'undefined'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return prerequisites.git.verifyAndInstall().then(()=>{ |
|
|
return prerequisites.git.verifyAndInstall().then(()=>{ |
|
|
var e = { message : 'verifyAndInstall', success : true} |
|
|
var e = { message : 'verifyAndInstall', success : true} |
|
|
var inittasks = [] |
|
|
var inittasks = [] |
|
|
var commantask = () => { preworkerconfig(); return elxrworker(true) } |
|
|
|
|
|
|
|
|
var commontask = () => { preworkerconfig(); return elxrworker(true) } |
|
|
if(!detection_state.localInstanceDetected) { |
|
|
if(!detection_state.localInstanceDetected) { |
|
|
var t1 = ()=>{ return createInstance(selectedinstance) }; |
|
|
var t1 = ()=>{ return createInstance(selectedinstance) }; |
|
|
t1.statuslog = statuslog |
|
|
t1.statuslog = statuslog |
|
|
|
|
|
|
|
|
var specifictask = shell_verse.getNonElevatedTask(t2) |
|
|
var specifictask = shell_verse.getNonElevatedTask(t2) |
|
|
} |
|
|
} |
|
|
inittasks.push( specifictask().catch((err) => { |
|
|
inittasks.push( specifictask().catch((err) => { |
|
|
e = err; |
|
|
|
|
|
console.error('Chosen cofiguraton failed or not found. Fix config and rerun or chose another.') |
|
|
|
|
|
console.error(err) |
|
|
|
|
|
}).then( commantask ) |
|
|
|
|
|
|
|
|
e = err; |
|
|
|
|
|
console.error('Chosen cofiguraton failed or not found. Fix config and rerun or chose another.') |
|
|
|
|
|
console.error(err) |
|
|
|
|
|
}).then( commontask ) |
|
|
// .finally(()=>{ |
|
|
// .finally(()=>{ |
|
|
// fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' }) |
|
|
// fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' }) |
|
|
// if(!e.success) fs.writeFileSync('run.done', 'error'); |
|
|
// if(!e.success) fs.writeFileSync('run.done', 'error'); |
|
|
|
|
|
|
|
|
// PB : TODO -- Convert all the cli args back to string. |
|
|
// PB : TODO -- Convert all the cli args back to string. |
|
|
// __filename will sure we are launhed using the same entry point. |
|
|
// __filename will sure we are launhed using the same entry point. |
|
|
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' ${__filename.replace(/\\/g, '\\\\')} ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' '); |
|
|
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' ${__filename.replace(/\\/g, '\\\\')} ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' '); |
|
|
// alert(cargs) |
|
|
|
|
|
var shell = new ActiveXObject('shell.application'); |
|
|
var shell = new ActiveXObject('shell.application'); |
|
|
// alert('launching node privilged. ' + processedArgs['nodepath']) |
|
|
// alert('launching node privilged. ' + processedArgs['nodepath']) |
|
|
// shell.ShellExecute('where', 'node', '', '', 10); |
|
|
|
|
|
|
|
|
// shell.ShellExecute('cmd.exe', '/k where node', '', '', 10); |
|
|
// shell.ShellExecute('cmd.exe', '/k notepad.exe', '', 'runas', 1); |
|
|
// shell.ShellExecute('cmd.exe', '/k notepad.exe', '', 'runas', 1); |
|
|
// shell.ShellExecute('cmd.exe ', '/k node "' + cargs + '"', '', 'runas', 1); |
|
|
|
|
|
|
|
|
// shell.ShellExecute('cmd.exe ', '/k node ', '', 'runas', 1); |
|
|
|
|
|
// shell.ShellExecute('cmd.exe ', '/k node ' + cargs + '', '', 'runas', 1); |
|
|
shell.ShellExecute('node', cargs, '', 'runas', 1); |
|
|
shell.ShellExecute('node', cargs, '', 'runas', 1); |
|
|
|
|
|
// alert('/k node ' + cargs + '') |
|
|
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1); |
|
|
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1); |
|
|
var fso = new ActiveXObject('Scripting.FileSystemObject'); |
|
|
var fso = new ActiveXObject('Scripting.FileSystemObject'); |
|
|
|
|
|
|