Browse Source

Elxr pull and use fixes

production
samuel 4 years ago
parent
commit
4564045abe
1 changed files with 31 additions and 7 deletions
  1. 31
    7
      index.js

+ 31
- 7
index.js View File

@@ -400,7 +400,7 @@ var __runcmd = function(label){
// env: env
// })

var performPull = repo => {
var performPull = (repo) => {
if(existsSync(repo)) {
console.log('pulling ' + repo)
return nodeShellExec('git', ['pull'], {
@@ -413,13 +413,24 @@ var __runcmd = function(label){
}
else {
console.log('cloning ' + repo)
return nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + repo + '.git'],
return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', '//172.16.0.27/repos/' + repo + '.git'],
{
inherit : true, shell: true,
env: process.env
, runas : processedArgs.runas
, title : `git clone ${'//172.16.0.27/repos/' + repo + '.git'}`
}).catch((e)=>{ console.error(e) })
}).catch((e)=>{ console.error(e) }).then(()=>{

return nodeShellExec('git', ['config', '--replace-all' , 'core.symlinks', true],
{
inherit : true, shell: true,
env: process.env
, cwd : repo
, runas : processedArgs.runas
, title : `git core.symlinks --replace-all true for ${'//172.16.0.27/repos/' + repo + '.git'}`
})


})
}
}

@@ -554,6 +565,13 @@ var __runcmd = function(label){
// If environment is not specified defaults to development.
// 1) NODE=test elxr use elixir

/*// Steps
1) Delete Config and Data symlinks
2) Make Links for config ({{name}}-config-{{node_env}}) and data with the NODE_ENV specified or default to dev
3) Iterates all repos and pull all. 'git', ['pull', '--all'].
4) Iterates all repos and checkout to the ENV specified. 'git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]
5) Iterates all repos and merge from source configured in mergeSource. 'git', ['merge', mergeSource],
*/
var runconfig = { NODE_ENV : process.env.NODE_ENV }
try { runconfig = Object.assign(runconfig, require('../run.js')) } catch(e) { }
if((!processedArgs.runas || processedArgs.runas !== 'self') &&
@@ -596,14 +614,16 @@ var __runcmd = function(label){
// cant use git checkout -b it fails with branch already exists.
var performCheckout = (repo)=>{
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true })
return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
return nodeShellExec('git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
// return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
// inherit : true, shell: true,
cwd : repo
// , stdio : ignore // Use when we want to silcence output completely.
, runas : processedArgs.runas
, title : `git switch -C -m ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}`
, title : `git checkout ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}`
}).catch((e)=>{ console.error(e); return { error : true, message : repo} })
}
if(runconfig.NODE_ENV === 'development') performCheckout = ()=>{ return Promise.resolve(true) }

var performPullAll = (repo)=>{
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true })
@@ -618,13 +638,17 @@ var __runcmd = function(label){
var mergeSources = {
'development' : null,
'test' : 'master',
'production' : 'test'
'production' : 'master'
}
var exludeMergeRepos = {
'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true
, 'elixir-data' : true
,'cihsr-config-development' : true, 'cihsr-config-test': true, 'cihsr-config-production' : true
, 'cihsr-data' : true
}
var excludeCheckouts = Object.assign(exludeMergeRepos)
delete excludeCheckouts[`elixir-config-${runconfig.NODE_ENV}`]
delete excludeCheckouts[`cihsr-config-${runconfig.NODE_ENV}`]

var mergeSource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]
var performMerge = (repo)=>{

Loading…
Cancel
Save