diff --git a/gulpfile.js b/gulpfile.js index 5ba901d3e..e42065c47 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,6 +25,7 @@ var clone = require('gulp-clone'), concat = require('gulp-concat'), concatCSS = require('gulp-concat-css'), + concatFnames = require('gulp-concat-filenames'), copy = require('gulp-copy'), debug = require('gulp-debug'), flatten = require('gulp-flatten'), @@ -40,6 +41,7 @@ var rename = require('gulp-rename'), replace = require('gulp-replace'), sourcemaps = require('gulp-sourcemaps'), + tap = require('gulp-tap'), uglify = require('gulp-uglify'), util = require('gulp-util'), watch = require('gulp-watch'), @@ -526,7 +528,6 @@ gulp.task('install', 'Set-up project for first time', function () { ; } - // determine semantic.json config if(answers.components) { json.components = answers.components; @@ -572,6 +573,30 @@ gulp.task('install', 'Set-up project for first time', function () { .pipe(gulp.dest('./')) ; } + + // write package.js + console.info('Creating package.js (Meteor)'); + var + packagedFolder = json.paths.output.packaged || output.packaged, + themesFolder = json.paths.output.themes || output.themes, + fnames = + '\n \'' + packagedFolder + 'semantic.css\',' + + '\n \'' + packagedFolder + 'semantic.js\',' + + '\n \'' + themesFolder + 'default/assets/images/flags.png\',' + + '\n \'' + themesFolder + 'default/assets/fonts/icons.eot\',' + + '\n \'' + themesFolder + 'default/assets/fonts/icons.otf\',' + + '\n \'' + themesFolder + 'default/assets/fonts/icons.svg\',' + + '\n \'' + themesFolder + 'default/assets/fonts/icons.ttf\',' + + '\n \'' + themesFolder + 'default/assets/fonts/icons.woff\'' + ; + gulp.src(release.templates.meteor) + .pipe(plumber()) + .pipe(flatten()) + .pipe(replace('{package-version}', version)) + .pipe(replace('{package-files}', fnames)) + .pipe(gulp.dest('./')) + ; + console.log(''); console.log(''); })) @@ -699,6 +724,7 @@ gulp.task('create repos', false, function(callback) { outputDirectory = release.outputRoot + component, isJavascript = fs.existsSync(output.compressed + component + '.js'), isCSS = fs.existsSync(output.compressed + component + '.css'), + assets = release.componentsAssets[component], capitalizedComponent = component.charAt(0).toUpperCase() + component.slice(1), packageName = release.packageRoot + component, repoName = release.repoRoot + capitalizedComponent, @@ -746,43 +772,48 @@ gulp.task('create repos', false, function(callback) { } }, task = { - all : component + ' creating', - repo : component + ' create repo', - bower : component + ' create bower.json', - readme : component + ' create README', - npm : component + ' create NPM Module', - notes : component + ' create release notes', - composer : component + ' create composer.json', - package : component + ' create package.json', - meteor : component + ' create package.js', - } + all : component + ' creating', + repo : component + ' create repo', + assetsPaths : component + ' get assets paths', + assets : component + ' copy assets', + bower : component + ' create bower.json', + readme : component + ' create README', + npm : component + ' create NPM Module', + notes : component + ' create release notes', + composer : component + ' create composer.json', + package : component + ' create package.json', + meteor : component + ' create package.js', + }, + taskSequence = (assets) + ? [ + task.repo, + task.assets, + task.assetsPaths, + task.npm, + task.bower, + task.readme, + task.package, + task.composer, + task.notes, + task.meteor + ] + : [ + task.repo, + task.npm, + task.bower, + task.readme, + task.package, + task.composer, + task.notes, + task.meteor + ], + fnames = '' ; - var fnames; - if(isJavascript) { - if(isCSS) { - fnames = ' \'' + component + '.js\',\n \'' + component + '.css\''; - } - else { - fnames = ' \'' + component + '.js\''; - } - } - else { - fnames = ' \'' + component + '.css\''; - } - - // Adds flags image as asset for UI-Flag - if (component == 'flag') { - fnames += ',\n \'assets/images/flags.png\''; - } - // Adds fonts as assets for UI-Icon - if (component == 'icon') { - fnames += ',\n \'assets/fonts/icons.eot\''; - fnames += ',\n \'assets/fonts/icons.otf\''; - fnames += ',\n \'assets/fonts/icons.svg\''; - fnames += ',\n \'assets/fonts/icons.ttf\''; - fnames += ',\n \'assets/fonts/icons.woff\''; - } + if(isJavascript) + fnames += ' \'' + component + '.js\',\n'; + if(isCSS) + fnames += ' \'' + component + '.css\',\n'; // copy dist files into output folder adjusting asset paths gulp.task(task.repo, false, function() { @@ -794,6 +825,32 @@ gulp.task('create repos', false, function(callback) { ; }); + // possibly copy assets + if (assets) { + var + baseFolder = source.themes + 'default/', + concatFilenamesOptions = { + newline: '', + root: source.themes + 'default/', + prepend: ' \'', + append: '\',' + } + ; + + gulp.task(task.assetsPaths, function() { + return gulp.src(baseFolder + assets, { base: baseFolder}) + .pipe(concatFnames("dummy.txt", concatFilenamesOptions)) + .pipe(tap(function(file) { fnames += file.contents; })) + ; + }); + + gulp.task(task.assets, false, function() { + return gulp.src(baseFolder + assets, { base: baseFolder}) + .pipe(gulp.dest(outputDirectory)) + ; + }); + } + // create npm module gulp.task(task.npm, false, function() { return gulp.src(release.source + component + '!(*.min|*.map).js') @@ -922,30 +979,23 @@ gulp.task('create repos', false, function(callback) { }); // create package.js - gulp.task(task.meteor, false, function() { - return gulp.src(release.templates.meteor) + var taskDeps = assets ? [task.assetsPaths] : false; + gulp.task(task.meteor, taskDeps, function() { + return gulp.src(release.templates.meteorComponent) .pipe(plumber()) .pipe(flatten()) .pipe(replace(regExp.match.name, regExp.replace.name)) .pipe(replace(regExp.match.titleName, regExp.replace.titleName)) .pipe(replace(regExp.match.mversion, regExp.replace.mversion)) .pipe(replace(regExp.match.mfiles, fnames)) + .pipe(rename('package.js')) .pipe(gulp.dest(outputDirectory)) ; }); // synchronous tasks in orchestrator? I think not gulp.task(task.all, false, function(callback) { - runSequence([ - task.repo, - task.npm, - task.bower, - task.readme, - task.package, - task.composer, - task.notes, - task.meteor - ], callback); + runSequence(taskSequence, callback); }); tasks.push(task.all); @@ -1168,4 +1218,4 @@ gulp.task('update git', false, function() { return stepRepo(); -}); \ No newline at end of file +}); diff --git a/package.js b/package.js index a1e1c9a81..c5c2fdc8c 100644 --- a/package.js +++ b/package.js @@ -2,7 +2,8 @@ Package.describe({ name: 'semantic:ui', summary: 'Semantic empowers designers and developers by creating a shared vocabulary for UI.', version: '1.0.1', - git: 'git://github.com/Semantic-Org/Semantic-UI.git#1.0' + git: 'git://github.com/Semantic-Org/Semantic-UI#1.0', + readme: 'https://github.com/Semantic-Org/Semantic-UI/blob/1.0/meteor/README.md' }); var where = 'client'; // Adds files only to the client @@ -13,12 +14,12 @@ Package.onUse(function(api) { api.addFiles([ 'dist/semantic.css', 'dist/semantic.js', + 'dist/themes/default/assets/images/flags.png', 'dist/themes/default/assets/fonts/icons.eot', 'dist/themes/default/assets/fonts/icons.otf', '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/fonts/icons.woff' ], where); }); diff --git a/package.json b/package.json index a91536494..899d55ed2 100755 --- a/package.json +++ b/package.json @@ -53,6 +53,8 @@ "gulp-watch": "x.x.x", "rtlcss": "x.x.x", "run-sequence": "x.x.x", - "wrench": "x.x.x" + "wrench": "x.x.x", + "gulp-concat-filenames": "0.0.3", + "gulp-tap": "^0.1.3" } } diff --git a/tasks/admin/release.js b/tasks/admin/release.js index 16c8d52cb..eb785add8 100644 --- a/tasks/admin/release.js +++ b/tasks/admin/release.js @@ -15,12 +15,13 @@ 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', - readme : './tasks/admin/templates/README.md', - notes : './RELEASE-NOTES.md' + 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', + notes : './RELEASE-NOTES.md' }, org : 'Semantic-Org', @@ -81,6 +82,12 @@ module.exports = { 'table', 'transition', 'video' - ] + ], + + // Assets needed by each component + componentsAssets : { + flag: 'assets/images/**', + icon: 'assets/fonts/**', + } }; diff --git a/tasks/admin/templates/package-component.js b/tasks/admin/templates/package-component.js new file mode 100644 index 000000000..e23645d10 --- /dev/null +++ b/tasks/admin/templates/package-component.js @@ -0,0 +1,16 @@ +Package.describe({ + name: 'semantic:ui-{component}', + summary: 'Semantic UI - {Component}, Single component release of {component}', + version: '{package-version}', + git: 'git://github.com/Semantic-Org/UI-{Component}.git', + //readme: 'git://github.com/Semantic-Org/UI-{Component}/tree/master/meteor/README.md' +}); + +var where = 'client'; // Adds files only to the client + +Package.onUse(function(api) { + api.versionsFrom('1.0'); + + api.addFiles([ +{package-files} ], where); +}); diff --git a/tasks/admin/templates/package.js b/tasks/admin/templates/package.js index 0e8118dba..8c1dcea26 100644 --- a/tasks/admin/templates/package.js +++ b/tasks/admin/templates/package.js @@ -1,9 +1,9 @@ Package.describe({ - name: 'semantic:ui-{component}', - summary: 'Semantic UI - {Component}, Single component release of {component}', + name: 'semantic:ui', + summary: 'Semantic empowers designers and developers by creating a shared vocabulary for UI.', version: '{package-version}', - git: 'git://github.com/Semantic-Org/UI-{Component}.git', - //readme: 'git://github.com/Semantic-Org/UI-{Component}/tree/master/meteor/README.md' + git: 'git://github.com/Semantic-Org/Semantic-UI.git#1.0', + readme: 'https://github.com/Semantic-Org/Semantic-UI/blob/1.0/meteor/README.md' }); var where = 'client'; // Adds files only to the client @@ -11,7 +11,19 @@ var where = 'client'; // Adds files only to the client Package.onUse(function(api) { api.versionsFrom('1.0'); + api.addFiles([{package-files} + ], where); +}); + +Package.onTest(function(api) { + api.use([ + 'tinytest', + 'http', + 'semantic:ui' + ], where); + api.addFiles([ -{package-files} + 'meteor/tests/test_fonts.js', + 'meteor/tests/test_images.js', ], where); -}); \ No newline at end of file +}); diff --git a/tasks/defaults.js b/tasks/defaults.js index 10083cdee..c11f0f1be 100755 --- a/tasks/defaults.js +++ b/tasks/defaults.js @@ -46,6 +46,7 @@ module.exports = { composer : 'composer.json', config : './semantic.json', npm : './package.json', + meteor : './package.js', site : './src/site', theme : './src/theme.config' }, @@ -66,4 +67,4 @@ module.exports = { }, clean : 'dist/' } -}; \ No newline at end of file +};