From 69dcb76e6b4095f221dbe63e8658a18594a39d83 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 2 Mar 2012 16:45:10 +0100 Subject: First iteration on grunt-based build. lint, qunit, concat, min and zip all work, but all have various limiations. --- grunt.js | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 grunt.js (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js new file mode 100644 index 000000000..b935a0bc7 --- /dev/null +++ b/grunt.js @@ -0,0 +1,99 @@ +/*global config:true, task:true*/ +var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); +config.init({ + pkg: '', + meta: { + banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + + '<%= template.today("m/d/yyyy") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' + }, + concat: { + // 'dist/ui/jquery-ui.js': ['', ''] + 'dist/jquery-ui.js': coreFiles.map(function(file) { + return 'ui/' + file; + }).concat(file.expand('ui/*.js').filter(function(file) { + return coreFiles.indexOf(file.substring(3)) === -1; + })) + }, + min: { + 'dist/jquery-ui.min.js': ['', 'dist/jquery-ui.js'] + }, + zip: { + dist: { + src: [ + 'dist/**/*.js', + 'README.md', + 'grunt.js', + 'package.json', + 'ui/**/*', + 'demos/**/*', + 'themes/**/*', + 'external/**/*', + 'tests/**/*' + ], + dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip' + } + }, + qunit: { + files: file.expand('tests/unit/**/*.html').filter(function(file) { + // disabling everything that doesn't (quite) work with PhantomJS for now + // except for all|index|test, try to include more as we go + return !(/(all|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html/).test(file); + }) + }, + lint: { + // TODO extend this to tests + files: ['ui/*'] + }, + jshint: { + options: { + curly: true, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true, + browser: true + }, + globals: { + jQuery: true + } + } +}); + +task.registerBasicTask('zip', 'Create a zip file for release', function(data) { + var files = file.expand(data.src); + log.writeln("Creating zip file " + data.dest); + + var done = this.async(); + + var zipstream = require('zipstream'); + var fs = require('fs'); + + var out = fs.createWriteStream(data.dest); + var zip = zipstream.createZip({ level: 1 }); + + zip.pipe(out); + + function addFile() { + if (!files.length) { + zip.finalize(function(written) { + log.writeln(written + ' total bytes written'); + done(); + }); + return; + } + var file = files.shift(); + log.verbose.writeln('Zipping ' + file); + zip.addFile(fs.createReadStream(file), { name: file }, addFile); + } + addFile(); +}); + +task.registerTask('default', 'lint qunit'); +task.registerTask('release', 'default concat min zip'); -- cgit v1.2.3 From 3cb276c4678cd4f2a1a8aec8e3cbf184b06c9251 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 2 Mar 2012 16:55:49 +0100 Subject: Add list of included files to min banner --- grunt.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index b935a0bc7..0b3f13874 100644 --- a/grunt.js +++ b/grunt.js @@ -1,21 +1,26 @@ /*global config:true, task:true*/ var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); +var allFiles = coreFiles.map(function(file) { + return 'ui/' + file; +}).concat(file.expand('ui/*.js').filter(function(file) { + return coreFiles.indexOf(file.substring(3)) === -1; +})); +var rawList = allFiles.map(function(file) { + return file.substring(3); +}); config.init({ pkg: '', meta: { banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= template.today("m/d/yyyy") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + + // TODO makes this banner only useful for the min-all task below... + '* Includes: ' + rawList.join(', ') + '\n' + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' }, concat: { - // 'dist/ui/jquery-ui.js': ['', ''] - 'dist/jquery-ui.js': coreFiles.map(function(file) { - return 'ui/' + file; - }).concat(file.expand('ui/*.js').filter(function(file) { - return coreFiles.indexOf(file.substring(3)) === -1; - })) + 'dist/jquery-ui.js': allFiles }, min: { 'dist/jquery-ui.min.js': ['', 'dist/jquery-ui.js'] -- cgit v1.2.3 From 15eb3ac8f1123fa3075dd7fc6ae738a87c45ca39 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 2 Mar 2012 17:19:48 +0100 Subject: Use isoDate format for min banner --- grunt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 0b3f13874..2a79ff226 100644 --- a/grunt.js +++ b/grunt.js @@ -12,7 +12,7 @@ config.init({ pkg: '', meta: { banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + - '<%= template.today("m/d/yyyy") %>\n' + + '<%= template.today("isoDate") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + // TODO makes this banner only useful for the min-all task below... '* Includes: ' + rawList.join(', ') + '\n' + -- cgit v1.2.3 From 98fc87a5d72472d813b618a333bc2fa23defaaec Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 6 Mar 2012 18:18:09 +0100 Subject: Build/grunt: Switch to adm-zip. Use addFile method until addLocalFile is implemented. --- grunt.js | 28 +++++++--------------------- package.json | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 2a79ff226..ab8d57f31 100644 --- a/grunt.js +++ b/grunt.js @@ -75,29 +75,15 @@ task.registerBasicTask('zip', 'Create a zip file for release', function(data) { var files = file.expand(data.src); log.writeln("Creating zip file " + data.dest); - var done = this.async(); - - var zipstream = require('zipstream'); var fs = require('fs'); - - var out = fs.createWriteStream(data.dest); - var zip = zipstream.createZip({ level: 1 }); - - zip.pipe(out); - - function addFile() { - if (!files.length) { - zip.finalize(function(written) { - log.writeln(written + ' total bytes written'); - done(); - }); - return; - } - var file = files.shift(); + var AdmZip = require('adm-zip'); + var zip = new AdmZip(); + files.forEach(function(file) { log.verbose.writeln('Zipping ' + file); - zip.addFile(fs.createReadStream(file), { name: file }, addFile); - } - addFile(); + zip.addFile(file, fs.readFileSync(file)); + }); + zip.writeZip(data.dest); + log.writeln("Wrote " + files.length + " files to " + data.dest); }); task.registerTask('default', 'lint qunit'); diff --git a/package.json b/package.json index f1bbdf69d..9745bda44 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": {}, "devDependencies": { "grunt": "0.2.x", - "zipstream": "0.2.x" + "adm-zip": "0.1.x" }, "keywords": [] } \ No newline at end of file -- cgit v1.2.3 From 953c49ff9d2597c96ec7e4c398288e7b6ef97b8f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 6 Mar 2012 18:52:50 +0100 Subject: Build/grunt: Extend concat and min tasks to include all the files the current build includes. Headers aren't correct yet. --- grunt.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index ab8d57f31..2ee625f51 100644 --- a/grunt.js +++ b/grunt.js @@ -8,6 +8,19 @@ var allFiles = coreFiles.map(function(file) { var rawList = allFiles.map(function(file) { return file.substring(3); }); + +var minify = { + 'dist/ui/minified/jquery-ui.min.js': ['', 'dist/ui/jquery-ui.js'], + // TODO adjust banner to get access to the list of included files + 'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['', 'dist/ui/i18n/jquery-ui-i18n.js'] +}; +function minFile(file) { + // TODO adjust banner to get access to the list of included files + minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['', file]; +} +allFiles.forEach(minFile); +file.expand('ui/i18n/*.js').forEach(minFile); + config.init({ pkg: '', meta: { @@ -20,11 +33,10 @@ config.init({ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' }, concat: { - 'dist/jquery-ui.js': allFiles - }, - min: { - 'dist/jquery-ui.min.js': ['', 'dist/jquery-ui.js'] + 'dist/ui/jquery-ui.js': allFiles, + 'dist/ui/i18n/jquery-ui-i18n.js': 'ui/i18n/*.js' }, + min: minify, zip: { dist: { src: [ @@ -80,11 +92,12 @@ task.registerBasicTask('zip', 'Create a zip file for release', function(data) { var zip = new AdmZip(); files.forEach(function(file) { log.verbose.writeln('Zipping ' + file); - zip.addFile(file, fs.readFileSync(file)); + // rewrite file names from dist folder (created by build), drop the /dist part + zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); }); zip.writeZip(data.dest); log.writeln("Wrote " + files.length + " files to " + data.dest); }); task.registerTask('default', 'lint qunit'); -task.registerTask('release', 'default concat min zip'); +task.registerTask('release', 'concat min zip'); -- cgit v1.2.3 From 3f1750330070de1c8a48ab42c4f4bb90e0372e02 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 6 Mar 2012 19:30:20 +0100 Subject: Build/grunt: Custom banners for the various minified files --- grunt.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 2ee625f51..fe1e92bc8 100644 --- a/grunt.js +++ b/grunt.js @@ -10,27 +10,38 @@ var rawList = allFiles.map(function(file) { }); var minify = { - 'dist/ui/minified/jquery-ui.min.js': ['', 'dist/ui/jquery-ui.js'], + 'dist/ui/minified/jquery-ui.min.js': ['', 'dist/ui/jquery-ui.js'], // TODO adjust banner to get access to the list of included files - 'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['', 'dist/ui/i18n/jquery-ui-i18n.js'] + 'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['', 'dist/ui/i18n/jquery-ui-i18n.js'] }; function minFile(file) { // TODO adjust banner to get access to the list of included files minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['', file]; } allFiles.forEach(minFile); -file.expand('ui/i18n/*.js').forEach(minFile); -config.init({ - pkg: '', - meta: { - banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + +var allI18nFiles = file.expand('ui/i18n/*.js'); +allI18nFiles.forEach(minFile); +var i18nfiles = allI18nFiles.map(function(file) { + return file.substring(8); +}); + +function createBanner(files) { + return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= template.today("isoDate") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + // TODO makes this banner only useful for the min-all task below... - '* Includes: ' + rawList.join(', ') + '\n' + + (files ? '* Includes: ' + files.join(', ') + '\n' : '') + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; +} + +config.init({ + pkg: '', + meta: { + banner: createBanner(), + bannerAll: createBanner(rawList), + bannerI18n: createBanner(i18nfiles) }, concat: { 'dist/ui/jquery-ui.js': allFiles, -- cgit v1.2.3 From 02981c7c4005143285c4012f2d15dc24ccaf6725 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 6 Mar 2012 19:31:00 +0100 Subject: Build/grunt: cleanup --- grunt.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index fe1e92bc8..45deca7bd 100644 --- a/grunt.js +++ b/grunt.js @@ -11,11 +11,9 @@ var rawList = allFiles.map(function(file) { var minify = { 'dist/ui/minified/jquery-ui.min.js': ['', 'dist/ui/jquery-ui.js'], - // TODO adjust banner to get access to the list of included files 'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['', 'dist/ui/i18n/jquery-ui-i18n.js'] }; function minFile(file) { - // TODO adjust banner to get access to the list of included files minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['', file]; } allFiles.forEach(minFile); @@ -30,7 +28,6 @@ function createBanner(files) { return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= template.today("isoDate") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + - // TODO makes this banner only useful for the min-all task below... (files ? '* Includes: ' + files.join(', ') + '\n' : '') + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; -- cgit v1.2.3 From cc3b08df2d8be44a72977d33f042bafa0e21de13 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 6 Mar 2012 20:15:51 +0100 Subject: Build/grunt: Minify CSS files, using sqwish. --- grunt.js | 53 +++++++++++++++++++++++++++++++++++++++++------------ package.json | 3 ++- 2 files changed, 43 insertions(+), 13 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 45deca7bd..44a49a372 100644 --- a/grunt.js +++ b/grunt.js @@ -1,13 +1,10 @@ /*global config:true, task:true*/ var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); -var allFiles = coreFiles.map(function(file) { +var uiFiles = coreFiles.map(function(file) { return 'ui/' + file; }).concat(file.expand('ui/*.js').filter(function(file) { return coreFiles.indexOf(file.substring(3)) === -1; })); -var rawList = allFiles.map(function(file) { - return file.substring(3); -}); var minify = { 'dist/ui/minified/jquery-ui.min.js': ['', 'dist/ui/jquery-ui.js'], @@ -16,19 +13,23 @@ var minify = { function minFile(file) { minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['', file]; } -allFiles.forEach(minFile); +uiFiles.forEach(minFile); var allI18nFiles = file.expand('ui/i18n/*.js'); allI18nFiles.forEach(minFile); -var i18nfiles = allI18nFiles.map(function(file) { - return file.substring(8); -}); + +// TODO move core to the front, theme to the end, exclude all and base +var cssFiles = file.expand('themes/base/*.css'); function createBanner(files) { + // strip folders + var fileNames = files && files.map(function(file) { + return file.replace(/.+\/(.+)$/, '$1'); + }); return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= template.today("isoDate") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + - (files ? '* Includes: ' + files.join(', ') + '\n' : '') + + (files ? '* Includes: ' + fileNames.join(', ') + '\n' : '') + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; } @@ -37,14 +38,21 @@ config.init({ pkg: '', meta: { banner: createBanner(), - bannerAll: createBanner(rawList), - bannerI18n: createBanner(i18nfiles) + bannerAll: createBanner(uiFiles), + bannerI18n: createBanner(allI18nFiles), + bannerCSS: createBanner(cssFiles) }, concat: { - 'dist/ui/jquery-ui.js': allFiles, + 'dist/ui/jquery-ui.js': uiFiles, 'dist/ui/i18n/jquery-ui-i18n.js': 'ui/i18n/*.js' }, min: minify, + css_min: { + dist: { + src: [''].concat(cssFiles), + dest: 'dist/themes/base/minified/jquery-ui.min.css' + } + }, zip: { dist: { src: [ @@ -107,5 +115,26 @@ task.registerBasicTask('zip', 'Create a zip file for release', function(data) { log.writeln("Wrote " + files.length + " files to " + data.dest); }); +task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( data ) { + var files = file.expand( data.src ); + // Get banner, if specified. It would be nice if UglifyJS supported ignoring + // all comments matching a certain pattern, like /*!...*/, but it doesn't. + var banner = task.directive(files[0], function() { return null; }); + if (banner === null) { + banner = ''; + } else { + files.shift(); + } + var max = task.helper( 'concat', files ); + // Concat banner + minified source. + var min = banner + require('sqwish').minify( max, false ); + file.write( data.dest, min ); + if ( task.hadErrors() ) { + return false; + } + log.writeln( 'File "' + data.dest + '" created.' ); + task.helper( 'min_max_info', min, max ); +}); + task.registerTask('default', 'lint qunit'); task.registerTask('release', 'concat min zip'); diff --git a/package.json b/package.json index 9745bda44..37cb6d035 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "dependencies": {}, "devDependencies": { "grunt": "0.2.x", - "adm-zip": "0.1.x" + "adm-zip": "0.1.x", + "sqwish": "0.2.x" }, "keywords": [] } \ No newline at end of file -- cgit v1.2.3 From 34f813413b9ccdb2eebd429a2e69198dcceec057 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 7 Mar 2012 14:51:20 +0100 Subject: Build/grunt: Update banner template to use task.current.data.src when no file list is given. --- grunt.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 44a49a372..93896f6cb 100644 --- a/grunt.js +++ b/grunt.js @@ -1,4 +1,20 @@ /*global config:true, task:true*/ +function stripDirectory(file) { + return file.replace(/.+\/(.+)$/, '$1'); +} +function createBanner(files) { + // strip folders + var fileNames = files && files.map(stripDirectory); + return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + + '<%= template.today("isoDate") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + + '* Includes: ' + (files ? fileNames.join(', ') : '<%= stripDirectory(task.current.data.src[1]) %>') + '\n' + + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; +} +// allow access from banner template +global.stripDirectory = stripDirectory; + var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); var uiFiles = coreFiles.map(function(file) { return 'ui/' + file; @@ -21,19 +37,6 @@ allI18nFiles.forEach(minFile); // TODO move core to the front, theme to the end, exclude all and base var cssFiles = file.expand('themes/base/*.css'); -function createBanner(files) { - // strip folders - var fileNames = files && files.map(function(file) { - return file.replace(/.+\/(.+)$/, '$1'); - }); - return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + - '<%= template.today("isoDate") %>\n' + - '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + - (files ? '* Includes: ' + fileNames.join(', ') + '\n' : '') + - '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; -} - config.init({ pkg: '', meta: { -- cgit v1.2.3 From 0bf7d25d6663ae6e5283cffbf8ac33f52dcf18f5 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 7 Mar 2012 15:16:32 +0100 Subject: Build/grunt: First draft for cdn tasks. Hashing works fine, zip file doesn't quite match the intended structure. --- grunt.js | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 93896f6cb..76f2d71ac 100644 --- a/grunt.js +++ b/grunt.js @@ -37,6 +37,23 @@ allI18nFiles.forEach(minFile); // TODO move core to the front, theme to the end, exclude all and base var cssFiles = file.expand('themes/base/*.css'); +var cdnFiles = [ + 'AUTHORS.txt', + 'GPL-LICENSE.txt', + 'MIT-LICENSE.txt', + 'dist/i18n/jquery-ui-i18n.js', + 'dist/i18n/jquery-ui-i18n.min.js', + 'ui/i18n/jquery.ui.datepicker-*.js', + 'dist/ui/i18n/jquery.ui.datepicker-*.min.js', + 'dist/ui/jquery-ui.js', + 'dist/ui/minified/jquery-ui.min.js', + 'themes/base/images/*.png', + 'dist/themes/base/jquery-ui.css', + 'themes/base/jquery.ui.*.css', + 'dist/themes/base/minified/*.css', + 'version.txt' +]; + config.init({ pkg: '', meta: { @@ -70,8 +87,15 @@ config.init({ 'tests/**/*' ], dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip' + }, + cdn: { + src: cdnFiles, + dest: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip' } }, + md5: { + 'dist/MANIFEST': cdnFiles + }, qunit: { files: file.expand('tests/unit/**/*.html').filter(function(file) { // disabling everything that doesn't (quite) work with PhantomJS for now @@ -139,5 +163,17 @@ task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( da task.helper( 'min_max_info', min, max ); }); +task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', function(data) { + var crypto = require('crypto'); + var hashes = []; + file.expand(data.src).forEach(function(fileName) { + var hash = crypto.createHash('md5'); + hash.update(file.read(fileName)); + hashes.push(fileName + ' ' + hash.digest('hex')); + }); + file.write(data.dest, hashes.join('\n') + '\n'); +}); + task.registerTask('default', 'lint qunit'); -task.registerTask('release', 'concat min zip'); +task.registerTask('release', 'concat min zip:dist'); +task.registerTask('release_cdn', 'concat min md5 zip:cdn'); \ No newline at end of file -- cgit v1.2.3 From face6de0b6a6f9651a3ea7bd5c0d73f432c63be8 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 8 Mar 2012 14:06:25 +0100 Subject: Build/grunt: Almost complete release and release_cdn tasks. Concat task fails to strip headers, everything else is in place. --- grunt.js | 211 +++++++++++++++++++++++++++++++++++++++++++++++++----------- version.txt | 1 - 2 files changed, 172 insertions(+), 40 deletions(-) delete mode 100644 version.txt (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 76f2d71ac..1ec85df90 100644 --- a/grunt.js +++ b/grunt.js @@ -23,39 +23,35 @@ var uiFiles = coreFiles.map(function(file) { })); var minify = { - 'dist/ui/minified/jquery-ui.min.js': ['', 'dist/ui/jquery-ui.js'], - 'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['', 'dist/ui/i18n/jquery-ui-i18n.js'] + 'dist/jquery-ui.min.js': ['', 'dist/jquery-ui.js'], + 'dist/i18n/jquery-ui-i18n.min.js': ['', 'dist/i18n/jquery-ui-i18n.js'] }; function minFile(file) { - minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['', file]; + minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'minified/')] = ['', file]; } uiFiles.forEach(minFile); var allI18nFiles = file.expand('ui/i18n/*.js'); allI18nFiles.forEach(minFile); -// TODO move core to the front, theme to the end, exclude all and base -var cssFiles = file.expand('themes/base/*.css'); - -var cdnFiles = [ - 'AUTHORS.txt', - 'GPL-LICENSE.txt', - 'MIT-LICENSE.txt', - 'dist/i18n/jquery-ui-i18n.js', - 'dist/i18n/jquery-ui-i18n.min.js', - 'ui/i18n/jquery.ui.datepicker-*.js', - 'dist/ui/i18n/jquery.ui.datepicker-*.min.js', - 'dist/ui/jquery-ui.js', - 'dist/ui/minified/jquery-ui.min.js', - 'themes/base/images/*.png', - 'dist/themes/base/jquery-ui.css', - 'themes/base/jquery.ui.*.css', - 'dist/themes/base/minified/*.css', - 'version.txt' -]; +var cssFiles = 'core accordion autocomplete button datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip theme'.split(' ').map(function(component) { + return 'themes/base/jquery.ui.' + component + '.css'; +}); +var minifyCSS = { + 'dist/jquery-ui.min.css': 'dist/jquery-ui.css' +}; +cssFiles.forEach(function(file) { + minifyCSS['dist/' + file.replace(/\.css$/, '.min.css').replace(/themes\/base\//, 'themes/base/minified/')] = ['', file]; +}); config.init({ pkg: '', + files: { + distFolder: 'dist/<%= pkg.name %>-<%= pkg.version %>', + cdnDistFolder: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn', + zip: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip', + cdnZip: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip' + }, meta: { banner: createBanner(), bannerAll: createBanner(uiFiles), @@ -63,20 +59,32 @@ config.init({ bannerCSS: createBanner(cssFiles) }, concat: { - 'dist/ui/jquery-ui.js': uiFiles, - 'dist/ui/i18n/jquery-ui-i18n.js': 'ui/i18n/*.js' - }, - min: minify, - css_min: { - dist: { + // TODO replace banners, both for JS and CSS + ui: { + src: [''].concat(uiFiles.map(function(file) { + // TODO why doesn't this work? + return ''; + })), + dest: 'dist/jquery-ui.js' + }, + i18n: { + src: ['', allI18nFiles], + dest: 'dist/i18n/jquery-ui-i18n.js' + }, + css: { src: [''].concat(cssFiles), - dest: 'dist/themes/base/minified/jquery-ui.min.css' + dest: 'dist/jquery-ui.css' } }, - zip: { + min: minify, + css_min: minifyCSS, + copy: { dist: { src: [ - 'dist/**/*.js', + 'AUTHORS.txt', + 'GPL-LICENSE.txt', + 'jquery-1.7.1.js', + 'MIT-LICENSE.txt', 'README.md', 'grunt.js', 'package.json', @@ -86,15 +94,92 @@ config.init({ 'external/**/*', 'tests/**/*' ], - dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip' + renames: { + 'dist/jquery-ui.js': 'ui/jquery-ui.js', + 'dist/jquery-ui.min.js': 'ui/minified/jquery-ui.min.js', + 'dist/i18n/jquery-ui-i18n.js': 'ui/i18n/jquery-ui-i18n.js', + 'dist/i18n/jquery-ui-i18n.min.js': 'ui/minified/i18n/jquery-ui-i18n.min.js', + 'dist/jquery-ui.css': 'themes/base/jquery-ui.css', + 'dist/jquery-ui.min.css': 'themes/base/minified/jquery-ui.min.css' + }, + dest: '<%= files.distFolder %>' + }, + dist_min: { + src: 'dist/minified/**/*', + strip: /^dist/, + dest: '<%= files.distFolder %>/ui' + }, + dist_css_min: { + src: 'dist/themes/base/minified/*.css', + strip: /^dist/, + dest: '<%= files.distFolder %>' + }, + dist_min_images: { + src: 'themes/base/images/*', + strip: /^themes\/base\//, + dest: '<%= files.distFolder %>/themes/base/minified' }, cdn: { - src: cdnFiles, - dest: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip' + src: [ + 'AUTHORS.txt', + 'GPL-LICENSE.txt', + 'MIT-LICENSE.txt', + 'ui/*.js', + 'themes/base/images/*.png', + 'themes/base/jquery.ui.*.css', + 'package.json' + ], + renames: { + 'dist/jquery-ui.js': 'jquery-ui.js', + 'dist/jquery-ui.min.js': 'jquery-ui.min.js', + 'dist/i18n/jquery-ui-i18n.js': 'i18n/jquery-ui-i18n.js', + 'dist/i18n/jquery-ui-i18n.min.js': 'i18n/jquery-ui-i18n.min.js', + 'dist/jquery-ui.css': 'themes/base/jquery-ui.css', + 'dist/jquery-ui.min.css': 'themes/base/minified/jquery-ui.min.css' + }, + dest: '<%= files.cdnDistFolder %>' + }, + cdn_i18n: { + src: 'ui/i18n/jquery.ui.datepicker-*.js', + strip: 'ui/', + dest: '<%= files.cdnDistFolder %>' + }, + cdn_i18n_min: { + src: 'dist/minified/i18n/jquery.ui.datepicker-*.js', + strip: 'dist/minified', + dest: '<%= files.cdnDistFolder %>' + }, + cdn_min: { + src: 'dist/minified/*.js', + strip: /^dist\/minified/, + dest: '<%= files.cdnDistFolder %>/ui' + }, + cdn_css_min: { + src: 'dist/themes/base/minified/*.css', + strip: /^dist/, + dest: '<%= files.cdnDistFolder %>' + }, + dist_min_images: { + src: 'themes/base/images/*', + strip: /^themes\/base\//, + dest: '<%= files.cdnDistFolder %>/themes/base/minified' + } + }, + zip: { + dist: { + src: '<%= files.distFolder %>/**/*', + dest: '<%= files.zip %>' + }, + cdn: { + src: '<%= files.cdnDistFolder %>/**/*', + dest: '<%= files.cdnZip %>' } }, md5: { - 'dist/MANIFEST': cdnFiles + cdn: { + dir: '<%= files.cdnDistFolder %>', + dest: '<%= files.cdnDistFolder %>/MANIFEST' + } }, qunit: { files: file.expand('tests/unit/**/*.html').filter(function(file) { @@ -126,6 +211,39 @@ config.init({ } }); +// grunt doesn't know about this files object, so need to process that manually once +// before any other variable is resolved, otherwise it would just include the templates +var files = config().files; +for (var key in files) { + files[key] = template.process(files[key], config()); +} +config('files', files); +// log.writeln(require('util').inspect(config().files)) + +task.registerTask('x', function() { + log.writeln(task.helper('concat', [''])); +}); + +task.registerBasicTask('copy', 'Copy files to destination folder and replace @VERSION with pkg.version', function(data) { + function replaceVersion(source) { + return source.replace("@VERSION", config("pkg").version); + } + var files = file.expand(data.src); + var target = data.dest + '/'; + files.forEach(function(fileName) { + var targetFile = data.strip ? fileName.replace(data.strip, '') : fileName; + file.copy(fileName, target + targetFile, replaceVersion); + }); + log.writeln('Copyied ' + files.length + ' files.'); + for (var fileName in data.renames) { + file.copy(fileName, target + template.process(data.renames[fileName], config())); + } + if (data.renames) { + log.writeln('Renamed ' + data.renames.length + ' files.'); + } +}); + + task.registerBasicTask('zip', 'Create a zip file for release', function(data) { var files = file.expand(data.src); log.writeln("Creating zip file " + data.dest); @@ -164,16 +282,31 @@ task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( da }); task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', function(data) { + // remove dest file before creating it, to make sure itself is not included + if (require('path').existsSync(data.dest)) { + require('fs').unlinkSync(data.dest); + } var crypto = require('crypto'); + var dir = template.process(data.dir, config()) + '/'; var hashes = []; - file.expand(data.src).forEach(function(fileName) { + file.expand(dir + '**/*').forEach(function(fileName) { var hash = crypto.createHash('md5'); hash.update(file.read(fileName)); - hashes.push(fileName + ' ' + hash.digest('hex')); + hashes.push(fileName.replace(dir, '') + ' ' + hash.digest('hex')); }); file.write(data.dest, hashes.join('\n') + '\n'); }); task.registerTask('default', 'lint qunit'); -task.registerTask('release', 'concat min zip:dist'); -task.registerTask('release_cdn', 'concat min md5 zip:cdn'); \ No newline at end of file +task.registerTask('build', 'concat min css_min'); +task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min zip:dist'); +task.registerTask('release_themes', 'build download_themes zip:themes'); +// TODO includes other themes in cdn release +task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min md5 zip:cdn'); + +task.registerTask('download_themes', function() { + // TODO use request.get to download the files specified in build/themes +}); + +// TODO add size task, see also build/sizer.js - copy from core grunt.js +// TODO add themes download task, part of release_cdn task diff --git a/version.txt b/version.txt deleted file mode 100644 index 13c1a7371..000000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -1.9pre -- cgit v1.2.3 From 6aa41bf4aee738ddeb2acbb85e5b12ce36798a2c Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 8 Mar 2012 14:52:50 +0100 Subject: Build/grunt: Partial download_themes task. Extracting currently fails with crc32 checksum failure --- grunt.js | 27 ++++++++++++++++++++++++--- package.json | 3 ++- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 1ec85df90..9218b00d9 100644 --- a/grunt.js +++ b/grunt.js @@ -301,12 +301,33 @@ task.registerTask('default', 'lint qunit'); task.registerTask('build', 'concat min css_min'); task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min zip:dist'); task.registerTask('release_themes', 'build download_themes zip:themes'); -// TODO includes other themes in cdn release +// TODO include other themes in cdn release task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min md5 zip:cdn'); task.registerTask('download_themes', function() { - // TODO use request.get to download the files specified in build/themes + var AdmZip = require('adm-zip'); + var done = this.async(); + var fs = require('fs'); + var request = require('request'); + var themes = file.read('build/themes').split(',').slice(0, 1); + var requests = 0; + file.mkdir('dist/tmp'); + themes.forEach(function(theme, index) { + requests += 1; + file.mkdir('dist/tmp/' + index); + var zipFileName = 'dist/tmp/' + index + '.zip'; + var out = fs.createWriteStream(zipFileName); + out.on('close', function() { + log.writeln("done downloading " + zipFileName); + var zip = new AdmZip(zipFileName); + zip.extractAllTo('dist/tmp/' + index + '/'); + requests -= 1; + if (requests === 0) { + done(); + } + }); + request('http://ui-dev.jquery.com/download/?' + theme).pipe(out); + }); }); // TODO add size task, see also build/sizer.js - copy from core grunt.js -// TODO add themes download task, part of release_cdn task diff --git a/package.json b/package.json index 37cb6d035..2d473076a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "devDependencies": { "grunt": "0.2.x", "adm-zip": "0.1.x", - "sqwish": "0.2.x" + "sqwish": "0.2.x", + "request": "0.2.x" }, "keywords": [] } \ No newline at end of file -- cgit v1.2.3 From 64ea9d427eb048dc6387557698b28a3ab3421241 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 8 Mar 2012 17:11:57 +0100 Subject: Build/grunt: Extend themes_download task with unzipping --- grunt.js | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 9218b00d9..0c900941d 100644 --- a/grunt.js +++ b/grunt.js @@ -49,8 +49,10 @@ config.init({ files: { distFolder: 'dist/<%= pkg.name %>-<%= pkg.version %>', cdnDistFolder: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn', + themesDistFolder: 'dist/<%= pkg.name %>-themes-<%= pkg.version %>', zip: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip', - cdnZip: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip' + cdnZip: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip', + themesZip: 'dist/<%= pkg.name %>-themes-<%= pkg.version %>.zip' }, meta: { banner: createBanner(), @@ -62,7 +64,7 @@ config.init({ // TODO replace banners, both for JS and CSS ui: { src: [''].concat(uiFiles.map(function(file) { - // TODO why doesn't this work? + // TODO why doesn't this work? because its a protected banner, and template.stripBanner skips that m( return ''; })), dest: 'dist/jquery-ui.js' @@ -159,10 +161,14 @@ config.init({ strip: /^dist/, dest: '<%= files.cdnDistFolder %>' }, - dist_min_images: { + cdn_min_images: { src: 'themes/base/images/*', strip: /^themes\/base\//, dest: '<%= files.cdnDistFolder %>/themes/base/minified' + }, + themes: { + // copy development-bundle/themes/**/*.js (excluding themes/base) + // rename jquery-ui-.*custom.css to jquery-ui.css } }, zip: { @@ -173,6 +179,10 @@ config.init({ cdn: { src: '<%= files.cdnDistFolder %>/**/*', dest: '<%= files.cdnZip %>' + }, + themes: { + src: '<%= files.themesDistFolder %>/**/*', + dest: '<%= files.themesZip %>' } }, md5: { @@ -300,16 +310,16 @@ task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', funct task.registerTask('default', 'lint qunit'); task.registerTask('build', 'concat min css_min'); task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min zip:dist'); -task.registerTask('release_themes', 'build download_themes zip:themes'); +task.registerTask('release_themes', 'build download_themes copy:themes zip:themes'); // TODO include other themes in cdn release -task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min md5 zip:cdn'); +task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min copy:cdn_min_images md5 zip:cdn'); task.registerTask('download_themes', function() { - var AdmZip = require('adm-zip'); - var done = this.async(); + // var AdmZip = require('adm-zip'); var fs = require('fs'); var request = require('request'); - var themes = file.read('build/themes').split(',').slice(0, 1); + var done = this.async(); + var themes = file.read('build/themes').split(','); var requests = 0; file.mkdir('dist/tmp'); themes.forEach(function(theme, index) { @@ -319,12 +329,22 @@ task.registerTask('download_themes', function() { var out = fs.createWriteStream(zipFileName); out.on('close', function() { log.writeln("done downloading " + zipFileName); - var zip = new AdmZip(zipFileName); - zip.extractAllTo('dist/tmp/' + index + '/'); - requests -= 1; - if (requests === 0) { - done(); - } + // TODO AdmZip produces "crc32 checksum failed", need to figure out why + // var zip = new AdmZip(zipFileName); + // zip.extractAllTo('dist/tmp/' + index + '/'); + // until then, using cli unzip... + task.helper("child_process", { + cmd: "unzip", + args: ["-d", "dist/tmp/" + index, zipFileName] + }, function(err, result) { + log.writeln("Unzipped " + zipFileName + ", deleting it now"); + fs.unlinkSync(zipFileName); + requests -= 1; + if (requests === 0) { + done(); + } + }); + }); request('http://ui-dev.jquery.com/download/?' + theme).pipe(out); }); -- cgit v1.2.3 From 4a2b004c073fc7b97b1a4f61db460100f09b7be6 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 13:52:18 +0100 Subject: Build/grunt: Finish release_themes task. Strip headers from concatenated files. --- grunt.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 14 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 0c900941d..2db730139 100644 --- a/grunt.js +++ b/grunt.js @@ -1,4 +1,9 @@ /*global config:true, task:true*/ +function stripBanner(files) { + return files.map(function(file) { + return ''; + }); +} function stripDirectory(file) { return file.replace(/.+\/(.+)$/, '$1'); } @@ -63,10 +68,7 @@ config.init({ concat: { // TODO replace banners, both for JS and CSS ui: { - src: [''].concat(uiFiles.map(function(file) { - // TODO why doesn't this work? because its a protected banner, and template.stripBanner skips that m( - return ''; - })), + src: ['', stripBanner(uiFiles)], dest: 'dist/jquery-ui.js' }, i18n: { @@ -74,7 +76,7 @@ config.init({ dest: 'dist/i18n/jquery-ui-i18n.js' }, css: { - src: [''].concat(cssFiles), + src: ['', stripBanner(cssFiles)], dest: 'dist/jquery-ui.css' } }, @@ -167,8 +169,13 @@ config.init({ dest: '<%= files.cdnDistFolder %>/themes/base/minified' }, themes: { - // copy development-bundle/themes/**/*.js (excluding themes/base) - // rename jquery-ui-.*custom.css to jquery-ui.css + src: [ + 'AUTHORS.txt', + 'GPL-LICENSE.txt', + 'MIT-LICENSE.txt', + 'package.json' + ], + dest: '<%= files.themesDistFolder %>' } }, zip: { @@ -186,9 +193,17 @@ config.init({ } }, md5: { + dist: { + dir: '<%= files.distFolder %>', + dest: '<%= files.distFolder %>/MANIFEST' + }, cdn: { dir: '<%= files.cdnDistFolder %>', dest: '<%= files.cdnDistFolder %>/MANIFEST' + }, + themes: { + dir: '<%= files.themesDistFolder %>', + dest: '<%= files.themesDistFolder %>/MANIFEST' } }, qunit: { @@ -307,13 +322,6 @@ task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', funct file.write(data.dest, hashes.join('\n') + '\n'); }); -task.registerTask('default', 'lint qunit'); -task.registerTask('build', 'concat min css_min'); -task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min zip:dist'); -task.registerTask('release_themes', 'build download_themes copy:themes zip:themes'); -// TODO include other themes in cdn release -task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min copy:cdn_min_images md5 zip:cdn'); - task.registerTask('download_themes', function() { // var AdmZip = require('adm-zip'); var fs = require('fs'); @@ -350,4 +358,32 @@ task.registerTask('download_themes', function() { }); }); +task.registerTask('copy_themes', function() { + // each package includes the base theme, ignore that + var filter = /themes\/base/; + var files = file.expand('dist/tmp/*/development-bundle/themes/**/*').filter(function(file) { + return !filter.test(file); + }); + var target = config('files.themesDistFolder') + '/'; + files.forEach(function(fileName) { + var targetFile = fileName.replace(/dist\/tmp\/\d+\/development-bundle\//, '').replace("jquery-ui-.custom", "jquery-ui.css"); + file.copy(fileName, target + targetFile); + }); + + // copy minified base theme from regular release + var distFolder = config('files.distFolder'); + files = file.expand(distFolder + '/themes/base/**/*'); + files.forEach(function(fileName) { + file.copy(fileName, target + fileName.replace(distFolder, '')); + }); +}); + // TODO add size task, see also build/sizer.js - copy from core grunt.js + +task.registerTask('default', 'lint qunit'); +task.registerTask('build', 'concat min css_min'); +task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist'); +// TODO also include (minified) base theme, share with regular dist, maybe just copy from release target +task.registerTask('release_themes', 'release download_themes copy_themes copy:themes md5:themes zip:themes'); +// TODO include other themes in cdn release +task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min copy:cdn_min_images md5:cdn zip:cdn'); -- cgit v1.2.3 From 60bbda3eb900eea18d35bfd8bdee59d970c4549b Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 14:02:00 +0100 Subject: Build/grunt: Cleanup todos --- grunt.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 2db730139..a079f04cf 100644 --- a/grunt.js +++ b/grunt.js @@ -66,7 +66,6 @@ config.init({ bannerCSS: createBanner(cssFiles) }, concat: { - // TODO replace banners, both for JS and CSS ui: { src: ['', stripBanner(uiFiles)], dest: 'dist/jquery-ui.js' @@ -383,7 +382,6 @@ task.registerTask('copy_themes', function() { task.registerTask('default', 'lint qunit'); task.registerTask('build', 'concat min css_min'); task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist'); -// TODO also include (minified) base theme, share with regular dist, maybe just copy from release target task.registerTask('release_themes', 'release download_themes copy_themes copy:themes md5:themes zip:themes'); // TODO include other themes in cdn release task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min copy:cdn_min_images md5:cdn zip:cdn'); -- cgit v1.2.3 From ff5895a39fd90cc3fd89568c05f73906a506ef88 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 15:18:26 +0100 Subject: Build/grunt: Add sizer task. Some cleanup in other areas. --- grunt.js | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 7 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index a079f04cf..0aff5a963 100644 --- a/grunt.js +++ b/grunt.js @@ -65,6 +65,12 @@ config.init({ bannerI18n: createBanner(allI18nFiles), bannerCSS: createBanner(cssFiles) }, + compare_size: { + files: [ + "dist/jquery-ui.js", + "dist/jquery-ui.min.js" + ] + }, concat: { ui: { src: ['', stripBanner(uiFiles)], @@ -242,11 +248,6 @@ for (var key in files) { files[key] = template.process(files[key], config()); } config('files', files); -// log.writeln(require('util').inspect(config().files)) - -task.registerTask('x', function() { - log.writeln(task.helper('concat', [''])); -}); task.registerBasicTask('copy', 'Copy files to destination folder and replace @VERSION with pkg.version', function(data) { function replaceVersion(source) { @@ -377,9 +378,79 @@ task.registerTask('copy_themes', function() { }); }); -// TODO add size task, see also build/sizer.js - copy from core grunt.js +// TODO merge with code in jQuery Core, share as grunt plugin/npm +// this here actually uses the provided filenames in the output +// the helpers should just be regular functions, no need to share those with the world +task.registerBasicTask("compare_size", "Compare size of this branch to master", function(data) { + var files = file.expand(data.src), + done = this.async(), + sizecache = __dirname + "/dist/.sizecache.json", + sources = { + min: file.read(files[1]), + max: file.read(files[0]) + }, + oldsizes = {}, + sizes = {}; + + try { + oldsizes = JSON.parse(file.read(sizecache)); + } catch(e) { + oldsizes = {}; + } + + // Obtain the current branch and continue... + task.helper("git_current_branch", function(err, branch) { + var key, diff; + + // Derived and adapted from Corey Frang's original `sizer` + log.writeln( "sizes - compared to master" ); + + sizes[files[0]] = sources.max.length; + sizes[files[1]] = sources.min.length; + sizes[files[1] + '.gz'] = task.helper("gzip", sources.min).length; + + for ( key in sizes ) { + diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] ); + if ( diff > 0 ) { + diff = "+" + diff; + } + console.log( "%s %s %s", + task.helper("lpad", sizes[ key ], 8 ), + task.helper("lpad", diff ? "(" + diff + ")" : "(-)", 8 ), + key + ); + } + + if ( branch === "master" ) { + // If master, write to file - this makes it easier to compare + // the size of your current code state to the master branch, + // without returning to the master to reset the cache + file.write( sizecache, JSON.stringify(sizes) ); + } + done(); + }); +}); +task.registerHelper("git_current_branch", function(done) { + task.helper("child_process", { + cmd: "git", + args: ["branch", "--no-color"] + }, function(err, result) { + var branch; + + result.split("\n").forEach(function(branch) { + var matches = /^\* (.*)/.exec( branch ); + if ( matches !== null && matches.length && matches[ 1 ] ) { + done( null, matches[ 1 ] ); + } + }); + }); +}); +task.registerHelper("lpad", function(str, len, chr) { + return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len ); +}); -task.registerTask('default', 'lint qunit'); +task.registerTask('default', 'lint qunit build compare_size'); +task.registerTask('sizer', 'concat:ui min:dist/jquery-ui.min.js compare_size'); task.registerTask('build', 'concat min css_min'); task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist'); task.registerTask('release_themes', 'release download_themes copy_themes copy:themes md5:themes zip:themes'); -- cgit v1.2.3 From 8a982f59685ce623b9d600c5d53ae4511e2ae5ce Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 16:23:57 +0100 Subject: Build/grunt: Use custom directive to strip banners. Now works against unmodified grunt again. --- grunt.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 0aff5a963..b60ac9e67 100644 --- a/grunt.js +++ b/grunt.js @@ -1,7 +1,7 @@ /*global config:true, task:true*/ function stripBanner(files) { return files.map(function(file) { - return ''; + return ''; }); } function stripDirectory(file) { @@ -19,6 +19,9 @@ function createBanner(files) { } // allow access from banner template global.stripDirectory = stripDirectory; +task.registerHelper('strip_all_banners', function(filepath) { + return file.read(filepath).replace(/^\s*\/\*[\s\S]*?\*\/\s*/g, ''); +}); var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); var uiFiles = coreFiles.map(function(file) { -- cgit v1.2.3 From 59a26c87c4ea38a6cf864e44dd8c05a4286d9cf3 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 16:25:51 +0100 Subject: Build/grunt: Can use config('pkg.version'), now was fixed in grunt --- grunt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index b60ac9e67..a2929ff28 100644 --- a/grunt.js +++ b/grunt.js @@ -254,7 +254,7 @@ config('files', files); task.registerBasicTask('copy', 'Copy files to destination folder and replace @VERSION with pkg.version', function(data) { function replaceVersion(source) { - return source.replace("@VERSION", config("pkg").version); + return source.replace("@VERSION", config("pkg.version")); } var files = file.expand(data.src); var target = data.dest + '/'; -- cgit v1.2.3 From fcab58aba48fbfbedb48079b521571238ea42ff5 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 17:18:35 +0100 Subject: Build/grunt: Use child process for zipping until adm-zip works better. Rewrote files config to make that work with the cwd requirement. --- grunt.js | 100 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 41 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index a2929ff28..5ee1e63c8 100644 --- a/grunt.js +++ b/grunt.js @@ -55,12 +55,9 @@ cssFiles.forEach(function(file) { config.init({ pkg: '', files: { - distFolder: 'dist/<%= pkg.name %>-<%= pkg.version %>', - cdnDistFolder: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn', - themesDistFolder: 'dist/<%= pkg.name %>-themes-<%= pkg.version %>', - zip: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip', - cdnZip: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip', - themesZip: 'dist/<%= pkg.name %>-themes-<%= pkg.version %>.zip' + dist: '<%= pkg.name %>-<%= pkg.version %>', + cdn: '<%= pkg.name %>-<%= pkg.version %>-cdn', + themes: '<%= pkg.name %>-themes-<%= pkg.version %>' }, meta: { banner: createBanner(), @@ -114,22 +111,22 @@ config.init({ 'dist/jquery-ui.css': 'themes/base/jquery-ui.css', 'dist/jquery-ui.min.css': 'themes/base/minified/jquery-ui.min.css' }, - dest: '<%= files.distFolder %>' + dest: 'dist/<%= files.dist %>' }, dist_min: { src: 'dist/minified/**/*', strip: /^dist/, - dest: '<%= files.distFolder %>/ui' + dest: 'dist/<%= files.dist %>/ui' }, dist_css_min: { src: 'dist/themes/base/minified/*.css', strip: /^dist/, - dest: '<%= files.distFolder %>' + dest: 'dist/<%= files.dist %>' }, dist_min_images: { src: 'themes/base/images/*', strip: /^themes\/base\//, - dest: '<%= files.distFolder %>/themes/base/minified' + dest: 'dist/<%= files.dist %>/themes/base/minified' }, cdn: { src: [ @@ -149,32 +146,32 @@ config.init({ 'dist/jquery-ui.css': 'themes/base/jquery-ui.css', 'dist/jquery-ui.min.css': 'themes/base/minified/jquery-ui.min.css' }, - dest: '<%= files.cdnDistFolder %>' + dest: 'dist/<%= files.cdn %>' }, cdn_i18n: { src: 'ui/i18n/jquery.ui.datepicker-*.js', strip: 'ui/', - dest: '<%= files.cdnDistFolder %>' + dest: 'dist/<%= files.cdn %>' }, cdn_i18n_min: { src: 'dist/minified/i18n/jquery.ui.datepicker-*.js', strip: 'dist/minified', - dest: '<%= files.cdnDistFolder %>' + dest: 'dist/<%= files.cdn %>' }, cdn_min: { src: 'dist/minified/*.js', strip: /^dist\/minified/, - dest: '<%= files.cdnDistFolder %>/ui' + dest: 'dist/<%= files.cdn %>/ui' }, cdn_css_min: { src: 'dist/themes/base/minified/*.css', strip: /^dist/, - dest: '<%= files.cdnDistFolder %>' + dest: 'dist/<%= files.cdn %>' }, cdn_min_images: { src: 'themes/base/images/*', strip: /^themes\/base\//, - dest: '<%= files.cdnDistFolder %>/themes/base/minified' + dest: 'dist/<%= files.cdn %>/themes/base/minified' }, themes: { src: [ @@ -183,35 +180,35 @@ config.init({ 'MIT-LICENSE.txt', 'package.json' ], - dest: '<%= files.themesDistFolder %>' + dest: 'dist/<%= files.themes %>' } }, zip: { dist: { - src: '<%= files.distFolder %>/**/*', - dest: '<%= files.zip %>' + src: '<%= files.dist %>', + dest: '<%= files.dist %>.zip' }, cdn: { - src: '<%= files.cdnDistFolder %>/**/*', - dest: '<%= files.cdnZip %>' + src: '<%= files.cdn %>', + dest: '<%= files.cdn %>.zip' }, themes: { - src: '<%= files.themesDistFolder %>/**/*', - dest: '<%= files.themesZip %>' + src: '<%= files.themes %>', + dest: '<%= files.themes %>.zip' } }, md5: { dist: { - dir: '<%= files.distFolder %>', - dest: '<%= files.distFolder %>/MANIFEST' + dir: 'dist/<%= files.dist %>', + dest: 'dist/<%= files.dist %>/MANIFEST' }, cdn: { - dir: '<%= files.cdnDistFolder %>', - dest: '<%= files.cdnDistFolder %>/MANIFEST' + dir: 'dist/<%= files.cdn %>', + dest: 'dist/<%= files.cdn %>/MANIFEST' }, themes: { - dir: '<%= files.themesDistFolder %>', - dest: '<%= files.themesDistFolder %>/MANIFEST' + dir: 'dist/<%= files.themes %>', + dest: 'dist/<%= files.themes %>/MANIFEST' } }, qunit: { @@ -266,26 +263,47 @@ task.registerBasicTask('copy', 'Copy files to destination folder and replace @VE for (var fileName in data.renames) { file.copy(fileName, target + template.process(data.renames[fileName], config())); } - if (data.renames) { + if (data.renames && data.renames.length) { log.writeln('Renamed ' + data.renames.length + ' files.'); } }); task.registerBasicTask('zip', 'Create a zip file for release', function(data) { - var files = file.expand(data.src); - log.writeln("Creating zip file " + data.dest); + var done = this.async(); + // TODO switch back to adm-zip for better cross-platform compability once it actually works + // 0.1.2 doesn't compress properly (or at all) - var fs = require('fs'); - var AdmZip = require('adm-zip'); - var zip = new AdmZip(); - files.forEach(function(file) { - log.verbose.writeln('Zipping ' + file); - // rewrite file names from dist folder (created by build), drop the /dist part - zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); + // var files = file.expand(data.src); + // log.writeln("Creating zip file " + data.dest); + + // var fs = require('fs'); + // var AdmZip = require('adm-zip'); + // var zip = new AdmZip(); + // files.forEach(function(file) { + // log.verbose.writeln('Zipping ' + file); + // // rewrite file names from dist folder (created by build), drop the /dist part + // zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); + // }); + // zip.writeZip(data.dest); + // log.writeln("Wrote " + files.length + " files to " + data.dest); + + var src = template.process(data.src, config()); + task.helper("child_process", { + cmd: "zip", + args: ["-r", data.dest, src], + opts: { + cwd: 'dist' + } + }, function(err, result) { + if (err) { + log.error(err); + done(); + return; + } + log.writeln("Zipped " + data.dest); + done(); }); - zip.writeZip(data.dest); - log.writeln("Wrote " + files.length + " files to " + data.dest); }); task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( data ) { -- cgit v1.2.3 From 19088fa91ece3b86550f9f63c1094ca96144c13e Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 17:42:57 +0100 Subject: Build/grunt: Fix a few oversights from the files config refactoring. Also finish the release_cdn target, now it includes all themes --- grunt.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 5ee1e63c8..542d0066d 100644 --- a/grunt.js +++ b/grunt.js @@ -134,8 +134,6 @@ config.init({ 'GPL-LICENSE.txt', 'MIT-LICENSE.txt', 'ui/*.js', - 'themes/base/images/*.png', - 'themes/base/jquery.ui.*.css', 'package.json' ], renames: { @@ -163,16 +161,16 @@ config.init({ strip: /^dist\/minified/, dest: 'dist/<%= files.cdn %>/ui' }, - cdn_css_min: { - src: 'dist/themes/base/minified/*.css', - strip: /^dist/, - dest: 'dist/<%= files.cdn %>' - }, cdn_min_images: { src: 'themes/base/images/*', strip: /^themes\/base\//, dest: 'dist/<%= files.cdn %>/themes/base/minified' }, + cdn_themes: { + src: 'dist/<%= files.themes %>/themes/**/*', + strip: 'dist/<%= files.themes %>', + dest: 'dist/<%= files.cdn %>' + }, themes: { src: [ 'AUTHORS.txt', @@ -255,8 +253,12 @@ task.registerBasicTask('copy', 'Copy files to destination folder and replace @VE } var files = file.expand(data.src); var target = data.dest + '/'; + var strip = data.strip; + if (typeof strip === 'string') { + strip = new RegExp('^' + template.process(strip, config()).replace(/[-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")); + } files.forEach(function(fileName) { - var targetFile = data.strip ? fileName.replace(data.strip, '') : fileName; + var targetFile = strip ? fileName.replace(strip, '') : fileName; file.copy(fileName, target + targetFile, replaceVersion); }); log.writeln('Copyied ' + files.length + ' files.'); @@ -385,14 +387,14 @@ task.registerTask('copy_themes', function() { var files = file.expand('dist/tmp/*/development-bundle/themes/**/*').filter(function(file) { return !filter.test(file); }); - var target = config('files.themesDistFolder') + '/'; + var target = 'dist/' + config('files.themes') + '/'; files.forEach(function(fileName) { var targetFile = fileName.replace(/dist\/tmp\/\d+\/development-bundle\//, '').replace("jquery-ui-.custom", "jquery-ui.css"); file.copy(fileName, target + targetFile); }); // copy minified base theme from regular release - var distFolder = config('files.distFolder'); + var distFolder = 'dist/' + config('files.dist'); files = file.expand(distFolder + '/themes/base/**/*'); files.forEach(function(fileName) { file.copy(fileName, target + fileName.replace(distFolder, '')); @@ -475,5 +477,4 @@ task.registerTask('sizer', 'concat:ui min:dist/jquery-ui.min.js compare_size'); task.registerTask('build', 'concat min css_min'); task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist'); task.registerTask('release_themes', 'release download_themes copy_themes copy:themes md5:themes zip:themes'); -// TODO include other themes in cdn release -task.registerTask('release_cdn', 'build copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_css_min copy:cdn_min_images md5:cdn zip:cdn'); +task.registerTask('release_cdn', 'release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn'); -- cgit v1.2.3 From 9fd5e7a153edb3dd5c060f7e6faad80c12120535 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 17:58:34 +0100 Subject: Build/grunt: Improve lint setup, configure options and globals for different contexts --- grunt.js | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 542d0066d..50e999993 100644 --- a/grunt.js +++ b/grunt.js @@ -217,8 +217,9 @@ config.init({ }) }, lint: { - // TODO extend this to tests - files: ['ui/*'] + ui: 'ui/*', + grunt: 'grunt.js', + tests: 'tests/unit/**/*.js' }, jshint: { options: { @@ -230,11 +231,38 @@ config.init({ noarg: true, sub: true, undef: true, - eqnull: true, - browser: true + eqnull: true }, - globals: { - jQuery: true + grunt: { + options: { + node: true + }, + globals: { + file: true, + log: true, + template: true + } + }, + ui: { + options: { + browser: true + }, + globals: { + jQuery: true + } + }, + tests: { + options: { + jquery: true + }, + globals: { + module: true, + test: true, + ok: true, + equal: true, + deepEqual: true, + QUnit: true + } } } }); @@ -255,7 +283,7 @@ task.registerBasicTask('copy', 'Copy files to destination folder and replace @VE var target = data.dest + '/'; var strip = data.strip; if (typeof strip === 'string') { - strip = new RegExp('^' + template.process(strip, config()).replace(/[-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")); + strip = new RegExp('^' + template.process(strip, config()).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")); } files.forEach(function(fileName) { var targetFile = strip ? fileName.replace(strip, '') : fileName; -- cgit v1.2.3 From 85ea681685f73498e22a7c120ad0e46430b97d7c Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 9 Mar 2012 17:59:57 +0100 Subject: Build/grunt: Improve lint setup, get rid of file comment, using gruntjs specific config anyway --- grunt.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 50e999993..e4db51f65 100644 --- a/grunt.js +++ b/grunt.js @@ -1,4 +1,3 @@ -/*global config:true, task:true*/ function stripBanner(files) { return files.map(function(file) { return ''; @@ -238,6 +237,8 @@ config.init({ node: true }, globals: { + task: true, + config: true, file: true, log: true, template: true -- cgit v1.2.3 From 2865a629871b1534b6e32418137f5d249da6f7fb Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sat, 10 Mar 2012 12:55:36 +0100 Subject: Build/grunt: Update codebase to adapt or make use of latest changes in grunt --- grunt.js | 75 +++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 36 insertions(+), 39 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index e4db51f65..fe840c15d 100644 --- a/grunt.js +++ b/grunt.js @@ -12,7 +12,7 @@ function createBanner(files) { return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= template.today("isoDate") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + - '* Includes: ' + (files ? fileNames.join(', ') : '<%= stripDirectory(task.current.data.src[1]) %>') + '\n' + + '* Includes: ' + (files ? fileNames.join(', ') : '<%= stripDirectory(task.current.file.src[1]) %>') + '\n' + '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; } @@ -21,6 +21,7 @@ global.stripDirectory = stripDirectory; task.registerHelper('strip_all_banners', function(filepath) { return file.read(filepath).replace(/^\s*\/\*[\s\S]*?\*\/\s*/g, ''); }); +var inspect = require('util').inspect; var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); var uiFiles = coreFiles.map(function(file) { @@ -196,15 +197,15 @@ config.init({ }, md5: { dist: { - dir: 'dist/<%= files.dist %>', + src: 'dist/<%= files.dist %>', dest: 'dist/<%= files.dist %>/MANIFEST' }, cdn: { - dir: 'dist/<%= files.cdn %>', + src: 'dist/<%= files.cdn %>', dest: 'dist/<%= files.cdn %>/MANIFEST' }, themes: { - dir: 'dist/<%= files.themes %>', + src: 'dist/<%= files.themes %>', dest: 'dist/<%= files.themes %>/MANIFEST' } }, @@ -268,21 +269,13 @@ config.init({ } }); -// grunt doesn't know about this files object, so need to process that manually once -// before any other variable is resolved, otherwise it would just include the templates -var files = config().files; -for (var key in files) { - files[key] = template.process(files[key], config()); -} -config('files', files); - -task.registerBasicTask('copy', 'Copy files to destination folder and replace @VERSION with pkg.version', function(data) { +task.registerBasicTask('copy', 'Copy files to destination folder and replace @VERSION with pkg.version', function() { function replaceVersion(source) { return source.replace("@VERSION", config("pkg.version")); } - var files = file.expand(data.src); - var target = data.dest + '/'; - var strip = data.strip; + var files = file.expand(this.file.src); + var target = this.file.dest + '/'; + var strip = this.data.strip; if (typeof strip === 'string') { strip = new RegExp('^' + template.process(strip, config()).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")); } @@ -291,22 +284,24 @@ task.registerBasicTask('copy', 'Copy files to destination folder and replace @VE file.copy(fileName, target + targetFile, replaceVersion); }); log.writeln('Copyied ' + files.length + ' files.'); - for (var fileName in data.renames) { - file.copy(fileName, target + template.process(data.renames[fileName], config())); + var renameCount = 0; + for (var fileName in this.data.renames) { + renameCount += 1; + file.copy(fileName, target + template.process(this.data.renames[fileName], config())); } - if (data.renames && data.renames.length) { - log.writeln('Renamed ' + data.renames.length + ' files.'); + if (renameCount) { + log.writeln('Renamed ' + renameCount + ' files.'); } }); -task.registerBasicTask('zip', 'Create a zip file for release', function(data) { +task.registerBasicTask('zip', 'Create a zip file for release', function() { var done = this.async(); // TODO switch back to adm-zip for better cross-platform compability once it actually works // 0.1.2 doesn't compress properly (or at all) - // var files = file.expand(data.src); - // log.writeln("Creating zip file " + data.dest); + // var files = file.expand(this.file.src); + // log.writeln("Creating zip file " + this.file.dest); // var fs = require('fs'); // var AdmZip = require('adm-zip'); @@ -316,13 +311,14 @@ task.registerBasicTask('zip', 'Create a zip file for release', function(data) { // // rewrite file names from dist folder (created by build), drop the /dist part // zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); // }); - // zip.writeZip(data.dest); - // log.writeln("Wrote " + files.length + " files to " + data.dest); + // zip.writeZip(this.file.dest); + // log.writeln("Wrote " + files.length + " files to " + this.file.dest); - var src = template.process(data.src, config()); + var dest = this.file.dest; + var src = template.process(this.file.src, config()); task.helper("child_process", { cmd: "zip", - args: ["-r", data.dest, src], + args: ["-r", dest, src], opts: { cwd: 'dist' } @@ -332,13 +328,13 @@ task.registerBasicTask('zip', 'Create a zip file for release', function(data) { done(); return; } - log.writeln("Zipped " + data.dest); + log.writeln("Zipped " + dest); done(); }); }); -task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( data ) { - var files = file.expand( data.src ); +task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function() { + var files = file.expand( this.file.src ); // Get banner, if specified. It would be nice if UglifyJS supported ignoring // all comments matching a certain pattern, like /*!...*/, but it doesn't. var banner = task.directive(files[0], function() { return null; }); @@ -350,28 +346,29 @@ task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( da var max = task.helper( 'concat', files ); // Concat banner + minified source. var min = banner + require('sqwish').minify( max, false ); - file.write( data.dest, min ); + file.write( this.file.dest, min ); if ( task.hadErrors() ) { return false; } - log.writeln( 'File "' + data.dest + '" created.' ); + log.writeln( 'File "' + this.file.dest + '" created.' ); task.helper( 'min_max_info', min, max ); }); -task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', function(data) { +task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', function() { // remove dest file before creating it, to make sure itself is not included - if (require('path').existsSync(data.dest)) { - require('fs').unlinkSync(data.dest); + if (require('path').existsSync(this.file.dest)) { + require('fs').unlinkSync(this.file.dest); } var crypto = require('crypto'); - var dir = template.process(data.dir, config()) + '/'; + var dir = this.file.src + '/'; var hashes = []; file.expand(dir + '**/*').forEach(function(fileName) { var hash = crypto.createHash('md5'); hash.update(file.read(fileName)); hashes.push(fileName.replace(dir, '') + ' ' + hash.digest('hex')); }); - file.write(data.dest, hashes.join('\n') + '\n'); + file.write(this.file.dest, hashes.join('\n') + '\n'); + log.writeln('Wrote ' + this.file.dest + ' with ' + hashes.length + ' hashes'); }); task.registerTask('download_themes', function() { @@ -433,8 +430,8 @@ task.registerTask('copy_themes', function() { // TODO merge with code in jQuery Core, share as grunt plugin/npm // this here actually uses the provided filenames in the output // the helpers should just be regular functions, no need to share those with the world -task.registerBasicTask("compare_size", "Compare size of this branch to master", function(data) { - var files = file.expand(data.src), +task.registerBasicTask("compare_size", "Compare size of this branch to master", function() { + var files = file.expand(this.file.src), done = this.async(), sizecache = __dirname + "/dist/.sizecache.json", sources = { -- cgit v1.2.3 From fd9b7d3475870cff054b0b21a310fb21e05ed794 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sat, 10 Mar 2012 13:45:16 +0100 Subject: Build/grunt: Integrate CSSLint --- grunt.js | 43 ++++++++++++++++++++++++++++++++++++++++++- package.json | 4 ++-- 2 files changed, 44 insertions(+), 3 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index fe840c15d..ae837d7fc 100644 --- a/grunt.js +++ b/grunt.js @@ -221,6 +221,15 @@ config.init({ grunt: 'grunt.js', tests: 'tests/unit/**/*.js' }, + csslint: { + base_theme: { + src: 'themes/base/*.css', + rules: { + 'import': false, + 'overqualified-elements': 2 + } + } + }, jshint: { options: { curly: true, @@ -333,6 +342,38 @@ task.registerBasicTask('zip', 'Create a zip file for release', function() { }); }); +task.registerBasicTask('csslint', 'Lint CSS files with csslint', function() { + var csslint = require('csslint').CSSLint; + var files = file.expand(this.file.src); + var ruleset = {}; + csslint.getRules().forEach(function(rule) { + ruleset[rule.id] = 1; + }); + for (var rule in this.data.rules) { + if (!this.data.rules[rule]) { + delete ruleset[rule]; + } else { + ruleset[rule] = this.data.rules[rule]; + } + } + var hadErrors = 0; + files.forEach(function(filepath) { + log.writeln('Linting ' + filepath); + var result = csslint.verify(file.read(filepath), ruleset); + result.messages.forEach(function(message) { + log.writeln('['.red + ('L' + message.line).yellow + ':'.red + ('C' + message.col).yellow + ']'.red); + log[message.type === 'error' ? 'error' : 'writeln'](message.message + ' ' + message.rule.desc + ' (' + message.rule.id + ')'); + }); + if (result.messages.length) { + hadErrors += 1; + } + }); + if (hadErrors) { + return false; + } + log.writeln('Lint free'); +}); + task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function() { var files = file.expand( this.file.src ); // Get banner, if specified. It would be nice if UglifyJS supported ignoring @@ -498,7 +539,7 @@ task.registerHelper("lpad", function(str, len, chr) { return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len ); }); -task.registerTask('default', 'lint qunit build compare_size'); +task.registerTask('default', 'lint csslint qunit build compare_size'); task.registerTask('sizer', 'concat:ui min:dist/jquery-ui.min.js compare_size'); task.registerTask('build', 'concat min css_min'); task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist'); diff --git a/package.json b/package.json index 2d473076a..cd0c9f78d 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,9 @@ "dependencies": {}, "devDependencies": { "grunt": "0.2.x", - "adm-zip": "0.1.x", "sqwish": "0.2.x", - "request": "0.2.x" + "request": "2.9.x", + "csslint": "0.9.x" }, "keywords": [] } \ No newline at end of file -- cgit v1.2.3 From 5e6fc4f086e72e9f247426f2cbe4a3cd7a2013fd Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sat, 10 Mar 2012 13:53:53 +0100 Subject: Build/grunt: Simplify css_min basic task, concat helper already takes care of executing directives --- grunt.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index ae837d7fc..cbf3d48a6 100644 --- a/grunt.js +++ b/grunt.js @@ -375,22 +375,9 @@ task.registerBasicTask('csslint', 'Lint CSS files with csslint', function() { }); task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function() { - var files = file.expand( this.file.src ); - // Get banner, if specified. It would be nice if UglifyJS supported ignoring - // all comments matching a certain pattern, like /*!...*/, but it doesn't. - var banner = task.directive(files[0], function() { return null; }); - if (banner === null) { - banner = ''; - } else { - files.shift(); - } - var max = task.helper( 'concat', files ); - // Concat banner + minified source. - var min = banner + require('sqwish').minify( max, false ); + var max = task.helper( 'concat', file.expand( this.file.src ) ); + var min = require('sqwish').minify( max, false ); file.write( this.file.dest, min ); - if ( task.hadErrors() ) { - return false; - } log.writeln( 'File "' + this.file.dest + '" created.' ); task.helper( 'min_max_info', min, max ); }); -- cgit v1.2.3 From 6f301eab57f888b56bcbe6277a0d584e2aacd508 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sat, 10 Mar 2012 15:07:53 +0100 Subject: Build/grunt: Fix copy_themes task, files.themes config property wasn't processed properly --- grunt.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index cbf3d48a6..585aed809 100644 --- a/grunt.js +++ b/grunt.js @@ -441,7 +441,8 @@ task.registerTask('copy_themes', function() { var files = file.expand('dist/tmp/*/development-bundle/themes/**/*').filter(function(file) { return !filter.test(file); }); - var target = 'dist/' + config('files.themes') + '/'; + // TODO the template.process call shouldn't be necessary + var target = 'dist/' + template.process(config('files.themes'), config()) + '/'; files.forEach(function(fileName) { var targetFile = fileName.replace(/dist\/tmp\/\d+\/development-bundle\//, '').replace("jquery-ui-.custom", "jquery-ui.css"); file.copy(fileName, target + targetFile); -- cgit v1.2.3 From 5fa2cd47bbf6163464357fbfcece45087ac0faa2 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sun, 11 Mar 2012 12:34:52 +0100 Subject: Build/grunt: Replace child_process helper with utils.spawn --- grunt.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 585aed809..b7d893cb8 100644 --- a/grunt.js +++ b/grunt.js @@ -325,7 +325,7 @@ task.registerBasicTask('zip', 'Create a zip file for release', function() { var dest = this.file.dest; var src = template.process(this.file.src, config()); - task.helper("child_process", { + utils.spawn({ cmd: "zip", args: ["-r", dest, src], opts: { @@ -418,7 +418,7 @@ task.registerTask('download_themes', function() { // var zip = new AdmZip(zipFileName); // zip.extractAllTo('dist/tmp/' + index + '/'); // until then, using cli unzip... - task.helper("child_process", { + utils.spawn({ cmd: "unzip", args: ["-d", "dist/tmp/" + index, zipFileName] }, function(err, result) { @@ -509,7 +509,7 @@ task.registerBasicTask("compare_size", "Compare size of this branch to master", }); }); task.registerHelper("git_current_branch", function(done) { - task.helper("child_process", { + utils.spawn({ cmd: "git", args: ["branch", "--no-color"] }, function(err, result) { -- cgit v1.2.3 From ee64f899e0eb47e4045d6049b78c7c089103476c Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sun, 11 Mar 2012 12:55:07 +0100 Subject: Build/grunt: Fix themes task --- grunt.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index b7d893cb8..f22322379 100644 --- a/grunt.js +++ b/grunt.js @@ -449,7 +449,8 @@ task.registerTask('copy_themes', function() { }); // copy minified base theme from regular release - var distFolder = 'dist/' + config('files.dist'); + // TODO same as the one above + var distFolder = 'dist/' + template.process(config('files.dist'), config()); files = file.expand(distFolder + '/themes/base/**/*'); files.forEach(function(fileName) { file.copy(fileName, target + fileName.replace(distFolder, '')); -- cgit v1.2.3 From b1167efd2898734b5f58ff1deb6d2c93d01dc51b Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 19 Mar 2012 17:12:21 -0400 Subject: Grunt: Coding standards. --- grunt.js | 964 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 483 insertions(+), 481 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index f22322379..9d0e721f2 100644 --- a/grunt.js +++ b/grunt.js @@ -1,536 +1,538 @@ -function stripBanner(files) { - return files.map(function(file) { - return ''; - }); +function stripBanner( files ) { + return files.map(function( file ) { + return ""; + }); } -function stripDirectory(file) { - return file.replace(/.+\/(.+)$/, '$1'); + +function stripDirectory( file ) { + return file.replace( /.+\/(.+)$/, "$1" ); } -function createBanner(files) { - // strip folders - var fileNames = files && files.map(stripDirectory); - return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + - '<%= template.today("isoDate") %>\n' + - '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + - '* Includes: ' + (files ? fileNames.join(', ') : '<%= stripDirectory(task.current.file.src[1]) %>') + '\n' + - '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'; + +function createBanner( files ) { + // strip folders + var fileNames = files && files.map( stripDirectory ); + return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + + "<%= template.today('isoDate') %>\n" + + "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" + + "* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(task.current.file.src[1]) %>") + "\n" + + "* Copyright (c) <%= template.today('yyyy') %> <%= pkg.author.name %>;" + + " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; } + // allow access from banner template global.stripDirectory = stripDirectory; -task.registerHelper('strip_all_banners', function(filepath) { - return file.read(filepath).replace(/^\s*\/\*[\s\S]*?\*\/\s*/g, ''); +task.registerHelper( "strip_all_banners", function( filepath ) { + return file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); }); -var inspect = require('util').inspect; +var inspect = require( "util" ).inspect; -var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', '); -var uiFiles = coreFiles.map(function(file) { - return 'ui/' + file; -}).concat(file.expand('ui/*.js').filter(function(file) { - return coreFiles.indexOf(file.substring(3)) === -1; +var coreFiles = "jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js".split( ", " ); +var uiFiles = coreFiles.map(function( file ) { + return "ui/" + file; +}).concat( file.expand( "ui/*.js" ).filter(function( file ) { + return coreFiles.indexOf( file.substring(3) ) === -1; })); var minify = { - 'dist/jquery-ui.min.js': ['', 'dist/jquery-ui.js'], - 'dist/i18n/jquery-ui-i18n.min.js': ['', 'dist/i18n/jquery-ui-i18n.js'] + "dist/jquery-ui.min.js": [ "", "dist/jquery-ui.js" ], + "dist/i18n/jquery-ui-i18n.min.js": [ "", "dist/i18n/jquery-ui-i18n.js" ] }; -function minFile(file) { - minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'minified/')] = ['', file]; +function minFile( file ) { + minify[ "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ) ] = [ "", file ]; } -uiFiles.forEach(minFile); +uiFiles.forEach( minFile ); -var allI18nFiles = file.expand('ui/i18n/*.js'); -allI18nFiles.forEach(minFile); +var allI18nFiles = file.expand( "ui/i18n/*.js" ); +allI18nFiles.forEach( minFile ); -var cssFiles = 'core accordion autocomplete button datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip theme'.split(' ').map(function(component) { - return 'themes/base/jquery.ui.' + component + '.css'; +var cssFiles = "core accordion autocomplete button datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip theme".split( " " ).map(function( component ) { + return "themes/base/jquery.ui." + component + ".css"; }); var minifyCSS = { - 'dist/jquery-ui.min.css': 'dist/jquery-ui.css' + "dist/jquery-ui.min.css": "dist/jquery-ui.css" }; -cssFiles.forEach(function(file) { - minifyCSS['dist/' + file.replace(/\.css$/, '.min.css').replace(/themes\/base\//, 'themes/base/minified/')] = ['', file]; +cssFiles.forEach(function( file ) { + minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", file ]; }); config.init({ - pkg: '', - files: { - dist: '<%= pkg.name %>-<%= pkg.version %>', - cdn: '<%= pkg.name %>-<%= pkg.version %>-cdn', - themes: '<%= pkg.name %>-themes-<%= pkg.version %>' - }, - meta: { - banner: createBanner(), - bannerAll: createBanner(uiFiles), - bannerI18n: createBanner(allI18nFiles), - bannerCSS: createBanner(cssFiles) - }, - compare_size: { - files: [ - "dist/jquery-ui.js", - "dist/jquery-ui.min.js" - ] - }, - concat: { - ui: { - src: ['', stripBanner(uiFiles)], - dest: 'dist/jquery-ui.js' - }, - i18n: { - src: ['', allI18nFiles], - dest: 'dist/i18n/jquery-ui-i18n.js' - }, - css: { - src: ['', stripBanner(cssFiles)], - dest: 'dist/jquery-ui.css' - } - }, - min: minify, - css_min: minifyCSS, - copy: { - dist: { - src: [ - 'AUTHORS.txt', - 'GPL-LICENSE.txt', - 'jquery-1.7.1.js', - 'MIT-LICENSE.txt', - 'README.md', - 'grunt.js', - 'package.json', - 'ui/**/*', - 'demos/**/*', - 'themes/**/*', - 'external/**/*', - 'tests/**/*' - ], - renames: { - 'dist/jquery-ui.js': 'ui/jquery-ui.js', - 'dist/jquery-ui.min.js': 'ui/minified/jquery-ui.min.js', - 'dist/i18n/jquery-ui-i18n.js': 'ui/i18n/jquery-ui-i18n.js', - 'dist/i18n/jquery-ui-i18n.min.js': 'ui/minified/i18n/jquery-ui-i18n.min.js', - 'dist/jquery-ui.css': 'themes/base/jquery-ui.css', - 'dist/jquery-ui.min.css': 'themes/base/minified/jquery-ui.min.css' - }, - dest: 'dist/<%= files.dist %>' - }, - dist_min: { - src: 'dist/minified/**/*', - strip: /^dist/, - dest: 'dist/<%= files.dist %>/ui' - }, - dist_css_min: { - src: 'dist/themes/base/minified/*.css', - strip: /^dist/, - dest: 'dist/<%= files.dist %>' - }, - dist_min_images: { - src: 'themes/base/images/*', - strip: /^themes\/base\//, - dest: 'dist/<%= files.dist %>/themes/base/minified' - }, - cdn: { - src: [ - 'AUTHORS.txt', - 'GPL-LICENSE.txt', - 'MIT-LICENSE.txt', - 'ui/*.js', - 'package.json' - ], - renames: { - 'dist/jquery-ui.js': 'jquery-ui.js', - 'dist/jquery-ui.min.js': 'jquery-ui.min.js', - 'dist/i18n/jquery-ui-i18n.js': 'i18n/jquery-ui-i18n.js', - 'dist/i18n/jquery-ui-i18n.min.js': 'i18n/jquery-ui-i18n.min.js', - 'dist/jquery-ui.css': 'themes/base/jquery-ui.css', - 'dist/jquery-ui.min.css': 'themes/base/minified/jquery-ui.min.css' - }, - dest: 'dist/<%= files.cdn %>' - }, - cdn_i18n: { - src: 'ui/i18n/jquery.ui.datepicker-*.js', - strip: 'ui/', - dest: 'dist/<%= files.cdn %>' - }, - cdn_i18n_min: { - src: 'dist/minified/i18n/jquery.ui.datepicker-*.js', - strip: 'dist/minified', - dest: 'dist/<%= files.cdn %>' - }, - cdn_min: { - src: 'dist/minified/*.js', - strip: /^dist\/minified/, - dest: 'dist/<%= files.cdn %>/ui' - }, - cdn_min_images: { - src: 'themes/base/images/*', - strip: /^themes\/base\//, - dest: 'dist/<%= files.cdn %>/themes/base/minified' - }, - cdn_themes: { - src: 'dist/<%= files.themes %>/themes/**/*', - strip: 'dist/<%= files.themes %>', - dest: 'dist/<%= files.cdn %>' - }, - themes: { - src: [ - 'AUTHORS.txt', - 'GPL-LICENSE.txt', - 'MIT-LICENSE.txt', - 'package.json' - ], - dest: 'dist/<%= files.themes %>' - } - }, - zip: { - dist: { - src: '<%= files.dist %>', - dest: '<%= files.dist %>.zip' - }, - cdn: { - src: '<%= files.cdn %>', - dest: '<%= files.cdn %>.zip' - }, - themes: { - src: '<%= files.themes %>', - dest: '<%= files.themes %>.zip' - } - }, - md5: { - dist: { - src: 'dist/<%= files.dist %>', - dest: 'dist/<%= files.dist %>/MANIFEST' - }, - cdn: { - src: 'dist/<%= files.cdn %>', - dest: 'dist/<%= files.cdn %>/MANIFEST' - }, - themes: { - src: 'dist/<%= files.themes %>', - dest: 'dist/<%= files.themes %>/MANIFEST' - } - }, - qunit: { - files: file.expand('tests/unit/**/*.html').filter(function(file) { - // disabling everything that doesn't (quite) work with PhantomJS for now - // except for all|index|test, try to include more as we go - return !(/(all|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html/).test(file); - }) - }, - lint: { - ui: 'ui/*', - grunt: 'grunt.js', - tests: 'tests/unit/**/*.js' - }, - csslint: { - base_theme: { - src: 'themes/base/*.css', - rules: { - 'import': false, - 'overqualified-elements': 2 - } - } - }, - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - eqnull: true - }, - grunt: { - options: { - node: true - }, - globals: { - task: true, - config: true, - file: true, - log: true, - template: true - } - }, - ui: { - options: { - browser: true - }, - globals: { - jQuery: true - } - }, - tests: { - options: { - jquery: true - }, - globals: { - module: true, - test: true, - ok: true, - equal: true, - deepEqual: true, - QUnit: true - } - } - } + pkg: "", + files: { + dist: "<%= pkg.name %>-<%= pkg.version %>", + cdn: "<%= pkg.name %>-<%= pkg.version %>-cdn", + themes: "<%= pkg.name %>-themes-<%= pkg.version %>" + }, + meta: { + banner: createBanner(), + bannerAll: createBanner( uiFiles ), + bannerI18n: createBanner( allI18nFiles ), + bannerCSS: createBanner( cssFiles ) + }, + compare_size: { + files: [ + "dist/jquery-ui.js", + "dist/jquery-ui.min.js" + ] + }, + concat: { + ui: { + src: [ "", stripBanner( uiFiles ) ], + dest: "dist/jquery-ui.js" + }, + i18n: { + src: [ "", allI18nFiles ], + dest: "dist/i18n/jquery-ui-i18n.js" + }, + css: { + src: [ "", stripBanner( cssFiles ) ], + dest: "dist/jquery-ui.css" + } + }, + min: minify, + css_min: minifyCSS, + copy: { + dist: { + src: [ + "AUTHORS.txt", + "GPL-LICENSE.txt", + "jquery-1.7.1.js", + "MIT-LICENSE.txt", + "README.md", + "grunt.js", + "package.json", + "ui/**/*", + "demos/**/*", + "themes/**/*", + "external/**/*", + "tests/**/*" + ], + renames: { + "dist/jquery-ui.js": "ui/jquery-ui.js", + "dist/jquery-ui.min.js": "ui/minified/jquery-ui.min.js", + "dist/i18n/jquery-ui-i18n.js": "ui/i18n/jquery-ui-i18n.js", + "dist/i18n/jquery-ui-i18n.min.js": "ui/minified/i18n/jquery-ui-i18n.min.js", + "dist/jquery-ui.css": "themes/base/jquery-ui.css", + "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" + }, + dest: "dist/<%= files.dist %>" + }, + dist_min: { + src: "dist/minified/**/*", + strip: /^dist/, + dest: "dist/<%= files.dist %>/ui" + }, + dist_css_min: { + src: "dist/themes/base/minified/*.css", + strip: /^dist/, + dest: "dist/<%= files.dist %>" + }, + dist_min_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/<%= files.dist %>/themes/base/minified" + }, + cdn: { + src: [ + "AUTHORS.txt", + "GPL-LICENSE.txt", + "MIT-LICENSE.txt", + "ui/*.js", + "package.json" + ], + renames: { + "dist/jquery-ui.js": "jquery-ui.js", + "dist/jquery-ui.min.js": "jquery-ui.min.js", + "dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js", + "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js", + "dist/jquery-ui.css": "themes/base/jquery-ui.css", + "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" + }, + dest: "dist/<%= files.cdn %>" + }, + cdn_i18n: { + src: "ui/i18n/jquery.ui.datepicker-*.js", + strip: "ui/", + dest: "dist/<%= files.cdn %>" + }, + cdn_i18n_min: { + src: "dist/minified/i18n/jquery.ui.datepicker-*.js", + strip: "dist/minified", + dest: "dist/<%= files.cdn %>" + }, + cdn_min: { + src: "dist/minified/*.js", + strip: /^dist\/minified/, + dest: "dist/<%= files.cdn %>/ui" + }, + cdn_min_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/<%= files.cdn %>/themes/base/minified" + }, + cdn_themes: { + src: "dist/<%= files.themes %>/themes/**/*", + strip: "dist/<%= files.themes %>", + dest: "dist/<%= files.cdn %>" + }, + themes: { + src: [ + "AUTHORS.txt", + "GPL-LICENSE.txt", + "MIT-LICENSE.txt", + "package.json" + ], + dest: "dist/<%= files.themes %>" + } + }, + zip: { + dist: { + src: "<%= files.dist %>", + dest: "<%= files.dist %>.zip" + }, + cdn: { + src: "<%= files.cdn %>", + dest: "<%= files.cdn %>.zip" + }, + themes: { + src: "<%= files.themes %>", + dest: "<%= files.themes %>.zip" + } + }, + md5: { + dist: { + src: "dist/<%= files.dist %>", + dest: "dist/<%= files.dist %>/MANIFEST" + }, + cdn: { + src: "dist/<%= files.cdn %>", + dest: "dist/<%= files.cdn %>/MANIFEST" + }, + themes: { + src: "dist/<%= files.themes %>", + dest: "dist/<%= files.themes %>/MANIFEST" + } + }, + qunit: { + files: file.expand( "tests/unit/**/*.html" ).filter(function( file ) { + // disabling everything that doesn't (quite) work with PhantomJS for now + // except for all|index|test, try to include more as we go + return !( /(all|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html/ ).test( file ); + }) + }, + lint: { + ui: "ui/*", + grunt: "grunt.js", + tests: "tests/unit/**/*.js" + }, + csslint: { + base_theme: { + src: "themes/base/*.css", + rules: { + "import": false, + "overqualified-elements": 2 + } + } + }, + jshint: { + options: { + curly: true, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true + }, + grunt: { + options: { + node: true + }, + globals: { + task: true, + config: true, + file: true, + log: true, + template: true + } + }, + ui: { + options: { + browser: true + }, + globals: { + jQuery: true + } + }, + tests: { + options: { + jquery: true + }, + globals: { + module: true, + test: true, + ok: true, + equal: true, + deepEqual: true, + QUnit: true + } + } + } }); -task.registerBasicTask('copy', 'Copy files to destination folder and replace @VERSION with pkg.version', function() { - function replaceVersion(source) { - return source.replace("@VERSION", config("pkg.version")); - } - var files = file.expand(this.file.src); - var target = this.file.dest + '/'; - var strip = this.data.strip; - if (typeof strip === 'string') { - strip = new RegExp('^' + template.process(strip, config()).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")); - } - files.forEach(function(fileName) { - var targetFile = strip ? fileName.replace(strip, '') : fileName; - file.copy(fileName, target + targetFile, replaceVersion); - }); - log.writeln('Copyied ' + files.length + ' files.'); - var renameCount = 0; - for (var fileName in this.data.renames) { - renameCount += 1; - file.copy(fileName, target + template.process(this.data.renames[fileName], config())); - } - if (renameCount) { - log.writeln('Renamed ' + renameCount + ' files.'); - } +task.registerBasicTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() { + function replaceVersion( source ) { + return source.replace( "@VERSION", config( "pkg.version" ) ); + } + var files = file.expand( this.file.src ); + var target = this.file.dest + "/"; + var strip = this.data.strip; + if ( typeof strip === "string" ) { + strip = new RegExp( "^" + template.process( strip, config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) ); + } + files.forEach(function( fileName ) { + var targetFile = strip ? fileName.replace( strip, "" ) : fileName; + file.copy( fileName, target + targetFile, replaceVersion ); + }); + log.writeln( "Copied " + files.length + " files." ); + var renameCount = 0; + for ( var fileName in this.data.renames ) { + renameCount += 1; + file.copy( fileName, target + template.process( this.data.renames[ fileName ], config() ) ); + } + if ( renameCount ) { + log.writeln( "Renamed " + renameCount + " files." ); + } }); -task.registerBasicTask('zip', 'Create a zip file for release', function() { - var done = this.async(); - // TODO switch back to adm-zip for better cross-platform compability once it actually works - // 0.1.2 doesn't compress properly (or at all) +task.registerBasicTask( "zip", "Create a zip file for release", function() { + var done = this.async(); + // TODO switch back to adm-zip for better cross-platform compability once it actually works + // 0.1.2 doesn't compress properly (or at all) - // var files = file.expand(this.file.src); - // log.writeln("Creating zip file " + this.file.dest); + // var files = file.expand(this.file.src); + // log.writeln("Creating zip file " + this.file.dest); - // var fs = require('fs'); - // var AdmZip = require('adm-zip'); - // var zip = new AdmZip(); - // files.forEach(function(file) { - // log.verbose.writeln('Zipping ' + file); - // // rewrite file names from dist folder (created by build), drop the /dist part - // zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); - // }); - // zip.writeZip(this.file.dest); - // log.writeln("Wrote " + files.length + " files to " + this.file.dest); + // var fs = require('fs'); + // var AdmZip = require('adm-zip'); + // var zip = new AdmZip(); + // files.forEach(function(file) { + // log.verbose.writeln('Zipping ' + file); + // // rewrite file names from dist folder (created by build), drop the /dist part + // zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); + // }); + // zip.writeZip(this.file.dest); + // log.writeln("Wrote " + files.length + " files to " + this.file.dest); - var dest = this.file.dest; - var src = template.process(this.file.src, config()); - utils.spawn({ - cmd: "zip", - args: ["-r", dest, src], - opts: { - cwd: 'dist' - } - }, function(err, result) { - if (err) { - log.error(err); - done(); - return; - } - log.writeln("Zipped " + dest); - done(); - }); + var dest = this.file.dest; + var src = template.process( this.file.src, config() ); + utils.spawn({ + cmd: "zip", + args: [ "-r", dest, src ], + opts: { + cwd: 'dist' + } + }, function( err, result ) { + if ( err ) { + log.error( err ); + done(); + return; + } + log.writeln( "Zipped " + dest ); + done(); + }); }); -task.registerBasicTask('csslint', 'Lint CSS files with csslint', function() { - var csslint = require('csslint').CSSLint; - var files = file.expand(this.file.src); - var ruleset = {}; - csslint.getRules().forEach(function(rule) { - ruleset[rule.id] = 1; - }); - for (var rule in this.data.rules) { - if (!this.data.rules[rule]) { - delete ruleset[rule]; - } else { - ruleset[rule] = this.data.rules[rule]; - } - } - var hadErrors = 0; - files.forEach(function(filepath) { - log.writeln('Linting ' + filepath); - var result = csslint.verify(file.read(filepath), ruleset); - result.messages.forEach(function(message) { - log.writeln('['.red + ('L' + message.line).yellow + ':'.red + ('C' + message.col).yellow + ']'.red); - log[message.type === 'error' ? 'error' : 'writeln'](message.message + ' ' + message.rule.desc + ' (' + message.rule.id + ')'); - }); - if (result.messages.length) { - hadErrors += 1; - } - }); - if (hadErrors) { - return false; - } - log.writeln('Lint free'); +task.registerBasicTask( "csslint", "Lint CSS files with csslint", function() { + var csslint = require( "csslint" ).CSSLint; + var files = file.expand( this.file.src ); + var ruleset = {}; + csslint.getRules().forEach(function( rule ) { + ruleset[ rule.id ] = 1; + }); + for ( var rule in this.data.rules ) { + if ( !this.data.rules[ rule ] ) { + delete ruleset[rule]; + } else { + ruleset[ rule ] = this.data.rules[ rule ]; + } + } + var hadErrors = 0; + files.forEach(function( filepath ) { + log.writeln( "Linting " + filepath ); + var result = csslint.verify( file.read( filepath ), ruleset ); + result.messages.forEach(function( message ) { + log.writeln( "[".red + ( "L" + message.line ).yellow + ":".red + ( "C" + message.col ).yellow + "]".red ); + log[ message.type === "error" ? "error" : "writeln" ]( message.message + " " + message.rule.desc + " (" + message.rule.id + ")" ); + }); + if ( result.messages.length ) { + hadErrors += 1; + } + }); + if (hadErrors) { + return false; + } + log.writeln( "Lint free" ); }); -task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function() { - var max = task.helper( 'concat', file.expand( this.file.src ) ); - var min = require('sqwish').minify( max, false ); - file.write( this.file.dest, min ); - log.writeln( 'File "' + this.file.dest + '" created.' ); - task.helper( 'min_max_info', min, max ); +task.registerBasicTask( "css_min", "Minify CSS files with Sqwish.", function() { + var max = task.helper( "concat", file.expand( this.file.src ) ); + var min = require( "sqwish" ).minify( max, false ); + file.write( this.file.dest, min ); + log.writeln( "File '" + this.file.dest + "' created." ); + task.helper( "min_max_info", min, max ); }); -task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', function() { - // remove dest file before creating it, to make sure itself is not included - if (require('path').existsSync(this.file.dest)) { - require('fs').unlinkSync(this.file.dest); - } - var crypto = require('crypto'); - var dir = this.file.src + '/'; - var hashes = []; - file.expand(dir + '**/*').forEach(function(fileName) { - var hash = crypto.createHash('md5'); - hash.update(file.read(fileName)); - hashes.push(fileName.replace(dir, '') + ' ' + hash.digest('hex')); - }); - file.write(this.file.dest, hashes.join('\n') + '\n'); - log.writeln('Wrote ' + this.file.dest + ' with ' + hashes.length + ' hashes'); +task.registerBasicTask( "md5", "Create list of md5 hashes for CDN uploads", function() { + // remove dest file before creating it, to make sure itself is not included + if ( require( "path" ).existsSync( this.file.dest ) ) { + require( "fs" ).unlinkSync( this.file.dest ); + } + var crypto = require( "crypto" ); + var dir = this.file.src + "/"; + var hashes = []; + file.expand( dir + "**/*" ).forEach(function( fileName ) { + var hash = crypto.createHash( "md5" ); + hash.update( file.read( fileName ) ); + hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); + }); + file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); + log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); }); -task.registerTask('download_themes', function() { - // var AdmZip = require('adm-zip'); - var fs = require('fs'); - var request = require('request'); - var done = this.async(); - var themes = file.read('build/themes').split(','); - var requests = 0; - file.mkdir('dist/tmp'); - themes.forEach(function(theme, index) { - requests += 1; - file.mkdir('dist/tmp/' + index); - var zipFileName = 'dist/tmp/' + index + '.zip'; - var out = fs.createWriteStream(zipFileName); - out.on('close', function() { - log.writeln("done downloading " + zipFileName); - // TODO AdmZip produces "crc32 checksum failed", need to figure out why - // var zip = new AdmZip(zipFileName); - // zip.extractAllTo('dist/tmp/' + index + '/'); - // until then, using cli unzip... - utils.spawn({ - cmd: "unzip", - args: ["-d", "dist/tmp/" + index, zipFileName] - }, function(err, result) { - log.writeln("Unzipped " + zipFileName + ", deleting it now"); - fs.unlinkSync(zipFileName); - requests -= 1; - if (requests === 0) { - done(); - } - }); - - }); - request('http://ui-dev.jquery.com/download/?' + theme).pipe(out); - }); +task.registerTask( "download_themes", function() { + // var AdmZip = require('adm-zip'); + var fs = require( "fs" ); + var request = require( "request" ); + var done = this.async(); + var themes = file.read( "build/themes" ).split(","); + var requests = 0; + file.mkdir( "dist/tmp" ); + themes.forEach(function( theme, index ) { + requests += 1; + file.mkdir( "dist/tmp/" + index ); + var zipFileName = "dist/tmp/" + index + ".zip"; + var out = fs.createWriteStream( zipFileName ); + out.on( "close", function() { + log.writeln( "done downloading " + zipFileName ); + // TODO AdmZip produces "crc32 checksum failed", need to figure out why + // var zip = new AdmZip(zipFileName); + // zip.extractAllTo('dist/tmp/' + index + '/'); + // until then, using cli unzip... + utils.spawn({ + cmd: "unzip", + args: [ "-d", "dist/tmp/" + index, zipFileName ] + }, function( err, result ) { + log.writeln( "Unzipped " + zipFileName + ", deleting it now" ); + fs.unlinkSync( zipFileName ); + requests -= 1; + if (requests === 0) { + done(); + } + }); + }); + request( "http://ui-dev.jquery.com/download/?" + theme ).pipe( out ); + }); }); -task.registerTask('copy_themes', function() { - // each package includes the base theme, ignore that - var filter = /themes\/base/; - var files = file.expand('dist/tmp/*/development-bundle/themes/**/*').filter(function(file) { - return !filter.test(file); - }); - // TODO the template.process call shouldn't be necessary - var target = 'dist/' + template.process(config('files.themes'), config()) + '/'; - files.forEach(function(fileName) { - var targetFile = fileName.replace(/dist\/tmp\/\d+\/development-bundle\//, '').replace("jquery-ui-.custom", "jquery-ui.css"); - file.copy(fileName, target + targetFile); - }); +task.registerTask( "copy_themes", function() { + // each package includes the base theme, ignore that + var filter = /themes\/base/; + var files = file.expand( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) { + return !filter.test( file ); + }); + // TODO the template.process call shouldn't be necessary + var target = "dist/" + template.process( config( "files.themes" ), config() ) + "/"; + files.forEach(function( fileName ) { + var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui.css" ); + file.copy( fileName, target + targetFile ); + }); - // copy minified base theme from regular release - // TODO same as the one above - var distFolder = 'dist/' + template.process(config('files.dist'), config()); - files = file.expand(distFolder + '/themes/base/**/*'); - files.forEach(function(fileName) { - file.copy(fileName, target + fileName.replace(distFolder, '')); - }); + // copy minified base theme from regular release + // TODO same as the one above + var distFolder = "dist/" + template.process( config( "files.dist" ), config() ); + files = file.expand( distFolder + "/themes/base/**/*" ); + files.forEach(function( fileName ) { + file.copy( fileName, target + fileName.replace( distFolder, "" ) ); + }); }); // TODO merge with code in jQuery Core, share as grunt plugin/npm // this here actually uses the provided filenames in the output // the helpers should just be regular functions, no need to share those with the world -task.registerBasicTask("compare_size", "Compare size of this branch to master", function() { - var files = file.expand(this.file.src), - done = this.async(), - sizecache = __dirname + "/dist/.sizecache.json", - sources = { - min: file.read(files[1]), - max: file.read(files[0]) - }, - oldsizes = {}, - sizes = {}; +task.registerBasicTask( "compare_size", "Compare size of this branch to master", function() { + var files = file.expand( this.file.src ), + done = this.async(), + sizecache = __dirname + "/dist/.sizecache.json", + sources = { + min: file.read( files[1] ), + max: file.read( files[0] ) + }, + oldsizes = {}, + sizes = {}; - try { - oldsizes = JSON.parse(file.read(sizecache)); - } catch(e) { - oldsizes = {}; - } + try { + oldsizes = JSON.parse( file.read( sizecache ) ); + } catch( e ) { + oldsizes = {}; + } - // Obtain the current branch and continue... - task.helper("git_current_branch", function(err, branch) { - var key, diff; + // Obtain the current branch and continue... + task.helper( "git_current_branch", function( err, branch ) { + var key, diff; - // Derived and adapted from Corey Frang's original `sizer` - log.writeln( "sizes - compared to master" ); + // Derived and adapted from Corey Frang's original `sizer` + log.writeln( "sizes - compared to master" ); - sizes[files[0]] = sources.max.length; - sizes[files[1]] = sources.min.length; - sizes[files[1] + '.gz'] = task.helper("gzip", sources.min).length; + sizes[ files[0] ] = sources.max.length; + sizes[ files[1] ] = sources.min.length; + sizes[ files[1] + ".gz" ] = task.helper( "gzip", sources.min ).length; - for ( key in sizes ) { - diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] ); - if ( diff > 0 ) { - diff = "+" + diff; - } - console.log( "%s %s %s", - task.helper("lpad", sizes[ key ], 8 ), - task.helper("lpad", diff ? "(" + diff + ")" : "(-)", 8 ), - key - ); - } + for ( key in sizes ) { + diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] ); + if ( diff > 0 ) { + diff = "+" + diff; + } + console.log( "%s %s %s", + task.helper("lpad", sizes[ key ], 8 ), + task.helper("lpad", diff ? "(" + diff + ")" : "(-)", 8 ), + key + ); + } - if ( branch === "master" ) { - // If master, write to file - this makes it easier to compare - // the size of your current code state to the master branch, - // without returning to the master to reset the cache - file.write( sizecache, JSON.stringify(sizes) ); - } - done(); - }); + if ( branch === "master" ) { + // If master, write to file - this makes it easier to compare + // the size of your current code state to the master branch, + // without returning to the master to reset the cache + file.write( sizecache, JSON.stringify(sizes) ); + } + done(); + }); }); -task.registerHelper("git_current_branch", function(done) { - utils.spawn({ - cmd: "git", - args: ["branch", "--no-color"] - }, function(err, result) { - var branch; +task.registerHelper( "git_current_branch", function( done ) { + utils.spawn({ + cmd: "git", + args: [ "branch", "--no-color" ] + }, function( err, result ) { + var branch; - result.split("\n").forEach(function(branch) { - var matches = /^\* (.*)/.exec( branch ); - if ( matches !== null && matches.length && matches[ 1 ] ) { - done( null, matches[ 1 ] ); - } - }); - }); + result.split( "\n" ).forEach(function( branch ) { + var matches = /^\* (.*)/.exec( branch ); + if ( matches !== null && matches.length && matches[ 1 ] ) { + done( null, matches[ 1 ] ); + } + }); + }); }); -task.registerHelper("lpad", function(str, len, chr) { - return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len ); +task.registerHelper( "lpad", function( str, len, chr ) { + return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len ); }); -task.registerTask('default', 'lint csslint qunit build compare_size'); -task.registerTask('sizer', 'concat:ui min:dist/jquery-ui.min.js compare_size'); -task.registerTask('build', 'concat min css_min'); -task.registerTask('release', 'build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist'); -task.registerTask('release_themes', 'release download_themes copy_themes copy:themes md5:themes zip:themes'); -task.registerTask('release_cdn', 'release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn'); +task.registerTask("default", "lint csslint qunit build compare_size" ); +task.registerTask("sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); +task.registerTask("build", "concat min css_min" ); +task.registerTask("release", "build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); +task.registerTask("release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); +task.registerTask("release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); -- cgit v1.2.3 From 5f95e7c815874afa562f54c9ca9f9d893f677dd7 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 19 Mar 2012 22:56:34 +0100 Subject: Build/grunt: Update to latest grunt API, using reigsterMultiTask instead of registerBasicTask --- grunt.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 9d0e721f2..f256f4766 100644 --- a/grunt.js +++ b/grunt.js @@ -281,7 +281,7 @@ config.init({ } }); -task.registerBasicTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() { +task.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() { function replaceVersion( source ) { return source.replace( "@VERSION", config( "pkg.version" ) ); } @@ -307,7 +307,7 @@ task.registerBasicTask( "copy", "Copy files to destination folder and replace @V }); -task.registerBasicTask( "zip", "Create a zip file for release", function() { +task.registerMultiTask( "zip", "Create a zip file for release", function() { var done = this.async(); // TODO switch back to adm-zip for better cross-platform compability once it actually works // 0.1.2 doesn't compress properly (or at all) @@ -345,7 +345,7 @@ task.registerBasicTask( "zip", "Create a zip file for release", function() { }); }); -task.registerBasicTask( "csslint", "Lint CSS files with csslint", function() { +task.registerMultiTask( "csslint", "Lint CSS files with csslint", function() { var csslint = require( "csslint" ).CSSLint; var files = file.expand( this.file.src ); var ruleset = {}; @@ -377,7 +377,7 @@ task.registerBasicTask( "csslint", "Lint CSS files with csslint", function() { log.writeln( "Lint free" ); }); -task.registerBasicTask( "css_min", "Minify CSS files with Sqwish.", function() { +task.registerMultiTask( "css_min", "Minify CSS files with Sqwish.", function() { var max = task.helper( "concat", file.expand( this.file.src ) ); var min = require( "sqwish" ).minify( max, false ); file.write( this.file.dest, min ); @@ -385,7 +385,7 @@ task.registerBasicTask( "css_min", "Minify CSS files with Sqwish.", function() { task.helper( "min_max_info", min, max ); }); -task.registerBasicTask( "md5", "Create list of md5 hashes for CDN uploads", function() { +task.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included if ( require( "path" ).existsSync( this.file.dest ) ) { require( "fs" ).unlinkSync( this.file.dest ); @@ -462,7 +462,7 @@ task.registerTask( "copy_themes", function() { // TODO merge with code in jQuery Core, share as grunt plugin/npm // this here actually uses the provided filenames in the output // the helpers should just be regular functions, no need to share those with the world -task.registerBasicTask( "compare_size", "Compare size of this branch to master", function() { +task.registerMultiTask( "compare_size", "Compare size of this branch to master", function() { var files = file.expand( this.file.src ), done = this.async(), sizecache = __dirname + "/dist/.sizecache.json", -- cgit v1.2.3 From 72d3aa2740ab8fc079098e8656f41e40c01ee550 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 19 Mar 2012 22:57:51 +0100 Subject: Build/grunt: Add a clean task. Good enough for now, but not really a good implementation --- grunt.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index f256f4766..e7395285a 100644 --- a/grunt.js +++ b/grunt.js @@ -459,6 +459,14 @@ task.registerTask( "copy_themes", function() { }); }); +task.registerTask( "clean", function() { + // TODO use node methods and keep the dir, only delete its content + utils.spawn({ + cmd: "rm", + args: [ "-rf", "dist" ] + }, this.async()); +}); + // TODO merge with code in jQuery Core, share as grunt plugin/npm // this here actually uses the provided filenames in the output // the helpers should just be regular functions, no need to share those with the world -- cgit v1.2.3 From 2a1ee3725818c339ab45894db0347e016188e2d8 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 19 Mar 2012 23:08:56 +0100 Subject: Build/grunt: Another attempt at using adm-zip. Keep the result in place, but don't (yet) use it - need to report issues to adm-zip --- grunt.js | 26 +++++++++++++------------- package.json | 3 ++- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index e7395285a..83522ebb4 100644 --- a/grunt.js +++ b/grunt.js @@ -308,24 +308,24 @@ task.registerMultiTask( "copy", "Copy files to destination folder and replace @V task.registerMultiTask( "zip", "Create a zip file for release", function() { - var done = this.async(); // TODO switch back to adm-zip for better cross-platform compability once it actually works - // 0.1.2 doesn't compress properly (or at all) - - // var files = file.expand(this.file.src); - // log.writeln("Creating zip file " + this.file.dest); + // 0.1.3 works, but result can't be unzipped + // its also a lot slower then zip program, probably due to how its used... + // var files = file.expand( "dist/" + this.file.src + "/**/*" ); + // log.writeln( "Creating zip file " + this.file.dest ); - // var fs = require('fs'); - // var AdmZip = require('adm-zip'); + // var fs = require( "fs" ); + // var AdmZip = require( "adm-zip" ); // var zip = new AdmZip(); - // files.forEach(function(file) { - // log.verbose.writeln('Zipping ' + file); - // // rewrite file names from dist folder (created by build), drop the /dist part - // zip.addFile(file.replace(/^dist/, ''), fs.readFileSync(file)); + // files.forEach(function( file ) { + // log.verbose.writeln( "Zipping " + file ); + // // rewrite file names from dist folder (created by build), drop the /dist part + // zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) ); // }); - // zip.writeZip(this.file.dest); - // log.writeln("Wrote " + files.length + " files to " + this.file.dest); + // zip.writeZip( "dist/" + this.file.dest ); + // log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); + var done = this.async(); var dest = this.file.dest; var src = template.process( this.file.src, config() ); utils.spawn({ diff --git a/package.json b/package.json index cd0c9f78d..02d7a1173 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "grunt": "0.2.x", "sqwish": "0.2.x", "request": "2.9.x", - "csslint": "0.9.x" + "csslint": "0.9.x", + "adm-zip": "0.1.x" }, "keywords": [] } \ No newline at end of file -- cgit v1.2.3 From a84512f9cfb796464e6e9ce4fc5d4a6d4f386635 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 21 Mar 2012 21:19:31 +0100 Subject: Build/grunt: Use rimraf for clean task. Fix cop_hemes task to correctly rename the -custom.css file --- grunt.js | 8 ++------ package.json | 3 ++- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 83522ebb4..37f2d9178 100644 --- a/grunt.js +++ b/grunt.js @@ -446,7 +446,7 @@ task.registerTask( "copy_themes", function() { // TODO the template.process call shouldn't be necessary var target = "dist/" + template.process( config( "files.themes" ), config() ) + "/"; files.forEach(function( fileName ) { - var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui.css" ); + var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" ); file.copy( fileName, target + targetFile ); }); @@ -460,11 +460,7 @@ task.registerTask( "copy_themes", function() { }); task.registerTask( "clean", function() { - // TODO use node methods and keep the dir, only delete its content - utils.spawn({ - cmd: "rm", - args: [ "-rf", "dist" ] - }, this.async()); + require( "rimraf" ).sync( "dist" ); }); // TODO merge with code in jQuery Core, share as grunt plugin/npm diff --git a/package.json b/package.json index 02d7a1173..de297f467 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "sqwish": "0.2.x", "request": "2.9.x", "csslint": "0.9.x", - "adm-zip": "0.1.x" + "adm-zip": "0.1.x", + "rimraf": "2.0.1" }, "keywords": [] } \ No newline at end of file -- cgit v1.2.3 From a00e7f3c8238a5a944d13d4df6745653fed766b7 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 21 Mar 2012 21:27:34 +0100 Subject: Build/grunt: Always clean befoe release task --- grunt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 37f2d9178..2004a2773 100644 --- a/grunt.js +++ b/grunt.js @@ -537,6 +537,6 @@ task.registerHelper( "lpad", function( str, len, chr ) { task.registerTask("default", "lint csslint qunit build compare_size" ); task.registerTask("sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); task.registerTask("build", "concat min css_min" ); -task.registerTask("release", "build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); +task.registerTask("release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); task.registerTask("release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); task.registerTask("release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); -- cgit v1.2.3 From a454c5d24632cac110fd36f2cdd3e7402069074f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 22 Mar 2012 13:51:08 +0100 Subject: Build/grunt: Use ascii encoding when reading files for digesting --- grunt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 2004a2773..e2d9ebc22 100644 --- a/grunt.js +++ b/grunt.js @@ -395,7 +395,7 @@ task.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", func var hashes = []; file.expand( dir + "**/*" ).forEach(function( fileName ) { var hash = crypto.createHash( "md5" ); - hash.update( file.read( fileName ) ); + hash.update( file.read( fileName, 'ascii' ) ); hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); }); file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); -- cgit v1.2.3 From 12832b7c35e2cb9e37ed4aa3f64a3c46eb114310 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 22 Mar 2012 13:54:47 +0100 Subject: Build/grunt: Coding standards --- grunt.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index e2d9ebc22..bbc358e4b 100644 --- a/grunt.js +++ b/grunt.js @@ -395,7 +395,7 @@ task.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", func var hashes = []; file.expand( dir + "**/*" ).forEach(function( fileName ) { var hash = crypto.createHash( "md5" ); - hash.update( file.read( fileName, 'ascii' ) ); + hash.update( file.read( fileName, "ascii" ) ); hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); }); file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); @@ -534,9 +534,9 @@ task.registerHelper( "lpad", function( str, len, chr ) { return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len ); }); -task.registerTask("default", "lint csslint qunit build compare_size" ); -task.registerTask("sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); -task.registerTask("build", "concat min css_min" ); -task.registerTask("release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); -task.registerTask("release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); -task.registerTask("release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); +task.registerTask( "default", "lint csslint qunit build compare_size" ); +task.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); +task.registerTask( "build", "concat min css_min" ); +task.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); +task.registerTask( "release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); +task.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); -- cgit v1.2.3 From 610e7949764462e50be308e2c15745004b4a267c Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 22 Mar 2012 21:28:55 +0100 Subject: Build/grunt: Fix copying of binary files --- grunt.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index bbc358e4b..dfc9c63b5 100644 --- a/grunt.js +++ b/grunt.js @@ -438,6 +438,7 @@ task.registerTask( "download_themes", function() { }); task.registerTask( "copy_themes", function() { + var fs = require( "fs" ); // each package includes the base theme, ignore that var filter = /themes\/base/; var files = file.expand( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) { @@ -447,7 +448,7 @@ task.registerTask( "copy_themes", function() { var target = "dist/" + template.process( config( "files.themes" ), config() ) + "/"; files.forEach(function( fileName ) { var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" ); - file.copy( fileName, target + targetFile ); + file.write( target + targetFile, fs.readFileSync( fileName ) ); }); // copy minified base theme from regular release -- cgit v1.2.3 From e4f0cab0430811edd2a37dc275409aefd309c014 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 23 Mar 2012 07:59:36 -0400 Subject: Grunt: Switch back to using file.copy(). --- grunt.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index dfc9c63b5..409f2684a 100644 --- a/grunt.js +++ b/grunt.js @@ -293,7 +293,11 @@ task.registerMultiTask( "copy", "Copy files to destination folder and replace @V } files.forEach(function( fileName ) { var targetFile = strip ? fileName.replace( strip, "" ) : fileName; - file.copy( fileName, target + targetFile, replaceVersion ); + if ( /png$/.test( fileName ) ) { + file.copy( fileName, target + targetFile ); + } else { + file.copy( fileName, target + targetFile, replaceVersion ); + } }); log.writeln( "Copied " + files.length + " files." ); var renameCount = 0; @@ -438,7 +442,6 @@ task.registerTask( "download_themes", function() { }); task.registerTask( "copy_themes", function() { - var fs = require( "fs" ); // each package includes the base theme, ignore that var filter = /themes\/base/; var files = file.expand( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) { @@ -448,7 +451,7 @@ task.registerTask( "copy_themes", function() { var target = "dist/" + template.process( config( "files.themes" ), config() ) + "/"; files.forEach(function( fileName ) { var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" ); - file.write( target + targetFile, fs.readFileSync( fileName ) ); + file.copy( fileName, target + targetFile ); }); // copy minified base theme from regular release -- cgit v1.2.3 From b2cca9ad19b55eed3574b493df2a30c5cd1965e7 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 23 Mar 2012 13:33:46 -0400 Subject: Grunt: Update for new grunt API. --- grunt.js | 162 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 83 insertions(+), 79 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 409f2684a..476fc8516 100644 --- a/grunt.js +++ b/grunt.js @@ -1,3 +1,5 @@ +module.exports = function( grunt ) { + function stripBanner( files ) { return files.map(function( file ) { return ""; @@ -12,24 +14,24 @@ function createBanner( files ) { // strip folders var fileNames = files && files.map( stripDirectory ); return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + - "<%= template.today('isoDate') %>\n" + + "<%= grunt.template.today('isoDate') %>\n" + "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" + - "* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(task.current.file.src[1]) %>") + "\n" + - "* Copyright (c) <%= template.today('yyyy') %> <%= pkg.author.name %>;" + + "* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(grunt.task.current.file.src[1]) %>") + "\n" + + "* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; } // allow access from banner template global.stripDirectory = stripDirectory; -task.registerHelper( "strip_all_banners", function( filepath ) { - return file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); +grunt.registerHelper( "strip_all_banners", function( filepath ) { + return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); }); var inspect = require( "util" ).inspect; var coreFiles = "jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js".split( ", " ); var uiFiles = coreFiles.map(function( file ) { return "ui/" + file; -}).concat( file.expand( "ui/*.js" ).filter(function( file ) { +}).concat( grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) { return coreFiles.indexOf( file.substring(3) ) === -1; })); @@ -42,7 +44,7 @@ function minFile( file ) { } uiFiles.forEach( minFile ); -var allI18nFiles = file.expand( "ui/i18n/*.js" ); +var allI18nFiles = grunt.file.expandFiles( "ui/i18n/*.js" ); allI18nFiles.forEach( minFile ); var cssFiles = "core accordion autocomplete button datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip theme".split( " " ).map(function( component ) { @@ -55,7 +57,7 @@ cssFiles.forEach(function( file ) { minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", file ]; }); -config.init({ +grunt.initConfig({ pkg: "", files: { dist: "<%= pkg.name %>-<%= pkg.version %>", @@ -213,7 +215,7 @@ config.init({ } }, qunit: { - files: file.expand( "tests/unit/**/*.html" ).filter(function( file ) { + files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { // disabling everything that doesn't (quite) work with PhantomJS for now // except for all|index|test, try to include more as we go return !( /(all|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html/ ).test( file ); @@ -281,58 +283,58 @@ config.init({ } }); -task.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() { +grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() { function replaceVersion( source ) { - return source.replace( "@VERSION", config( "pkg.version" ) ); + return source.replace( "@VERSION", grunt.config( "pkg.version" ) ); } - var files = file.expand( this.file.src ); + var files = grunt.file.expandFiles( this.file.src ); var target = this.file.dest + "/"; var strip = this.data.strip; if ( typeof strip === "string" ) { - strip = new RegExp( "^" + template.process( strip, config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) ); + strip = new RegExp( "^" + grunt.template.process( strip, grunt.config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) ); } files.forEach(function( fileName ) { var targetFile = strip ? fileName.replace( strip, "" ) : fileName; if ( /png$/.test( fileName ) ) { - file.copy( fileName, target + targetFile ); + grunt.file.copy( fileName, target + targetFile ); } else { - file.copy( fileName, target + targetFile, replaceVersion ); + grunt.file.copy( fileName, target + targetFile, replaceVersion ); } }); - log.writeln( "Copied " + files.length + " files." ); + grunt.log.writeln( "Copied " + files.length + " files." ); var renameCount = 0; for ( var fileName in this.data.renames ) { renameCount += 1; - file.copy( fileName, target + template.process( this.data.renames[ fileName ], config() ) ); + grunt.file.copy( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) ); } if ( renameCount ) { - log.writeln( "Renamed " + renameCount + " files." ); + grunt.log.writeln( "Renamed " + renameCount + " files." ); } }); -task.registerMultiTask( "zip", "Create a zip file for release", function() { +grunt.registerMultiTask( "zip", "Create a zip file for release", function() { // TODO switch back to adm-zip for better cross-platform compability once it actually works // 0.1.3 works, but result can't be unzipped // its also a lot slower then zip program, probably due to how its used... - // var files = file.expand( "dist/" + this.file.src + "/**/*" ); - // log.writeln( "Creating zip file " + this.file.dest ); + // var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" ); + // grunt.log.writeln( "Creating zip file " + this.file.dest ); // var fs = require( "fs" ); // var AdmZip = require( "adm-zip" ); // var zip = new AdmZip(); // files.forEach(function( file ) { - // log.verbose.writeln( "Zipping " + file ); + // grunt.verbose.writeln( "Zipping " + file ); // // rewrite file names from dist folder (created by build), drop the /dist part // zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) ); // }); // zip.writeZip( "dist/" + this.file.dest ); - // log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); + // grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); var done = this.async(); var dest = this.file.dest; - var src = template.process( this.file.src, config() ); - utils.spawn({ + var src = grunt.template.process( this.file.src, grunt.config() ); + grunt.utils.spawn({ cmd: "zip", args: [ "-r", dest, src ], opts: { @@ -340,18 +342,18 @@ task.registerMultiTask( "zip", "Create a zip file for release", function() { } }, function( err, result ) { if ( err ) { - log.error( err ); + grunt.log.error( err ); done(); return; } - log.writeln( "Zipped " + dest ); + grunt.log.writeln( "Zipped " + dest ); done(); }); }); -task.registerMultiTask( "csslint", "Lint CSS files with csslint", function() { +grunt.registerMultiTask( "csslint", "Lint CSS files with csslint", function() { var csslint = require( "csslint" ).CSSLint; - var files = file.expand( this.file.src ); + var files = grunt.file.expandFiles( this.file.src ); var ruleset = {}; csslint.getRules().forEach(function( rule ) { ruleset[ rule.id ] = 1; @@ -365,10 +367,10 @@ task.registerMultiTask( "csslint", "Lint CSS files with csslint", function() { } var hadErrors = 0; files.forEach(function( filepath ) { - log.writeln( "Linting " + filepath ); - var result = csslint.verify( file.read( filepath ), ruleset ); + grunt.log.writeln( "Linting " + filepath ); + var result = csslint.verify( grunt.file.read( filepath ), ruleset ); result.messages.forEach(function( message ) { - log.writeln( "[".red + ( "L" + message.line ).yellow + ":".red + ( "C" + message.col ).yellow + "]".red ); + grunt.log.writeln( "[".red + ( "L" + message.line ).yellow + ":".red + ( "C" + message.col ).yellow + "]".red ); log[ message.type === "error" ? "error" : "writeln" ]( message.message + " " + message.rule.desc + " (" + message.rule.id + ")" ); }); if ( result.messages.length ) { @@ -378,18 +380,18 @@ task.registerMultiTask( "csslint", "Lint CSS files with csslint", function() { if (hadErrors) { return false; } - log.writeln( "Lint free" ); + grunt.log.writeln( "Lint free" ); }); -task.registerMultiTask( "css_min", "Minify CSS files with Sqwish.", function() { - var max = task.helper( "concat", file.expand( this.file.src ) ); +grunt.registerMultiTask( "css_min", "Minify CSS files with Sqwish.", function() { + var max = grunt.helper( "concat", grunt.file.expandFiles( this.file.src ) ); var min = require( "sqwish" ).minify( max, false ); - file.write( this.file.dest, min ); - log.writeln( "File '" + this.file.dest + "' created." ); - task.helper( "min_max_info", min, max ); + grunt.file.write( this.file.dest, min ); + grunt.log.writeln( "File '" + this.file.dest + "' created." ); + grunt.helper( "min_max_info", min, max ); }); -task.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { +grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included if ( require( "path" ).existsSync( this.file.dest ) ) { require( "fs" ).unlinkSync( this.file.dest ); @@ -397,39 +399,39 @@ task.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", func var crypto = require( "crypto" ); var dir = this.file.src + "/"; var hashes = []; - file.expand( dir + "**/*" ).forEach(function( fileName ) { + grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) { var hash = crypto.createHash( "md5" ); - hash.update( file.read( fileName, "ascii" ) ); + hash.update( grunt.file.read( fileName, "ascii" ) ); hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); }); - file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); - log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); + grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); + grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); }); -task.registerTask( "download_themes", function() { +grunt.registerTask( "download_themes", function() { // var AdmZip = require('adm-zip'); var fs = require( "fs" ); var request = require( "request" ); var done = this.async(); - var themes = file.read( "build/themes" ).split(","); + var themes = grunt.file.read( "build/themes" ).split(","); var requests = 0; - file.mkdir( "dist/tmp" ); + grunt.file.mkdir( "dist/tmp" ); themes.forEach(function( theme, index ) { requests += 1; - file.mkdir( "dist/tmp/" + index ); + grunt.file.mkdir( "dist/tmp/" + index ); var zipFileName = "dist/tmp/" + index + ".zip"; var out = fs.createWriteStream( zipFileName ); out.on( "close", function() { - log.writeln( "done downloading " + zipFileName ); + grunt.log.writeln( "done downloading " + zipFileName ); // TODO AdmZip produces "crc32 checksum failed", need to figure out why // var zip = new AdmZip(zipFileName); // zip.extractAllTo('dist/tmp/' + index + '/'); // until then, using cli unzip... - utils.spawn({ + grunt.utils.spawn({ cmd: "unzip", args: [ "-d", "dist/tmp/" + index, zipFileName ] }, function( err, result ) { - log.writeln( "Unzipped " + zipFileName + ", deleting it now" ); + grunt.log.writeln( "Unzipped " + zipFileName + ", deleting it now" ); fs.unlinkSync( zipFileName ); requests -= 1; if (requests === 0) { @@ -441,62 +443,62 @@ task.registerTask( "download_themes", function() { }); }); -task.registerTask( "copy_themes", function() { +grunt.registerTask( "copy_themes", function() { // each package includes the base theme, ignore that var filter = /themes\/base/; - var files = file.expand( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) { + var files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) { return !filter.test( file ); }); - // TODO the template.process call shouldn't be necessary - var target = "dist/" + template.process( config( "files.themes" ), config() ) + "/"; + // TODO the grunt.template.process call shouldn't be necessary + var target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/"; files.forEach(function( fileName ) { var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" ); - file.copy( fileName, target + targetFile ); + grunt.file.copy( fileName, target + targetFile ); }); // copy minified base theme from regular release // TODO same as the one above - var distFolder = "dist/" + template.process( config( "files.dist" ), config() ); - files = file.expand( distFolder + "/themes/base/**/*" ); + var distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ); + files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" ); files.forEach(function( fileName ) { - file.copy( fileName, target + fileName.replace( distFolder, "" ) ); + grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) ); }); }); -task.registerTask( "clean", function() { +grunt.registerTask( "clean", function() { require( "rimraf" ).sync( "dist" ); }); // TODO merge with code in jQuery Core, share as grunt plugin/npm // this here actually uses the provided filenames in the output // the helpers should just be regular functions, no need to share those with the world -task.registerMultiTask( "compare_size", "Compare size of this branch to master", function() { - var files = file.expand( this.file.src ), +grunt.registerMultiTask( "compare_size", "Compare size of this branch to master", function() { + var files = grunt.file.expandFiles( this.file.src ), done = this.async(), sizecache = __dirname + "/dist/.sizecache.json", sources = { - min: file.read( files[1] ), - max: file.read( files[0] ) + min: grunt.file.read( files[1] ), + max: grunt.file.read( files[0] ) }, oldsizes = {}, sizes = {}; try { - oldsizes = JSON.parse( file.read( sizecache ) ); + oldsizes = JSON.parse( grunt.file.read( sizecache ) ); } catch( e ) { oldsizes = {}; } // Obtain the current branch and continue... - task.helper( "git_current_branch", function( err, branch ) { + grunt.helper( "git_current_branch", function( err, branch ) { var key, diff; // Derived and adapted from Corey Frang's original `sizer` - log.writeln( "sizes - compared to master" ); + grunt.log.writeln( "sizes - compared to master" ); sizes[ files[0] ] = sources.max.length; sizes[ files[1] ] = sources.min.length; - sizes[ files[1] + ".gz" ] = task.helper( "gzip", sources.min ).length; + sizes[ files[1] + ".gz" ] = grunt.helper( "gzip", sources.min ).length; for ( key in sizes ) { diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] ); @@ -504,8 +506,8 @@ task.registerMultiTask( "compare_size", "Compare size of this branch to master", diff = "+" + diff; } console.log( "%s %s %s", - task.helper("lpad", sizes[ key ], 8 ), - task.helper("lpad", diff ? "(" + diff + ")" : "(-)", 8 ), + grunt.helper("lpad", sizes[ key ], 8 ), + grunt.helper("lpad", diff ? "(" + diff + ")" : "(-)", 8 ), key ); } @@ -514,13 +516,13 @@ task.registerMultiTask( "compare_size", "Compare size of this branch to master", // If master, write to file - this makes it easier to compare // the size of your current code state to the master branch, // without returning to the master to reset the cache - file.write( sizecache, JSON.stringify(sizes) ); + grunt.file.write( sizecache, JSON.stringify(sizes) ); } done(); }); }); -task.registerHelper( "git_current_branch", function( done ) { - utils.spawn({ +grunt.registerHelper( "git_current_branch", function( done ) { + grunt.utils.spawn({ cmd: "git", args: [ "branch", "--no-color" ] }, function( err, result ) { @@ -534,13 +536,15 @@ task.registerHelper( "git_current_branch", function( done ) { }); }); }); -task.registerHelper( "lpad", function( str, len, chr ) { +grunt.registerHelper( "lpad", function( str, len, chr ) { return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len ); }); -task.registerTask( "default", "lint csslint qunit build compare_size" ); -task.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); -task.registerTask( "build", "concat min css_min" ); -task.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); -task.registerTask( "release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); -task.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); +grunt.registerTask( "default", "lint csslint qunit build compare_size" ); +grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); +grunt.registerTask( "build", "concat min css_min" ); +grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); +grunt.registerTask( "release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); +grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); + +}; -- cgit v1.2.3 From cd020af6278500b53d7a45d80d00804855e82b14 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 28 Mar 2012 11:45:27 +0200 Subject: Build/grunt: Extract css related tasks, use grunt-css instead --- grunt.js | 48 ++++++------------------------------------------ package.json | 5 ++--- 2 files changed, 8 insertions(+), 45 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 476fc8516..223225a8d 100644 --- a/grunt.js +++ b/grunt.js @@ -21,6 +21,10 @@ function createBanner( files ) { " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; } +// a working grunt.loadNpmTasks replacement +// gets us csslint and cssmin tasks +require('grunt-css')(grunt); + // allow access from banner template global.stripDirectory = stripDirectory; grunt.registerHelper( "strip_all_banners", function( filepath ) { @@ -91,7 +95,7 @@ grunt.initConfig({ } }, min: minify, - css_min: minifyCSS, + cssmin: minifyCSS, copy: { dist: { src: [ @@ -351,46 +355,6 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { }); }); -grunt.registerMultiTask( "csslint", "Lint CSS files with csslint", function() { - var csslint = require( "csslint" ).CSSLint; - var files = grunt.file.expandFiles( this.file.src ); - var ruleset = {}; - csslint.getRules().forEach(function( rule ) { - ruleset[ rule.id ] = 1; - }); - for ( var rule in this.data.rules ) { - if ( !this.data.rules[ rule ] ) { - delete ruleset[rule]; - } else { - ruleset[ rule ] = this.data.rules[ rule ]; - } - } - var hadErrors = 0; - files.forEach(function( filepath ) { - grunt.log.writeln( "Linting " + filepath ); - var result = csslint.verify( grunt.file.read( filepath ), ruleset ); - result.messages.forEach(function( message ) { - grunt.log.writeln( "[".red + ( "L" + message.line ).yellow + ":".red + ( "C" + message.col ).yellow + "]".red ); - log[ message.type === "error" ? "error" : "writeln" ]( message.message + " " + message.rule.desc + " (" + message.rule.id + ")" ); - }); - if ( result.messages.length ) { - hadErrors += 1; - } - }); - if (hadErrors) { - return false; - } - grunt.log.writeln( "Lint free" ); -}); - -grunt.registerMultiTask( "css_min", "Minify CSS files with Sqwish.", function() { - var max = grunt.helper( "concat", grunt.file.expandFiles( this.file.src ) ); - var min = require( "sqwish" ).minify( max, false ); - grunt.file.write( this.file.dest, min ); - grunt.log.writeln( "File '" + this.file.dest + "' created." ); - grunt.helper( "min_max_info", min, max ); -}); - grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included if ( require( "path" ).existsSync( this.file.dest ) ) { @@ -542,7 +506,7 @@ grunt.registerHelper( "lpad", function( str, len, chr ) { grunt.registerTask( "default", "lint csslint qunit build compare_size" ); grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" ); -grunt.registerTask( "build", "concat min css_min" ); +grunt.registerTask( "build", "concat min cssmin" ); grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); grunt.registerTask( "release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" ); grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); diff --git a/package.json b/package.json index de297f467..a395037f8 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,9 @@ ], "dependencies": {}, "devDependencies": { - "grunt": "0.2.x", - "sqwish": "0.2.x", + "grunt": "0.3.x", + "grunt-css": "0.1.0", "request": "2.9.x", - "csslint": "0.9.x", "adm-zip": "0.1.x", "rimraf": "2.0.1" }, -- cgit v1.2.3 From 3e7504156ac9e2fbef434e109306699ee87ddc9d Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 29 Mar 2012 12:48:21 +0200 Subject: Build/grunt: Use grunt.loadNpmTasks, now that its actually working --- grunt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 223225a8d..ee1e8397f 100644 --- a/grunt.js +++ b/grunt.js @@ -23,7 +23,7 @@ function createBanner( files ) { // a working grunt.loadNpmTasks replacement // gets us csslint and cssmin tasks -require('grunt-css')(grunt); +grunt.loadNpmTasks('grunt-css'); // allow access from banner template global.stripDirectory = stripDirectory; -- cgit v1.2.3 From 748702c29ac00df5bfc4090dc3fa1b3a9e65da70 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 29 Mar 2012 16:29:27 +0200 Subject: Build/grunt: Add download_docs task for 1.8 --- grunt.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index ee1e8397f..ea8b86094 100644 --- a/grunt.js +++ b/grunt.js @@ -372,6 +372,43 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); }); +// only needed for 1.8 +grunt.registerTask( "download_docs", function() { + function capitalize(value) { + return value[0].toUpperCase() + value.slice(1); + } + // should be grunt.config("pkg.version")? + var version = "1.8"; + var docsDir = "dist/docs"; + var files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position" + .split(" ").map(function(widget) { + return { + url: "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize(widget), + dest: docsDir + '/' + widget + '.html' + }; + }); + files = files.concat("animate addClass effect hide removeClass show switchClass toggle toggleClass".split(" ").map(function(widget) { + return { + url: "http://docs.jquery.com/action/render/UI/Effects/" + widget, + dest: docsDir + '/' + widget + '.html' + }; + })); + files = files.concat("Blind Clip Drop Explode Fade Fold Puff Slide Scale Bounce Highlight Pulsate Shake Size Transfer".split(" ").map(function(widget) { + return { + url: "http://docs.jquery.com/action/render/UI/Effects/" + widget, + dest: docsDir + '/effect-' + widget.toLowerCase() + '.html' + }; + })); + var fs = require( "fs" ); + var request = require( "request" ); + grunt.file.mkdir( "dist/docs" ); + grunt.utils.async.forEach( files, function( file, done ) { + var out = fs.createWriteStream( file.dest ); + out.on( "close", done ); + request( file.url ).pipe( out ); + }, this.async() ); +}); + grunt.registerTask( "download_themes", function() { // var AdmZip = require('adm-zip'); var fs = require( "fs" ); -- cgit v1.2.3 From ff72467038f35fd7d031b33cf61d37ee02535a52 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 30 Mar 2012 13:32:23 -0400 Subject: Grunt: Move common modules to top, along with lists of files. --- grunt.js | 144 ++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 88 insertions(+), 56 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index ea8b86094..e18baeece 100644 --- a/grunt.js +++ b/grunt.js @@ -1,5 +1,80 @@ module.exports = function( grunt ) { +var // modules + fs = require( "fs" ), + path = require( "path" ), + request = require( "request" ), + util = require( "util" ), + inspect = util.inspect, + + // files + coreFiles = [ + "jquery.ui.core.js", + "jquery.ui.widget.js", + "jquery.ui.mouse.js", + "jquery.ui.draggable.js", + "jquery.ui.droppable.js", + "jquery.ui.resizable.js", + "jquery.ui.selectable.js", + "jquery.ui.sortable.js", + "jquery.effects.core.js" + ], + + uiFiles = coreFiles.map(function( file ) { + return "ui/" + file; + }).concat( grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) { + return coreFiles.indexOf( file.substring(3) ) === -1; + })), + + allI18nFiles = grunt.file.expandFiles( "ui/i18n/*.js" ), + + cssFiles = [ + "core", + "accordion", + "autocomplete", + "button", + "datepicker", + "dialog", + "menu", + "progressbar", + "resizable", + "selectable", + "slider", + "spinner", + "tabs", + "tooltip", + "theme" + ].map(function( component ) { + return "themes/base/jquery.ui." + component + ".css"; + }), + + // minified files + minify = { + "dist/jquery-ui.min.js": [ "", "dist/jquery-ui.js" ], + "dist/i18n/jquery-ui-i18n.min.js": [ "", "dist/i18n/jquery-ui-i18n.js" ] + }, + + minifyCSS = { + "dist/jquery-ui.min.css": "dist/jquery-ui.css" + }; + + +uiFiles.concat( allI18nFiles ).forEach(function( file ) { + minify[ "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ) ] = [ "", file ]; +}); + +cssFiles.forEach(function( file ) { + minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", file ]; +}); + + +// csslint and cssmin tasks +grunt.loadNpmTasks( "grunt-css" ); + +grunt.registerHelper( "strip_all_banners", function( filepath ) { + return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); +}); + function stripBanner( files ) { return files.map(function( file ) { return ""; @@ -9,6 +84,8 @@ function stripBanner( files ) { function stripDirectory( file ) { return file.replace( /.+\/(.+)$/, "$1" ); } +// allow access from banner template +global.stripDirectory = stripDirectory; function createBanner( files ) { // strip folders @@ -21,46 +98,6 @@ function createBanner( files ) { " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; } -// a working grunt.loadNpmTasks replacement -// gets us csslint and cssmin tasks -grunt.loadNpmTasks('grunt-css'); - -// allow access from banner template -global.stripDirectory = stripDirectory; -grunt.registerHelper( "strip_all_banners", function( filepath ) { - return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); -}); -var inspect = require( "util" ).inspect; - -var coreFiles = "jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js".split( ", " ); -var uiFiles = coreFiles.map(function( file ) { - return "ui/" + file; -}).concat( grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) { - return coreFiles.indexOf( file.substring(3) ) === -1; -})); - -var minify = { - "dist/jquery-ui.min.js": [ "", "dist/jquery-ui.js" ], - "dist/i18n/jquery-ui-i18n.min.js": [ "", "dist/i18n/jquery-ui-i18n.js" ] -}; -function minFile( file ) { - minify[ "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ) ] = [ "", file ]; -} -uiFiles.forEach( minFile ); - -var allI18nFiles = grunt.file.expandFiles( "ui/i18n/*.js" ); -allI18nFiles.forEach( minFile ); - -var cssFiles = "core accordion autocomplete button datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip theme".split( " " ).map(function( component ) { - return "themes/base/jquery.ui." + component + ".css"; -}); -var minifyCSS = { - "dist/jquery-ui.min.css": "dist/jquery-ui.css" -}; -cssFiles.forEach(function( file ) { - minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", file ]; -}); - grunt.initConfig({ pkg: "", files: { @@ -324,16 +361,15 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { // var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" ); // grunt.log.writeln( "Creating zip file " + this.file.dest ); - // var fs = require( "fs" ); - // var AdmZip = require( "adm-zip" ); - // var zip = new AdmZip(); - // files.forEach(function( file ) { - // grunt.verbose.writeln( "Zipping " + file ); - // // rewrite file names from dist folder (created by build), drop the /dist part - // zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) ); - // }); - // zip.writeZip( "dist/" + this.file.dest ); - // grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); + //var AdmZip = require( "adm-zip" ); + //var zip = new AdmZip(); + //files.forEach(function( file ) { + // grunt.verbose.writeln( "Zipping " + file ); + // // rewrite file names from dist folder (created by build), drop the /dist part + // zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) ); + //}); + //zip.writeZip( "dist/" + this.file.dest ); + //grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); var done = this.async(); var dest = this.file.dest; @@ -357,8 +393,8 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included - if ( require( "path" ).existsSync( this.file.dest ) ) { - require( "fs" ).unlinkSync( this.file.dest ); + if ( path.existsSync( this.file.dest ) ) { + fs.unlinkSync( this.file.dest ); } var crypto = require( "crypto" ); var dir = this.file.src + "/"; @@ -399,8 +435,6 @@ grunt.registerTask( "download_docs", function() { dest: docsDir + '/effect-' + widget.toLowerCase() + '.html' }; })); - var fs = require( "fs" ); - var request = require( "request" ); grunt.file.mkdir( "dist/docs" ); grunt.utils.async.forEach( files, function( file, done ) { var out = fs.createWriteStream( file.dest ); @@ -411,8 +445,6 @@ grunt.registerTask( "download_docs", function() { grunt.registerTask( "download_themes", function() { // var AdmZip = require('adm-zip'); - var fs = require( "fs" ); - var request = require( "request" ); var done = this.async(); var themes = grunt.file.read( "build/themes" ).split(","); var requests = 0; -- cgit v1.2.3 From b3374b9063a250214e4939788a99160a5d7c1de2 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 2 Apr 2012 15:49:34 +0200 Subject: Build/grunt: grunt.file.copy now expects options as third argument. Fixes the version replacing --- grunt.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index e18baeece..0f72e4842 100644 --- a/grunt.js +++ b/grunt.js @@ -339,7 +339,9 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ if ( /png$/.test( fileName ) ) { grunt.file.copy( fileName, target + targetFile ); } else { - grunt.file.copy( fileName, target + targetFile, replaceVersion ); + grunt.file.copy( fileName, target + targetFile, { + process: replaceVersion + }); } }); grunt.log.writeln( "Copied " + files.length + " files." ); -- cgit v1.2.3 From 83756a1d874823389f6e378ebdce014efe3d9bf7 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 2 Apr 2012 16:05:59 +0200 Subject: Build/grunt: Strip existing (protected) headers from to-be-minified CSS files --- grunt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 0f72e4842..a8ab7c666 100644 --- a/grunt.js +++ b/grunt.js @@ -64,7 +64,7 @@ uiFiles.concat( allI18nFiles ).forEach(function( file ) { }); cssFiles.forEach(function( file ) { - minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", file ]; + minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", "" ]; }); -- cgit v1.2.3 From 585ef702ef117232778113efc9979d51549abeeb Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 2 Apr 2012 11:12:49 -0400 Subject: Grunt: Copy jquery from root regardless of version; fix include list for minified CSS files. --- grunt.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index a8ab7c666..3be684908 100644 --- a/grunt.js +++ b/grunt.js @@ -82,7 +82,9 @@ function stripBanner( files ) { } function stripDirectory( file ) { - return file.replace( /.+\/(.+)$/, "$1" ); + // TODO: we're receiving the directive, so we need to strip the trailing > + // we should be receving a clean path without the directive + return file.replace( /.+\/(.+?)>?$/, "$1" ); } // allow access from banner template global.stripDirectory = stripDirectory; @@ -138,7 +140,7 @@ grunt.initConfig({ src: [ "AUTHORS.txt", "GPL-LICENSE.txt", - "jquery-1.7.1.js", + "jquery-*.js", "MIT-LICENSE.txt", "README.md", "grunt.js", -- cgit v1.2.3 From 3876c874e3f311d263aef9f99ed2780afa1d41d7 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 2 Apr 2012 13:15:54 -0400 Subject: Grunt: Whitelist js and css files for @version replacement instead of blacklisting png. --- grunt.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 3be684908..ad4c8bd40 100644 --- a/grunt.js +++ b/grunt.js @@ -338,12 +338,12 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ } files.forEach(function( fileName ) { var targetFile = strip ? fileName.replace( strip, "" ) : fileName; - if ( /png$/.test( fileName ) ) { - grunt.file.copy( fileName, target + targetFile ); - } else { + if ( /(js|css)$/.test( fileName ) ) { grunt.file.copy( fileName, target + targetFile, { process: replaceVersion }); + } else { + grunt.file.copy( fileName, target + targetFile ); } }); grunt.log.writeln( "Copied " + files.length + " files." ); -- cgit v1.2.3 From 3e6877a892b8fb70f1130f639dfde09ce5af6236 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 2 Apr 2012 19:12:10 -0400 Subject: Grunt: Fixed jshint options. --- grunt.js | 93 ++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 37 deletions(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index ad4c8bd40..1e8a197dc 100644 --- a/grunt.js +++ b/grunt.js @@ -278,52 +278,71 @@ grunt.initConfig({ } } }, - jshint: { - options: { + jshint: (function() { + var defaults = { curly: true, + eqnull: true, eqeqeq: true, - immed: true, + expr: true, latedef: true, newcap: true, noarg: true, - sub: true, - undef: true, - eqnull: true - }, - grunt: { - options: { - node: true - }, - globals: { - task: true, - config: true, - file: true, - log: true, - template: true + onevar: true, + // TODO: limit to multi-line comments https://github.com/jshint/jshint/issues/503 + smarttabs: true, + // TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504 + // strict: true, + // TODO: enable trailing + // trailing: true, + undef: true + }; + + function extend( a, b ) { + for ( var prop in b ) { + a[ prop ] = b[ prop ]; } - }, - ui: { - options: { - browser: true + return a; + } + + return { + options: defaults, + grunt: { + options: extend({ + node: true + }, defaults ), + globals: { + task: true, + config: true, + file: true, + log: true, + template: true + } }, - globals: { - jQuery: true - } - }, - tests: { - options: { - jquery: true + ui: { + options: extend({ + browser: true, + jquery: true + }, defaults ), + globals: { + Globalize: true + } }, - globals: { - module: true, - test: true, - ok: true, - equal: true, - deepEqual: true, - QUnit: true + tests: { + options: extend({ + browser: true, + jquery: true + }, defaults ), + globals: { + module: true, + test: true, + ok: true, + equal: true, + deepEqual: true, + QUnit: true + } } - } - } + }; + })() }); grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() { -- cgit v1.2.3 From ea4345db06222225f47d2ef9af6121d34e6e497e Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 2 Apr 2012 22:20:18 -0400 Subject: Grunt: Removed newcap option from jshint task. --- grunt.js | 1 - 1 file changed, 1 deletion(-) (limited to 'grunt.js') diff --git a/grunt.js b/grunt.js index 1e8a197dc..74713be5d 100644 --- a/grunt.js +++ b/grunt.js @@ -285,7 +285,6 @@ grunt.initConfig({ eqeqeq: true, expr: true, latedef: true, - newcap: true, noarg: true, onevar: true, // TODO: limit to multi-line comments https://github.com/jshint/jshint/issues/503 -- cgit v1.2.3