|
|
@ -6,13 +6,9 @@ |
|
|
|
|
|
|
|
This task update all SUI individual component repos with new versions of components |
|
|
|
|
|
|
|
* Creates new repo if doesnt exist (locally & GitHub) |
|
|
|
* Adds remote it doesnt exists |
|
|
|
* Commits changes |
|
|
|
* Pulls latest changes from repo |
|
|
|
* Merges changes if necessary |
|
|
|
* Tag new releases if version changed in main repo |
|
|
|
* Commits changes from create repo |
|
|
|
* Pushes changes to GitHub |
|
|
|
* Tag new releases if version changed in main repo |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
@ -100,15 +96,6 @@ module.exports = function() { |
|
|
|
|
|
|
|
console.info('Processing repository:' + outputDirectory); |
|
|
|
|
|
|
|
function nextRepo() { |
|
|
|
console.log('Sleeping for 1 second...'); |
|
|
|
// avoid rate throttling
|
|
|
|
global.clearTimeout(timer); |
|
|
|
timer = global.setTimeout(function() { |
|
|
|
stepRepo() |
|
|
|
}, 1500); |
|
|
|
} |
|
|
|
|
|
|
|
// standard path
|
|
|
|
function commitFiles() { |
|
|
|
// commit files
|
|
|
@ -121,7 +108,7 @@ module.exports = function() { |
|
|
|
}) |
|
|
|
.on('finish', function(callback) { |
|
|
|
if(canProceed) { |
|
|
|
pullFiles(); |
|
|
|
pushFiles(); |
|
|
|
} |
|
|
|
else { |
|
|
|
console.info('Nothing new to commit'); |
|
|
@ -131,137 +118,51 @@ module.exports = function() { |
|
|
|
; |
|
|
|
} |
|
|
|
|
|
|
|
function pullFiles() { |
|
|
|
console.info('Pulling ' + component + ' files'); |
|
|
|
git.pull('origin', 'master', pullOptions, function(error) { |
|
|
|
if(error && error.message.search("Couldn't find remote ref") != -1) { |
|
|
|
console.error('Cant find remote ref'); |
|
|
|
setupRepo(); |
|
|
|
} |
|
|
|
else { |
|
|
|
checkoutOurs(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function checkoutOurs() { |
|
|
|
gulp.src('**/*', gitOptions) |
|
|
|
.pipe(git.checkoutFiles(checkoutOptions)) |
|
|
|
.on('error', function(error) { |
|
|
|
canProceed = false; |
|
|
|
}) |
|
|
|
.on('finish', function(callback) { |
|
|
|
if(canProceed) { |
|
|
|
mergeCommit(); |
|
|
|
} |
|
|
|
else { |
|
|
|
console.log(checkoutOptions); |
|
|
|
console.error('Error checking out "ours"'); |
|
|
|
} |
|
|
|
}) |
|
|
|
; |
|
|
|
} |
|
|
|
|
|
|
|
// commit files
|
|
|
|
function mergeCommit() { |
|
|
|
gulp.src('', gitOptions) |
|
|
|
.pipe(git.add(gitOptions)) |
|
|
|
.pipe(git.commit(mergeMessage, { args: commitArgs, cwd: outputDirectory })) |
|
|
|
.on('error', function(error) { |
|
|
|
canProceed = false; |
|
|
|
}) |
|
|
|
.on('finish', function(callback) { |
|
|
|
if(canProceed) { |
|
|
|
console.info('Updating ' + component, commitArgs); |
|
|
|
tagFiles(); |
|
|
|
} |
|
|
|
else { |
|
|
|
console.info('Nothing new to commit'); |
|
|
|
stepRepo(); |
|
|
|
} |
|
|
|
}) |
|
|
|
; |
|
|
|
} |
|
|
|
|
|
|
|
// tag files
|
|
|
|
function tagFiles() { |
|
|
|
console.info('Tagging new version ' + component, version); |
|
|
|
git.tag(version, 'Updated version from semantic-ui (automatic)', function (err) { |
|
|
|
pushFiles(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// push changess to remote
|
|
|
|
function pushFiles() { |
|
|
|
console.info('Pushing files for ' + component); |
|
|
|
git.push('origin', 'master', { args: '', cwd: outputDirectory }, function(error) { |
|
|
|
if(error && error.message.search("Couldn't find remote ref") != -1) { |
|
|
|
setupRepo(); |
|
|
|
} |
|
|
|
console.info('Push completed successfully'); |
|
|
|
createRelease(); |
|
|
|
nextRepo(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// create release on GitHub.com
|
|
|
|
function createRelease() { |
|
|
|
console.log('Tagging release as ', version);/* |
|
|
|
github.createRelease(releaseOptions, { |
|
|
|
nextRepo(); |
|
|
|
tagFiles(); |
|
|
|
});*/ |
|
|
|
nextRepo(); |
|
|
|
} |
|
|
|
|
|
|
|
// set-up local repo
|
|
|
|
function setupRepo() { |
|
|
|
if(localRepoSetup) { |
|
|
|
addRemote(); |
|
|
|
} |
|
|
|
else { |
|
|
|
initRepo(); |
|
|
|
} |
|
|
|
tagFiles(); |
|
|
|
} |
|
|
|
|
|
|
|
// set-up path
|
|
|
|
function createRepo() { |
|
|
|
console.info('Creating GitHub repo ' + repoURL); |
|
|
|
github.repos.createFromOrg({ |
|
|
|
org : release.org, |
|
|
|
name : repoName, |
|
|
|
homepage : release.homepage |
|
|
|
}, function() { |
|
|
|
setupRepo(); |
|
|
|
// Tags files locally
|
|
|
|
function tagFiles() { |
|
|
|
console.info('Tagging new version ' + component, version); |
|
|
|
git.tag(version, 'Updated version from semantic-ui (automatic)', function (err) { |
|
|
|
nextRepo(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function initRepo() { |
|
|
|
console.info('Initializing repository for ' + component); |
|
|
|
git.init(gitOptions, function(error) { |
|
|
|
if(error) { |
|
|
|
console.error('Error initializing repo'); |
|
|
|
return; |
|
|
|
} |
|
|
|
addRemote(); |
|
|
|
}); |
|
|
|
// Steps to next repository
|
|
|
|
function nextRepo() { |
|
|
|
console.log('Sleeping for 1 second...'); |
|
|
|
// avoid rate throttling
|
|
|
|
global.clearTimeout(timer); |
|
|
|
return stepRepo() |
|
|
|
} |
|
|
|
|
|
|
|
function addRemote() { |
|
|
|
console.info('Adding remote origin as ' + gitURL); |
|
|
|
git.addRemote('origin', gitURL, gitOptions, function(){ |
|
|
|
commitFiles(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if(localRepoSetup) { |
|
|
|
commitFiles(); |
|
|
|
} |
|
|
|
else { |
|
|
|
setupRepo(); |
|
|
|
// createRepo() only use to create remote repo (easier to do manually)
|
|
|
|
console.error('Repository must be setup before running update components'); |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return stepRepo(); |
|
|
|
stepRepo(); |
|
|
|
|
|
|
|
}; |