From f87b4e0f4ac2342dff260c32aa8d08148e76f7a4 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 21 Dec 2012 18:26:56 +0100 Subject: Build: Migrate to grunt 0.4. Rename to Gruntfile, upgrade to newer grunt-css and grunt-html, update custom tasks. Drop qunit-junit plugin, not worth the trouble. Update release script to run grunt-prepare after npm-install. --- Gruntfile.js | 385 +++++++++++++++++++++++++++++++++++++++++++++++ build/release/release.js | 3 + build/tasks/build.js | 52 +++---- grunt.js | 345 ------------------------------------------ package.json | 17 ++- 5 files changed, 422 insertions(+), 380 deletions(-) create mode 100644 Gruntfile.js delete mode 100644 grunt.js diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 000000000..06a1855a4 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,385 @@ +module.exports = function( grunt ) { + +"use strict"; + +var + // 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.ui.effect.js" + ], + + uiFiles = coreFiles.map(function( file ) { + return "ui/" + file; + }).concat( expandFiles( "ui/*.js" ).filter(function( file ) { + return coreFiles.indexOf( file.substring(3) ) === -1; + })), + + allI18nFiles = 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 = { + options: { + preserveComments: false + }, + main: { + options: { + banner: createBanner( uiFiles ) + }, + files: { + "dist/jquery-ui.min.js": "dist/jquery-ui.js" + } + }, + i18n: { + options: { + banner: createBanner( allI18nFiles ) + }, + files: { + "dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js" + } + } + }, + + minifyCSS = { + options: { + keepSpecialComments: 0 + }, + main: { + options: { + keepSpecialComments: '*' + }, + src: "dist/jquery-ui.css", + dest: "dist/jquery-ui.min.css" + } + }, + + compareFiles = { + files: [ + "dist/jquery-ui.js", + "dist/jquery-ui.min.js" + ] + }; + +function mapMinFile( file ) { + return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ); +} + +function expandFiles( files ) { + return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) { + return values[ 0 ]; + }); +} + +uiFiles.concat( allI18nFiles ).forEach(function( file ) { + minify[ file ] = { + options: { + banner: createBanner() + }, + files: {} + }; + minify[ file ].files[ mapMinFile( file ) ] = file; +}); + +cssFiles.forEach(function( file ) { + minifyCSS[ file ] = { + options: { + banner: createBanner() + }, + src: file, + dest: "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) + }; +}); + +uiFiles.forEach(function( file ) { + // TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13 + compareFiles[ file ] = [ file, mapMinFile( file ) ]; +}); + +// grunt plugins +grunt.loadNpmTasks( "grunt-contrib-jshint" ); +grunt.loadNpmTasks( "grunt-contrib-uglify" ); +grunt.loadNpmTasks( "grunt-contrib-concat" ); +grunt.loadNpmTasks( "grunt-contrib-qunit" ); +grunt.loadNpmTasks( "grunt-css" ); +grunt.loadNpmTasks( "grunt-html" ); +grunt.loadNpmTasks( "grunt-compare-size" ); +grunt.loadNpmTasks( "grunt-git-authors" ); +// local testswarm and build tasks +grunt.loadTasks( "build/tasks" ); + +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 %> - " + + "<%= grunt.template.today('isoDate') %>\n" + + "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" + + (files ? "* Includes: " + fileNames.join(", ") + "\n" : "")+ + "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + + " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n"; +} + +grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + files: { + dist: "<%= pkg.name %>-<%= pkg.version %>", + cdn: "<%= pkg.name %>-<%= pkg.version %>-cdn", + themes: "<%= pkg.name %>-themes-<%= pkg.version %>" + }, + compare_size: compareFiles, + concat: { + ui: { + options: { + banner: createBanner( uiFiles ), + stripBanners: { + block: true + } + }, + src: uiFiles, + dest: "dist/jquery-ui.js" + }, + i18n: { + options: { + banner: createBanner( allI18nFiles ) + }, + src: allI18nFiles, + dest: "dist/i18n/jquery-ui-i18n.js" + }, + css: { + options: { + banner: createBanner( cssFiles ), + stripBanners: { + block: true + } + }, + src: cssFiles, + dest: "dist/jquery-ui.css" + } + }, + uglify: minify, + cssmin: minifyCSS, + htmllint: { + // ignore files that contain invalid html, used only for ajax content testing + all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) { + return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file ); + }) + }, + copy: { + dist: { + src: [ + "AUTHORS.txt", + "jquery-*.js", + "MIT-LICENSE.txt", + "README.md", + "Gruntfile.js", + "package.json", + "*.jquery.json", + "ui/**/*", + "ui/.jshintrc", + "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_units_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/" + }, + dist_min_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/<%= files.dist %>/themes/base/minified" + }, + cdn: { + src: [ + "AUTHORS.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", + "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: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { + // disabling everything that doesn't (quite) work with PhantomJS for now + // TODO except for all|index|test, try to include more as we go + return !( /(all|index|test|dialog|dialog_deprecated|tabs|tooltip)\.html$/ ).test( file ); + }) + }, + jshint: { + ui: { + options: { + jshintrc: "ui/.jshintrc" + }, + files: { + src: "ui/*.js" + } + }, + grunt: { + options: { + jshintrc: ".jshintrc" + }, + files: { + src: [ "Gruntfile.js", "build/**/*.js" ] + } + }, + tests: { + options: { + jshintrc: "tests/.jshintrc" + }, + files: { + src: "tests/unit/**/*.js" + } + } + }, + csslint: { + // nothing: [] + // TODO figure out what to check for, then fix and enable + base_theme: { + src: expandFiles( "themes/base/*.css" ).filter(function( file ) { + // TODO remove items from this list once rewritten + return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); + }), + // TODO consider reenabling some of these rules + rules: { + "adjoining-classes": false, + "import": false, + "outline-none": false, + // especially this one + "overqualified-elements": false, + "compatible-vendor-prefixes": false + } + } + } +}); + +grunt.registerTask( "default", [ "jshint", "csslint", "htmllint", "qunit" ] ); +grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] ); +grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] ); +grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] ); +grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist".split( " " ) ); +grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes".split( " " ) ); +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".split( " " ) ); + +}; diff --git a/build/release/release.js b/build/release/release.js index 2eab5283f..6a387494b 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -72,6 +72,9 @@ function cloneRepo() { if ( exec( "npm install download.jqueryui.com" ).code !== 0 ) { abort( "Error installing dependencies." ); } + if ( exec( "cd node_modules/download.jqueryui.com && grunt prepare" ).code !== 0 ) { + abort( "Error installing dependencies." ); + } } echo(); } diff --git a/build/tasks/build.js b/build/tasks/build.js index a8f25f98f..978bee004 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -5,6 +5,19 @@ module.exports = function( grunt ) { var path = require( "path" ), fs = require( "fs" ); +function expandFiles( files ) { + return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).filter(function(filepath) { + // restrict to files, exclude folders + try { + return fs.statSync( filepath[ 0 ] ).isFile(); + } catch(e) { + throw grunt.task.taskError(e.message, e); + } + }).map(function( values ) { + return values[ 0 ]; + }); +} + grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() { var pkg = grunt.config( "pkg" ), base = { @@ -97,8 +110,8 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ grunt.file.copy( src, dest ); } } - var files = grunt.file.expandFiles( this.file.src ), - target = this.file.dest + "/", + var files = expandFiles( this.filesSrc ), + target = this.data.dest + "/", strip = this.data.strip, renameCount = 0, fileName; @@ -121,28 +134,11 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ 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 = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" ); - // grunt.log.writeln( "Creating zip file " + 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(), - dest = this.file.dest, - src = grunt.template.process( this.file.src, grunt.config() ); - grunt.utils.spawn({ + dest = this.data.dest; + grunt.util.spawn({ cmd: "zip", - args: [ "-r", dest, src ], + args: [ "-r", dest, this.data.src ], opts: { cwd: 'dist' } @@ -159,19 +155,19 @@ 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 ( fs.existsSync( this.file.dest ) ) { - fs.unlinkSync( this.file.dest ); + if ( fs.existsSync( this.data.dest ) ) { + fs.unlinkSync( this.data.dest ); } var crypto = require( "crypto" ), - dir = this.file.src + "/", + dir = this.filesSrc + "/", hashes = []; - grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) { + expandFiles( dir + "**/*" ).forEach(function( fileName ) { var hash = crypto.createHash( "md5" ); hash.update( grunt.file.read( fileName, "ascii" ) ); hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); }); - grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); - grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); + grunt.file.write( this.data.dest, hashes.join( "\n" ) + "\n" ); + grunt.log.writeln( "Wrote " + this.data.dest + " with " + hashes.length + " hashes" ); }); grunt.registerTask( "generate_themes", function() { diff --git a/grunt.js b/grunt.js deleted file mode 100644 index d599496cc..000000000 --- a/grunt.js +++ /dev/null @@ -1,345 +0,0 @@ -module.exports = function( grunt ) { - -"use strict"; - -var - // 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.ui.effect.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" - }, - - compareFiles = { - all: [ - "dist/jquery-ui.js", - "dist/jquery-ui.min.js" - ] - }; - -function mapMinFile( file ) { - return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ); -} - -uiFiles.concat( allI18nFiles ).forEach(function( file ) { - minify[ mapMinFile( file ) ] = [ "", file ]; -}); - -cssFiles.forEach(function( file ) { - minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", "" ]; -}); - -uiFiles.forEach(function( file ) { - compareFiles[ file ] = [ file, mapMinFile( file ) ]; -}); - -// grunt plugins -grunt.loadNpmTasks( "grunt-css" ); -grunt.loadNpmTasks( "grunt-html" ); -grunt.loadNpmTasks( "grunt-compare-size" ); -grunt.loadNpmTasks( "grunt-junit" ); -grunt.loadNpmTasks( "grunt-git-authors" ); -// local testswarm and build tasks -grunt.loadTasks( "build/tasks" ); - -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 ""; - }); -} - -function stripDirectory( file ) { - // 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; - -function createBanner( files ) { - // strip folders - var fileNames = files && files.map( stripDirectory ); - return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + - "<%= grunt.template.today('isoDate') %>\n" + - "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" + - "* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(grunt.task.current.file.src[1]) %>") + "\n" + - "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + - " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; -} - -grunt.initConfig({ - 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: compareFiles, - 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, - cssmin: minifyCSS, - htmllint: { - // ignore files that contain invalid html, used only for ajax content testing - all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) { - return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file ); - }) - }, - copy: { - dist: { - src: [ - "AUTHORS.txt", - "jquery-*.js", - "MIT-LICENSE.txt", - "README.md", - "grunt.js", - "package.json", - "*.jquery.json", - "ui/**/*", - "ui/.jshintrc", - "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_units_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/" - }, - dist_min_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/<%= files.dist %>/themes/base/minified" - }, - cdn: { - src: [ - "AUTHORS.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", - "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: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { - // disabling everything that doesn't (quite) work with PhantomJS for now - // TODO except for all|index|test, try to include more as we go - return !( /(all|index|test|dialog|dialog_deprecated|tabs|tooltip)\.html$/ ).test( file ); - }) - }, - lint: { - ui: "ui/*.js", - grunt: [ "grunt.js", "build/**/*.js" ], - tests: "tests/unit/**/*.js" - }, - csslint: { - // nothing: [] - // TODO figure out what to check for, then fix and enable - base_theme: { - src: grunt.file.expandFiles( "themes/base/*.css" ).filter(function( file ) { - // TODO remove items from this list once rewritten - return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); - }), - // TODO consider reenabling some of these rules - rules: { - "adjoining-classes": false, - "import": false, - "outline-none": false, - // especially this one - "overqualified-elements": false, - "compatible-vendor-prefixes": false - } - } - }, - jshint: (function() { - function parserc( path ) { - var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ), - settings = { - options: rc, - globals: {} - }; - - (rc.predef || []).forEach(function( prop ) { - settings.globals[ prop ] = true; - }); - delete rc.predef; - - return settings; - } - - return { - grunt: parserc(), - ui: parserc( "ui/" ), - // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519 - // TODO: don't create so many globals in tests - tests: parserc( "tests/" ) - }; - })() -}); - -grunt.registerTask( "default", "lint csslint htmllint qunit" ); -grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" ); -grunt.registerTask( "sizer_all", "concat:ui min compare_size" ); -grunt.registerTask( "build", "concat min cssmin copy:dist_units_images" ); -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 generate_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 ae8b13dc8..89667bf34 100644 --- a/package.json +++ b/package.json @@ -53,13 +53,16 @@ ], "dependencies": {}, "devDependencies": { - "grunt": "~0.3.17", - "grunt-css": "0.2.0", - "grunt-compare-size": "0.1.4", - "grunt-html": "0.1.1", - "grunt-junit": "0.1.5", - "grunt-git-authors": "1.0.0", - "rimraf": "2.0.1", + "grunt": "0.4.0", + "grunt-contrib-jshint": "0.1.1", + "grunt-contrib-uglify": "0.1.1", + "grunt-contrib-concat": "0.1.3", + "grunt-contrib-qunit": "0.1.1", + "grunt-css": "0.5.4", + "grunt-compare-size": "0.3.1", + "grunt-html": "0.3.3", + "grunt-git-authors": "1.1.0", + "rimraf": "2.1.4", "testswarm": "1.0.0-alpha" }, "keywords": [] -- cgit v1.2.3