Browse Source

Retooling of admin tasks

pull/1825/head
jlukic 9 years ago
parent
commit
c01587558e
7 changed files with 107 additions and 94 deletions
  1. 5
      package.json
  2. 29
      tasks/admin/create-components.js
  3. 2
      tasks/admin/release-all.js
  4. 117
      tasks/admin/update-components.js
  5. 11
      tasks/config/admin/release.js
  6. 17
      tasks/config/admin/templates/package-component.js
  7. 20
      tasks/config/admin/templates/package.js

5
package.json

@ -1,6 +1,6 @@
{
"name" : "semantic-ui",
"version" : "1.9.0",
"version" : "1.9.2",
"title" : "Semantic UI",
"description" : "Semantic empowers designers and developers by creating a shared vocabulary for UI.",
"homepage" : "http://www.semantic-ui.com",
@ -80,7 +80,8 @@
"devDependencies": {
"github" : "^0.2.3",
"gulp-concat-filenames" : "^0.0.3",
"gulp-git" : "^0.5.5",
"gulp-debug" : "^2.0.0",
"gulp-git" : "^1.0.0",
"gulp-karma" : "0.0.4",
"gulp-tap" : "^0.1.3",
"karma" : "^0.12.28",

29
tasks/admin/create-components.js

@ -19,16 +19,18 @@ var
// node dependencies
console = require('better-console'),
del = require('del'),
fs = require('fs'),
path = require('path'),
runSequence = require('run-sequence'),
// admin dependencies
concatFileNames = require('gulp-concat-filenames'),
debug = require('gulp-debug'),
flatten = require('gulp-flatten'),
git = require('gulp-git'),
plumber = require('gulp-plumber'),
jsonEditor = require('gulp-json-editor'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
tap = require('gulp-tap'),
@ -37,13 +39,15 @@ var
config = require('../config/user'),
github = require('../config/admin/github'),
release = require('../config/admin/release'),
project = require('../config/project/release'),
// shorthand
version = release.version,
version = project.version,
output = config.paths.output
;
module.exports = function(callback) {
var
stream,
@ -117,9 +121,16 @@ module.exports = function(callback) {
composer : component + ' create composer.json',
package : component + ' create package.json',
meteor : component + ' create package.js',
}
},
// paths to includable assets
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 + '.*')
@ -231,9 +242,9 @@ module.exports = function(callback) {
};
composer.main = component + '.js';
}
composer.name = 'semantic/' + component;
composer.name = 'semantic/' + component;
if(version) {
composer.version = version;
composer.version = version;
}
composer.description = 'Single component release of ' + component;
return composer;
@ -268,8 +279,8 @@ module.exports = function(callback) {
if(isCSS) {
fileNames += ' \'' + component + '.css\',\n';
}
return gulp.src(outputDirectory + '/assets/**/' + component + '?(s).*', { base: outputDirectory})
.pipe(concatFileNames('dummy.txt', {
return gulp.src(outputDirectory + assetPath, { base: outputDirectory})
.pipe(concatFileNames('/dev/null', {
newline : '',
root : outputDirectory,
prepend : ' \'',
@ -277,14 +288,14 @@ module.exports = function(callback) {
}))
.pipe(tap(function(file) { fileNames += file.contents; }))
.on('end', function(){
gulp.src(release.templates.meteorComponent)
gulp.src(release.templates.meteor)
.pipe(plumber())
.pipe(flatten())
.pipe(replace(regExp.match.name, regExp.replace.name))
.pipe(replace(regExp.match.titleName, regExp.replace.titleName))
.pipe(replace(regExp.match.version, version))
.pipe(replace(regExp.match.files, fileNames))
.pipe(rename(release.files.npm))
.pipe(rename(release.files.meteor))
.pipe(gulp.dest(outputDirectory))
;
})

2
tasks/admin/release-all.js

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

117
tasks/admin/update-components.js

@ -30,14 +30,16 @@ var
// admin files
github = require('../config/admin/github.js'),
release = require('../config/admin/release'),
project = require('../config/project/release'),
// oAuth configuration for GitHub
oAuth = fs.existsSync(__dirname + '/../config/admin/oauth.js')
? require('../config/admin/oauth')
: false,
package = requireDotFile('package.json'),
version = package.version
// shorthand
version = project.version
;
module.exports = function() {
@ -68,9 +70,11 @@ module.exports = function() {
outputDirectory = path.resolve(release.outputRoot + component),
capitalizedComponent = component.charAt(0).toUpperCase() + component.slice(1),
repoName = release.repoRoot + capitalizedComponent,
gitOptions = { cwd: outputDirectory },
quietOptions = { args: '-q', cwd: outputDirectory },
localRepoSetup = fs.existsSync(path.join(outputDirectory, '.git')),
gitOptions = { cwd: outputDirectory, quiet: true },
quietOptions = { args: '-q', cwd: outputDirectory, quiet: true },
checkoutOptions = { args: '--ours', cwd: outputDirectory },
pullOptions = { args: '', cwd: outputDirectory },
gitURL = 'https://github.com/' + release.org + '/' + repoName + '.git',
repoURL = 'https://github.com/' + release.org + '/' + repoName + '/',
@ -89,7 +93,8 @@ module.exports = function() {
? '--author "' + oAuth.name + ' <' + oAuth.email + '>"'
: '',
canPush = true
localRepoSetup = fs.existsSync(path.join(outputDirectory, '.git')),
canProceed = true
;
@ -101,7 +106,7 @@ module.exports = function() {
global.clearTimeout(timer);
timer = global.setTimeout(function() {
stepRepo()
}, 500);
}, 1500);
}
// standard path
@ -112,49 +117,73 @@ module.exports = function() {
.pipe(git.add(gitOptions))
.pipe(git.commit(commitMessage, { args: commitArgs, cwd: outputDirectory }))
.on('error', function(error) {
console.info('Nothing new to commit');
nextRepo();
// canProceed = false; bug in git commit <https://github.com/stevelacy/gulp-git/issues/49>
})
.on('finish', function(callback) {
pullFiles();
if(canProceed) {
pullFiles();
}
else {
console.info('Nothing new to commit');
nextRepo();
}
})
;
}
function pullFiles() {
console.info('Pulling ' + component + ' files');
git.pull('origin', 'master', { args: '', cwd: outputDirectory }, function(error) {
git.pull('origin', 'master', pullOptions, function(error) {
if(error && error.message.search("Couldn't find remote ref") != -1) {
console.error('Cant find remote ref');
createRepo();
setupRepo();
}
else {
console.info('Pull completed successfully');
mergeCommit();
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() {
// commit files
gulp.src('', gitOptions)
.pipe(git.add(gitOptions))
.pipe(git.commit(mergeMessage, { args: commitArgs, cwd: outputDirectory }))
.on('error', function(error) {
canPush = false;
canProceed = false;
})
.on('finish', function(callback) {
if(canPush) {
console.info('Adding merge commit for ' + component, commitArgs);
if(canProceed) {
console.info('Updating ' + component, commitArgs);
tagFiles();
}
else {
console.info('Nothing new to merge');
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) {
@ -162,17 +191,37 @@ module.exports = function() {
});
}
// 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) {
createRepo();
setupRepo();
}
console.info('Push completed successfully');
createRelease();
nextRepo();
});
}
function createRelease() {
console.log('Tagging release as ', version);/*
github.createRelease(releaseOptions, {
nextRepo();
});*/
nextRepo();
}
// set-up local repo
function setupRepo() {
if(localRepoSetup) {
addRemote();
}
else {
initRepo();
}
}
// set-up path
function createRepo() {
console.info('Creating GitHub repo ' + repoURL);
@ -181,12 +230,7 @@ module.exports = function() {
name : repoName,
homepage : release.homepage
}, function() {
if(localRepoSetup) {
addRemote();
}
else {
initRepo();
}
setupRepo();
});
}
@ -203,20 +247,8 @@ module.exports = function() {
function addRemote() {
console.info('Adding remote origin as ' + gitURL);
git.addRemote('origin', gitURL, gitOptions, firstPushFiles);
}
function firstPushFiles() {
console.info('First Push for ' + component);
git.push('origin', 'master', { args: '-u', cwd: outputDirectory }, function(error) {
if(error) {
console.info(error);
pullFiles();
}
else {
console.info('First push completed successfully');
nextRepo();
}
git.addRemote('origin', gitURL, gitOptions, function(){
commitFiles();
});
}
@ -224,11 +256,12 @@ module.exports = function() {
commitFiles();
}
else {
createRepo();
setupRepo();
// createRepo() only use to create remote repo (easier to do manually)
}
};
stepRepo();
return stepRepo();
};

11
tasks/config/admin/release.js

@ -15,12 +15,11 @@ module.exports = {
},
templates: {
bower : './tasks/admin/templates/bower.json',
composer : './tasks/admin/templates/composer.json',
package : './tasks/admin/templates/package.json',
meteor : './tasks/admin/templates/package.js',
meteorComponent : './tasks/admin/templates/package-component.js',
readme : './tasks/admin/templates/README.md',
bower : './tasks/config/admin/templates/bower.json',
composer : './tasks/config/admin/templates/composer.json',
package : './tasks/config/admin/templates/package.json',
meteor : './tasks/config/admin/templates/package.js',
readme : './tasks/config/admin/templates/README.md',
notes : './RELEASE-NOTES.md'
},

17
tasks/config/admin/templates/package-component.js

@ -1,17 +0,0 @@
var
where = 'client' // Adds files only to the client
;
Package.describe({
name : 'semantic:ui-{component}',
summary : 'Semantic UI - {Component} (official): Single component release of {component}',
version : '{version}',
git : 'git://github.com/Semantic-Org/UI-{Component}.git',
});
Package.onUse(function(api) {
api.versionsFrom('1.0');
api.addFiles([
{files}
], where);
});

20
tasks/config/admin/templates/package.js

@ -3,11 +3,10 @@ var
;
Package.describe({
name : 'semantic:ui',
summary : 'Semantic UI (Official): a UI component framework based around useful principles from natural language.',
name : 'semantic:ui-{component}',
summary : 'Semantic UI - {Component} (official): Single component release of {component}',
version : '{version}',
git : 'git://github.com/Semantic-Org/Semantic-UI.git',
readme : 'https://github.com/Semantic-Org/README.md'
git : 'git://github.com/Semantic-Org/UI-{Component}.git',
});
Package.onUse(function(api) {
@ -16,16 +15,3 @@ Package.onUse(function(api) {
{files}
], where);
});
Package.onTest(function(api) {
api.use([
'tinytest',
'http',
'semantic:ui'
], where);
api.addFiles([
'test/meteor/fonts.js',
'test/meteor/assets.js',
], where);
});
Loading…
Cancel
Save