|
|
|
|
|
|
|
|
// --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. |
|
|
__runcmd('runas') |
|
|
|
|
|
|
|
|
return __runcmd('runas') |
|
|
} |
|
|
} |
|
|
else __runcmd(processedArgs.label || processedArgs._[0] || 'h'); |
|
|
|
|
|
|
|
|
else return __runcmd(processedArgs.label || processedArgs._[0] || 'h'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var getManifest = function () { |
|
|
var getManifest = function () { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
, elevated: [] |
|
|
, elevated: [] |
|
|
, exludeMergeRepos: {} |
|
|
, exludeMergeRepos: {} |
|
|
, instanceName: processedArgs._[1] || 'chess' |
|
|
|
|
|
|
|
|
, instanceName: 'chess' |
|
|
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. |
|
|
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. |
|
|
, node_env: (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env || 'development' |
|
|
|
|
|
|
|
|
, node_env: 'development' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return Object.assign({ root }, __default); |
|
|
return Object.assign({ root }, __default); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.all(downloadtasks).then(() => { return any(installtasks) }) |
|
|
return Promise.all(downloadtasks).then(() => { return any(installtasks) }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function acquirelocalinstances(selected){ |
|
|
|
|
|
var chessinstances = utils.assign(require(path.normalize(selected.root + '/chessinstances.js'))); |
|
|
|
|
|
chessinstances.current_run.instanceName = processedArgs._[1] = selected.instanceName || processedArgs._[1] || chessinstances.current_run.instanceName; |
|
|
|
|
|
chessinstances.current_run.node_env = processedArgs.node_env = selected.node_env || processedArgs.node_env || chessinstances.current_run.node_env; |
|
|
|
|
|
selectedinstance = Object.assign(chessinstances[chessinstances.current_run.instanceName][chessinstances.current_run.node_env], selected); |
|
|
|
|
|
|
|
|
function initinstances(chessinstances, selected) { |
|
|
|
|
|
chessinstances.current_run.instanceName = processedArgs._[1] = processedArgs._[1] || chessinstances.current_run.instanceName || selected.instanceName; |
|
|
|
|
|
chessinstances.current_run.node_env = processedArgs.node_env = processedArgs.node_env || chessinstances.current_run.node_env || selected.node_env; |
|
|
|
|
|
chessinstances[chessinstances.current_run.instanceName] = chessinstances[chessinstances.current_run.instanceName] || {} |
|
|
|
|
|
selectedinstance = Object.assign(selected, chessinstances[chessinstances.current_run.instanceName][chessinstances.current_run.node_env], clioverrides); |
|
|
repomanifest = selectedinstance |
|
|
repomanifest = selectedinstance |
|
|
return chessinstances |
|
|
return chessinstances |
|
|
} |
|
|
} |
|
|
|
|
|
function acquirelocalinstances(selected){ |
|
|
|
|
|
var chessinstances = utils.assign(require(path.normalize(selected.root + '/chessinstances.js'))); |
|
|
|
|
|
return initinstances(chessinstances, selected) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
function updateselection(selected) { selectedinstance = utils.assign(selectedinstance, selected) } |
|
|
var detectedInstance = detectInstance(); // From launch location etc. |
|
|
var detectedInstance = detectInstance(); // From launch location etc. |
|
|
var selectedinstance = detectedInstance |
|
|
var selectedinstance = detectedInstance |
|
|
|
|
|
|
|
|
|
|
|
var clioverrides = { } |
|
|
|
|
|
processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null; |
|
|
|
|
|
processedArgs.node_env ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || 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 maintask = () => { |
|
|
var maintask = () => { |
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
catch (e) { |
|
|
catch (e) { |
|
|
console.error(e) |
|
|
console.error(e) |
|
|
// No local instances config found. We acquire user choices and proceed to reattempt. |
|
|
// No local instances config found. We acquire user choices and proceed to reattempt. |
|
|
|
|
|
chessinstances = {} |
|
|
|
|
|
chessinstances.current_run = {} |
|
|
|
|
|
initinstances(chessinstances, selectedinstance) |
|
|
return acquireChoices(selectedinstance).then(() => { |
|
|
return acquireChoices(selectedinstance).then(() => { |
|
|
try { |
|
|
try { |
|
|
var chessinstances = acquirelocalinstances(selectedinstance) |
|
|
var chessinstances = acquirelocalinstances(selectedinstance) |
|
|
|
|
|
|
|
|
console.log('We will create a new one with the instance and environment chosen...') |
|
|
console.log('We will create a new one with the instance and environment chosen...') |
|
|
} |
|
|
} |
|
|
finally { |
|
|
finally { |
|
|
|
|
|
|
|
|
return acquireConfig(selectedinstance, chessinstances).catch((e) => { |
|
|
return acquireConfig(selectedinstance, chessinstances).catch((e) => { |
|
|
console.error('Chosen cofiguraton failed or not found') |
|
|
console.error('Chosen cofiguraton failed or not found') |
|
|
console.error(e) |
|
|
console.error(e) |
|
|
|
|
|
|
|
|
.finally(()=>{ |
|
|
.finally(()=>{ |
|
|
fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' }) |
|
|
fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' }) |
|
|
fs.writeFileSync('run.done', 'error'); |
|
|
fs.writeFileSync('run.done', 'error'); |
|
|
return process.exit() |
|
|
|
|
|
|
|
|
// return process.exit() |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |