|
|
|
|
|
|
|
|
// env: env |
|
|
// env: env |
|
|
// }) |
|
|
// }) |
|
|
|
|
|
|
|
|
var performPull = repo => { |
|
|
|
|
|
|
|
|
var performPull = (repo) => { |
|
|
if(existsSync(repo)) { |
|
|
if(existsSync(repo)) { |
|
|
console.log('pulling ' + repo) |
|
|
console.log('pulling ' + repo) |
|
|
return nodeShellExec('git', ['pull'], { |
|
|
return nodeShellExec('git', ['pull'], { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
console.log('cloning ' + repo) |
|
|
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, |
|
|
inherit : true, shell: true, |
|
|
env: process.env |
|
|
env: process.env |
|
|
, runas : processedArgs.runas |
|
|
, 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'}` |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If environment is not specified defaults to development. |
|
|
// If environment is not specified defaults to development. |
|
|
// 1) NODE=test elxr use elixir |
|
|
// 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 } |
|
|
var runconfig = { NODE_ENV : process.env.NODE_ENV } |
|
|
try { runconfig = Object.assign(runconfig, require('../run.js')) } catch(e) { } |
|
|
try { runconfig = Object.assign(runconfig, require('../run.js')) } catch(e) { } |
|
|
if((!processedArgs.runas || processedArgs.runas !== 'self') && |
|
|
if((!processedArgs.runas || processedArgs.runas !== 'self') && |
|
|
|
|
|
|
|
|
// cant use git checkout -b it fails with branch already exists. |
|
|
// cant use git checkout -b it fails with branch already exists. |
|
|
var performCheckout = (repo)=>{ |
|
|
var performCheckout = (repo)=>{ |
|
|
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true }) |
|
|
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, |
|
|
// inherit : true, shell: true, |
|
|
cwd : repo |
|
|
cwd : repo |
|
|
// , stdio : ignore // Use when we want to silcence output completely. |
|
|
// , stdio : ignore // Use when we want to silcence output completely. |
|
|
, runas : processedArgs.runas |
|
|
, 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} }) |
|
|
}).catch((e)=>{ console.error(e); return { error : true, message : repo} }) |
|
|
} |
|
|
} |
|
|
|
|
|
if(runconfig.NODE_ENV === 'development') performCheckout = ()=>{ return Promise.resolve(true) } |
|
|
|
|
|
|
|
|
var performPullAll = (repo)=>{ |
|
|
var performPullAll = (repo)=>{ |
|
|
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true }) |
|
|
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true }) |
|
|
|
|
|
|
|
|
var mergeSources = { |
|
|
var mergeSources = { |
|
|
'development' : null, |
|
|
'development' : null, |
|
|
'test' : 'master', |
|
|
'test' : 'master', |
|
|
'production' : 'test' |
|
|
|
|
|
|
|
|
'production' : 'master' |
|
|
} |
|
|
} |
|
|
var exludeMergeRepos = { |
|
|
var exludeMergeRepos = { |
|
|
'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true |
|
|
'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) |
|
|
var excludeCheckouts = Object.assign(exludeMergeRepos) |
|
|
delete excludeCheckouts[`elixir-config-${runconfig.NODE_ENV}`] |
|
|
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 mergeSource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV] |
|
|
var performMerge = (repo)=>{ |
|
|
var performMerge = (repo)=>{ |