Browse Source

Fixes for npm build

pull/4/head
demo 3 years ago
parent
commit
45a52e48bf
1 changed files with 32 additions and 42 deletions
  1. 32
    42
      index.js

+ 32
- 42
index.js View File

var any = utils.any; var any = utils.any;
var Tasq = utils.Tasq var Tasq = utils.Tasq
var statuslog = utils.Traq var statuslog = utils.Traq
var Traq = utils.Traq
Tasq.addlistener(statuslog.statuslog) Tasq.addlistener(statuslog.statuslog)






var brandName = 'elixir'; var brandName = 'elixir';
// Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in. // Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in.
var nodeenv = process.env.NODE_ENV || processedArgs.node_env || 'development'
if(nodeenv.trim() === 'production') nodeenv = 'production'
var nodeenv = process.env.NODE_ENV.trim() || processedArgs.node_env || 'development'
// var repomanifest = require('../'+brandName+'-config-'+ nodeenv +'/repo-manifest')() // var repomanifest = require('../'+brandName+'-config-'+ nodeenv +'/repo-manifest')()
var exludeMergeRepos = []; var exludeMergeRepos = [];
var useGitPull = processedArgs.useGitPull || false; var useGitPull = processedArgs.useGitPull || false;
var configpath = '../' + configrepo; var configpath = '../' + configrepo;
var configPromise = null var configPromise = null


if(!existsSync(configpath)){
configPromise = performPull(configrepo)
}
if(!existsSync(configpath)){ configPromise = performPull(configrepo) }
else configPromise = Promise.resolve(true) else configPromise = Promise.resolve(true)


configPromise.then(()=>{ configPromise.then(()=>{


var manifestpath = '../'+brandName+'-config-'+nodeenv+'/repo-manifest'; var manifestpath = '../'+brandName+'-config-'+nodeenv+'/repo-manifest';
// var manifestpath = '../'+brandName+'-config-'+'production'+'/repo-manifest'; // var manifestpath = '../'+brandName+'-config-'+'production'+'/repo-manifest';
console.dir(manifestpath)
// console.dir(manifestpath)
var repomanifest = require(manifestpath)() var repomanifest = require(manifestpath)()
console.dir(repomanifest)
// console.dir(repomanifest)


var gitRepos = repomanifest.repos var gitRepos = repomanifest.repos


// elxr pull -- Defaults to run config // elxr pull -- Defaults to run config
var env = Object.assign({}, process.env); // Shallow clone it. var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env)
console.log('Running exlr pull : ' + path.dirname(__dirname)) 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
// })


var useGitPull = processedArgs.useGitPull || false; var useGitPull = processedArgs.useGitPull || false;
var getPullCmd = (repo)=>{ var getPullCmd = (repo)=>{
} }
, 'npmi' : ()=>{ , 'npmi' : ()=>{
var tasks = []; var tasks = [];
var bowerRepos = ['client']


var npmbuildrepos = ['loopback-jsonapi-model-serializer'] var npmbuildrepos = ['loopback-jsonapi-model-serializer']
npmbuildrepos.forEach(repo => { npmbuildrepos.forEach(repo => {
tasks.push(()=>{ tasks.push(()=>{
var p = nodeShellExec('npm', ['i --force'], {
return nodeShellExec('npm', ['i --force'], {
inherit : true, shell: true inherit : true, shell: true
, cwd : repo , cwd : repo
, env: process.env , env: process.env
, title : `npm i for ${repo}` , title : `npm i for ${repo}`
}).catch((e)=>{ }).catch((e)=>{
console.error('Ignoring Benign Error'); console.error(e)
console.error('Ignoring Benign Error'); console.error(e);
}).then(()=>{ }).then(()=>{
console.log(`--------------------npm run build for ${repo}--------------------`)
return nodeShellExec('npm', ['run build'], { return nodeShellExec('npm', ['run build'], {
inherit : true, shell: true inherit : true, shell: true
, cwd : repo , cwd : repo
, env: process.env , env: process.env
, title : `npm run build for ${repo}` , title : `npm run build for ${repo}`
}).catch(Tasq.catch)
})


return p;
}).then(Tasq.then).catch(Tasq.catch)
})
}) })
}) })
any(tasks).then(()=>{ any(tasks).then(()=>{


gitRepos = gitRepos.concat(elevatedRunasRepos);
gitRepos.push('client/server'); gitRepos.push('client/server');
gitRepos = gitRepos.concat(elevatedRunasRepos);


var rmtasks = []
var repotasks = [] var repotasks = []
gitRepos.forEach(repo => { gitRepos.forEach(repo => {
console.log('npm i for ' + repo)
repotasks.push(
nodeShellExec('rm', ['package-lock.json'], {
rmtasks.push(()=>{
console.log(`--------------------rm package-lock.json for ${repo}--------------------`)
return nodeShellExec('rm', ['package-lock.json'], {
inherit : true, shell: true inherit : true, shell: true
, cwd : repo , cwd : repo
, env: process.env , env: process.env
, title : `rm 'package-lock.json' for ${repo}` , title : `rm 'package-lock.json' for ${repo}`
}).catch((e)=>{console.error(e)})
.then(()=>{
if( npmbuildrepos.indexOf(repo) < 0) {
// tasks.push(()=>{
}).catch((e)=>{console.error(e)})
})
if( npmbuildrepos.indexOf(repo) < 0) {
repotasks.push(
()=>{
console.log(`--------------------npm i for ${repo}--------------------`)
var p = nodeShellExec('npm', ['i --force'], { var p = nodeShellExec('npm', ['i --force'], {
inherit : true, shell: true inherit : true, shell: true
, cwd : repo , cwd : repo
, env: process.env , env: process.env
, title : `npm i for ${repo}` , title : `npm i for ${repo}`
}).catch(Tasq.catch)
}).then(Tasq.then).catch(Tasq.catch)
return p; return p;
// })
}
})
)
})
}
}) })

var bowerRepos = ['client']
bowerRepos.forEach(repo => { bowerRepos.forEach(repo => {
repotasks.push(()=>{ repotasks.push(()=>{
var p = nodeShellExec('bower', ['install'], { var p = nodeShellExec('bower', ['install'], {
, cwd : repo , cwd : repo
, env: process.env , env: process.env
, title : `bower i for ${repo}` , title : `bower i for ${repo}`
}).catch(Tasq.catch)
}).then(Tasq.then).catch(Tasq.catch)
return p; return p;
}) })
}) })


return any(repotasks);
return Promise.all(rmtasks).then(()=>any(repotasks));
}).catch(e=>{ }).catch(e=>{
}).finally(statuslog.finally) }).finally(statuslog.finally)

Loading…
Cancel
Save