Explorar el Código

Added cihsr use

production
Pradeep Bhaskaran hace 4 años
padre
commit
846f78123b
Se han modificado 1 ficheros con 86 adiciones y 44 borrados
  1. 86
    44
      index.js

+ 86
- 44
index.js Ver fichero

// elxr // elxr
// A cli tool for elixr. // A cli tool for elixr.
const { existsSync } = require('fs'); const { existsSync } = require('fs');
const fs = require('fs')
const { spawn, spawnSync } = require('child_process'); const { spawn, spawnSync } = require('child_process');
const cliargs = require('../elxr/cliargs'); // Use minimist... const cliargs = require('../elxr/cliargs'); // Use minimist...
const processedArgs = cliargs(process.argv.slice(2)); const processedArgs = cliargs(process.argv.slice(2));
, 'clientverse' , 'clientverse'
, 'serververse' , 'serververse'
, 'client' , 'client'
// , 'client/server'
, 'elxr' , 'elxr'
, 'elixir-client' , 'elixir-client'
, 'elixir-client-unlinked' , 'elixir-client-unlinked'
, 'ember-searchable-select' , 'ember-searchable-select'
, 'loopback-component-jsonapi' , 'loopback-component-jsonapi'
, 'config'
, 'elixir-config'
, 'cihsr-config'
, 'cihsr-data'
, 'elixir-data'
, 'loopback-connector-ds' , 'loopback-connector-ds'
, 'chess-server-lib' , 'chess-server-lib'
, 'elixir-server'
, 'chess-server'
, 'setup' , 'setup'
] ]


// Repositiories that have symlinks that required elevated priviletes in windows to create symlinks
//
var elevatedRunasRepos = [
'elixir-server'
, 'cihsr-server'
, 'chess-server'
]


var env = Object.assign({}, process.env); // Shallow clone it. var env = Object.assign({}, process.env); // Shallow clone it.
var __runcmd = function(label){ var __runcmd = function(label){


// env: env // env: env
// }) // })


var performPull = repo => {
if(existsSync(repo)) {
console.log('pulling ' + repo)
nodeShellExec('git', ['pull'], {
inherit : true, shell: true,
cwd : repo
// , env: process.env
, title : `git pull ${repo}`
}).catch((e)=>{ console.error(e) })
}
else {
console.log('cloning ' + repo)
nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + repo + '.git'],
{
inherit : true, shell: true,
env: process.env
, title : `git clone ${'//172.16.0.27/repos/' + repo + '.git'}`
}).catch((e)=>{ console.error(e) })
}
}

var isElevated; var isElevated;
try { try {
nodeShellExec( "fsutil", ["dirty", "query", "C:"], { nodeShellExec( "fsutil", ["dirty", "query", "C:"], {
, title : `check privileged execution mode using fsutil dirty query C:` , title : `check privileged execution mode using fsutil dirty query C:`
}).then((exitcode)=>{ }).then((exitcode)=>{
console.log('Elevated') console.log('Elevated')
var isElevated = true;
console.dir(processedArgs._[1])
if(processedArgs._[1] === 'runas') elevatedRunasRepos.forEach(performPull);
else gitRepos.forEach(performPull);
}).catch(()=>{ }).catch(()=>{
console.log('Not Elevated')
console.log('Not Elevated');
gitRepos.forEach(performPull)
console.log('Requesting Elevated Privileges') console.log('Requesting Elevated Privileges')
nodeShellExec('MSHTA', ["javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('node', 'elxr pull', '', 'runas', 1);close();"]
nodeShellExec('MSHTA', ["javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('node', 'elxr pull runas', '', 'runas', 1);close();"]
, { , {
inherit : true
// inherit : true
// , shell: true // , shell: true
, env: process.env
,
title : `runsAs`
env: process.env
, title : `runas`
} }
); );
}); });
// isElevated = true; // isElevated = true;
} }
catch ( e ) { catch ( e ) {
// isElevated = false;
console.error(e)
} }
// nodeShellExec('MSHTA', ["javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('node', 'elxr pull', '', 'runas', 1);close();"]);


gitRepos.forEach(repo => {
if(existsSync(repo)) {
console.log('pulling ' + repo)
nodeShellExec('git', ['pull'], {
inherit : true, shell: true,
cwd : repo
, env: process.env
, title : `git pull ${repo}`
}).catch((e)=>{ console.error(e) })
}
else {
console.log('cloning ' + repo)
nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + repo + '.git'],
{
inherit : true, shell: true,
cwd : repo
, env: process.env
, title : `git clone ${'//172.16.0.27/repos/' + repo + '.git'}`
}).catch((e)=>{ console.error(e) })
}
})
} }
, 'npmi' : ()=>{ , 'npmi' : ()=>{
var tasks = []; var tasks = [];
env.DEBUG = 'loopback:connector:' + dbForLabel(label) env.DEBUG = 'loopback:connector:' + dbForLabel(label)
nodeShellExec('node', ['--inspect=9228', 'elixir/server.js'], { nodeShellExec('node', ['--inspect=9228', 'elixir/server.js'], {
inherit : true,
// inherit : true,
shell: true, detached: true, shell: true, detached: true,
cwd : 'elixir-server', cwd : 'elixir-server',
env: env env: env
}) })


nodeShellExec('node', ['--inspect=9227', 'elixr/server.js'], {
inherit : true,
shell: true, detached: true,
cwd : 'elixir-server',
env: env
})
// nodeShellExec('node', ['--inspect=9226', ' bin/www'], { // nodeShellExec('node', ['--inspect=9226', ' bin/www'], {
// inherit : true, // inherit : true,
// shell: true, detached: true, // shell: true, detached: true,
// }) // })


nodeShellExec('ember', ['s'], { nodeShellExec('ember', ['s'], {
inherit : true,
// inherit : true,
shell: true, detached: true, shell: true, detached: true,
cwd : 'client/', cwd : 'client/',
env: env env: env
}) })
} }
, 'use' : ()=>{
try {
var runconfig = require('./run.js')
if(processedArgs._[1] && runconfig.use === processedArgs._[1]) {
return;
}
else runconfig.use = processedArgs._[1];
fs.writeFileSync('./run.js', 'module.exports = ' + JSON.stringify(runconfig))
}
catch(e) {
runconfig = { use : processedArgs._[1] };
fs.writeFileSync('./run.js', 'module.exports = ' + JSON.stringify(runconfig))
}
var tasks = [
()=>{
var p = nodeShellExec('mklink', ['/D', 'data', 'data-' + runconfig.use], {
inherit : true, shell: true
, env: process.env
}).catch((e)=>{ console.error(e) })
return p;
},
()=>{
var p = nodeShellExec('mklink', ['/D', 'config', 'config-' + runconfig.use], {
inherit : true, shell: true
, env: process.env
}).catch((e)=>{ console.error(e) })
return p;
}
]
any(tasks)

// Antibiotic stewardship program.
// 1st use is fine.
// Max vials dispense
// 2nd use Pharmacy needs justification Form.
// Approval after a certain period of time.
}
, 'g' : ()=>{ , 'g' : ()=>{
if(processedArgs.h) { if(processedArgs.h) {



Cargando…
Cancelar
Guardar