|
|
|
|
|
|
|
|
var path = require('path') |
|
|
var path = require('path') |
|
|
// Serialize a set of functions that will execute to return a promises one after the other. |
|
|
// Serialize a set of functions that will execute to return a promises one after the other. |
|
|
// Will stop when any one fails. |
|
|
// Will stop when any one fails. |
|
|
function any(iterable) { |
|
|
|
|
|
|
|
|
function any(iterable, continueOnFailure) { |
|
|
return iterable.reduce( |
|
|
return iterable.reduce( |
|
|
(p, fn, i ,a) => { |
|
|
(p, fn, i ,a) => { |
|
|
// console.log('accumulator :'); |
|
|
// console.log('accumulator :'); |
|
|
|
|
|
|
|
|
return dbsForLabel[label] || 'mysql' |
|
|
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 env = Object.assign({}, process.env); // Shallow clone it. |
|
|
var __runcmd = function(label){ |
|
|
var __runcmd = function(label){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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', 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'], { |
|
|
nodeShellExec('git', ['pull'], { |
|
|
// inherit : true, shell: true |
|
|
// inherit : true, shell: true |
|
|
// , |
|
|
// , |
|
|
cwd : clonable |
|
|
|
|
|
|
|
|
cwd : repo |
|
|
// , env: process.env |
|
|
// , env: process.env |
|
|
, title : `git pull ${clonable}` |
|
|
|
|
|
|
|
|
, title : `git pull ${repo}` |
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
} |
|
|
} |
|
|
else { |
|
|
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 |
|
|
// inherit : true, shell: true |
|
|
// , |
|
|
// , |
|
|
cwd : clonable |
|
|
|
|
|
|
|
|
cwd : repo |
|
|
// , env: process.env |
|
|
// , 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) }) |
|
|
}).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)=>{ |
|
|
, '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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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'); |
|
|
|
|
|
child.stderr.setEncoding('utf8'); |
|
|
child.stdout.on('data', (chunk) => { messages.push(chunk); /*console.log(chunk)*/}); |
|
|
child.stdout.on('data', (chunk) => { messages.push(chunk); /*console.log(chunk)*/}); |
|
|
child.on('error', (chunk) => { messages.push(chunk); /*console.error(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) => { |
|
|
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) |
|
|
if(code !== 0 ) return reject(code) |
|
|
resolve(true) |
|
|
resolve(true) |
|
|
}); |
|
|
}); |