Browse Source
Merge branch 'admin-tasks' of github.com:Semantic-Org/Semantic-UI into next
pull/1845/head
Merge branch 'admin-tasks' of github.com:Semantic-Org/Semantic-UI into next
pull/1845/head
16 changed files with 690 additions and 77 deletions
Split View
Diff Options
-
2package.json
-
13tasks/admin/components/create.js
-
30tasks/admin/components/init.js
-
41tasks/admin/components/update.js
-
134tasks/admin/distributions/create.js
-
170tasks/admin/distributions/init.js
-
180tasks/admin/distributions/update.js
-
13tasks/admin/release-all.js
-
16tasks/admin/release.js
-
28tasks/collections/admin.js
-
35tasks/config/admin/release.js
-
0tasks/config/admin/templates/component-package.js
-
47tasks/config/admin/templates/css-package.js
-
47tasks/config/admin/templates/less-package.js
-
7tasks/docs/serve.js
-
4tasks/watch.js
@ -0,0 +1,134 @@ |
|||
/******************************* |
|||
Create Distributions |
|||
*******************************/ |
|||
|
|||
/* |
|||
This will create individual distribution repositories for each SUI distribution |
|||
|
|||
* copy distribution files to release |
|||
* update package.json file |
|||
*/ |
|||
|
|||
var |
|||
gulp = require('gulp'), |
|||
|
|||
// 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'), |
|||
jsonEditor = require('gulp-json-editor'), |
|||
plumber = require('gulp-plumber'), |
|||
rename = require('gulp-rename'), |
|||
replace = require('gulp-replace'), |
|||
tap = require('gulp-tap'), |
|||
|
|||
// config
|
|||
config = require('../../config/user'), |
|||
release = require('../../config/admin/release'), |
|||
project = require('../../config/project/release'), |
|||
|
|||
// shorthand
|
|||
version = project.version, |
|||
output = config.paths.output |
|||
|
|||
; |
|||
|
|||
|
|||
module.exports = function(callback) { |
|||
var |
|||
stream, |
|||
index, |
|||
tasks = [] |
|||
; |
|||
|
|||
for(index in release.distributions) { |
|||
|
|||
var |
|||
distribution = release.distributions[index] |
|||
; |
|||
|
|||
// streams... designed to save time and make coding fun...
|
|||
(function(distribution) { |
|||
|
|||
var |
|||
distLowerCase = distribution.toLowerCase(), |
|||
outputDirectory = path.join(release.outputRoot, distLowerCase), |
|||
packageFile = path.join(outputDirectory, release.files.npm), |
|||
repoName = release.distRepoRoot + distribution, |
|||
regExp = { |
|||
match : { |
|||
version : '{version}' |
|||
} |
|||
}, |
|||
task = { |
|||
all : distribution + ' copying files', |
|||
repo : distribution + ' create repo', |
|||
meteor : distribution + ' create meteor package.js', |
|||
package : distribution + ' create package.json' |
|||
} |
|||
; |
|||
|
|||
|
|||
gulp.task(task.meteor, function() { |
|||
gulp.src(release.templates.meteor[distLowerCase]) |
|||
.pipe(plumber()) |
|||
.pipe(debug()) |
|||
.pipe(flatten()) |
|||
.pipe(replace(regExp.match.version, version)) |
|||
.pipe(rename(release.files.meteor)) |
|||
.pipe(gulp.dest(outputDirectory)) |
|||
; |
|||
}); |
|||
|
|||
if(distribution == 'CSS') { |
|||
gulp.task(task.repo, function() { |
|||
return gulp.src('./dist/themes/default/**/*', { base: './dist/' }) |
|||
.pipe(gulp.src('./dist/components/*', { base: './dist/' })) |
|||
.pipe(gulp.src('./dist/*', { base: './dist/' })) |
|||
.pipe(plumber()) |
|||
.pipe(gulp.dest(outputDirectory)) |
|||
; |
|||
}); |
|||
} |
|||
else if(distribution == 'LESS') { |
|||
gulp.task(task.repo, function() { |
|||
return gulp.src('./src/theme.config.example', { base: './src/' }) |
|||
.pipe(gulp.src('./src/definitions/**/*', { base: './src/' })) |
|||
.pipe(gulp.src('./src/_site/**/*', { base: './src/' })) |
|||
.pipe(gulp.src('./src/themes/**/*', { base: './src/' })) |
|||
.pipe(plumber()) |
|||
.pipe(gulp.dest(outputDirectory)) |
|||
; |
|||
}); |
|||
} |
|||
|
|||
// extend package.json
|
|||
gulp.task(task.package, function() { |
|||
return gulp.src(packageFile) |
|||
.pipe(plumber()) |
|||
.pipe(jsonEditor(function(package) { |
|||
if(version) { |
|||
package.version = version; |
|||
} |
|||
return package; |
|||
})) |
|||
.pipe(gulp.dest(outputDirectory)) |
|||
; |
|||
}); |
|||
|
|||
tasks.push(task.meteor); |
|||
tasks.push(task.repo); |
|||
tasks.push(task.package); |
|||
|
|||
})(distribution); |
|||
} |
|||
runSequence(tasks, callback); |
|||
}; |
@ -0,0 +1,170 @@ |
|||
/******************************* |
|||
Init Dist Repos |
|||
*******************************/ |
|||
|
|||
/* |
|||
|
|||
This task pulls the latest version of distribution from GitHub |
|||
|
|||
* Creates new repo if doesnt exist (locally & GitHub) |
|||
* Adds remote it doesnt exists |
|||
* Pulls latest changes from repo |
|||
|
|||
*/ |
|||
|
|||
var |
|||
gulp = require('gulp'), |
|||
|
|||
// node dependencies
|
|||
console = require('better-console'), |
|||
del = require('del'), |
|||
fs = require('fs'), |
|||
path = require('path'), |
|||
git = require('gulp-git'), |
|||
githubAPI = require('github'), |
|||
mkdirp = require('mkdirp'), |
|||
|
|||
// 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, |
|||
|
|||
// shorthand
|
|||
version = project.version |
|||
; |
|||
|
|||
module.exports = function(callback) { |
|||
|
|||
var |
|||
index = -1, |
|||
total = release.distributions.length, |
|||
timer, |
|||
stream, |
|||
stepRepo |
|||
; |
|||
|
|||
if(!oAuth) { |
|||
console.error('Must add oauth token for GitHub in tasks/config/admin/oauth.js'); |
|||
return; |
|||
} |
|||
|
|||
// Do Git commands synchronously per component, to avoid issues
|
|||
stepRepo = function() { |
|||
|
|||
index = index + 1; |
|||
|
|||
if(index >= total) { |
|||
callback(); |
|||
return; |
|||
} |
|||
|
|||
var |
|||
component = release.distributions[index], |
|||
lowerCaseComponent = component.toLowerCase(), |
|||
outputDirectory = path.resolve(release.outputRoot + lowerCaseComponent), |
|||
repoName = release.distRepoRoot + component, |
|||
|
|||
gitOptions = { cwd: outputDirectory }, |
|||
pullOptions = { args: '-q', cwd: outputDirectory, quiet: true }, |
|||
resetOptions = { args: '-q --hard', cwd: outputDirectory, quiet: true }, |
|||
|
|||
gitURL = 'https://github.com/' + release.org + '/' + repoName + '.git', |
|||
repoURL = 'https://github.com/' + release.org + '/' + repoName + '/', |
|||
localRepoSetup = fs.existsSync(path.join(outputDirectory, '.git')) |
|||
; |
|||
|
|||
console.log('Processing repository: ' + outputDirectory); |
|||
|
|||
// create folder if doesn't exist
|
|||
if( !fs.existsSync(outputDirectory) ) { |
|||
mkdirp.sync(outputDirectory); |
|||
} |
|||
|
|||
// clean folder
|
|||
if(release.outputRoot.search('../repos') == 0) { |
|||
console.info('Cleaning dir', outputDirectory); |
|||
del.sync([outputDirectory + '**/*'], {silent: true, force: true}); |
|||
} |
|||
|
|||
// set-up local repo
|
|||
function setupRepo() { |
|||
if(localRepoSetup) { |
|||
addRemote(); |
|||
} |
|||
else { |
|||
initRepo(); |
|||
} |
|||
} |
|||
|
|||
function initRepo() { |
|||
console.info('Initializing repository for ' + component); |
|||
git.init(gitOptions, function(error) { |
|||
if(error) { |
|||
console.error('Error initializing repo', error); |
|||
} |
|||
addRemote(); |
|||
}); |
|||
} |
|||
|
|||
function createRepo() { |
|||
console.info('Creating GitHub repo ' + repoURL); |
|||
github.repos.createFromOrg({ |
|||
org : release.org, |
|||
name : repoName, |
|||
homepage : release.homepage |
|||
}, function() { |
|||
setupRepo(); |
|||
}); |
|||
} |
|||
|
|||
function addRemote() { |
|||
console.info('Adding remote origin as ' + gitURL); |
|||
git.addRemote('origin', gitURL, gitOptions, function(){ |
|||
pullFiles(); |
|||
}); |
|||
} |
|||
|
|||
function pullFiles() { |
|||
console.info('Pulling ' + component + ' files'); |
|||
git.pull('origin', 'master', pullOptions, function(error) { |
|||
resetFiles(); |
|||
}); |
|||
} |
|||
|
|||
function resetFiles() { |
|||
console.info('Resetting files to head'); |
|||
git.reset('HEAD', resetOptions, function(error) { |
|||
nextRepo(); |
|||
}); |
|||
} |
|||
|
|||
function nextRepo() { |
|||
//console.log('Sleeping for 1 second...');
|
|||
// avoid rate throttling
|
|||
global.clearTimeout(timer); |
|||
timer = global.setTimeout(function() { |
|||
stepRepo() |
|||
}, 0); |
|||
} |
|||
|
|||
|
|||
if(localRepoSetup) { |
|||
pullFiles(); |
|||
} |
|||
else { |
|||
setupRepo(); |
|||
// createRepo() only use to create remote repo (easier to do manually)
|
|||
} |
|||
|
|||
}; |
|||
|
|||
stepRepo(); |
|||
|
|||
|
|||
}; |
@ -0,0 +1,180 @@ |
|||
/******************************* |
|||
Update Repos |
|||
*******************************/ |
|||
|
|||
/* |
|||
|
|||
This task update all SUI individual distribution repos with new versions of distributions |
|||
|
|||
* Commits changes from create repo |
|||
* Pushes changes to GitHub |
|||
* Tag new releases if version changed in main repo |
|||
|
|||
*/ |
|||
|
|||
var |
|||
gulp = require('gulp'), |
|||
|
|||
// node dependencies
|
|||
console = require('better-console'), |
|||
fs = require('fs'), |
|||
path = require('path'), |
|||
git = require('gulp-git'), |
|||
githubAPI = require('github'), |
|||
requireDotFile = require('require-dot-file'), |
|||
|
|||
// 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, |
|||
|
|||
// shorthand
|
|||
version = project.version |
|||
; |
|||
|
|||
module.exports = function() { |
|||
|
|||
var |
|||
index = -1, |
|||
total = release.distributions.length, |
|||
timer, |
|||
stream, |
|||
stepRepo |
|||
; |
|||
|
|||
if(!oAuth) { |
|||
console.error('Must add oauth token for GitHub in tasks/config/admin/oauth.js'); |
|||
return; |
|||
} |
|||
|
|||
// Do Git commands synchronously per distribution, to avoid issues
|
|||
stepRepo = function() { |
|||
|
|||
index = index + 1; |
|||
if(index >= total) { |
|||
return; |
|||
} |
|||
|
|||
var |
|||
distribution = release.distributions[index], |
|||
outputDirectory = path.resolve(path.join(release.outputRoot, distribution.toLowerCase() )), |
|||
repoName = release.distRepoRoot + distribution, |
|||
|
|||
gitURL = 'https://github.com/' + release.org + '/' + repoName + '.git', |
|||
repoURL = 'https://github.com/' + release.org + '/' + repoName + '/', |
|||
|
|||
commitArgs = (oAuth.name !== undefined && oAuth.email !== undefined) |
|||
? '--author "' + oAuth.name + ' <' + oAuth.email + '>"' |
|||
: '', |
|||
|
|||
distributionPackage = fs.existsSync(outputDirectory + 'package.json' ) |
|||
? require(outputDirectory + 'package.json') |
|||
: false, |
|||
|
|||
isNewVersion = (version && distributionPackage.version != version), |
|||
|
|||
commitMessage = (isNewVersion) |
|||
? 'Updated distribution to version ' + version |
|||
: 'Updated files from main repo', |
|||
|
|||
gitOptions = { cwd: outputDirectory }, |
|||
commitOptions = { args: commitArgs, cwd: outputDirectory }, |
|||
releaseOptions = { tag_name: version, owner: release.org, repo: repoName }, |
|||
|
|||
fileModeOptions = { args : 'config core.fileMode false', cwd: outputDirectory }, |
|||
usernameOptions = { args : 'config user.name "' + oAuth.name + '"', cwd: outputDirectory }, |
|||
emailOptions = { args : 'config user.email "' + oAuth.email + '"', cwd: outputDirectory }, |
|||
|
|||
localRepoSetup = fs.existsSync(path.join(outputDirectory, '.git')), |
|||
canProceed = true |
|||
; |
|||
|
|||
|
|||
console.info('Processing repository:' + outputDirectory); |
|||
|
|||
function setConfig() { |
|||
git.exec(fileModeOptions, function() { |
|||
git.exec(usernameOptions, function () { |
|||
git.exec(emailOptions, function () { |
|||
commitFiles(); |
|||
}); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
// standard path
|
|||
function commitFiles() { |
|||
// commit files
|
|||
console.info('Committing ' + distribution + ' files', commitArgs); |
|||
gulp.src('**/*', gitOptions) |
|||
.pipe(git.add(gitOptions)) |
|||
.pipe(git.commit(commitMessage, commitOptions)) |
|||
.on('error', function(error) { |
|||
// canProceed = false; bug in git commit <https://github.com/stevelacy/gulp-git/issues/49>
|
|||
}) |
|||
.on('finish', function(callback) { |
|||
if(canProceed) { |
|||
pushFiles(); |
|||
} |
|||
else { |
|||
console.info('Nothing new to commit'); |
|||
nextRepo(); |
|||
} |
|||
}) |
|||
; |
|||
} |
|||
|
|||
// push changess to remote
|
|||
function pushFiles() { |
|||
console.info('Pushing files for ' + distribution); |
|||
git.push('origin', 'master', { args: '', cwd: outputDirectory }, function(error) { |
|||
console.info('Push completed successfully'); |
|||
createRelease(); |
|||
}); |
|||
} |
|||
|
|||
// create release on GitHub.com
|
|||
function createRelease() { |
|||
console.log('Tagging release as ', version); |
|||
github.releases.createRelease(releaseOptions, function() { |
|||
nextRepo(); |
|||
tagFiles(); |
|||
}); |
|||
tagFiles(); |
|||
} |
|||
|
|||
// Tags files locally
|
|||
function tagFiles() { |
|||
console.info('Tagging new version ' + distribution, version); |
|||
git.tag(version, 'Updated version from semantic-ui (automatic)', function (err) { |
|||
nextRepo(); |
|||
}); |
|||
} |
|||
|
|||
// Steps to next repository
|
|||
function nextRepo() { |
|||
console.log('Sleeping for 1 second...'); |
|||
// avoid rate throttling
|
|||
global.clearTimeout(timer); |
|||
timer = global.setTimeout(stepRepo, 500); |
|||
} |
|||
|
|||
|
|||
if(localRepoSetup) { |
|||
setConfig(); |
|||
} |
|||
else { |
|||
console.error('Repository must be setup before running update distributions'); |
|||
} |
|||
|
|||
}; |
|||
|
|||
stepRepo(); |
|||
|
|||
}; |
@ -0,0 +1,47 @@ |
|||
var |
|||
where = 'client' // Adds files only to the client
|
|||
; |
|||
|
|||
Package.describe({ |
|||
name : 'semantic:ui-css', |
|||
summary : 'Semantic UI - CSS Release of Semantic UI', |
|||
version : '{version}', |
|||
git : 'git://github.com/Semantic-Org/Semantic-UI-CSS.git', |
|||
}); |
|||
|
|||
Package.onUse(function(api) { |
|||
|
|||
var |
|||
fs = require('fs'), |
|||
path = require('path'), |
|||
files, |
|||
walk |
|||
; |
|||
|
|||
// recursive sync walk
|
|||
walk = function(dir) { |
|||
var |
|||
dir = dir || __dirname, |
|||
list = fs.readdirSync(dir), |
|||
files = [] |
|||
; |
|||
list.forEach(function(file) { |
|||
var |
|||
filePath = path.join(dir, file), |
|||
stat = fs.statSync(filePath) |
|||
; |
|||
if(stat && stat.isDirectory() && file !== 'node_modules') { |
|||
files = files.concat(walk(filePath)); |
|||
} |
|||
else { |
|||
files.push(filePath); |
|||
} |
|||
}) |
|||
return files |
|||
} |
|||
files = walk(); |
|||
|
|||
api.versionsFrom('1.0'); |
|||
api.addFiles(files, 'clent'); |
|||
|
|||
}); |
@ -0,0 +1,47 @@ |
|||
var |
|||
where = 'client' // Adds files only to the client
|
|||
; |
|||
|
|||
Package.describe({ |
|||
name : 'semantic:ui', |
|||
summary : 'Semantic UI - LESS Release of Semantic UI', |
|||
version : '{version}', |
|||
git : 'git://github.com/Semantic-Org/Semantic-UI-LESS.git', |
|||
}); |
|||
|
|||
Package.onUse(function(api) { |
|||
|
|||
var |
|||
fs = require('fs'), |
|||
path = require('path'), |
|||
files, |
|||
walk |
|||
; |
|||
|
|||
// recursive sync walk
|
|||
walk = function(dir) { |
|||
var |
|||
dir = dir || __dirname, |
|||
list = fs.readdirSync(dir), |
|||
files = [] |
|||
; |
|||
list.forEach(function(file) { |
|||
var |
|||
filePath = path.join(dir, file), |
|||
stat = fs.statSync(filePath) |
|||
; |
|||
if(stat && stat.isDirectory() && file !== 'node_modules') { |
|||
files = files.concat(walk(filePath)); |
|||
} |
|||
else { |
|||
files.push(filePath); |
|||
} |
|||
}) |
|||
return files |
|||
} |
|||
files = walk(); |
|||
|
|||
api.versionsFrom('1.0'); |
|||
api.addFiles(files, 'clent'); |
|||
|
|||
}); |
Write
Preview
Loading…
Cancel
Save