From 2bc5d6fd3fd850e548281eb6fcb772225fd21dfb Mon Sep 17 00:00:00 2001 From: jlukic Date: Fri, 16 Jan 2015 16:40:32 -0500 Subject: [PATCH] Iterating on gulpfile restructure --- gulpfile.js | 176 +++++++++++---------- package.js | 27 ++-- package.json | 2 - tasks/admin/templates/package-component.js | 18 ++- tasks/admin/templates/package.js | 8 +- 5 files changed, 122 insertions(+), 109 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b172a6568..2af544536 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,57 +16,40 @@ var del = require('del'), extend = require('extend'), fs = require('fs'), + + // unsure path = require('path'), - runSequence = require('run-sequence'), - wrench = require('wrench'), - // gulp dependencies + // watch / build deps autoprefixer = require('gulp-autoprefixer'), chmod = require('gulp-chmod'), clone = require('gulp-clone'), concat = require('gulp-concat'), - concatCSS = require('gulp-concat-css'), - concatFileNames = require('gulp-concat-filenames'), copy = require('gulp-copy'), debug = require('gulp-debug'), flatten = require('gulp-flatten'), header = require('gulp-header'), - jeditor = require('gulp-json-editor'), karma = require('gulp-karma'), less = require('gulp-less'), minifyCSS = require('gulp-minify-css'), - notify = require('gulp-notify'), plumber = require('gulp-plumber'), print = require('gulp-print'), - prompt = require('gulp-prompt'), rename = require('gulp-rename'), replace = require('gulp-replace'), - rtlcss = require('gulp-rtlcss'), - sourcemaps = require('gulp-sourcemaps'), - tap = require('gulp-tap'), uglify = require('gulp-uglify'), util = require('gulp-util'), watch = require('gulp-watch'), + // rtl + rtlcss = require('gulp-rtlcss'), + // config banner = require('./tasks/banner'), comments = require('./tasks/comments'), defaults = require('./tasks/defaults'), log = require('./tasks/log'), - questions = require('./tasks/questions'), settings = require('./tasks/gulp-settings'), - // admin - release = require('./tasks/admin/release'), - git = require('gulp-git'), - githubAPI = require('github'), - - oAuth = fs.existsSync('./tasks/admin/oauth.js') - ? require('./tasks/admin/oauth') - : false, - github, - - // local runSetup = false, overwrite = true, @@ -136,14 +119,6 @@ var : 'Unknown' ; - // create glob for matching filenames from components in semantic.json - componentGlob = (typeof config.components == 'object') - ? (config.components.length > 1) - ? '{' + config.components.join(',') + '}' - : config.components[0] - : '{' + defaults.components.join(',') + '}' - ; - // relative asset paths for css assetPaths = { uncompressed : path.relative(output.uncompressed, output.themes).replace(/\\/g,'/'), @@ -163,6 +138,15 @@ var } } clean = base + clean; + + // create glob for matching filenames from components in semantic.json + componentGlob = (typeof config.components == 'object') + ? (config.components.length > 1) + ? '{' + config.components.join(',') + '}' + : config.components[0] + : '{' + defaults.components.join(',') + '}' + ; + } ; @@ -250,7 +234,6 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb // unified css stream stream = gulp.src(srcPath) .pipe(plumber()) - //.pipe(sourcemaps.init()) .pipe(less(settings.less)) .pipe(replace(comments.variables.in, comments.variables.out)) .pipe(replace(comments.large.in, comments.large.out)) @@ -266,7 +249,6 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb uncompressedStream .pipe(plumber()) .pipe(replace(assetPaths.source, assetPaths.uncompressed)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(gulp.dest(output.uncompressed)) @@ -282,7 +264,6 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb .pipe(replace(assetPaths.source, assetPaths.compressed)) .pipe(minifyCSS(settings.minify)) .pipe(rename(settings.rename.minCSS)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(gulp.dest(output.compressed)) @@ -299,10 +280,10 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb }) ; - // watch for changes in assets + // watch for changes in assets that match component names (or their plural) gulp .watch([ - source.themes + '**/assets/**' + source.themes + '**/assets/**/' + componentGlob + '?(s).*' ], function(file) { // copy assets gulp.src(file.path, { base: source.themes }) @@ -323,7 +304,6 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb .pipe(chmod(config.permission)) .pipe(gulp.dest(output.uncompressed)) .pipe(print(log.created)) - .pipe(sourcemaps.init()) .pipe(uglify(settings.uglify)) .pipe(rename(settings.rename.minJS)) .pipe(chmod(config.permission)) @@ -364,7 +344,7 @@ gulp.task('build', 'Builds all files from source', function(callback) { assetPaths.source = '../../themes'; // path.relative returns wrong path (hardcoded for src) // copy assets - gulp.src(source.themes + '**/assets/**') + gulp.src(source.themes + '**/assets/**/' + componentGlob + '?(s).*') .pipe(chmod(config.permission)) .pipe(gulp.dest(output.themes)) ; @@ -376,7 +356,6 @@ gulp.task('build', 'Builds all files from source', function(callback) { .pipe(chmod(config.permission)) .pipe(gulp.dest(output.uncompressed)) .pipe(print(log.created)) - // .pipe(sourcemaps.init()) .pipe(uglify(settings.uglify)) .pipe(rename(settings.rename.minJS)) .pipe(header(banner, settings.header)) @@ -392,7 +371,6 @@ gulp.task('build', 'Builds all files from source', function(callback) { // unified css stream stream = gulp.src(source.definitions + '**/' + componentGlob + '.less') .pipe(plumber()) - //.pipe(sourcemaps.init()) .pipe(less(settings.less)) .pipe(flatten()) .pipe(replace(comments.variables.in, comments.variables.out)) @@ -409,7 +387,6 @@ gulp.task('build', 'Builds all files from source', function(callback) { uncompressedStream .pipe(plumber()) .pipe(replace(assetPaths.source, assetPaths.uncompressed)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(gulp.dest(output.uncompressed)) @@ -425,7 +402,6 @@ gulp.task('build', 'Builds all files from source', function(callback) { .pipe(replace(assetPaths.source, assetPaths.compressed)) .pipe(minifyCSS(settings.minify)) .pipe(rename(settings.rename.minCSS)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(gulp.dest(output.compressed)) @@ -446,11 +422,11 @@ gulp.task('version', 'Displays current version of Semantic', function(callback) console.log('Semantic UI ' + version); }); + /******************************* RTL Tasks *******************************/ - /* Watch RTL */ gulp.task('watch rtl', 'Watch for site/theme changes (Default Task)', function(callback) { @@ -513,7 +489,6 @@ gulp.task('watch rtl', 'Watch for site/theme changes (Default Task)', function(c // unified css stream stream = gulp.src(srcPath) .pipe(plumber()) - //.pipe(sourcemaps.init()) .pipe(less(settings.less)) .pipe(replace(comments.variables.in, comments.variables.out)) .pipe(replace(comments.large.in, comments.large.out)) @@ -530,7 +505,6 @@ gulp.task('watch rtl', 'Watch for site/theme changes (Default Task)', function(c uncompressedStream .pipe(plumber()) .pipe(replace(assetPaths.source, assetPaths.uncompressed)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(rename(settings.rename.rtlCSS)) @@ -546,7 +520,6 @@ gulp.task('watch rtl', 'Watch for site/theme changes (Default Task)', function(c .pipe(clone()) .pipe(replace(assetPaths.source, assetPaths.compressed)) .pipe(minifyCSS(settings.minify)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(rename(settings.rename.rtlMinCSS)) @@ -588,7 +561,6 @@ gulp.task('watch rtl', 'Watch for site/theme changes (Default Task)', function(c .pipe(chmod(config.permission)) .pipe(gulp.dest(output.uncompressed)) .pipe(print(log.created)) - .pipe(sourcemaps.init()) .pipe(uglify(settings.uglify)) .pipe(rename(settings.rename.minJS)) .pipe(chmod(config.permission)) @@ -636,7 +608,6 @@ gulp.task('build rtl', 'Builds all files from source', function(callback) { .pipe(chmod(config.permission)) .pipe(gulp.dest(output.uncompressed)) .pipe(print(log.created)) - // .pipe(sourcemaps.init()) .pipe(uglify(settings.uglify)) .pipe(rename(settings.rename.minJS)) .pipe(header(banner, settings.header)) @@ -652,7 +623,6 @@ gulp.task('build rtl', 'Builds all files from source', function(callback) { // unified css stream stream = gulp.src(source.definitions + '**/' + componentGlob + '.less') .pipe(plumber()) - //.pipe(sourcemaps.init()) .pipe(less(settings.less)) .pipe(flatten()) .pipe(replace(comments.variables.in, comments.variables.out)) @@ -670,7 +640,6 @@ gulp.task('build rtl', 'Builds all files from source', function(callback) { uncompressedStream .pipe(plumber()) .pipe(replace(assetPaths.source, assetPaths.uncompressed)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(rename(settings.rename.rtlCSS)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) @@ -687,7 +656,6 @@ gulp.task('build rtl', 'Builds all files from source', function(callback) { .pipe(replace(assetPaths.source, assetPaths.compressed)) .pipe(minifyCSS(settings.minify)) .pipe(rename(settings.rename.rtlMinCSS)) - //.pipe(sourcemaps.write('/', settings.sourcemap)) .pipe(header(banner, settings.header)) .pipe(chmod(config.permission)) .pipe(gulp.dest(output.compressed)) @@ -773,10 +741,19 @@ gulp.task('package compressed js', false, function() { ; }); +/******************************* + Install Tasks +*******************************/ + +var + // install dependencies + jeditor = require('gulp-json-editor'), + prompt = require('gulp-prompt'), + wrench = require('wrench'), -/*-------------- - Config ----------------*/ + questions = require('./tasks/questions'), + +; gulp.task('check install', false, function () { setTimeout(function() { @@ -934,16 +911,36 @@ gulp.task('install', 'Set-up project for first time', function () { *******************************/ var + // admin dependencies + concatFileNames = require('gulp-concat-filenames'), + git = require('gulp-git'), + githubAPI = require('github'), + runSequence = require('run-sequence'), + tap = require('gulp-tap'), + + // admin files adminQuestions = require('./tasks/admin/questions'), - newVersion = false + release = require('./tasks/admin/release'), + + // stores oauth info for GitHub API + oAuth = fs.existsSync('./tasks/admin/oauth.js') + ? require('./tasks/admin/oauth') + : false, + github, + ; + +/*-------------- + Docs +---------------*/ + + /* Moves watched files to static site generator output */ gulp.task('serve-docs', false, function () { config = require('./tasks/admin/docs.json'); getConfigValues(); - // copy source files gulp .watch([ @@ -981,10 +978,18 @@ gulp.task('build-docs', false, function () { /* Release */ gulp.task('release', false, function() { - // gulp bump - // Ask for release type (minor, major, patch) - // Bump package.json - // Bump composer.json + + // gulp build + runSequence( + 'build', + 'create files' + ); + +}); + +/* Release All */ +gulp.task('release all', false, function() { + if(!oAuth) { console.error('Must add node include tasks/admin/oauth.js with oauth token for GitHub'); return; @@ -1003,17 +1008,12 @@ gulp.task('release', false, function() { }); // gulp build - //runSequence('update git'); - runSequence('build', 'create repos', 'update git'); - - // #Create SCSS Version - // #Create RTL Release - -}); + runSequence( + 'build', + 'create components', + 'update component repos' + ); -/* Build Component Release Only */ -gulp.task('build release', false, function() { - runSequence('build', 'create repos'); }); @@ -1021,8 +1021,18 @@ gulp.task('build release', false, function() { Internal ---------------*/ - -gulp.task('create repos', false, function(callback) { +/* + This will create individual component repositories for each SUI component + + * copy component files from release + * create commonjs files as index.js for NPM release + * create release notes that filter only items related to component + * custom package.json file from template + * create bower.json from template + * create README from template + * create meteor.js file +*/ +gulp.task('create components', false, function(callback) { var stream, index, @@ -1032,7 +1042,7 @@ gulp.task('create repos', false, function(callback) { for(index in release.components) { var - component = release.components[index] + component = release.components[index] ; // streams... designed to save time and make coding fun... @@ -1242,23 +1252,23 @@ gulp.task('create repos', false, function(callback) { ; }); - // Creates Meteor package.js - // Tries to list assets to be added among the files list - // inside the package.js file for Meteor + // Creates component meteor package.js gulp.task(task.meteor, function() { - var fileNames = ''; + var + fileNames = '' + ; if(isJavascript) { fileNames += ' \'' + component + '.js\',\n'; } if(isCSS) { fileNames += ' \'' + component + '.css\',\n'; } - return gulp.src(outputDirectory + '/assets/**', { base: outputDirectory}) + return gulp.src(outputDirectory + '/assets/**/' + component + '?(s).*', { base: outputDirectory}) .pipe(concatFileNames('dummy.txt', { - newline: '', - root: outputDirectory, - prepend: ' \'', - append: '\',' + newline : '', + root : outputDirectory, + prepend : ' \'', + append : '\',' })) .pipe(tap(function(file) { fileNames += file.contents;})) .on('end', function(){ @@ -1343,7 +1353,7 @@ gulp.task('register repos', false, function(callback) { stepRepo(); }); -gulp.task('update git', false, function() { +gulp.task('update component repos', false, function() { var index = -1, total = release.components.length, diff --git a/package.js b/package.js index 4aaf8c407..8dfcf3d2f 100644 --- a/package.js +++ b/package.js @@ -1,16 +1,17 @@ +var + where = 'client' // Adds files only to the client +; + Package.describe({ - name: 'semantic:ui', - summary: 'Semantic (official): a UI component framework based around useful principles from natural language.', - version: '1.7.0', - git: 'git://github.com/Semantic-Org/Semantic-UI.git', - readme: 'https://github.com/Semantic-Org/Semantic-UI/blob/master/meteor/README.md' + git : 'git://github.com/Semantic-Org/Semantic-UI.git', + name : 'semantic:ui', + readme : 'https://github.com/Semantic-Org/Semantic-UI/blob/master/meteor/README.md', + summary : 'Semantic (official): a UI component framework based around useful principles from natural language.', + version : '1.7.0' }); -var where = 'client'; // Adds files only to the client - Package.onUse(function(api) { api.versionsFrom('1.0'); - api.addFiles([ 'dist/semantic.css', 'dist/semantic.js', @@ -19,19 +20,19 @@ Package.onUse(function(api) { 'dist/themes/default/assets/fonts/icons.svg', 'dist/themes/default/assets/fonts/icons.ttf', 'dist/themes/default/assets/fonts/icons.woff', - 'dist/themes/default/assets/images/flags.png', + 'dist/themes/default/assets/images/flags.png' ], where); }); Package.onTest(function(api) { api.use([ - 'tinytest', 'http', - 'semantic:ui' + 'semantic:ui', + 'tinytest' ], where); api.addFiles([ - 'meteor/tests/test_fonts.js', - 'meteor/tests/test_images.js', + 'test/meteor/assets.js', + 'test/meteor/fonts.js', ], where); }); diff --git a/package.json b/package.json index d7b8bf9c4..6f34789b6 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "gulp-concat-filenames": "^0.0.3", "gulp-copy": "0.0.2", "gulp-csscomb": "^3.0.3", - "gulp-debug": "^1.0.1", "gulp-flatten": "0.0.4", "gulp-git": "^0.5.5", "gulp-header": "^1.2.2", @@ -50,7 +49,6 @@ "gulp-rename": "^1.2.0", "gulp-replace": "^0.5.0", "gulp-rtlcss": "^0.1.2", - "gulp-sourcemaps": "^1.2.8", "gulp-tap": "^0.1.3", "gulp-uglify": "^1.0.1", "gulp-util": "^3.0.1", diff --git a/tasks/admin/templates/package-component.js b/tasks/admin/templates/package-component.js index 63911e850..0f4c199ab 100644 --- a/tasks/admin/templates/package-component.js +++ b/tasks/admin/templates/package-component.js @@ -1,15 +1,17 @@ +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: '{package-version}', - git: 'git://github.com/Semantic-Org/UI-{Component}.git', + 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', }); -var where = 'client'; // Adds files only to the client - Package.onUse(function(api) { api.versionsFrom('1.0'); - api.addFiles([ -{package-files} ], where); + {files} + ], where); }); diff --git a/tasks/admin/templates/package.js b/tasks/admin/templates/package.js index 4a09cbdb7..1a59aff47 100644 --- a/tasks/admin/templates/package.js +++ b/tasks/admin/templates/package.js @@ -4,15 +4,17 @@ var Package.describe({ name : 'semantic:ui', - summary : 'Semantic (official): a UI component framework based around useful principles from natural language.', + summary : 'Semantic UI (Official): a UI component framework based around useful principles from natural language.', version : '{version}', git : 'git://github.com/Semantic-Org/Semantic-UI.git', - readme : 'https://github.com/Semantic-Org/Semantic-UI/blob/master/meteor/README.md' + readme : 'https://github.com/Semantic-Org/README.md' }); Package.onUse(function(api) { api.versionsFrom('1.0'); - api.addFiles([ {files} ], where); + api.addFiles([ + {files} + ], where); }); Package.onTest(function(api) {