|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
instanceroot = root.replace(/\\/, '/'); |
|
|
instanceroot = root.replace(/\\/, '/'); |
|
|
var __default = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Object.assign({ root }, __default); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Default is public server only. |
|
|
|
|
|
reposervers: ['https://git.bbh.org.in'] |
|
|
|
|
|
|
|
|
var __default = { |
|
|
|
|
|
|
|
|
// All public repos are by default available. |
|
|
|
|
|
, repos: [ |
|
|
|
|
|
|
|
|
// Default is public server only. |
|
|
|
|
|
// All public repos are by default available. |
|
|
|
|
|
reposervers: ['https://git.bbh.org.in'] |
|
|
|
|
|
, repos: [ |
|
|
'setup' |
|
|
'setup' |
|
|
, 'elxr' |
|
|
|
|
|
, 'loopback-connector-mysql' |
|
|
|
|
|
, 'loopback-jsonapi-model-serializer' |
|
|
|
|
|
, 'loopback-component-jsonapi' |
|
|
|
|
|
, 'ember-service-worker' |
|
|
|
|
|
, 'ember-service-worker-asset-cache' |
|
|
|
|
|
, 'ember-service-worker-cache-fallback' |
|
|
|
|
|
, 'ember-service-worker-index' |
|
|
|
|
|
, 'ember-sw-client-route' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
, elevated: [] |
|
|
|
|
|
, exludeMergeRepos: {} |
|
|
|
|
|
, instanceName: 'chess' |
|
|
|
|
|
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. |
|
|
|
|
|
, node_env: 'development' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Object.assign({ root }, __default); |
|
|
|
|
|
|
|
|
, 'elxr' |
|
|
|
|
|
, 'loopback-connector-mysql' |
|
|
|
|
|
, 'loopback-jsonapi-model-serializer' |
|
|
|
|
|
, 'loopback-component-jsonapi' |
|
|
|
|
|
, 'ember-service-worker' |
|
|
|
|
|
, 'ember-service-worker-asset-cache' |
|
|
|
|
|
, 'ember-service-worker-cache-fallback' |
|
|
|
|
|
, 'ember-service-worker-index' |
|
|
|
|
|
, 'ember-sw-client-route' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
, elevated: [] |
|
|
|
|
|
, exludeMergeRepos: {} |
|
|
|
|
|
, instanceName: 'chess' |
|
|
|
|
|
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. |
|
|
|
|
|
, node_env: 'development' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var gitUser = 'chessdemo'; |
|
|
|
|
|
var gitEmail = 'chessdemo@bbh.org.in' |
|
|
|
|
|
var downloadsdir = '../Downloads'; |
|
|
var downloadsdir = '../Downloads'; |
|
|
var prerequisites = [ |
|
|
var prerequisites = [ |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
, '/VERYSILENT' |
|
|
, '/VERYSILENT' |
|
|
// , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
// , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
]] |
|
|
]] |
|
|
, preinstallsteps: () => { |
|
|
|
|
|
|
|
|
, preinstallsteps: function() { |
|
|
var prompt = cli.prompt; |
|
|
var prompt = cli.prompt; |
|
|
var steps = [ |
|
|
var steps = [ |
|
|
() => { |
|
|
() => { |
|
|
if (!existsSync(downloadsdir + '/' + preq.installer)) { |
|
|
|
|
|
return nodeShellExec('download.bat', [preq.url, downloadsdir + '/' + preq.installer]) |
|
|
|
|
|
|
|
|
if (!existsSync(downloadsdir + '/' + this.installer)) { |
|
|
|
|
|
return nodeShellExec('download.bat', [this.url, downloadsdir + '/' + this.installer]) |
|
|
} |
|
|
} |
|
|
else return Promise.resolve(true) |
|
|
else return Promise.resolve(true) |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
var prompts = [ |
|
|
var prompts = [ |
|
|
() => prompt.ask(`git user name : ( <= ${gitUser} )`).then((user) => { gitUser = user; }) |
|
|
() => prompt.ask(`git user name : ( <= ${gitUser} )`).then((user) => { gitUser = user; }) |
|
|
, () => prompt.ask(`git user name : ( <= ${gitEmail} )`).then((email) => { gitEmail = email; }) |
|
|
|
|
|
|
|
|
, () => prompt.ask(`git email : ( <= ${gitEmail} )`).then((email) => { gitEmail = email; }) |
|
|
] |
|
|
] |
|
|
return Promise.all([any(steps), any(prompts)]).finally(() => { prompt.close() }) |
|
|
|
|
|
|
|
|
return any([any(steps), any(prompts)]).then(() => { prompt.close() }) |
|
|
} |
|
|
} |
|
|
, installsteps: function () { |
|
|
, installsteps: function () { |
|
|
return any([this.installcmd].map(callsheltask)) |
|
|
return any([this.installcmd].map(callsheltask)) |
|
|
} |
|
|
} |
|
|
, postinstallsteps: () => { |
|
|
|
|
|
var steps = [ |
|
|
|
|
|
['git', ['config', '--global', '--add', 'user.name', `${gitUser}`]] |
|
|
|
|
|
, ['git', ['config', '--global', '--add', 'user.email', `${gitEmail}`]] |
|
|
|
|
|
] |
|
|
|
|
|
return any(steps.map(callsheltask)).then(() => { }) |
|
|
|
|
|
|
|
|
, postinstallsteps: function(){ |
|
|
|
|
|
|
|
|
|
|
|
var prompt = cli.prompt; |
|
|
|
|
|
|
|
|
|
|
|
var gitUser = 'guest'; |
|
|
|
|
|
var gitEmail = 'guest@bbh.org.in'; |
|
|
|
|
|
var prompts = []; |
|
|
|
|
|
prompts.push( |
|
|
|
|
|
()=>{ |
|
|
|
|
|
var choices = { 0 : 'guest', 1 : 'chessdemo' } |
|
|
|
|
|
return prompt.ask( |
|
|
|
|
|
`git user name \n ` + Object.keys(choices).map(choice => { return ` ${(+choice) + 1}) ${choices[choice]} `}).join('\n') + `\n default ( <= ${choices[0]} ) : ` |
|
|
|
|
|
).then(choice => { |
|
|
|
|
|
if(!choice) return gitUser = choices[0]; |
|
|
|
|
|
if(choice && isNaN(+choice)) return gitUser = choice; |
|
|
|
|
|
return gitUser = choices[choice + 1]; |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
prompts.push( |
|
|
|
|
|
()=>{ |
|
|
|
|
|
var choices = { 0 : 'guest@bbh.org.in', 1 : 'chessdemo@bbh.org.in' } |
|
|
|
|
|
return prompt.ask( |
|
|
|
|
|
`git user email \n ` + Object.keys(choices).map(choice => { return ` ${(+choice) + 1}) ${choices[choice]} `}).join('\n') + `\n default ( <= ${choices[0]} ) : ` |
|
|
|
|
|
).then(choice => { |
|
|
|
|
|
if(!choice) return gitEmail = choices[0]; |
|
|
|
|
|
if(choice && isNaN(+choice)) return gitEmail = choice; |
|
|
|
|
|
return gitEmail = choices[choice + 1]; |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return any(prompts).then(()=>{ |
|
|
|
|
|
var steps = [ |
|
|
|
|
|
['git', ['config', '--global', '--add', 'user.name', `${gitUser}`]] |
|
|
|
|
|
, ['git', ['config', '--global', '--add', 'user.email', `${gitEmail}`]] |
|
|
|
|
|
] |
|
|
|
|
|
return any(steps.map(callsheltask)).then(() => { |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
, install: function () { |
|
|
, install: function () { |
|
|
return any([ /*this.preinstallsteps,*/ this.installsteps, this.postinstallsteps]) |
|
|
|
|
|
|
|
|
return any([ /*this.preinstallsteps,*/ this.installsteps.bind(this), this.postinstallsteps.bind(this)]) |
|
|
|
|
|
} |
|
|
|
|
|
, verifyAndInstall : function(){ |
|
|
|
|
|
return getTaskCheckExists(this.shellcmd, { ignorefailures: true })().then((exists) => { |
|
|
|
|
|
if(exists) { |
|
|
|
|
|
// return any(['git', ['config', '--global', '-l']].map(callsheltask)) |
|
|
|
|
|
return this.getUser(null, this.postinstallsteps.bind(this)) |
|
|
|
|
|
} |
|
|
|
|
|
return this.install(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
, getUser : function(repo, onNoResult){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onNoResult = onNoResult || function(){return false} |
|
|
|
|
|
var globalOrLocal = '--global'; |
|
|
|
|
|
if(!repo) globalOrLocal = '--global'; |
|
|
|
|
|
else globalOrLocal = '--local' |
|
|
|
|
|
|
|
|
|
|
|
return any([['git', ['config', globalOrLocal, '--get-all', 'user.name']]].map(callsheltask)).then((result)=>{ |
|
|
|
|
|
// not yet configured. |
|
|
|
|
|
if(!result.success) return onNoResult() |
|
|
|
|
|
else { |
|
|
|
|
|
var users = result.messages[0].trim().split('\n'); |
|
|
|
|
|
if(users.length === 0 || |
|
|
|
|
|
users.length === 1 && users[0] === 'guest') { |
|
|
|
|
|
|
|
|
|
|
|
return onNoResult() |
|
|
|
|
|
} |
|
|
|
|
|
else return users[0]; // PB : TODO == We should probably prompt with all the users available for selection ! |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((e)=>{ |
|
|
|
|
|
console.log(e) |
|
|
|
|
|
return onNoResult() |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
, |
|
|
, |
|
|
|
|
|
|
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
, path.resolve(downloadsdir + '/' + 'node-v14.16.0-x64.msi') |
|
|
, path.resolve(downloadsdir + '/' + 'node-v14.16.0-x64.msi') |
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
|
|
|
, install : function() { return any([this.installcmd].map(callsheltask)).then(() => { }) } |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
prerequisites.forEach(p=>{ prerequisites[p.shellcmd] = p }) |
|
|
|
|
|
|
|
|
function ensureDirectoryExistence(filePath) { |
|
|
function ensureDirectoryExistence(filePath) { |
|
|
var dirname = path.dirname(filePath); |
|
|
var dirname = path.dirname(filePath); |
|
|
if (fs.existsSync(dirname)) { |
|
|
if (fs.existsSync(dirname)) { |
|
|
|
|
|
|
|
|
if (exists) console.log(`${preq.shellcmd} exists`) |
|
|
if (exists) console.log(`${preq.shellcmd} exists`) |
|
|
else { |
|
|
else { |
|
|
console.log(`${preq.shellcmd} is not installed`) |
|
|
console.log(`${preq.shellcmd} is not installed`) |
|
|
return preq.preinstallsteps().then(() => { |
|
|
|
|
|
installtasks.push(task.install) |
|
|
|
|
|
|
|
|
return preq.preinstallsteps.call(preq).then(() => { |
|
|
|
|
|
installtasks.push(preq.install.bind(preq)) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
})) |
|
|
})) |
|
|
|
|
|
|
|
|
processedArgs.node_env ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env |
|
|
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; |
|
|
: (process.env.NODE_ENV && process.env.NODE_ENV.trim()) ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()): null; |
|
|
|
|
|
|
|
|
|
|
|
selectedinstance = detectedInstance = Object.assign(selectedinstance, clioverrides); |
|
|
var maintask = () => { |
|
|
var maintask = () => { |
|
|
try { |
|
|
try { |
|
|
// Default cmd to run ! |
|
|
// Default cmd to run ! |
|
|
var chessinstances = acquirelocalinstances(selectedinstance); |
|
|
var chessinstances = acquirelocalinstances(selectedinstance); |
|
|
processedArgs._[0] === processedArgs._[0] || 'pull'; |
|
|
processedArgs._[0] === processedArgs._[0] || 'pull'; |
|
|
// defaultRepoServer = repomanifest.reposervers[0] // PB : TODO -- Attempt first one that is available and online from all that are available... |
|
|
// defaultRepoServer = repomanifest.reposervers[0] // PB : TODO -- Attempt first one that is available and online from all that are available... |
|
|
return acquireConfig(selectedinstance, chessinstances).catch((e) => { |
|
|
|
|
|
console.error('Exisitng config Failed. Fix config and rerun or chose another.') |
|
|
|
|
|
console.error(e); |
|
|
|
|
|
}).then(() => { return elxrworker(true) }) |
|
|
|
|
|
|
|
|
return prerequisites.git.verifyAndInstall().then(()=>{ |
|
|
|
|
|
return acquireConfig(selectedinstance, chessinstances).catch((e) => { |
|
|
|
|
|
console.error('Exisitng config Failed. Fix config and rerun or chose another.') |
|
|
|
|
|
console.error(e); |
|
|
|
|
|
}).then(() => { return elxrworker(true) }) |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
catch (e) { |
|
|
catch (e) { |
|
|
console.error(e) |
|
|
console.error(e) |
|
|
|
|
|
|
|
|
chessinstances = {} |
|
|
chessinstances = {} |
|
|
chessinstances.current_run = {} |
|
|
chessinstances.current_run = {} |
|
|
initinstances(chessinstances, selectedinstance) |
|
|
initinstances(chessinstances, selectedinstance) |
|
|
return acquireChoices(selectedinstance).then(() => { |
|
|
|
|
|
|
|
|
var todo = Promise.resolve(true); |
|
|
|
|
|
if(processedArgs._[0] && selectedinstance.node_env && selectedinstance.instanceName){ |
|
|
|
|
|
// Weve been told what to do. |
|
|
|
|
|
todo = Promise.resolve(true) |
|
|
|
|
|
} |
|
|
|
|
|
else todo = acquireChoices(selectedinstance) |
|
|
|
|
|
|
|
|
|
|
|
return todo.then(() => { |
|
|
try { |
|
|
try { |
|
|
var chessinstances = acquirelocalinstances(selectedinstance) |
|
|
var chessinstances = acquirelocalinstances(selectedinstance) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
console.log('A config will be createed with the instance and environment chosen...') |
|
|
console.log('A config will be createed with the instance and environment chosen...') |
|
|
} |
|
|
} |
|
|
finally { |
|
|
finally { |
|
|
|
|
|
|
|
|
return acquireConfig(selectedinstance, chessinstances).catch((e) => { |
|
|
|
|
|
console.error('Chosen cofiguraton failed or not found') |
|
|
|
|
|
console.error(e) |
|
|
|
|
|
}).then(() => { return elxrworker(true) }) |
|
|
|
|
|
.finally(()=>{ |
|
|
|
|
|
fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' }) |
|
|
|
|
|
fs.writeFileSync('run.done', 'error'); |
|
|
|
|
|
// return process.exit() |
|
|
|
|
|
|
|
|
return prerequisites.git.verifyAndInstall().then(()=>{ |
|
|
|
|
|
return acquireConfig(selectedinstance, chessinstances).catch((e) => { |
|
|
|
|
|
console.error('Chosen cofiguraton failed or not found') |
|
|
|
|
|
console.error(e) |
|
|
|
|
|
}).then(() => { return elxrworker(true) }) |
|
|
|
|
|
.finally(()=>{ |
|
|
|
|
|
fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' }) |
|
|
|
|
|
fs.writeFileSync('run.done', 'error'); |
|
|
|
|
|
// return process.exit() |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |