2 module
.exports = function( grunt
) {
10 "jquery.ui.draggable.js",
11 "jquery.ui.droppable.js",
12 "jquery.ui.resizable.js",
13 "jquery.ui.selectable.js",
14 "jquery.ui.sortable.js",
18 uiFiles
= coreFiles
.map(function( file
) {
20 }).concat( grunt
.file
.expandFiles( "ui/*.js" ).filter(function( file
) {
21 return coreFiles
.indexOf( file
.substring(3) ) === -1;
24 allI18nFiles
= grunt
.file
.expandFiles( "ui/i18n/*.js" ),
42 ].map(function( component
) {
43 return "themes/base/jquery.ui." + component
+ ".css";
48 "dist/jquery-ui.min.js": [ "<banner:meta.bannerAll>", "dist/jquery-ui.js" ],
49 "dist/i18n/jquery-ui-i18n.min.js": [ "<banner:meta.bannerI18n>", "dist/i18n/jquery-ui-i18n.js" ]
53 "dist/jquery-ui.min.css": "dist/jquery-ui.css"
59 "dist/jquery-ui.min.js"
63 function mapMinFile( file
) {
64 return "dist/" + file
.replace( /\.js
$/, ".min.js" ).replace( /ui\//, "minified/" );
67 uiFiles
.concat( allI18nFiles
).forEach(function( file
) {
68 minify
[ mapMinFile( file
) ] = [ "<banner>", file
];
71 cssFiles
.forEach(function( file
) {
72 minifyCSS
[ "dist/" + file
.replace( /\.css
$/, ".min.css" ).replace( /themes
\/base\//, "themes/base/minified/" ) ] = [ "<banner>", "<strip_all_banners:" + file
+ ">" ];
75 uiFiles
.forEach(function( file
) {
76 compareFiles
[ file
] = [ file
, mapMinFile( file
) ];
80 grunt
.loadNpmTasks( "grunt-css" );
81 grunt
.loadNpmTasks( "grunt-html" );
82 grunt
.loadNpmTasks( "grunt-compare-size" );
83 grunt
.loadNpmTasks( "grunt-junit" );
84 grunt
.loadNpmTasks( "grunt-git-authors" );
85 // local testswarm and build tasks
86 grunt
.loadTasks( "build/tasks" );
88 grunt
.registerHelper( "strip_all_banners", function( filepath
) {
89 return grunt
.file
.read( filepath
).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" );
92 function stripBanner( files
) {
93 return files
.map(function( file
) {
94 return "<strip_all_banners:" + file
+ ">";
98 function stripDirectory( file
) {
99 // TODO: we're receiving the directive, so we need to strip the trailing >
100 // we should be receving a clean path without the directive
101 return file
.replace( /.+\/(.+?)>?$/, "$1" );
103 // allow access from banner template
104 global
.stripDirectory
= stripDirectory
;
106 function createBanner( files
) {
108 var fileNames
= files
&& files
.map( stripDirectory
);
109 return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
110 "<%= grunt.template.today('isoDate') %>\n" +
111 "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" +
112 "* Includes: " + (files
? fileNames
.join(", ") : "<%= stripDirectory(grunt.task.current.file.src[1]) %>") + "\n" +
113 "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
114 " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */";
118 pkg
: "<json:package.json>",
120 dist
: "<%= pkg.name %>-<%= pkg.version %>",
121 cdn
: "<%= pkg.name %>-<%= pkg.version %>-cdn",
122 themes
: "<%= pkg.name %>-themes-<%= pkg.version %>"
125 banner
: createBanner(),
126 bannerAll
: createBanner( uiFiles
),
127 bannerI18n
: createBanner( allI18nFiles
),
128 bannerCSS
: createBanner( cssFiles
)
130 compare_size
: compareFiles
,
133 src
: [ "<banner:meta.bannerAll>", stripBanner( uiFiles
) ],
134 dest
: "dist/jquery-ui.js"
137 src
: [ "<banner:meta.bannerI18n>", allI18nFiles
],
138 dest
: "dist/i18n/jquery-ui-i18n.js"
141 src
: [ "<banner:meta.bannerCSS>", stripBanner( cssFiles
) ],
142 dest
: "dist/jquery-ui.css"
148 // ignore files that contain invalid html, used only for ajax content testing
149 all
: grunt
.file
.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file
) {
150 return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file
);
170 "dist/jquery-ui.js": "ui/jquery-ui.js",
171 "dist/jquery-ui.min.js": "ui/minified/jquery-ui.min.js",
172 "dist/i18n/jquery-ui-i18n.js": "ui/i18n/jquery-ui-i18n.js",
173 "dist/i18n/jquery-ui-i18n.min.js": "ui/minified/i18n/jquery-ui-i18n.min.js",
174 "dist/jquery-ui.css": "themes/base/jquery-ui.css",
175 "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css"
177 dest
: "dist/<%= files.dist %>"
180 src
: "dist/minified/**/*",
182 dest
: "dist/<%= files.dist %>/ui"
185 src
: "dist/themes/base/minified/*.css",
187 dest
: "dist/<%= files.dist %>"
190 src
: "themes/base/images/*",
191 strip
: /^themes\/base\//,
195 src
: "themes/base/images/*",
196 strip
: /^themes\/base\//,
197 dest
: "dist/<%= files.dist %>/themes/base/minified"
207 "dist/jquery-ui.js": "jquery-ui.js",
208 "dist/jquery-ui.min.js": "jquery-ui.min.js",
209 "dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js",
210 "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js",
211 "dist/jquery-ui.css": "themes/base/jquery-ui.css",
212 "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css"
214 dest
: "dist/<%= files.cdn %>"
217 src
: "ui/i18n/jquery.ui.datepicker-*.js",
219 dest
: "dist/<%= files.cdn %>"
222 src
: "dist/minified/i18n/jquery.ui.datepicker-*.js",
223 strip
: "dist/minified",
224 dest
: "dist/<%= files.cdn %>"
227 src
: "dist/minified/*.js",
228 strip
: /^dist\/minified/,
229 dest
: "dist/<%= files.cdn %>/ui"
232 src
: "themes/base/images/*",
233 strip
: /^themes\/base\//,
234 dest
: "dist/<%= files.cdn %>/themes/base/minified"
237 src
: "dist/<%= files.themes %>/themes/**/*",
238 strip
: "dist/<%= files.themes %>",
239 dest
: "dist/<%= files.cdn %>"
247 dest
: "dist/<%= files.themes %>"
252 src
: "<%= files.dist %>",
253 dest
: "<%= files.dist %>.zip"
256 src
: "<%= files.cdn %>",
257 dest
: "<%= files.cdn %>.zip"
260 src
: "<%= files.themes %>",
261 dest
: "<%= files.themes %>.zip"
266 src
: "dist/<%= files.dist %>",
267 dest
: "dist/<%= files.dist %>/MANIFEST"
270 src
: "dist/<%= files.cdn %>",
271 dest
: "dist/<%= files.cdn %>/MANIFEST"
274 src
: "dist/<%= files.themes %>",
275 dest
: "dist/<%= files.themes %>/MANIFEST"
279 files
: grunt
.file
.expandFiles( "tests/unit/**/*.html" ).filter(function( file
) {
280 // disabling everything that doesn't (quite) work with PhantomJS for now
281 // TODO except for all|index|test, try to include more as we go
282 return !( /(all|all-active|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html$/ ).test( file
);
286 ui
: grunt
.file
.expandFiles( "ui/*.js" ).filter(function( file
) {
287 // TODO remove items from this list once rewritten
288 return !( /(mouse|datepicker|draggable|droppable|resizable|selectable|sortable)\.js$/ ).test( file
);
290 grunt
: [ "grunt.js", "build/**/*.js" ],
291 tests
: "tests/unit/**/*.js"
295 // TODO figure out what to check for, then fix and enable
297 src
: grunt
.file
.expandFiles( "themes/base/*.css" ).filter(function( file
) {
298 // TODO remove items from this list once rewritten
299 return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file
);
301 // TODO consider reenabling some of these rules
305 "outline-none": false,
306 // especially this one
307 "overqualified-elements": false
311 jshint
: (function() {
312 function parserc( path
) {
313 var rc
= grunt
.file
.readJSON( (path
|| "") + ".jshintrc" ),
319 (rc
.predef
|| []).forEach(function( prop
) {
320 settings
.globals
[ prop
] = true;
328 // TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504
329 // TODO: limit `smarttabs` to multi-line comments https://github.com/jshint/jshint/issues/503
331 ui
: parserc( "ui/" ),
332 // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519
333 // TODO: don't create so many globals in tests
334 tests
: parserc( "tests/" )
339 grunt
.registerTask( "default", "lint csslint htmllint qunit" );
340 grunt
.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" );
341 grunt
.registerTask( "sizer_all", "concat:ui min compare_size" );
342 grunt
.registerTask( "build", "concat min cssmin copy:dist_units_images" );
343 grunt
.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" );
344 grunt
.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes" );
345 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" );