Explorar el Código

variious changes

pull/10/head
pb hace 2 años
padre
commit
64b96cf455
Se han modificado 2 ficheros con 84 adiciones y 172 borrados
  1. 82
    170
      i.win.js
  2. 2
    2
      win_verse.js

+ 82
- 170
i.win.js Ver fichero

@@ -130,21 +130,17 @@ catch(e) {
a.WriteLine("set PATH=%PATH%;" + codepath )
// a.WriteLine("set LAUNCHEDWITHENV=YES" )
var __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b'
var currentIsExlr = function() {
var runningInExlr = function() {
var __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b'
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...
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("SET LAUNCHEDWITHENV=YES && cscript "+sfn+" /all:true")
}
// a.WriteLine("powershell.exe ^")
@@ -861,7 +857,8 @@ function __main( selectedinstance ){

var callsheltask = function(args) {
// console.log('callsheltask : ' + args)
return function() { return nodeShellExec.apply(null, args) } }
return function() {
return nodeShellExec.apply(null, args) } }
var gitUser = 'guest';
var gitEmail = 'guest@bbh.org.in';

@@ -920,7 +917,7 @@ function __main( selectedinstance ){
WScript.Echo(all)
if(!all && preq.optional) return
var p = preq.exists().then(function(exists) {
if (exists && !preq.forceinstall) console.log( preq.shellcmd + ' exists');
if (exists) console.log( preq.shellcmd + ' exists');
else {
console.log(exists)
console.log(preq.shellcmd + ' is not installed');
@@ -976,21 +973,6 @@ function __main( selectedinstance ){
})
}

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) {
var hash = {}, result = [];
for ( var i = 0, l = arr.length; i < l; ++i ) {
@@ -1253,7 +1235,18 @@ function __main( selectedinstance ){
, installcmd: ['MSIEXEC.exe', ['/i'
, path.normalize(downloadsdir + '/' + 'node-v14.17.3-x64.msi')
, 'ACCEPT=YES', '/passive']]
, install : install
, 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;
@@ -1306,9 +1299,22 @@ function __main( selectedinstance ){
return any(steps)
// return any([any(steps), any(prompts)])
}
, install : install
, postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') }
, exists : exists
, 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'
@@ -1340,120 +1346,43 @@ function __main( selectedinstance ){
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)
}
, 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.")
}
)
return any(steps)
// return any([any(steps), any(prompts)])
else throw e
}).then(function(){
return self.postinstallsteps()
})
}
}
, {
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
, postinstallsteps : function() { return sysAddPathVar('%USERPROFILE%\\AppData/Local\\Microsoft\\WindowsApps') }
, 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')
, path.normalize(downloadsdir + '/' + 'mysql-installer-community-8.0.30.0.msi')
//, 'ACCEPT=YES', '/passive'
]]
, install : install
]]
, 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;
@@ -1480,7 +1409,6 @@ function __main( selectedinstance ){
}
, {
shellcmd: 'elxr'
, forceinstall : true
, installcmd: [ isWin() ? 'npm.cmd' : 'npm' , ['link'], { cwd : selectedinstance.root + '\\elxr' /* cwd should be the cloned dir*/}]
, preinstallsteps: function() {
var self = this;
@@ -1497,39 +1425,23 @@ function __main( selectedinstance ){
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){ chessRepo = choice } )
var ifns = [ ['git', ['clone', 'http://git.bbh.org.in/chess/elxr'] ] ]
if(existsSyncFolder( selectedinstance.root + '\\elxr')) {
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.
ifns = [ ['git', ['pull'], { cwd : selectedinstance.root + '\\elxr' } ] ]
}
)
return any(steps).then(function(){
var ifns = [

['git', ['clone', chessRepo + '/chess/elxr'] ]
]
if(existsSyncFolder( selectedinstance.root + '\\elxr')) {
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.
ifns = [ ['git', ['pull'], { cwd : selectedinstance.root + '\\elxr' } ] ]
}
else {
throw 'elxr subfolder not recognized as a git repository. Please cleanup and continue.'
}
else {
throw 'elxr subfolder not recognized as a git repository. Please cleanup and continue.'
}
else console.log(selectedinstance.root + '\\elxr' + ' NOT FOUND ')
ifns.push(['npm', ['i'], { cwd : '.\\elxr' } ])
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
})
}
else console.log(selectedinstance.root + '\\elxr' + ' NOT FOUND ')
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
})
}
var ifns = [ self.installcmd ]
@@ -1546,8 +1458,8 @@ function __main( selectedinstance ){
, install: function () {
var self = this;
console.log('Elxr Install called')
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"'])
return any([ /*self.preinstallsteps,*/ function(){ return self.installsteps() }
, nodeShellExec('node', [selectedinstance.root + '\\elxr\\index.js', 'init'])
// , nodeShellExec('node', [selectedinstance.root + 'elxr\\index.js'])
])
}

+ 2
- 2
win_verse.js Ver fichero

@@ -25,12 +25,12 @@ var shell_verse = {
var __runasresult = null;
return taskToRun().then((r)=>{
// PB : TODO -- Every elevation should have its own messaging file. Async writes from multiple processes are a problem here...
elevatedRunIPCWriteMessage( runlogjson, { info : taskToRun.info, success: true } )
elevatedRunIPCWriteMessage( runlogjson, ', ' + JSON.stringify( { info : taskToRun.info, success: true }) )
if(!inBatch) fs.writeFileSync('run.done', 'success') // PB : TODO -- This should be done conditionally if we are running inproc.
return __runasresult = r;
})
.catch((e) => {
elevatedRunIPCWriteMessage( runlogjson, e )
elevatedRunIPCWriteMessage( runlogjson, ', ' + JSON.stringify(e ) )
if(!inBatch)fs.writeFileSync('run.done', 'failure')
console.error(e)
})

Cargando…
Cancelar
Guardar