|
|
|
|
|
|
|
|
|
|
|
|
|
|
var scripthostName = 'node' |
|
|
var scripthostName = 'node' |
|
|
var __Promise = {}; |
|
|
var __Promise = {}; |
|
|
var promises = []; |
|
|
var promises = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------- |
|
|
// -------------------------------------------- |
|
|
// Node Exists. Lets launch ourselves in Node itself |
|
|
// Node Exists. Lets launch ourselves in Node itself |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WScript = function(){} |
|
|
|
|
|
WScript.Echo = function(m){ |
|
|
|
|
|
console.log('Invalid Wscript') |
|
|
|
|
|
throw "Failed in Node Run." |
|
|
|
|
|
} |
|
|
var wait = function(ms, cb) {any |
|
|
var wait = function(ms, cb) {any |
|
|
return new __Promise(function(resolve){ setTimeout(resolve, ms) } ).then(function(){ cb() }); |
|
|
return new __Promise(function(resolve){ setTimeout(resolve, ms) } ).then(function(){ cb() }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var existsSync = require('fs').existsSync; |
|
|
var existsSync = require('fs').existsSync; |
|
|
var existsSyncFolder = existsSync |
|
|
var existsSyncFolder = existsSync |
|
|
var path = require('path'); |
|
|
var path = require('path'); |
|
|
|
|
|
console.log('before cliverse') |
|
|
var cli = require('./cliverse') |
|
|
var cli = require('./cliverse') |
|
|
var nodeShellExec = cli.nodeShellExec; |
|
|
var nodeShellExec = cli.nodeShellExec; |
|
|
|
|
|
console.log('before bbhverse') |
|
|
var utils = require('bbhverse'); |
|
|
var utils = require('bbhverse'); |
|
|
var any = utils.any; |
|
|
|
|
|
var wait = setTimeout |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var any = utils.any; |
|
|
|
|
|
var wait = setTimeout |
|
|
|
|
|
|
|
|
// -------------------------------------------- |
|
|
// -------------------------------------------- |
|
|
|
|
|
|
|
|
var selectedinstance = { root : path.resolve(".") } |
|
|
|
|
|
|
|
|
// PB : TODO -- This should be parent dir if elxr is already installed. |
|
|
|
|
|
var selectedinstance = { root : path.resolve(".") } |
|
|
__main(selectedinstance) |
|
|
__main(selectedinstance) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WScript.Echo('-val=' + WScript.Arguments.Named(argEnumerator.item()) + '=val-') // Value |
|
|
// WScript.Echo('-val=' + WScript.Arguments.Named(argEnumerator.item()) + '=val-') // Value |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// cscript elxr/i.win.js /all:true |
|
|
var all = WScript.Arguments.Named('all'); |
|
|
var all = WScript.Arguments.Named('all'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trim = function(str) { return str.replace(/^\s+|\s+$/g, ''); }; |
|
|
|
|
|
|
|
|
|
|
|
var fs = new ActiveXObject('Scripting.FileSystemObject'); |
|
|
|
|
|
var WshShell = WScript.CreateObject("WScript.Shell") |
|
|
|
|
|
var ENV = WshShell.Environment("Process") |
|
|
|
|
|
var sfn = WScript.ScriptFullName |
|
|
|
|
|
// WScript.Echo(sfn) |
|
|
|
|
|
var cd = fs.GetAbsolutePathName(".") |
|
|
|
|
|
var cfn = cd + '\\i.win.js' |
|
|
|
|
|
// WScript.Echo(cfn) |
|
|
|
|
|
var waslaunchedwithenv = trim(ENV.Item('LAUNCHEDWITHENV')); |
|
|
|
|
|
|
|
|
|
|
|
// for(e=new Enumerator(ENV); !e.atEnd(); e.moveNext()) WScript.echo(e.item(e)); |
|
|
|
|
|
if(waslaunchedwithenv !== "YES"){ |
|
|
|
|
|
|
|
|
|
|
|
var a = fs.CreateTextFile("launchwithenv.bat", true) |
|
|
|
|
|
a.WriteLine("@echo off") |
|
|
|
|
|
a.WriteLine("echo %PATH%") |
|
|
|
|
|
var gitpath = "C:\\Program Files\\Git\\cmd" |
|
|
|
|
|
var nodepath = "C:\\Program Files\\nodejs\\" |
|
|
|
|
|
var codepath = "C:\\Users\\Pradeep\\AppData\\Local\\Programs\\Microsoft VS Code\\bin" |
|
|
|
|
|
a.WriteLine("set PATH=%PATH%;" + gitpath ) |
|
|
|
|
|
a.WriteLine("set PATH=%PATH%;" + nodepath ) |
|
|
|
|
|
a.WriteLine("set PATH=%PATH%;" + codepath ) |
|
|
|
|
|
// a.WriteLine("set LAUNCHEDWITHENV=YES" ) |
|
|
|
|
|
|
|
|
|
|
|
var __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b' |
|
|
|
|
|
var currentIsExlr = function() { |
|
|
|
|
|
if(fs.FileExists('./' + __ALIAS__STAMP__)) return true |
|
|
|
|
|
} |
|
|
|
|
|
var runningInExlr = currentIsExlr() |
|
|
|
|
|
if(cfn === sfn && runningInExlr) { |
|
|
|
|
|
a.WriteLine("cd .."); |
|
|
|
|
|
a.WriteLine("SET LAUNCHEDWITHENV=YES && cscript "+cfn+" /all:true") // PB : TODO -- Retain all script args... |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var guesselxr = fs.FileExists(cd + './elxr/' + __ALIAS__STAMP__) |
|
|
|
|
|
if(guesselxr) { |
|
|
|
|
|
a.WriteLine("SET LAUNCHEDWITHENV=YES && cscript "+cd + './elxr/' + 'i.win.js' +" /all:true") |
|
|
|
|
|
} |
|
|
|
|
|
else a.WriteLine("SET LAUNCHEDWITHENV=YES && cscript "+sfn+" /all:true") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// a.WriteLine("powershell.exe ^") |
|
|
|
|
|
// a.WriteLine("[Environment]::GetEnvironmentVariable('Path')" ) |
|
|
|
|
|
a.Close() |
|
|
|
|
|
WshShell.run("cmd /k launchwithenv.bat") |
|
|
|
|
|
WScript.Quit() |
|
|
|
|
|
// WshShell.run("powershell -noexit [Environment]::GetEnvironmentVariable(\"\"Path\"\"\) ") |
|
|
|
|
|
// WshShell.run("powershell -noexit [Environment]::SetEnvironmentVariable(\"\"Path\"\", $env:Path + \"\";C:\\tttt\"\", \"\"Machine\"\"\) ") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
console = { |
|
|
console = { |
|
|
log : function(m) { WScript.Echo(m)} |
|
|
log : function(m) { WScript.Echo(m)} |
|
|
, error : function(m) {WScript.Echo(m) } |
|
|
, error : function(m) {WScript.Echo(m) } |
|
|
|
|
|
|
|
|
// promises.splice(0,1) |
|
|
// promises.splice(0,1) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function batchshellescape(str) { |
|
|
|
|
|
return str.replace('=', '^=') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function nodeShellExec(command, cargs, options){ |
|
|
function nodeShellExec(command, cargs, options){ |
|
|
|
|
|
|
|
|
|
|
|
// for(var arg=0; arg < cargs.length; arg++) { |
|
|
|
|
|
// // cargs[arg] = '"' + batchshellescape(cargs[arg]) +'"'; |
|
|
|
|
|
// cargs[arg] = '"' + cargs[arg] +'"'; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
var elevatedshellexecute = function(cmd, argstr){ |
|
|
var elevatedshellexecute = function(cmd, argstr){ |
|
|
shell.ShellExecute(cmd, argstr , "", "", 1); |
|
|
shell.ShellExecute(cmd, argstr , "", "", 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var objShell = WScript.createobject("wscript.shell") |
|
|
var objShell = WScript.createobject("wscript.shell") |
|
|
// console.log(argstr.join( ' ')) |
|
|
// console.log(argstr.join( ' ')) |
|
|
|
|
|
console.log(cmd + ' ' + argstr.join(' ')) |
|
|
var oExec = objShell.Exec(cmd + ' ' + argstr.join(' ')) |
|
|
var oExec = objShell.Exec(cmd + ' ' + argstr.join(' ')) |
|
|
var result = {} |
|
|
var result = {} |
|
|
var shellresult = { shell : objShell, result : result } |
|
|
var shellresult = { shell : objShell, result : result } |
|
|
|
|
|
|
|
|
// } |
|
|
// } |
|
|
// else { |
|
|
// else { |
|
|
// console.log('There is no runfile.') |
|
|
// console.log('There is no runfile.') |
|
|
// console.log(shellresult.strOutput) |
|
|
|
|
|
|
|
|
console.log(shellresult.strOutput) |
|
|
|
|
|
|
|
|
wrapup(shellresult.result) |
|
|
wrapup(shellresult.result) |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
function __main( selectedinstance ){ |
|
|
function __main( selectedinstance ){ |
|
|
var downloadsdir = selectedinstance.root + '/Downloads'; |
|
|
var downloadsdir = selectedinstance.root + '/Downloads'; |
|
|
|
|
|
|
|
|
var callsheltask = function(args) { return function() { return nodeShellExec.apply(null, args) } } |
|
|
|
|
|
|
|
|
var callsheltask = function(args) { |
|
|
|
|
|
// console.log('callsheltask : ' + args) |
|
|
|
|
|
return function() { return nodeShellExec.apply(null, args) } } |
|
|
var gitUser = 'guest'; |
|
|
var gitUser = 'guest'; |
|
|
var gitEmail = 'guest@bbh.org.in'; |
|
|
var gitEmail = 'guest@bbh.org.in'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var downloadtasks = []; |
|
|
var downloadtasks = []; |
|
|
var installtasks = []; |
|
|
var installtasks = []; |
|
|
prerequisites.forEach(function(preq) { |
|
|
prerequisites.forEach(function(preq) { |
|
|
|
|
|
WScript.Echo(all) |
|
|
if(!all && preq.optional) return |
|
|
if(!all && preq.optional) return |
|
|
var p = preq.exists().then(function(exists) { |
|
|
var p = preq.exists().then(function(exists) { |
|
|
if (exists) console.log( preq.shellcmd + ' exists'); |
|
|
|
|
|
|
|
|
if (exists && !preq.forceinstall) console.log( preq.shellcmd + ' exists'); |
|
|
else { |
|
|
else { |
|
|
console.log(exists) |
|
|
console.log(exists) |
|
|
console.log(preq.shellcmd + ' is not installed'); |
|
|
console.log(preq.shellcmd + ' is not installed'); |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function install() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
if(!ifns.map) ifns.map = map; |
|
|
|
|
|
console.log('Installing') |
|
|
|
|
|
return any(ifns.map(callsheltask))['catch'](function(e){ |
|
|
|
|
|
if(e.code === 1602) { |
|
|
|
|
|
console.warn("Installation was probably cancelled.") |
|
|
|
|
|
} |
|
|
|
|
|
else throw e |
|
|
|
|
|
}).then(function(){ |
|
|
|
|
|
return self.postinstallsteps && self.postinstallsteps() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function unique(arr) { |
|
|
function unique(arr) { |
|
|
var hash = {}, result = []; |
|
|
var hash = {}, result = []; |
|
|
for ( var i = 0, l = arr.length; i < l; ++i ) { |
|
|
for ( var i = 0, l = arr.length; i < l; ++i ) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// var ENV = Object.assign({}, process.env); // Shallow clone it. |
|
|
// var ENV = Object.assign({}, process.env); // Shallow clone it. |
|
|
var WshShell = WScript.CreateObject("WScript.Shell") |
|
|
|
|
|
var ENV = WshShell.Environment("Process") |
|
|
|
|
|
// WScript.echo( ENV("Path") ) |
|
|
// WScript.echo( ENV("Path") ) |
|
|
function sysAddPathVar(path){ |
|
|
function sysAddPathVar(path){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// , nodeShellExec('set', [/*'/m',*/ 'PATH', '"%PATH%;' + newpath + '"' ]) |
|
|
// , nodeShellExec('set', [/*'/m',*/ 'PATH', '"%PATH%;' + newpath + '"' ]) |
|
|
] ); |
|
|
] ); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var getCmdString = function(args){ return args[0] + ' ' + args[1].join(' ') } |
|
|
|
|
|
|
|
|
|
|
|
var getgitshelltask = function(args, onEachError) { return function(){ |
|
|
|
|
|
console.log('----------getgitshelltask--------------called') |
|
|
|
|
|
return nodeShellExec( "cmd", ['/c', getCmdString(args)], args[2]) |
|
|
|
|
|
// .catch( onEachError || function(e){ console.error(e) }) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
var prerequisites = [ |
|
|
var prerequisites = [ |
|
|
{ |
|
|
|
|
|
shellcmd: 'git', |
|
|
|
|
|
url: 'https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
, installer: 'Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
, installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
'/WAIT', downloadsdir + '/' + 'Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
, '/VERYSILENT' |
|
|
|
|
|
// , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
|
|
|
]] |
|
|
|
|
|
, preinstallsteps: function() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
console.log('Git preinstall steps') |
|
|
|
|
|
|
|
|
// { |
|
|
|
|
|
// shellcmd: 'git', |
|
|
|
|
|
// url: 'https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
// , installer: 'Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
// , installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
// '/WAIT', downloadsdir + '/' + 'Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
// , '/VERYSILENT' |
|
|
|
|
|
// // , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
|
|
|
// ]] |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('Git preinstall steps') |
|
|
|
|
|
|
|
|
var steps = []; |
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
// console.log('cli prompt steps') |
|
|
|
|
|
var choices = { 0 : 'guest', 1 : 'chessdemo' } |
|
|
|
|
|
return cli.prompt(choices, 'git user name', gitUser).then(function(choice){ gitUser = choice } ) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// // steps.push( |
|
|
|
|
|
// // function(){ |
|
|
|
|
|
// // // console.log('cli prompt steps') |
|
|
|
|
|
// // var choices = { 0 : 'guest', 1 : 'chessdemo' } |
|
|
|
|
|
// // return cli.prompt(choices, 'git user name', gitUser).then(function(choice){ gitUser = choice } ) |
|
|
|
|
|
// // } |
|
|
|
|
|
// // ) |
|
|
|
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
var choices = { 0 : 'guest@bbh.org.in', 1 : 'chessdemo@bbh.org.in' } |
|
|
|
|
|
return cli.prompt(choices, 'git user email', gitEmail).then(function(choice){ gitEmail = choice }) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer]) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
return Promise.resolve(true) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
return any(steps) |
|
|
|
|
|
// return any([any(steps), any(prompts)]) |
|
|
|
|
|
} |
|
|
|
|
|
, installsteps: function () { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
console.log('Git Installsteps called') |
|
|
|
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
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 |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
, postinstallsteps: function(){ |
|
|
|
|
|
|
|
|
// // steps.push( |
|
|
|
|
|
// // function(){ |
|
|
|
|
|
// // var choices = { 0 : 'guest@bbh.org.in', 1 : 'chessdemo@bbh.org.in' } |
|
|
|
|
|
// // return cli.prompt(choices, 'git user email', gitEmail).then(function(choice){ gitEmail = choice }) |
|
|
|
|
|
// // } |
|
|
|
|
|
// // ) |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer]) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// , installsteps: function () { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('Git Installsteps called') |
|
|
|
|
|
// var ifns = [self.installcmd] |
|
|
|
|
|
// 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 |
|
|
|
|
|
// }) |
|
|
|
|
|
// } |
|
|
|
|
|
// , postinstallsteps: function(){ |
|
|
|
|
|
|
|
|
// PB : TODO -- Detect failure or cancellation before attenpting postinstall steps... |
|
|
|
|
|
var steps = []; |
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
var choices = { 0 : 'guest', 1 : 'chessdemo' } |
|
|
|
|
|
return cli.prompt(choices, 'git user name', gitUser).then(function(choice){ gitUser = choice } ) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// // PB : TODO -- Detect failure or cancellation before attenpting postinstall steps... |
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// var choices = { 0 : 'guest', 1 : 'chessdemo' } |
|
|
|
|
|
// return cli.prompt(choices, 'git user name', gitUser).then(function(choice){ gitUser = choice } ) |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
var choices = { 0 : 'guest@bbh.org.in', 1 : 'chessdemo@bbh.org.in' } |
|
|
|
|
|
return cli.prompt(choices, 'git user email', gitEmail).then(function(choice){ gitEmail = choice }) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// var choices = { 0 : 'guest@bbh.org.in', 1 : 'chessdemo@bbh.org.in' } |
|
|
|
|
|
// return cli.prompt(choices, 'git user email', gitEmail).then(function(choice){ gitEmail = choice }) |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
return any(steps).then(function(){ |
|
|
|
|
|
var steps = [ |
|
|
|
|
|
['git', ['config', '--global', '--add', 'user.name', gitUser]] |
|
|
|
|
|
, ['git', ['config', '--global', '--add', 'user.email', gitEmail]] |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
// return any(steps).then(function(){ |
|
|
|
|
|
// var steps = [ |
|
|
|
|
|
// ['git', ['config', '--global', '--add', 'user.name', gitUser]] |
|
|
|
|
|
// , ['git', ['config', '--global', '--add', 'user.email', gitEmail]] |
|
|
|
|
|
// ] |
|
|
|
|
|
|
|
|
if(!steps.map) steps.map = map; |
|
|
|
|
|
return any(steps.map(callsheltask)).then(function(){ |
|
|
|
|
|
|
|
|
// if(!steps.map) steps.map = map; |
|
|
|
|
|
// return any(steps.map(callsheltask)).then(function(){ |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
, install: function () { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
console.log('Git Install called') |
|
|
|
|
|
return any([ /*self.preinstallsteps,*/ function(){ return self.installsteps() }, function(){ return self.postinstallsteps() } ]) |
|
|
|
|
|
} |
|
|
|
|
|
, verifyAndInstall : function(){ |
|
|
|
|
|
var self = this; |
|
|
|
|
|
return self.exists().then( function(exits) { |
|
|
|
|
|
if(exists) return self.getUser(null, function(){ return self.postinstallsteps() } ) |
|
|
|
|
|
else return self.install(); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
, exists : exists |
|
|
|
|
|
, getUser : function(repo, onNoResult){ |
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
// }); |
|
|
|
|
|
// } |
|
|
|
|
|
// , install: function () { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('Git Install called') |
|
|
|
|
|
|
|
|
|
|
|
// var createTasq = function(args, shellT, onEachError) { |
|
|
|
|
|
// var tasq = shellT ? shellT(args) : ( function(){ |
|
|
|
|
|
// console.log('sdsfdsdf ' + args) |
|
|
|
|
|
// return any([nodeShellExec.apply(null, args)]) |
|
|
|
|
|
// // .catch( onEachError || function(e){ console.error(e) } ) |
|
|
|
|
|
// }) |
|
|
|
|
|
// tasq.toString = function(){ return JSON.stringify(args)} |
|
|
|
|
|
// return tasq; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// var execserial = function(tasklist, task, shellT, onEachError){ |
|
|
|
|
|
// var exec = function(taskArgs){ |
|
|
|
|
|
// console.log('execcing ' + task) |
|
|
|
|
|
// var thistask = task.concat(); |
|
|
|
|
|
// thistask[1] = thistask[1].concat() |
|
|
|
|
|
// thistask[1].push.apply(thistask[1], taskArgs) |
|
|
|
|
|
// return createTasq(thistask, shellT) |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// tasklist.map = map |
|
|
|
|
|
// console.log('execlist ' + tasklist.map(exec)) |
|
|
|
|
|
// return any(tasklist.map(exec)) |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
onNoResult = onNoResult || function(){return false} |
|
|
|
|
|
var globalOrLocal = '--global'; |
|
|
|
|
|
if(!repo) globalOrLocal = '--global'; |
|
|
|
|
|
else globalOrLocal = '--local' |
|
|
|
|
|
var fns = [['git', ['config', globalOrLocal, '--get-all', 'user.name']]] |
|
|
|
|
|
if(!ifns.map) ifns.map = map; |
|
|
|
|
|
return any(fns.map(callsheltask)).then(function(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') { |
|
|
|
|
|
|
|
|
// function resetgitconfig(){ |
|
|
|
|
|
|
|
|
|
|
|
// // https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage |
|
|
|
|
|
// // Git Credential storage... |
|
|
|
|
|
// // git config --global credential.helper 'store --file ~/.gitcredentials' |
|
|
|
|
|
// // git credential-store --file ~/.gitcredentials store |
|
|
|
|
|
// // // notepad C:/Program Files/Git/etc/gitconfig |
|
|
|
|
|
// // git config --global --unset credential |
|
|
|
|
|
// // git config --edit --system |
|
|
|
|
|
// // git config --global credential.helper "store --file ~/gitcredentials" |
|
|
|
|
|
// // git credential fill |
|
|
|
|
|
// // git credential-store --file ~/git.store store |
|
|
|
|
|
|
|
|
|
|
|
// // Find system git config |
|
|
|
|
|
// // git config --global --edit |
|
|
|
|
|
// // git config --list --show-origin |
|
|
|
|
|
// // git config --list --show-origin --show-scope |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // https://stackoverflow.com/questions/35942754/how-can-i-save-username-and-password-in-git |
|
|
|
|
|
// // Recipie |
|
|
|
|
|
// // git config --global --unset credentials.helper |
|
|
|
|
|
// // cd /path/to/my/repo |
|
|
|
|
|
// // git config --unset credential.helper |
|
|
|
|
|
// // git config credential.helper 'store --file ~/.git_repo_credentials' |
|
|
|
|
|
// // git config credential.*.username my_user_name |
|
|
|
|
|
// // git config credential.https://gitlab.com.username my_user_name |
|
|
|
|
|
|
|
|
|
|
|
// // git credential fill |
|
|
|
|
|
// // git config --global credential.modalprompt false // doesnst work. |
|
|
|
|
|
// // core askpass = ;;; https://stackoverflow.com/questions/37182847/how-do-i-disable-git-credential-manager-for-windows |
|
|
|
|
|
// var options = { |
|
|
|
|
|
// inherit: true, shell: true //, env: process.env |
|
|
|
|
|
// , cwd: selectedinstance.root |
|
|
|
|
|
// // , runas: processedArgs.runas |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// var task = ['git', ['config'], options] |
|
|
|
|
|
|
|
|
|
|
|
// var tasklist = [ |
|
|
|
|
|
// // ['--global', '--unset credentials.helper'] |
|
|
|
|
|
// // ['--unset', 'credentials.helper'] |
|
|
|
|
|
// // , |
|
|
|
|
|
// // ['credential.helper', `'store --file git_repo_credentials'`] |
|
|
|
|
|
// ['--global', 'credential.helper', "'store --file ~/.git_repo_credentials'"] |
|
|
|
|
|
// , ['--global', '--replace-all', 'user.name', 'pb'] |
|
|
|
|
|
// , ['--global', '--replace-all', 'user.email', 'pradeep@bbh.org.in'] |
|
|
|
|
|
|
|
|
|
|
|
// // , ['--list'] |
|
|
|
|
|
// // , ['credential', 'fill'] |
|
|
|
|
|
// ] |
|
|
|
|
|
// var onEachError = function(e) { console.error( e.messages.join('\n') + e.result + '\n' + util.inspect(e) + '\n') } |
|
|
|
|
|
// var shellT = function(args) { |
|
|
|
|
|
// return getgitshelltask(args, onEachError) |
|
|
|
|
|
// // .catch(e => console.error( e.messages.join('\n') + e.result + '\n' + util.inspect(e) + '\n' + tasq.toString()) ) |
|
|
|
|
|
// } |
|
|
|
|
|
// execserial(tasklist, task, shellT, onEachError ) |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// return any([ /*self.preinstallsteps,*/ |
|
|
|
|
|
// function(){ return self.installsteps() } |
|
|
|
|
|
// , function() { resetgitconfig() } |
|
|
|
|
|
// , function(){ return self.postinstallsteps() } |
|
|
|
|
|
// ]) |
|
|
|
|
|
// } |
|
|
|
|
|
// , verifyAndInstall : function(){ |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// return self.exists().then( function(exits) { |
|
|
|
|
|
// if(exists) return self.getUser(null, function(){ return self.postinstallsteps() } ) |
|
|
|
|
|
// else return self.install(); |
|
|
|
|
|
// }) |
|
|
|
|
|
// } |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// , getUser : function(repo, onNoResult){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// onNoResult = onNoResult || function(){return false} |
|
|
|
|
|
// var globalOrLocal = '--global'; |
|
|
|
|
|
// if(!repo) globalOrLocal = '--global'; |
|
|
|
|
|
// else globalOrLocal = '--local' |
|
|
|
|
|
// var fns = [['git', ['config', globalOrLocal, '--get-all', 'user.name']]] |
|
|
|
|
|
// if(!ifns.map) ifns.map = map; |
|
|
|
|
|
// return any(fns.map(callsheltask)).then(function(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'](function(e){ |
|
|
|
|
|
console.log(e) |
|
|
|
|
|
return onNoResult() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
, |
|
|
|
|
|
{ |
|
|
|
|
|
shellcmd: 'node', |
|
|
|
|
|
url: 'https://nodejs.org/dist/v14.17.6/node-v14.17.6-x64.msi' |
|
|
|
|
|
, installer: 'node-v14.17.3-x64.msi' |
|
|
|
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
|
|
|
, path.normalize(downloadsdir + '/' + 'node-v14.17.3-x64.msi') |
|
|
|
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
|
|
|
, install : function() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
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 |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
, exists : exists |
|
|
|
|
|
, preinstallsteps: function() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
console.log('Node preinstall steps') |
|
|
|
|
|
|
|
|
// return onNoResult() |
|
|
|
|
|
// } |
|
|
|
|
|
// else return users[0]; // PB : TODO == We should probably prompt with all the users available for selection ! |
|
|
|
|
|
// } |
|
|
|
|
|
// }) |
|
|
|
|
|
// ['catch'](function(e){ |
|
|
|
|
|
// console.log(e) |
|
|
|
|
|
// return onNoResult() |
|
|
|
|
|
// }) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// , |
|
|
|
|
|
// { |
|
|
|
|
|
// shellcmd: 'node', |
|
|
|
|
|
// url: 'https://nodejs.org/dist/v14.17.6/node-v14.17.6-x64.msi' |
|
|
|
|
|
// , installer: 'node-v14.17.3-x64.msi' |
|
|
|
|
|
// , installcmd: ['MSIEXEC.exe', ['/i' |
|
|
|
|
|
// , path.normalize(downloadsdir + '/' + 'node-v14.17.3-x64.msi') |
|
|
|
|
|
// , 'ACCEPT=YES', '/passive']] |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('Node preinstall steps') |
|
|
|
|
|
|
|
|
var steps = []; |
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer] |
|
|
|
|
|
, { waitmsg : 'downloading node please wait' }) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
return Promise.resolve(true) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', ['"' + self.url + '"', downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
return any(steps) |
|
|
|
|
|
// return any([any(steps), any(prompts)]) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
, { |
|
|
|
|
|
shellcmd: 'python2' |
|
|
|
|
|
, optional : true |
|
|
|
|
|
, url: 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' |
|
|
|
|
|
, installer: 'python-2.7.18.amd64.msi' |
|
|
|
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
|
|
|
, path.normalize(downloadsdir + '/' + 'python-2.7.18.amd64.msi') |
|
|
|
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
|
|
|
, preinstallsteps : function() { return Promise.resolve(true) } |
|
|
|
|
|
, install : function() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
if(!ifns.map) ifns.map = map; |
|
|
|
|
|
console.log('Installing') |
|
|
|
|
|
return any(ifns.map(callsheltask))['catch'](function(e){ |
|
|
|
|
|
if(e.code === 1602) { |
|
|
|
|
|
console.warn("Installation was probably cancelled.") |
|
|
|
|
|
} |
|
|
|
|
|
else throw e |
|
|
|
|
|
}).then(function(){ |
|
|
|
|
|
return self.postinstallsteps() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
, postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') } |
|
|
|
|
|
, exists : exists |
|
|
|
|
|
} |
|
|
|
|
|
, { |
|
|
|
|
|
shellcmd: 'code' |
|
|
|
|
|
, optional : true |
|
|
|
|
|
, url: 'https://vscode-update.azurewebsites.net/latest/win32-x64/stable' |
|
|
|
|
|
, installer: 'vscode-win32-x64-latest-stable.exe' |
|
|
|
|
|
, installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
'/WAIT', downloadsdir + '/' + 'Git-2.33.0.2-64-bit.exe' |
|
|
|
|
|
, '/VERYSILENT' |
|
|
|
|
|
// , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
|
|
|
]] |
|
|
|
|
|
, preinstallsteps : function() { return Promise.resolve(true) } |
|
|
|
|
|
, install : function() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
if(!ifns.map) ifns.map = map; |
|
|
|
|
|
console.log('Installing') |
|
|
|
|
|
return any(ifns.map(callsheltask))['catch'](function(e){ |
|
|
|
|
|
if(e.code === 1602) { |
|
|
|
|
|
console.warn("Installation was probably cancelled.") |
|
|
|
|
|
} |
|
|
|
|
|
else throw e |
|
|
|
|
|
}).then(function(){ |
|
|
|
|
|
return self.postinstallsteps() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
, postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') } |
|
|
|
|
|
, exists : exists |
|
|
|
|
|
} |
|
|
|
|
|
, { |
|
|
|
|
|
shellcmd: 'elxr' |
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// , { |
|
|
|
|
|
// shellcmd: 'python' |
|
|
|
|
|
// , optional : true |
|
|
|
|
|
// , url: 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' |
|
|
|
|
|
// , installer: 'python-2.7.18.amd64.msi' |
|
|
|
|
|
// , installcmd: ['MSIEXEC.exe', ['/i' |
|
|
|
|
|
// , path.normalize(downloadsdir + '/' + 'python-2.7.18.amd64.msi') |
|
|
|
|
|
// , 'ACCEPT=YES', '/passive']] |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log(self.shellcmd + ' preinstall steps') |
|
|
|
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') } |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// } |
|
|
|
|
|
// , { |
|
|
|
|
|
// shellcmd: 'code' |
|
|
|
|
|
// , optional : true |
|
|
|
|
|
// , url: 'https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user' |
|
|
|
|
|
// , installer: 'VSCodeUserSetup-x64-1.65.2.exe' |
|
|
|
|
|
// , installcmd: ['cmd /c', ['start /WAIT ' + downloadsdir + '/' + 'VSCodeUserSetup-x64-1.65.2.exe /VERYSILENT' |
|
|
|
|
|
// // , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
|
|
|
// ]] |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log(self.shellcmd + ' preinstall steps') |
|
|
|
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// console.log(self.url) |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', ['"' + self.url + '"', downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') } |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// } |
|
|
|
|
|
// , { |
|
|
|
|
|
// shellcmd: 'sqlexpress', |
|
|
|
|
|
// url: 'https://go.microsoft.com/fwlink/?linkid=866658' |
|
|
|
|
|
// , installer: 'SQL2019-SSEI-Expr.exe' |
|
|
|
|
|
// , installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
// '/WAIT', downloadsdir + '/' + 'SQL2019-SSEI-Expr.exe' |
|
|
|
|
|
// , '/Quiet' |
|
|
|
|
|
// //, 'SSMSInstallRoot=%systemdrive%\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\ManagementStudio' |
|
|
|
|
|
// ]] |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('Node preinstall steps') |
|
|
|
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', ['"' + self.url + '"', downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// , { |
|
|
|
|
|
// shellcmd: 'Ssms2019.exe', |
|
|
|
|
|
// url: 'https://aka.ms/ssmsfullsetup' |
|
|
|
|
|
// , installer: 'SSMS-Setup-ENU.exe' |
|
|
|
|
|
// , installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
// '/WAIT', downloadsdir + '/' + 'SSMS-Setup-ENU.exe' |
|
|
|
|
|
// , '/Quiet' |
|
|
|
|
|
// //, 'SSMSInstallRoot=%systemdrive%\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\ManagementStudio' |
|
|
|
|
|
// ]] |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('smss preinstall steps') |
|
|
|
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// console.log(self.url) |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', ['"' + self.url + '"', downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// , { |
|
|
|
|
|
// shellcmd: 'Ssms.exe', |
|
|
|
|
|
// url: 'https://go.microsoft.com/fwlink/?linkid=2043154&clcid=0x409' |
|
|
|
|
|
// , installer: 'SSMS-Setup-ENU.exe' |
|
|
|
|
|
// , installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
// '/WAIT', downloadsdir + '/' + 'SSMS-Setup-ENU.exe' |
|
|
|
|
|
// , '/Quiet' |
|
|
|
|
|
// //, 'SSMSInstallRoot=%systemdrive%\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\ManagementStudio' |
|
|
|
|
|
// ]] |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('smss preinstall steps') |
|
|
|
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// console.log(self.url) |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', ['"' + self.url + '"', downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// , { |
|
|
|
|
|
// shellcmd: 'mysql', |
|
|
|
|
|
// 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' |
|
|
|
|
|
// , installcmd: ['MSIEXEC.exe', ['/i' |
|
|
|
|
|
// , path.normalize(downloadsdir + '/' + 'mysql-installer-community-8.0.30.0.msi') |
|
|
|
|
|
// //, 'ACCEPT=YES', '/passive' |
|
|
|
|
|
// ]] |
|
|
|
|
|
// , install : install |
|
|
|
|
|
// , exists : exists |
|
|
|
|
|
// , preinstallsteps: function() { |
|
|
|
|
|
// var self = this; |
|
|
|
|
|
// console.log('mysql preinstall steps') |
|
|
|
|
|
|
|
|
|
|
|
// var steps = []; |
|
|
|
|
|
// steps.push( |
|
|
|
|
|
// function(){ |
|
|
|
|
|
// if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
// console.log(self.url) |
|
|
|
|
|
// return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer] |
|
|
|
|
|
// , { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
|
|
|
|
// return any(steps) |
|
|
|
|
|
// // return any([any(steps), any(prompts)]) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// , |
|
|
|
|
|
{ |
|
|
|
|
|
shellcmd: 'elxr' |
|
|
|
|
|
, forceinstall : true |
|
|
, installcmd: [ isWin() ? 'npm.cmd' : 'npm' , ['link'], { cwd : selectedinstance.root + '\\elxr' /* cwd should be the cloned dir*/}] |
|
|
, installcmd: [ isWin() ? 'npm.cmd' : 'npm' , ['link'], { cwd : selectedinstance.root + '\\elxr' /* cwd should be the cloned dir*/}] |
|
|
, preinstallsteps: function() { |
|
|
, preinstallsteps: function() { |
|
|
var self = this; |
|
|
var self = this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var steps = []; |
|
|
var steps = []; |
|
|
steps.push( |
|
|
steps.push( |
|
|
function(){ |
|
|
|
|
|
console.log('Elxr PreInstallsteps called') |
|
|
|
|
|
var ifns = [ ['git', ['clone', 'http://git.bbh/chess\\elxr'] ] ] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
|
|
|
return any([any(steps)]) |
|
|
|
|
|
} |
|
|
|
|
|
, installsteps: function () { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
console.log('Elxr Installsteps called') |
|
|
|
|
|
var installIfNotExists = function(){ |
|
|
|
|
|
console.log('Elxr PreInstallsteps called') |
|
|
|
|
|
var steps = []; |
|
|
|
|
|
var chessRepo = 'https://git.bbh.org.in' |
|
|
|
|
|
steps.push( |
|
|
|
|
|
function(){ |
|
|
|
|
|
// console.log('cli prompt steps') |
|
|
|
|
|
var choices = { 0 : 'http://git.bbh', 1 : 'https://git.bbh.org.in' } |
|
|
|
|
|
return cli.prompt(choices, 'git repository : ', chessRepo).then(function(choice){ |
|
|
|
|
|
console.log( 'choice : ' + choice) |
|
|
|
|
|
chessRepo = choice } ) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
return any(steps).then(function(){ |
|
|
|
|
|
var ifns = [ |
|
|
|
|
|
['git', ['clone', chessRepo + '/chess/elxr'] ] |
|
|
|
|
|
] |
|
|
|
|
|
console.log( 'chessRepo : ' + chessRepo) |
|
|
if(existsSyncFolder( selectedinstance.root + '\\elxr')) { |
|
|
if(existsSyncFolder( selectedinstance.root + '\\elxr')) { |
|
|
if(existsSyncFolder( selectedinstance.root + '\\elxr\\.git')) { |
|
|
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. |
|
|
// PB : TODO -- use a elxr guid signature to detect more reliably folders named the same that is not us. |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else console.log(selectedinstance.root + '\\elxr' + ' NOT FOUND ') |
|
|
else console.log(selectedinstance.root + '\\elxr' + ' NOT FOUND ') |
|
|
|
|
|
ifns.push(['npm', ['i'], { cwd : '.\\elxr' } ]) |
|
|
if(!ifns.map) ifns.map = map; |
|
|
if(!ifns.map) ifns.map = map; |
|
|
return any(ifns.map(callsheltask))['catch'](function(e){ |
|
|
return any(ifns.map(callsheltask))['catch'](function(e){ |
|
|
if(e.code === 1602) { |
|
|
if(e.code === 1602) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else throw e |
|
|
else throw e |
|
|
}) |
|
|
}) |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
return any([any(steps)]) |
|
|
|
|
|
} |
|
|
|
|
|
, installsteps: function () { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
console.log('Elxr Installsteps called') |
|
|
|
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
var ifns = [ self.installcmd ] |
|
|
if(!ifns.map) ifns.map = map; |
|
|
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 |
|
|
|
|
|
|
|
|
return installIfNotExists().then(function(){ |
|
|
|
|
|
return any(ifns.map(callsheltask))['catch'](function(e){ |
|
|
|
|
|
if(e.code === 1602) { |
|
|
|
|
|
console.warn("Installation was probably cancelled.") |
|
|
|
|
|
} |
|
|
|
|
|
else throw e |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
, install: function () { |
|
|
, install: function () { |
|
|
var self = this; |
|
|
var self = this; |
|
|
console.log('Elxr Install called') |
|
|
console.log('Elxr Install called') |
|
|
return any([ /*self.preinstallsteps,*/ function(){ return self.installsteps() } ]) |
|
|
|
|
|
|
|
|
return any([ self.preinstallsteps, function(){ return self.installsteps() } |
|
|
|
|
|
, 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']) |
|
|
|
|
|
]) |
|
|
} |
|
|
} |
|
|
// , exists : function(){ |
|
|
// , exists : function(){ |
|
|
// console.log('Elxr PreInstallsteps called') |
|
|
// console.log('Elxr PreInstallsteps called') |
|
|
|
|
|
|
|
|
promises.push(verifyAndInstallPrerequisites()) |
|
|
promises.push(verifyAndInstallPrerequisites()) |
|
|
|
|
|
|
|
|
startPromises(); |
|
|
startPromises(); |
|
|
} |
|
|
|