Browse Source

elxr cli commands

production
Pradeep Bhaskaran 4 years ago
parent
commit
8b697619da
1 changed files with 76 additions and 15 deletions
  1. 76
    15
      index.js

+ 76
- 15
index.js View File

const processedArgs = cliargs(process.argv.slice(2)); const processedArgs = cliargs(process.argv.slice(2));
console.dir(processedArgs) console.dir(processedArgs)


var path = require('path')

var cli = 'elxr'; var cli = 'elxr';
var ver = '#unversioned'; var ver = '#unversioned';
var help = '#unkown list of commands... please refer dveloper documentation for ' + cli; var help = '#unkown list of commands... please refer dveloper documentation for ' + cli;
return dbsForLabel[label] || 'mysql' return dbsForLabel[label] || 'mysql'
} }


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


var op = { var op = {
'h' : ()=>{ console.log(cli + ' ' + ver + ' ' + help); return '-h' } 'h' : ()=>{ console.log(cli + ' ' + ver + ' ' + help); return '-h' }
, 'upgrade' : ()=>{
console.log('Running exlr upgrade in : ' + path.dirname(__dirname))
console.log('Currently only upgrades ember : ' + path.dirname(__dirname));
console.info('Uninstalling existing ember globally') ;
var step1 = nodeShellExec('cmd', ['/c', 'npm', 'uninstall', '-g', 'ember-cli'], {
stdio: ['pipe', process.stdout, process.stderr],
inherit : true,
shell: true,
cwd : path.dirname(__dirname),
env: env
})
step1.on('close', ()=>{
console.info('Installing ember globally') ;
var step2 = nodeShellExec('cmd', ['/c', 'npm', 'install', '-g', 'ember-cli'], {
stdio: ['pipe', process.stdout, process.stderr],
inherit : true,
shell: true,
cwd : path.dirname(__dirname),
env: env
})
step2.on('close', ()=>{
nodeShellExec('cmd', ['/c', 'ember', '--version'], {
stdio: ['pipe', process.stdout, process.stderr],
inherit : true,
shell: true,
cwd : path.dirname(__dirname),
env: env
})
})
})
}
, 'pull' : (label) => {
var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env)
console.log('Running exlr pull : ' + path.dirname(__dirname))
nodeShellExec('cmd', ['/c', 'setup\\utility\\chess.bat', 'pull'], {
// nodeShellExec('cmd', ['/c', '..\\setup\\utility\\chess.bat', 'pull'], {
stdio: ['pipe', process.stdout, process.stderr],
inherit : true,
shell: true,
cwd : path.dirname(__dirname),
env: env
})
}
, 'start' : (label)=>{ , 'start' : (label)=>{
console.log('Starting Elixir Server.'); console.log('Starting Elixir Server.');
var env = Object.assign({}, process.env); // Shallow clone it. var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env) // console.dir(env)
env.NODE_ENV = label;
env.NODE_ENV = label || 'development';
env.DEBUG = 'loopback:connector:' + dbForLabel(label) env.DEBUG = 'loopback:connector:' + dbForLabel(label)
nodeShellExec('node', ['--inspect=9228', 'sage-rw/server.js'], {
nodeShellExec('node', ['--inspect=9228', 'elixir/server.js'], {
inherit : true, inherit : true,
shell: true, detached: true, shell: true, detached: true,
cwd : 'loopback',
env: env,
shell : true
cwd : 'elixir-server',
env: env
}) })


nodeShellExec('node', ['--inspect=9227', 'sage-r/server.js'], {
nodeShellExec('node', ['--inspect=9227', 'elixr/server.js'], {
inherit : true, inherit : true,
shell: true, detached: true, shell: true, detached: true,
cwd : 'loopback',
env: env,
shell : true
cwd : 'elixir-server',
env: env
}) })
// nodeShellExec('node', ['--inspect=9226', ' bin/www'], { // nodeShellExec('node', ['--inspect=9226', ' bin/www'], {
nodeShellExec('ember', ['s'], { nodeShellExec('ember', ['s'], {
inherit : true, inherit : true,
shell: true, detached: true, shell: true, detached: true,
cwd : 'qms/',
env: env,
shell : true
cwd : 'client/',
env: env
}) })
} }
, 'g' : ()=>{ , 'g' : ()=>{
// // , env : process.env // // , env : process.env
// }; // };
// nodeShellExec('git', ['init'], { inherit : true}); // nodeShellExec('git', ['init'], { inherit : true});
if(0){
nodeShellExec('pwd', { inherit : true}); nodeShellExec('pwd', { inherit : true});
//$ "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1" http://localhost:4200/tests/index.html?grep=loopback //$ "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1" http://localhost:4200/tests/index.html?grep=loopback
nodeShellExec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", [ nodeShellExec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", [
"--profile-directory=Profile 1" "--profile-directory=Profile 1"
, 'http://localhost:4200/tests/index.html?grep=model convert ember to loopback' + '&filter=none' /*+ '&filter=model convert ember to loopback'*/]); , 'http://localhost:4200/tests/index.html?grep=model convert ember to loopback' + '&filter=none' /*+ '&filter=model convert ember to loopback'*/]);
}
// nodeShellExec('npm', ['init', '-y'], options); // nodeShellExec('npm', ['init', '-y'], options);
// nodeShellExec('npm', ['init', '-y'], options); // nodeShellExec('npm', ['init', '-y'], options);
// }) // })

var g = {
'client' : ()=>{
console.info('Creating new ember client named : ' + processedArgs._[2] ) ;
var step1 = nodeShellExec('cmd', ['/c', 'ember', 'new', processedArgs._[2]], {
stdio: ['pipe', process.stdout, process.stderr],
inherit : true,
shell: true,
cwd : path.dirname(__dirname),
env: env
})
}
}
g[processedArgs._[1]]();
} }
} }
return op[label] ? op[label]() : op['start'](label); return op[label] ? op[label]() : op['start'](label);
const child = spawn(...arguments); const child = spawn(...arguments);


// use child.stdout.setEncoding('utf8'); if you want text chunks // use child.stdout.setEncoding('utf8'); if you want text chunks
child.stdout.setEncoding('utf8');
// child.stdout.setEncoding('utf8');
// console.log('here') // console.log('here')


child.stdout.on('data', (chunk) => console.log(chunk));
// child.stdout.on('data', (chunk) => console.log(chunk));


child.on('error', (chunk) => console.error(chunk)); child.on('error', (chunk) => console.error(chunk));
child.stderr.pipe(process.stderr);
// child.stderr.pipe(process.stderr);


child.on('close', (code) => console.log(`child process ${Array.from(arguments)[0]} exited with code ${code}`)); child.on('close', (code) => console.log(`child process ${Array.from(arguments)[0]} exited with code ${code}`));
return child; return child;

Loading…
Cancel
Save