|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
// -------------------------------------------- |
|
|
// -------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cscript elxr/i.win.js /all:true |
|
|
// 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 runningInExlr = function() { |
|
|
|
|
|
var __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b' |
|
|
|
|
|
if(fs.FileExists('./' + __ALIAS__STAMP__)) return true |
|
|
|
|
|
} |
|
|
|
|
|
if(cfn === sfn && runningInExlr()) { |
|
|
|
|
|
|
|
|
|
|
|
a.WriteLine("cd .."); |
|
|
|
|
|
a.WriteLine("SET LAUNCHEDWITHENV=YES && cscript "+cfn+" /all:true") // PB : TODO -- Retain all script args... |
|
|
|
|
|
} |
|
|
|
|
|
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) |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var callsheltask = function(args) { |
|
|
var callsheltask = function(args) { |
|
|
// console.log('callsheltask : ' + args) |
|
|
// console.log('callsheltask : ' + args) |
|
|
return function() { |
|
|
|
|
|
return nodeShellExec.apply(null, 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 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){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
steps.push( |
|
|
steps.push( |
|
|
function(){ |
|
|
function(){ |
|
|
if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer] |
|
|
|
|
|
, { waitmsg : 'downloading node please wait' }) |
|
|
|
|
|
|
|
|
return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', ['"' + self.url + '"', downloadsdir + '/' + self.installer] |
|
|
|
|
|
, { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
console.log(self.installer + ' Already exits Download skipped.') |
|
|
console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
, { |
|
|
, { |
|
|
shellcmd: 'python2' |
|
|
|
|
|
|
|
|
shellcmd: 'python' |
|
|
, optional : true |
|
|
, optional : true |
|
|
, url: 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' |
|
|
, url: 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' |
|
|
, installer: 'python-2.7.18.amd64.msi' |
|
|
, installer: 'python-2.7.18.amd64.msi' |
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
, path.normalize(downloadsdir + '/' + 'python-2.7.18.amd64.msi') |
|
|
, path.normalize(downloadsdir + '/' + 'python-2.7.18.amd64.msi') |
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
, preinstallsteps : function() { return Promise.resolve(true) } |
|
|
|
|
|
, install : function() { |
|
|
|
|
|
|
|
|
, 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 : function() { |
|
|
var self = this; |
|
|
var self = this; |
|
|
var ifns = [self.installcmd] |
|
|
var ifns = [self.installcmd] |
|
|
if(!ifns.map) ifns.map = map; |
|
|
if(!ifns.map) ifns.map = map; |
|
|
|
|
|
|
|
|
, optional : true |
|
|
, optional : true |
|
|
, url: 'https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user' |
|
|
, url: 'https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user' |
|
|
, installer: 'VSCodeUserSetup-x64-1.65.2.exe' |
|
|
, installer: 'VSCodeUserSetup-x64-1.65.2.exe' |
|
|
, installcmd: ['cmd', ['/c', 'start', |
|
|
|
|
|
'/WAIT', downloadsdir + '/' + 'VSCodeUserSetup-x64-1.65.2.exe' |
|
|
|
|
|
, '/VERYSILENT' |
|
|
|
|
|
|
|
|
, installcmd: ['cmd /c', ['start /WAIT ' + downloadsdir + '/' + 'VSCodeUserSetup-x64-1.65.2.exe /VERYSILENT' |
|
|
// , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
// , '/MERGETASKS=!runcode' // This is required only for vscode... |
|
|
]] |
|
|
]] |
|
|
, preinstallsteps : function() { return Promise.resolve(true) } |
|
|
|
|
|
|
|
|
, 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 : function() { |
|
|
, install : function() { |
|
|
var self = this; |
|
|
var self = this; |
|
|
var ifns = [self.installcmd] |
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
, { |
|
|
, { |
|
|
shellcmd: 'mysql', |
|
|
shellcmd: 'mysql', |
|
|
url: 'https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.29.0.msi' |
|
|
|
|
|
, installer: 'mysql-installer-community-8.0.29.0.msi' |
|
|
|
|
|
|
|
|
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' |
|
|
, installcmd: ['MSIEXEC.exe', ['/i' |
|
|
, path.normalize(downloadsdir + '/' + 'mysql-installer-community-8.0.29.0.msi') |
|
|
|
|
|
, 'ACCEPT=YES', '/passive']] |
|
|
|
|
|
|
|
|
, path.normalize(downloadsdir + '/' + 'mysql-installer-community-8.0.30.0.msi') |
|
|
|
|
|
//, 'ACCEPT=YES', '/passive' |
|
|
|
|
|
]] |
|
|
, install : function() { |
|
|
, install : function() { |
|
|
var self = this; |
|
|
var self = this; |
|
|
var ifns = [self.installcmd] |
|
|
var ifns = [self.installcmd] |
|
|
|
|
|
|
|
|
steps.push( |
|
|
steps.push( |
|
|
function(){ |
|
|
function(){ |
|
|
if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
if (!existsSync(downloadsdir + '/' + self.installer)) { |
|
|
|
|
|
console.log(self.url) |
|
|
return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer] |
|
|
return nodeShellExec(selectedinstance.root + '/.elxr/run-' + runtimestamp + '/download.bat', [self.url, downloadsdir + '/' + self.installer] |
|
|
, { waitmsg : 'downloading mysql please wait' }) |
|
|
|
|
|
|
|
|
, { waitmsg : 'downloading '+ self.shellcmd +' please wait' }) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
console.log(self.installer + ' Already exits Download skipped.') |
|
|
console.log(self.installer + ' Already exits Download skipped.') |
|
|
|
|
|
|
|
|
console.log('Elxr Installsteps called') |
|
|
console.log('Elxr Installsteps called') |
|
|
var installIfNotExists = function(){ |
|
|
var installIfNotExists = function(){ |
|
|
console.log('Elxr PreInstallsteps called') |
|
|
console.log('Elxr PreInstallsteps called') |
|
|
var ifns = [ ['git', ['clone', 'http://git.bbh/chess/elxr'] ] ] |
|
|
|
|
|
|
|
|
var ifns = [ |
|
|
|
|
|
['git', ['clone', 'http://git.bbh.org.in/chess/elxr'] ] |
|
|
|
|
|
] |
|
|
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) { |