Ver código fonte

npmi utility for elxr cli

production
Pradeep Bhaskaran 4 anos atrás
pai
commit
f982451707
1 arquivos alterados com 67 adições e 31 exclusões
  1. 67
    31
      index.js

+ 67
- 31
index.js Ver arquivo

@@ -11,7 +11,7 @@ console.dir(processedArgs)
var path = require('path')
// Serialize a set of functions that will execute to return a promises one after the other.
// Will stop when any one fails.
function any(iterable) {
function any(iterable, continueOnFailure) {
return iterable.reduce(
(p, fn, i ,a) => {
// console.log('accumulator :');
@@ -103,6 +103,26 @@ var dbForLabel = function(label){
return dbsForLabel[label] || 'mysql'
}

// Relevant git repos
var gitRepos = [
'ember-masonry-grid'
, 'bbhverse'
, 'clientverse'
, 'serververse'
, 'client'
, 'elxr'
, 'elixir-client'
, 'elixir-client-unlinked'
, 'ember-searchable-select'
, 'loopback-component-jsonapi'
, 'config'
, 'loopback-connector-ds'
, 'chess-server-lib'
, 'elixir-server'
, 'chess-server'
, 'setup'
]

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

@@ -223,49 +243,62 @@ var __runcmd = function(label){
// nodeShellExec('MSHTA', ["javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('node', 'elxr pull', '', 'runas', 1);close();"]);

// Clone if not exists
var gitclonables = [
'ember-masonry-grid'
, 'bbhverse'
, 'clientverse'
, 'serververse'
, 'client'
, 'elixir-client'
, 'elixir-client-unlinked'
, 'ember-searchable-select'
, 'loopback-component-jsonapi'
, 'config'
, 'loopback-connector-ds'
, 'chess-server-lib'
, 'elixir-server'
, 'chess-server'
, 'setup'
]

gitclonables.forEach(clonable => {
if(existsSync(clonable)) {
console.log('pulling ' + clonable)
gitRepos.forEach(repo => {
if(existsSync(repo)) {
console.log('pulling ' + repo)
nodeShellExec('git', ['pull'], {
// inherit : true, shell: true
// ,
cwd : clonable
cwd : repo
// , env: process.env
, title : `git pull ${clonable}`
, title : `git pull ${repo}`
}).catch((e)=>{ console.error(e) })
}
else {
console.log('cloning ' + clonable)
nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + clonable + '.git'],
console.log('cloning ' + repo)
nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + repo + '.git'],
{
// inherit : true, shell: true
// ,
cwd : clonable
cwd : repo
// , env: process.env
, title : `git clone ${'//172.16.0.27/repos/' + clonable + '.git'}`
, title : `git clone ${'//172.16.0.27/repos/' + repo + '.git'}`
}).catch((e)=>{ console.error(e) })
}
})
}
, 'npmi' : ()=>{
var tasks = [];
gitRepos.forEach(repo => {
console.log('npm i for ' + repo)
// nodeShellExec('pwd', [], {
// // inherit : true, shell: true
// cwd : repo
// // , env: process.env
// , title : `pwd for ${repo}`
// }).catch((e)=>{ console.error(e) })
// nodeShellExec('rm', ['package-lock.json'], {
// inherit : true, shell: true
// , cwd : repo
// , env: process.env
// , title : `rm 'package-lock.json' for ${repo}`
// }).catch((e)=>{ console.error(e) })
tasks.push(()=>{
var p = nodeShellExec('npm', ['i'], {
inherit : true, shell: true
, cwd : repo
, env: process.env
, title : `npm i for ${repo}`
}).catch((e)=>{ console.error(e) })
return p;
})
})
any(tasks);
}
, 'start' : (label)=>{
console.log('Starting Elixir Server.');
var env = Object.assign({}, process.env); // Shallow clone it.
@@ -376,14 +409,17 @@ function nodeShellExec() {
// use child.stdout.setEncoding('utf8'); if you want text chunks
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
child.stdout.on('data', (chunk) => { messages.push(chunk); /*console.log(chunk)*/});
child.on('error', (chunk) => { messages.push(chunk); /*console.error(chunk)*/ });
child.stderr.pipe(process.stderr);
child.stderr.on('data', (chunk) => { messages.push(chunk); /*console.log(chunk)*/});
// child.stderr.pipe(process.stderr);

child.on('close', (code) => {
console.log(` ${args[2].title} exited with code ${code}`)
console.log(messages)
console.log([` ${args[2].title} exited with code ${code}`])
// console.log([ messages.join('') ])
process.stdout.write( messages.join('') )
if(code !== 0 ) return reject(code)
resolve(true)
});

Carregando…
Cancelar
Salvar