2012-04-20 13:38:04 +00:00
|
|
|
|
/*jshint node: true */
|
2012-03-23 17:33:46 +00:00
|
|
|
|
module.exports = function( grunt ) {
|
|
|
|
|
|
2012-03-30 17:32:23 +00:00
|
|
|
|
var // modules
|
|
|
|
|
fs = require( "fs" ),
|
|
|
|
|
path = require( "path" ),
|
|
|
|
|
request = require( "request" ),
|
|
|
|
|
|
|
|
|
|
// 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": [ "<banner:meta.bannerAll>", "dist/jquery-ui.js" ],
|
|
|
|
|
"dist/i18n/jquery-ui-i18n.min.js": [ "<banner:meta.bannerI18n>", "dist/i18n/jquery-ui-i18n.js" ]
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
minifyCSS = {
|
|
|
|
|
"dist/jquery-ui.min.css": "dist/jquery-ui.css"
|
2012-04-24 13:48:14 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
compareFiles = {
|
|
|
|
|
all: [
|
|
|
|
|
"dist/jquery-ui.js",
|
|
|
|
|
"dist/jquery-ui.min.js"
|
|
|
|
|
]
|
2012-03-30 17:32:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
2012-04-24 13:48:14 +00:00
|
|
|
|
function mapMinFile( file ) {
|
|
|
|
|
return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" );
|
|
|
|
|
}
|
2012-03-30 17:32:23 +00:00
|
|
|
|
|
|
|
|
|
uiFiles.concat( allI18nFiles ).forEach(function( file ) {
|
2012-04-24 13:48:14 +00:00
|
|
|
|
minify[ mapMinFile( file ) ] = [ "<banner>", file ];
|
2012-03-30 17:32:23 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cssFiles.forEach(function( file ) {
|
2012-04-02 14:05:59 +00:00
|
|
|
|
minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "<banner>", "<strip_all_banners:" + file + ">" ];
|
2012-03-30 17:32:23 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-04-24 13:48:14 +00:00
|
|
|
|
uiFiles.forEach(function( file ) {
|
|
|
|
|
compareFiles[ file ] = [ file, mapMinFile( file ) ];
|
|
|
|
|
});
|
2012-03-30 17:32:23 +00:00
|
|
|
|
|
|
|
|
|
// csslint and cssmin tasks
|
|
|
|
|
grunt.loadNpmTasks( "grunt-css" );
|
2012-04-12 17:32:11 +00:00
|
|
|
|
// file size comparison tasks
|
|
|
|
|
grunt.loadNpmTasks( "grunt-compare-size" );
|
2012-04-22 10:19:16 +00:00
|
|
|
|
// html validation task
|
|
|
|
|
grunt.loadNpmTasks( "grunt-html" );
|
2012-03-30 17:32:23 +00:00
|
|
|
|
|
|
|
|
|
grunt.registerHelper( "strip_all_banners", function( filepath ) {
|
|
|
|
|
return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" );
|
|
|
|
|
});
|
|
|
|
|
|
2012-03-19 21:12:21 +00:00
|
|
|
|
function stripBanner( files ) {
|
|
|
|
|
return files.map(function( file ) {
|
|
|
|
|
return "<strip_all_banners:" + file + ">";
|
|
|
|
|
});
|
2012-03-09 12:52:18 +00:00
|
|
|
|
}
|
2012-03-19 21:12:21 +00:00
|
|
|
|
|
|
|
|
|
function stripDirectory( file ) {
|
2012-04-02 15:12:49 +00:00
|
|
|
|
// 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" );
|
2012-03-07 13:51:20 +00:00
|
|
|
|
}
|
2012-03-30 17:32:23 +00:00
|
|
|
|
// allow access from banner template
|
|
|
|
|
global.stripDirectory = stripDirectory;
|
2012-03-19 21:12:21 +00:00
|
|
|
|
|
|
|
|
|
function createBanner( files ) {
|
|
|
|
|
// strip folders
|
|
|
|
|
var fileNames = files && files.map( stripDirectory );
|
|
|
|
|
return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
|
2012-03-23 17:33:46 +00:00
|
|
|
|
"<%= grunt.template.today('isoDate') %>\n" +
|
2012-03-19 21:12:21 +00:00
|
|
|
|
"<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" +
|
2012-03-23 17:33:46 +00:00
|
|
|
|
"* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(grunt.task.current.file.src[1]) %>") + "\n" +
|
|
|
|
|
"* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
|
2012-03-19 21:12:21 +00:00
|
|
|
|
" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */";
|
2012-03-07 13:51:20 +00:00
|
|
|
|
}
|
2012-03-19 21:12:21 +00:00
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.initConfig({
|
2012-03-19 21:12:21 +00:00
|
|
|
|
pkg: "<json:package.json>",
|
|
|
|
|
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 )
|
|
|
|
|
},
|
2012-04-24 13:48:14 +00:00
|
|
|
|
compare_size: compareFiles,
|
2012-03-19 21:12:21 +00:00
|
|
|
|
concat: {
|
|
|
|
|
ui: {
|
|
|
|
|
src: [ "<banner:meta.bannerAll>", stripBanner( uiFiles ) ],
|
|
|
|
|
dest: "dist/jquery-ui.js"
|
|
|
|
|
},
|
|
|
|
|
i18n: {
|
|
|
|
|
src: [ "<banner:meta.bannerI18n>", allI18nFiles ],
|
|
|
|
|
dest: "dist/i18n/jquery-ui-i18n.js"
|
|
|
|
|
},
|
|
|
|
|
css: {
|
|
|
|
|
src: [ "<banner:meta.bannerCSS>", stripBanner( cssFiles ) ],
|
|
|
|
|
dest: "dist/jquery-ui.css"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
min: minify,
|
2012-03-28 09:45:27 +00:00
|
|
|
|
cssmin: minifyCSS,
|
2012-04-23 16:10:28 +00:00
|
|
|
|
htmllint: {
|
2012-04-26 18:04:34 +00:00
|
|
|
|
// ignore files that contain invalid html, used only for ajax content testing
|
|
|
|
|
all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) {
|
2012-04-27 11:06:09 +00:00
|
|
|
|
return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file );
|
2012-04-26 18:04:34 +00:00
|
|
|
|
})
|
2012-04-22 10:19:16 +00:00
|
|
|
|
},
|
2012-03-19 21:12:21 +00:00
|
|
|
|
copy: {
|
|
|
|
|
dist: {
|
|
|
|
|
src: [
|
|
|
|
|
"AUTHORS.txt",
|
|
|
|
|
"GPL-LICENSE.txt",
|
2012-04-02 15:12:49 +00:00
|
|
|
|
"jquery-*.js",
|
2012-03-19 21:12:21 +00:00
|
|
|
|
"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 %>"
|
|
|
|
|
},
|
2012-05-02 16:39:31 +00:00
|
|
|
|
dist_units_images: {
|
|
|
|
|
src: "themes/base/images/*",
|
|
|
|
|
strip: /^themes\/base\//,
|
|
|
|
|
dest: "dist/"
|
|
|
|
|
},
|
2012-03-19 21:12:21 +00:00
|
|
|
|
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: {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// disabling everything that doesn't (quite) work with PhantomJS for now
|
2012-04-04 09:14:03 +00:00
|
|
|
|
// TODO except for all|index|test, try to include more as we go
|
|
|
|
|
return !( /(all|all-active|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html$/ ).test( file );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
lint: {
|
2012-04-04 08:52:41 +00:00
|
|
|
|
ui: grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) {
|
2012-04-04 09:14:03 +00:00
|
|
|
|
// TODO remove items from this list once rewritten
|
2012-04-04 08:52:41 +00:00
|
|
|
|
return !( /(effects.core|mouse|datepicker|draggable|droppable|resizable|selectable|sortable)\.js$/ ).test( file );
|
|
|
|
|
}),
|
2012-04-19 15:21:24 +00:00
|
|
|
|
grunt: "grunt.js",
|
|
|
|
|
tests: "tests/unit/**/*.js"
|
2012-03-19 21:12:21 +00:00
|
|
|
|
},
|
|
|
|
|
csslint: {
|
2012-04-04 09:14:03 +00:00
|
|
|
|
// nothing: []
|
|
|
|
|
// TODO figure out what to check for, then fix and enable
|
2012-03-19 21:12:21 +00:00
|
|
|
|
base_theme: {
|
2012-04-04 09:14:03 +00:00
|
|
|
|
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
|
2012-03-19 21:12:21 +00:00
|
|
|
|
rules: {
|
|
|
|
|
"import": false,
|
2012-04-04 09:14:03 +00:00
|
|
|
|
"important": false,
|
|
|
|
|
"outline-none": false,
|
|
|
|
|
// especially this one
|
|
|
|
|
"overqualified-elements": false
|
2012-03-19 21:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2012-04-02 23:12:10 +00:00
|
|
|
|
jshint: (function() {
|
2012-04-20 13:38:04 +00:00
|
|
|
|
function parserc( path ) {
|
|
|
|
|
var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
|
|
|
|
|
settings = {
|
|
|
|
|
options: rc,
|
|
|
|
|
globals: {}
|
|
|
|
|
};
|
2012-04-02 23:12:10 +00:00
|
|
|
|
|
2012-04-20 13:38:04 +00:00
|
|
|
|
(rc.predef || []).forEach(function( prop ) {
|
|
|
|
|
settings.globals[ prop ] = true;
|
|
|
|
|
});
|
|
|
|
|
delete rc.predef;
|
|
|
|
|
|
|
|
|
|
return settings;
|
2012-04-02 23:12:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
2012-04-20 13:38:04 +00:00
|
|
|
|
// TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504
|
|
|
|
|
// TODO: limit `smarttabs` to multi-line comments https://github.com/jshint/jshint/issues/503
|
|
|
|
|
options: 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/" )
|
2012-04-02 23:12:10 +00:00
|
|
|
|
};
|
|
|
|
|
})()
|
2012-03-02 15:45:10 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-04-30 13:14:33 +00:00
|
|
|
|
grunt.registerTask( "testswarm", function( commit, configFile ) {
|
2012-04-29 20:59:45 +00:00
|
|
|
|
var test,
|
|
|
|
|
testswarm = require( "testswarm" ),
|
2012-04-29 21:03:53 +00:00
|
|
|
|
testBase = "http://swarm.jquery.org/git/jquery-ui/" + commit + "/tests/unit/",
|
2012-04-29 20:59:45 +00:00
|
|
|
|
testUrls = [],
|
|
|
|
|
tests = {
|
2012-05-07 10:17:45 +00:00
|
|
|
|
"Accordion": "accordion/accordion.html",
|
|
|
|
|
"Accordion_deprecated": "accordion/accordion_deprecated.html",
|
|
|
|
|
"Autocomplete": "autocomplete/autocomplete.html",
|
|
|
|
|
"Button": "button/button.html",
|
|
|
|
|
"Core": "core/core.html",
|
|
|
|
|
//"datepicker/datepicker.html",
|
|
|
|
|
//"dialog/dialog.html",
|
|
|
|
|
//"draggable/draggable.html",
|
|
|
|
|
//"droppable/droppable.html",
|
|
|
|
|
"Effects": "effects/effects.html",
|
|
|
|
|
"Menu": "menu/menu.html",
|
|
|
|
|
"Position": "position/position.html",
|
|
|
|
|
"Position_deprecated": "position/position_deprecated.html",
|
|
|
|
|
"Progressbar": "progressbar/progressbar.html",
|
|
|
|
|
//"resizable/resizable.html",
|
|
|
|
|
//"selectable/selectable.html",
|
|
|
|
|
//"slider/slider.html",
|
|
|
|
|
//"sortable/sortable.html",
|
|
|
|
|
"Spinner": "spinner/spinner.html",
|
|
|
|
|
"Tabs": "tabs/tabs.html",
|
|
|
|
|
"Tabs_deprecated": "tabs/tabs_deprecated.html",
|
|
|
|
|
"Tooltip": "tooltip/tooltip.html",
|
|
|
|
|
"Widget": "widget/widget.html"
|
|
|
|
|
};
|
|
|
|
|
for ( test in tests ) {
|
2012-05-04 14:07:07 +00:00
|
|
|
|
testUrls.push( testBase + tests[ test ] + "?nojshint=true" );
|
2012-04-29 20:59:45 +00:00
|
|
|
|
}
|
2012-04-28 21:36:38 +00:00
|
|
|
|
testswarm({
|
2012-04-30 11:14:50 +00:00
|
|
|
|
url: "http://swarm.jquery.org/",
|
2012-04-30 12:57:00 +00:00
|
|
|
|
pollInterval: 10000,
|
2012-05-07 10:17:45 +00:00
|
|
|
|
timeout: 1000 * 60 * 20,
|
2012-04-28 12:03:13 +00:00
|
|
|
|
done: this.async()
|
|
|
|
|
}, {
|
|
|
|
|
authUsername: "jqueryui",
|
2012-05-07 10:17:45 +00:00
|
|
|
|
authToken: grunt.file.readJSON( configFile ).jqueryui.authToken,
|
2012-05-07 17:44:09 +00:00
|
|
|
|
jobName: 'jQuery UI commit #<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
|
|
|
|
|
runMax: 3,
|
2012-04-29 20:59:45 +00:00
|
|
|
|
"runNames[]": Object.keys(tests),
|
|
|
|
|
"runUrls[]": testUrls,
|
2012-04-30 12:57:00 +00:00
|
|
|
|
"browserSets[]": ["popular"]
|
2012-04-28 12:03:13 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
function replaceVersion( source ) {
|
2012-04-18 20:17:21 +00:00
|
|
|
|
return source.replace( /@VERSION/g, grunt.config( "pkg.version" ) );
|
|
|
|
|
}
|
|
|
|
|
function copyFile( src, dest ) {
|
|
|
|
|
if ( /(js|css)$/.test( src ) ) {
|
|
|
|
|
grunt.file.copy( src, dest, {
|
|
|
|
|
process: replaceVersion
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
grunt.file.copy( src, dest );
|
|
|
|
|
}
|
2012-03-19 21:12:21 +00:00
|
|
|
|
}
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var files = grunt.file.expandFiles( this.file.src ),
|
|
|
|
|
target = this.file.dest + "/",
|
|
|
|
|
strip = this.data.strip,
|
|
|
|
|
renameCount = 0,
|
|
|
|
|
fileName;
|
2012-03-19 21:12:21 +00:00
|
|
|
|
if ( typeof strip === "string" ) {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
strip = new RegExp( "^" + grunt.template.process( strip, grunt.config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
files.forEach(function( fileName ) {
|
|
|
|
|
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
|
2012-04-18 20:17:21 +00:00
|
|
|
|
copyFile( fileName, target + targetFile );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
});
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.log.writeln( "Copied " + files.length + " files." );
|
2012-04-04 09:14:03 +00:00
|
|
|
|
for ( fileName in this.data.renames ) {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
renameCount += 1;
|
2012-04-18 20:17:21 +00:00
|
|
|
|
copyFile( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
if ( renameCount ) {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.log.writeln( "Renamed " + renameCount + " files." );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
}
|
2012-03-08 13:06:25 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// TODO switch back to adm-zip for better cross-platform compability once it actually works
|
2012-03-19 22:08:56 +00:00
|
|
|
|
// 0.1.3 works, but result can't be unzipped
|
|
|
|
|
// its also a lot slower then zip program, probably due to how its used...
|
2012-03-23 17:33:46 +00:00
|
|
|
|
// var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" );
|
|
|
|
|
// grunt.log.writeln( "Creating zip file " + this.file.dest );
|
2012-03-09 16:18:35 +00:00
|
|
|
|
|
2012-03-30 17:32:23 +00:00
|
|
|
|
//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 );
|
2012-03-02 15:45:10 +00:00
|
|
|
|
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var done = this.async(),
|
|
|
|
|
dest = this.file.dest,
|
|
|
|
|
src = grunt.template.process( this.file.src, grunt.config() );
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.utils.spawn({
|
2012-03-19 21:12:21 +00:00
|
|
|
|
cmd: "zip",
|
|
|
|
|
args: [ "-r", dest, src ],
|
|
|
|
|
opts: {
|
|
|
|
|
cwd: 'dist'
|
|
|
|
|
}
|
|
|
|
|
}, function( err, result ) {
|
|
|
|
|
if ( err ) {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.log.error( err );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
done();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.log.writeln( "Zipped " + dest );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
done();
|
|
|
|
|
});
|
2012-03-02 15:45:10 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// remove dest file before creating it, to make sure itself is not included
|
2012-03-30 17:32:23 +00:00
|
|
|
|
if ( path.existsSync( this.file.dest ) ) {
|
|
|
|
|
fs.unlinkSync( this.file.dest );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
}
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var crypto = require( "crypto" ),
|
|
|
|
|
dir = this.file.src + "/",
|
|
|
|
|
hashes = [];
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
var hash = crypto.createHash( "md5" );
|
2012-03-23 17:33:46 +00:00
|
|
|
|
hash.update( grunt.file.read( fileName, "ascii" ) );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) );
|
|
|
|
|
});
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" );
|
|
|
|
|
grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" );
|
2012-03-07 14:16:32 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-03-29 14:29:27 +00:00
|
|
|
|
// 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")?
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var version = "1.8",
|
|
|
|
|
docsDir = "dist/docs",
|
|
|
|
|
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'
|
|
|
|
|
};
|
|
|
|
|
});
|
2012-03-29 14:29:27 +00:00
|
|
|
|
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'
|
|
|
|
|
};
|
|
|
|
|
}));
|
|
|
|
|
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() );
|
|
|
|
|
});
|
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.registerTask( "download_themes", function() {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// var AdmZip = require('adm-zip');
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var done = this.async(),
|
|
|
|
|
themes = grunt.file.read( "build/themes" ).split(","),
|
|
|
|
|
requests = 0;
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.file.mkdir( "dist/tmp" );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
themes.forEach(function( theme, index ) {
|
|
|
|
|
requests += 1;
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.file.mkdir( "dist/tmp/" + index );
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var zipFileName = "dist/tmp/" + index + ".zip",
|
|
|
|
|
out = fs.createWriteStream( zipFileName );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
out.on( "close", function() {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.log.writeln( "done downloading " + zipFileName );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// 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...
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.utils.spawn({
|
2012-03-19 21:12:21 +00:00
|
|
|
|
cmd: "unzip",
|
|
|
|
|
args: [ "-d", "dist/tmp/" + index, zipFileName ]
|
|
|
|
|
}, function( err, result ) {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.log.writeln( "Unzipped " + zipFileName + ", deleting it now" );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
fs.unlinkSync( zipFileName );
|
|
|
|
|
requests -= 1;
|
|
|
|
|
if (requests === 0) {
|
|
|
|
|
done();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
request( "http://ui-dev.jquery.com/download/?" + theme ).pipe( out );
|
|
|
|
|
});
|
2012-03-08 13:06:25 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.registerTask( "copy_themes", function() {
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// each package includes the base theme, ignore that
|
2012-04-04 09:14:03 +00:00
|
|
|
|
var filter = /themes\/base/,
|
|
|
|
|
files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) {
|
|
|
|
|
return !filter.test( file );
|
|
|
|
|
}),
|
|
|
|
|
// TODO the grunt.template.process call shouldn't be necessary
|
|
|
|
|
target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
|
|
|
|
|
distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
files.forEach(function( fileName ) {
|
2012-03-21 20:19:31 +00:00
|
|
|
|
var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" );
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.file.copy( fileName, target + targetFile );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
});
|
2012-03-09 12:52:18 +00:00
|
|
|
|
|
2012-03-19 21:12:21 +00:00
|
|
|
|
// copy minified base theme from regular release
|
2012-03-23 17:33:46 +00:00
|
|
|
|
files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
files.forEach(function( fileName ) {
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) );
|
2012-03-19 21:12:21 +00:00
|
|
|
|
});
|
2012-03-09 12:52:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
|
grunt.registerTask( "clean", function() {
|
2012-03-21 20:19:31 +00:00
|
|
|
|
require( "rimraf" ).sync( "dist" );
|
2012-03-19 21:57:51 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-04-30 12:57:00 +00:00
|
|
|
|
grunt.registerTask( "default", "lint csslint htmllint qunit" );
|
2012-04-24 13:48:14 +00:00
|
|
|
|
grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" );
|
|
|
|
|
grunt.registerTask( "sizer_all", "concat:ui min compare_size" );
|
2012-05-02 16:39:31 +00:00
|
|
|
|
grunt.registerTask( "build", "concat min cssmin copy:dist_units_images" );
|
2012-03-23 17:33:46 +00:00
|
|
|
|
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" );
|
|
|
|
|
|
|
|
|
|
};
|