| @@ -3,6 +3,7 @@ | |||
| // elxr | |||
| // A cli tool for elixr. | |||
| const { existsSync } = require('fs'); | |||
| const fs = require('fs') | |||
| const { spawn, spawnSync } = require('child_process'); | |||
| const cliargs = require('../elxr/cliargs'); // Use minimist... | |||
| const processedArgs = cliargs(process.argv.slice(2)); | |||
| @@ -110,19 +111,30 @@ var gitRepos = [ | |||
| , 'clientverse' | |||
| , 'serververse' | |||
| , 'client' | |||
| // , 'client/server' | |||
| , 'elxr' | |||
| , 'elixir-client' | |||
| , 'elixir-client-unlinked' | |||
| , 'ember-searchable-select' | |||
| , 'loopback-component-jsonapi' | |||
| , 'config' | |||
| , 'elixir-config' | |||
| , 'cihsr-config' | |||
| , 'cihsr-data' | |||
| , 'elixir-data' | |||
| , 'loopback-connector-ds' | |||
| , 'chess-server-lib' | |||
| , 'elixir-server' | |||
| , 'chess-server' | |||
| , '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 __runcmd = function(label){ | |||
| @@ -215,6 +227,27 @@ var __runcmd = function(label){ | |||
| // 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; | |||
| try { | |||
| nodeShellExec( "fsutil", ["dirty", "query", "C:"], { | |||
| @@ -223,50 +256,29 @@ var __runcmd = function(label){ | |||
| , title : `check privileged execution mode using fsutil dirty query C:` | |||
| }).then((exitcode)=>{ | |||
| console.log('Elevated') | |||
| var isElevated = true; | |||
| console.dir(processedArgs._[1]) | |||
| if(processedArgs._[1] === 'runas') elevatedRunasRepos.forEach(performPull); | |||
| else gitRepos.forEach(performPull); | |||
| }).catch(()=>{ | |||
| console.log('Not Elevated') | |||
| console.log('Not Elevated'); | |||
| gitRepos.forEach(performPull) | |||
| 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 | |||
| , env: process.env | |||
| , | |||
| title : `runsAs` | |||
| env: process.env | |||
| , title : `runas` | |||
| } | |||
| ); | |||
| }); | |||
| // isElevated = true; | |||
| } | |||
| 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' : ()=>{ | |||
| var tasks = []; | |||
| @@ -306,19 +318,12 @@ var __runcmd = function(label){ | |||
| env.DEBUG = 'loopback:connector:' + dbForLabel(label) | |||
| nodeShellExec('node', ['--inspect=9228', 'elixir/server.js'], { | |||
| inherit : true, | |||
| // inherit : true, | |||
| shell: true, detached: true, | |||
| cwd : 'elixir-server', | |||
| 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'], { | |||
| // inherit : true, | |||
| // shell: true, detached: true, | |||
| @@ -328,12 +333,49 @@ var __runcmd = function(label){ | |||
| // }) | |||
| nodeShellExec('ember', ['s'], { | |||
| inherit : true, | |||
| // inherit : true, | |||
| shell: true, detached: true, | |||
| cwd : 'client/', | |||
| 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' : ()=>{ | |||
| if(processedArgs.h) { | |||