Browse Source

Fixed use instancename

production
chess 3 years ago
parent
commit
e5257ec878
2 changed files with 94 additions and 52 deletions
  1. 48
    27
      i.js
  2. 46
    25
      index.js

+ 48
- 27
i.js View File

@@ -1,4 +1,4 @@
/* Version: 1.0.0 - May 12, 2021 19:58:01 */
/* Version: 1.0.0 - May 14, 2021 00:18:25 */
'use strict';

var path$1 = require('path');
@@ -23611,7 +23611,7 @@ var nodeShellExec = cliverse.nodeShellExec;



const BUILD_VERSION = 'Version: 1.0.0 - built on May 12, 2021 19:58:01';
const BUILD_VERSION = 'Version: 1.0.0 - built on May 14, 2021 00:18:25';
const runtimestamp = (new Date()).getTime();
function getVersion() { return BUILD_VERSION; }
console.log(getVersion());
@@ -24607,9 +24607,9 @@ var op = {
return promise = promise.then(()=>{ return elxr.getpulltask(def)() }).catch(e => { console.error( 'performPullOrCloneForBranch : Failed ' + e );})
};

var performCloneAndCheckout = null;
// cant use git checkout -b it fails when branch already exists.
var performCheckout = (def) => {
var performCheckout = performCloneAndCheckout = (def) => {
if (excludeCheckouts[def.repo]) return Promise.resolve({ 'skipped': true })
return performPullOrCloneForBranch(def).then(()=>{
@@ -24624,7 +24624,24 @@ var op = {
})
};

if (runconfig.NODE_ENV === 'development') performCheckout = (def) => { return performPullOrCloneForBranch(def) };
var mergeSources = {
'development': null,
'test': 'master',
'production': 'master'
};
var mergesource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV];

// Checkout is reduced to pull provided the current branch is the targetbranch
if(branch === mergesource) performCheckout = (def) => {
var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo);
return nodeShellExec.apply(null, dscoverbranchcmd(repo)).then(__branch=>{
if(branch === __branch) return performCloneAndCheckout(def)
return performPullOrCloneForBranch(def)
})
.catch((e) => { console.error(e); return { error: true, message: repo } })
};
// else performCheckout = (def) => { return performPullOrCloneForBranch(def) }

var performPullAll = (def) => {
if (excludeCheckouts[def.repo]) return Promise.resolve({ 'skipped': true })
@@ -24635,17 +24652,11 @@ var op = {
, title: `git pull -all for ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} ${def.repo}`
}).catch((e) => { console.error(e); return { error: true, message: def.repo } })
};

var mergeSources = {
'development': null,
'test': 'master',
'production': 'master'
};
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 = (def) => {
if (exludeMergeRepos[def.repo]) return Promise.resolve({ 'skipped': true })
return nodeShellExec('git', ['merge', mergesource], {
@@ -24654,7 +24665,7 @@ var op = {
, runas: processedArgs.runas
}).catch((e) => { console.error(e); })
};
if (runconfig.NODE_ENV === 'development') performMerge = () => { return Promise.resolve(true) };
if(!mergesource || branch === mergesource) performMerge = () => { return Promise.resolve(true) };

// var performRepoOperation = function(def) {
// elevatedRunasRepos.map((repo) => enqueueCheckout({ repo, branch: def.branch, requiresElevation : true }))
@@ -24671,25 +24682,28 @@ var op = {
//Switch to target branch
return any(gitRepos.map((repodef) => { return performCheckout({ repo : repodef.repo, branch}).catch(e=>{ console.log(e); }) } ))
// pull or clone target branch
.then(() => any(gitRepos.map((repo) => performPullAll(repo))) )
.then(() => {
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(gitRepos.map((repo) => performPullAll(repo)))
})
// switch to source branch
.then( () => {
if(mergesource) return any(gitRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource})))
else return Promise.resolve(true) // Dont do anything if there is no source to merge from.
if(!mergesource || branch === mergesource ) return Promise.resolve(true) // Dont do anything if there is no source to merge from.
return any(gitRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource})))
})
//Pull on merge source branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource ) return Promise.resolve(true)
return any(gitRepos.map((repo) => performPullAll(repo)))
})
//Switch to target branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource ) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch})))
})
.then( //Merge source branch to target branch
() => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(gitRepos.map((repo) => performMerge( repo ))).catch(err => { console.error('error in performMerge ' + err); })
})
})
@@ -24722,27 +24736,31 @@ var op = {
}
return any(tasks).then(()=>{
// checkout target branch
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch, requiresElevation : true})))
// pull or clone target branch
.then( () => any(elevatedRunasRepos.map((repo) => performPullAll(repo))) )
.then(() => {
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repo) => performPullAll(repo)))
})
// switch to source branch
.then( () => {
if(mergesource) return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource, requiresElevation : true})))
else return Promise.resolve(true) // Dont do anything if there is no source to merge from.
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource, requiresElevation : true})))
})
//Pull on merge source branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performPullAll({repo : repodef.repo, requiresElevation : true })))
})
//Switch to target branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch, requiresElevation : true})))
})
.then( //Merge source branch to target branch
() => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performMerge({ repo : repodef.repo, requiresElevation : true }))).catch(err => { console.error('error in performMerge ' + err); })
})
.then(() => {
@@ -24901,9 +24919,12 @@ var elxr = {
if(def.elevatedRepos){
elevatedpulltasks = function() {
return any(def.elevatedRepos.map((def) => performPull(def.repo))).then(() => {
fs.writeFileSync('run.done', 'success');
// fs.writeFileSync('run.done', 'success')
return true;
}).catch(() => { fs.writeFileSync('run.done', 'error'); })
}).catch((e) => {
console.error(e);
fs.writeFileSync('run.done', 'error');
})
};
}
if(def.reqularRepos) {

+ 46
- 25
index.js View File

@@ -1014,9 +1014,9 @@ var op = {
return promise = promise.then(()=>{ return elxr.getpulltask(def)() }).catch(e => { console.error( 'performPullOrCloneForBranch : Failed ' + e )})
}

var performCloneAndCheckout = null;
// cant use git checkout -b it fails when branch already exists.
var performCheckout = (def) => {
var performCheckout = performCloneAndCheckout = (def) => {
if (excludeCheckouts[def.repo]) return Promise.resolve({ 'skipped': true })
return performPullOrCloneForBranch(def).then(()=>{
@@ -1048,7 +1048,24 @@ var op = {
queue.push(function(){ return task(def)}.bind(def));
}

if (runconfig.NODE_ENV === 'development') performCheckout = (def) => { return performPullOrCloneForBranch(def) }
var mergeSources = {
'development': null,
'test': 'master',
'production': 'master'
}
var mergesource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]

// Checkout is reduced to pull provided the current branch is the targetbranch
if(branch === mergesource) performCheckout = (def) => {
var dscoverbranchcmd = gitops.getdiscoverbranchcmd(repo)
return nodeShellExec.apply(null, dscoverbranchcmd(repo)).then(__branch=>{
if(branch === __branch) return performCloneAndCheckout(def)
return performPullOrCloneForBranch(def)
})
.catch((e) => { console.error(e); return { error: true, message: repo } })
}
// else performCheckout = (def) => { return performPullOrCloneForBranch(def) }

var performPullAll = (def) => {
if (excludeCheckouts[def.repo]) return Promise.resolve({ 'skipped': true })
@@ -1059,17 +1076,11 @@ var op = {
, title: `git pull -all for ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} ${def.repo}`
}).catch((e) => { console.error(e); return { error: true, message: def.repo } })
}

var mergeSources = {
'development': null,
'test': 'master',
'production': 'master'
}
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 = (def) => {
if (exludeMergeRepos[def.repo]) return Promise.resolve({ 'skipped': true })
return nodeShellExec('git', ['merge', mergesource], {
@@ -1078,7 +1089,7 @@ var op = {
, runas: processedArgs.runas
}).catch((e) => { console.error(e) })
}
if (runconfig.NODE_ENV === 'development') performMerge = () => { return Promise.resolve(true) }
if(!mergesource || branch === mergesource) performMerge = () => { return Promise.resolve(true) }

// var performRepoOperation = function(def) {
// elevatedRunasRepos.map((repo) => enqueueCheckout({ repo, branch: def.branch, requiresElevation : true }))
@@ -1095,25 +1106,28 @@ var op = {
//Switch to target branch
return any(gitRepos.map((repodef) => { return performCheckout({ repo : repodef.repo, branch}).catch(e=>{ console.log(e); }) } ))
// pull or clone target branch
.then(() => any(gitRepos.map((repo) => performPullAll(repo))) )
.then(() => {
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(gitRepos.map((repo) => performPullAll(repo)))
})
// switch to source branch
.then( () => {
if(mergesource) return any(gitRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource})))
else return Promise.resolve(true) // Dont do anything if there is no source to merge from.
if(!mergesource || branch === mergesource ) return Promise.resolve(true) // Dont do anything if there is no source to merge from.
return any(gitRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource})))
})
//Pull on merge source branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource ) return Promise.resolve(true)
return any(gitRepos.map((repo) => performPullAll(repo)))
})
//Switch to target branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource ) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch})))
})
.then( //Merge source branch to target branch
() => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(gitRepos.map((repo) => performMerge( repo ))).catch(err => { console.error('error in performMerge ' + err) })
})
})
@@ -1146,27 +1160,31 @@ var op = {
}
return any(tasks).then(()=>{
// checkout target branch
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch, requiresElevation : true})))
// pull or clone target branch
.then( () => any(elevatedRunasRepos.map((repo) => performPullAll(repo))) )
.then(() => {
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repo) => performPullAll(repo)))
})
// switch to source branch
.then( () => {
if(mergesource) return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource, requiresElevation : true})))
else return Promise.resolve(true) // Dont do anything if there is no source to merge from.
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource, requiresElevation : true})))
})
//Pull on merge source branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performPullAll({repo : repodef.repo, requiresElevation : true })))
})
//Switch to target branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch, requiresElevation : true})))
})
.then( //Merge source branch to target branch
() => {
if(!mergesource) return Promise.resolve(true)
if(!mergesource || branch === mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repodef) => performMerge({ repo : repodef.repo, requiresElevation : true }))).catch(err => { console.error('error in performMerge ' + err) })
})
.then(() => {
@@ -1353,9 +1371,12 @@ var elxr = {
if(def.elevatedRepos){
elevatedpulltasks = function() {
return any(def.elevatedRepos.map((def) => performPull(def.repo))).then(() => {
fs.writeFileSync('run.done', 'success')
// fs.writeFileSync('run.done', 'success')
return true;
}).catch(() => { fs.writeFileSync('run.done', 'error') })
}).catch((e) => {
console.error(e)
fs.writeFileSync('run.done', 'error')
})
}
}
if(def.reqularRepos) {

Loading…
Cancel
Save