Browse Source

Add init repo task

pull/1825/head
jlukic 9 years ago
parent
commit
ebe25eb70c
5 changed files with 26 additions and 126 deletions
  1. 2
      package.json
  2. 5
      tasks/admin/create-components.js
  3. 1
      tasks/admin/release-all.js
  4. 137
      tasks/admin/update-components.js
  5. 7
      tasks/collections/admin.js

2
package.json

@ -1,6 +1,6 @@
{
"name" : "semantic-ui",
"version" : "1.9.2",
"version" : "1.9.0",
"title" : "Semantic UI",
"description" : "Semantic empowers designers and developers by creating a shared vocabulary for UI.",
"homepage" : "http://www.semantic-ui.com",

5
tasks/admin/create-components.js

@ -126,11 +126,6 @@ module.exports = function(callback) {
assetPath = '/assets/**/' + component + '?(s).*'
;
if(release.outputRoot.search('../components') == 0) {
console.info('Cleaned dir', outputDirectory);
del.sync([outputDirectory], {silent: true, force: true});
}
// copy dist files into output folder adjusting asset paths
gulp.task(task.repo, false, function() {
return gulp.src(release.source + component + '.*')

1
tasks/admin/release-all.js

@ -19,6 +19,7 @@ module.exports = function() {
runSequence(
//'build', // build Semantic
'init components', // create each component repo
'create components', // create each component repo
'update components' // update component repos on github
);

137
tasks/admin/update-components.js

@ -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();
};

7
tasks/collections/admin.js

@ -17,6 +17,7 @@
module.exports = function(gulp) {
var
// single component releases
initComponents = require('../admin/init-components'),
createComponents = require('../admin/create-components'),
updateComponents = require('../admin/update-components'),
@ -28,8 +29,10 @@ module.exports = function(gulp) {
release = require('../admin/release')
;
gulp.task('create components', 'Creates local repos for each component', createComponents);
gulp.task('update components', 'Commits component updates to GitHub', updateComponents);
gulp.task('init components', 'Grabs each component from GitHub', initComponents);
gulp.task('create components', 'Updates files in each repo', createComponents);
gulp.task('update components', 'Commits component updates from create to GitHub', updateComponents);
gulp.task('register repos', 'Registers packages with Bower and NPM', registerRepos);
gulp.task('release all', 'Publishes all releases (components, package)', releaseAll);
gulp.task('release', 'Publishes only packaged releases', release);

Loading…
Cancel
Save