2012-03-23 17:33:46 +00:00
|
|
|
module.exports = function( grunt ) {
|
|
|
|
|
2012-10-22 21:41:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
2012-09-13 13:50:43 +00:00
|
|
|
var
|
2012-03-30 17:32:23 +00:00
|
|
|
// files
|
|
|
|
coreFiles = [
|
2013-12-02 18:36:12 +00:00
|
|
|
"core.js",
|
|
|
|
"widget.js",
|
|
|
|
"mouse.js",
|
|
|
|
"draggable.js",
|
|
|
|
"droppable.js",
|
|
|
|
"resizable.js",
|
|
|
|
"selectable.js",
|
|
|
|
"sortable.js",
|
|
|
|
"effect.js"
|
2012-03-30 17:32:23 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
uiFiles = coreFiles.map(function( file ) {
|
|
|
|
return "ui/" + file;
|
2012-12-21 17:26:56 +00:00
|
|
|
}).concat( expandFiles( "ui/*.js" ).filter(function( file ) {
|
2013-12-07 16:12:51 +00:00
|
|
|
return coreFiles.indexOf( file.substring( 3 ) ) === -1;
|
|
|
|
}) ),
|
2012-03-30 17:32:23 +00:00
|
|
|
|
2012-12-21 17:26:56 +00:00
|
|
|
allI18nFiles = expandFiles( "ui/i18n/*.js" ),
|
2012-03-30 17:32:23 +00:00
|
|
|
|
|
|
|
cssFiles = [
|
|
|
|
"core",
|
|
|
|
"accordion",
|
|
|
|
"autocomplete",
|
|
|
|
"button",
|
|
|
|
"datepicker",
|
|
|
|
"dialog",
|
2014-04-14 13:45:34 +00:00
|
|
|
"draggable",
|
2012-03-30 17:32:23 +00:00
|
|
|
"menu",
|
|
|
|
"progressbar",
|
|
|
|
"resizable",
|
|
|
|
"selectable",
|
2012-11-15 16:10:30 +00:00
|
|
|
"selectmenu",
|
2014-04-14 13:45:34 +00:00
|
|
|
"sortable",
|
2012-03-30 17:32:23 +00:00
|
|
|
"slider",
|
|
|
|
"spinner",
|
|
|
|
"tabs",
|
|
|
|
"tooltip",
|
|
|
|
"theme"
|
|
|
|
].map(function( component ) {
|
2013-12-02 18:36:12 +00:00
|
|
|
return "themes/base/" + component + ".css";
|
2012-03-30 17:32:23 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
// minified files
|
|
|
|
minify = {
|
2012-12-21 17:26:56 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
2012-03-30 17:32:23 +00:00
|
|
|
},
|
|
|
|
|
2012-04-24 13:48:14 +00:00
|
|
|
compareFiles = {
|
|
|
|
all: [
|
|
|
|
"dist/jquery-ui.js",
|
|
|
|
"dist/jquery-ui.min.js"
|
|
|
|
]
|
2014-05-25 21:27:24 +00:00
|
|
|
},
|
|
|
|
component = grunt.option( "component" ) || "**";
|
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
|
|
|
|
2012-12-21 17:26:56 +00:00
|
|
|
function expandFiles( files ) {
|
|
|
|
return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) {
|
|
|
|
return values[ 0 ];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-03-30 17:32:23 +00:00
|
|
|
uiFiles.concat( allI18nFiles ).forEach(function( file ) {
|
2012-12-21 17:26:56 +00:00
|
|
|
minify[ file ] = {
|
|
|
|
options: {
|
|
|
|
banner: createBanner()
|
|
|
|
},
|
|
|
|
files: {}
|
|
|
|
};
|
|
|
|
minify[ file ].files[ mapMinFile( file ) ] = file;
|
2012-03-30 17:32:23 +00:00
|
|
|
});
|
|
|
|
|
2012-04-24 13:48:14 +00:00
|
|
|
uiFiles.forEach(function( file ) {
|
2012-12-21 17:26:56 +00:00
|
|
|
// TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13
|
2013-12-07 16:12:51 +00:00
|
|
|
compareFiles[ file ] = [ file, mapMinFile( file ) ];
|
2012-04-24 13:48:14 +00:00
|
|
|
});
|
2012-03-30 17:32:23 +00:00
|
|
|
|
2012-06-09 15:30:52 +00:00
|
|
|
// grunt plugins
|
2014-02-05 18:43:08 +00:00
|
|
|
require( "load-grunt-tasks" )( grunt );
|
2012-06-08 15:35:11 +00:00
|
|
|
// local testswarm and build tasks
|
2012-06-14 13:37:53 +00:00
|
|
|
grunt.loadTasks( "build/tasks" );
|
2012-03-30 17:32:23 +00:00
|
|
|
|
2012-03-19 21:12:21 +00:00
|
|
|
function stripDirectory( file ) {
|
2012-04-02 15:12:49 +00:00
|
|
|
return file.replace( /.+\/(.+?)>?$/, "$1" );
|
2012-03-07 13:51:20 +00:00
|
|
|
}
|
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-12-21 17:26:56 +00:00
|
|
|
"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
|
2013-12-09 12:02:19 +00:00
|
|
|
(files ? "* Includes: " + fileNames.join(", ") + "\n" : "") +
|
2012-08-09 14:13:24 +00:00
|
|
|
"* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
|
2012-12-21 17:26:56 +00:00
|
|
|
" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n";
|
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({
|
2013-12-07 16:12:51 +00:00
|
|
|
pkg: grunt.file.readJSON( "package.json" ),
|
2012-03-19 21:12:21 +00:00
|
|
|
files: {
|
2013-06-05 12:38:08 +00:00
|
|
|
dist: "<%= pkg.name %>-<%= pkg.version %>"
|
2012-03-19 21:12:21 +00:00
|
|
|
},
|
2012-04-24 13:48:14 +00:00
|
|
|
compare_size: compareFiles,
|
2012-03-19 21:12:21 +00:00
|
|
|
concat: {
|
|
|
|
ui: {
|
2012-12-21 17:26:56 +00:00
|
|
|
options: {
|
|
|
|
banner: createBanner( uiFiles ),
|
|
|
|
stripBanners: {
|
|
|
|
block: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
src: uiFiles,
|
2012-03-19 21:12:21 +00:00
|
|
|
dest: "dist/jquery-ui.js"
|
|
|
|
},
|
|
|
|
i18n: {
|
2012-12-21 17:26:56 +00:00
|
|
|
options: {
|
|
|
|
banner: createBanner( allI18nFiles )
|
|
|
|
},
|
|
|
|
src: allI18nFiles,
|
2012-03-19 21:12:21 +00:00
|
|
|
dest: "dist/i18n/jquery-ui-i18n.js"
|
|
|
|
},
|
|
|
|
css: {
|
2012-12-21 17:26:56 +00:00
|
|
|
options: {
|
|
|
|
banner: createBanner( cssFiles ),
|
|
|
|
stripBanners: {
|
|
|
|
block: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
src: cssFiles,
|
2012-03-19 21:12:21 +00:00
|
|
|
dest: "dist/jquery-ui.css"
|
|
|
|
}
|
|
|
|
},
|
2013-10-10 16:42:21 +00:00
|
|
|
jscs: {
|
|
|
|
// datepicker, sortable, resizable and draggable are getting rewritten, ignore until that's done
|
2014-02-17 21:08:41 +00:00
|
|
|
ui: [ "ui/*.js", "!ui/datepicker.js", "!ui/sortable.js", "!ui/resizable.js" ],
|
2013-10-10 16:42:21 +00:00
|
|
|
// TODO enable this once we have a tool that can help with fixing formatting of existing files
|
|
|
|
// tests: "tests/unit/**/*.js",
|
2014-03-12 09:35:15 +00:00
|
|
|
grunt: [ "Gruntfile.js", "build/tasks/*.js" ]
|
2013-10-10 16:42:21 +00:00
|
|
|
},
|
2012-12-21 17:26:56 +00:00
|
|
|
uglify: minify,
|
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 ) {
|
2013-03-15 13:04:22 +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
|
|
|
qunit: {
|
2014-05-25 21:27:24 +00:00
|
|
|
files: expandFiles( "tests/unit/" + component + "/*.html" ).filter(function( file ) {
|
2013-12-02 20:54:29 +00:00
|
|
|
return !( /(all|index|test)\.html$/ ).test( file );
|
|
|
|
}),
|
|
|
|
options: {
|
|
|
|
page: {
|
|
|
|
viewportSize: { width: 700, height: 500 }
|
|
|
|
}
|
|
|
|
}
|
2012-03-19 21:12:21 +00:00
|
|
|
},
|
2012-12-21 17:26:56 +00:00
|
|
|
jshint: {
|
2013-11-01 18:44:14 +00:00
|
|
|
options: {
|
|
|
|
jshintrc: true
|
2012-12-21 17:26:56 +00:00
|
|
|
},
|
2013-11-11 19:12:21 +00:00
|
|
|
all: [
|
2013-11-01 18:44:14 +00:00
|
|
|
"ui/*.js",
|
|
|
|
"Gruntfile.js",
|
|
|
|
"build/**/*.js",
|
|
|
|
"tests/unit/**/*.js"
|
|
|
|
]
|
2012-03-19 21:12:21 +00:00
|
|
|
},
|
|
|
|
csslint: {
|
|
|
|
base_theme: {
|
2013-03-15 13:36:49 +00:00
|
|
|
src: "themes/base/*.css",
|
2013-03-11 14:29:08 +00:00
|
|
|
options: {
|
2013-03-15 13:57:45 +00:00
|
|
|
csslintrc: ".csslintrc"
|
2012-03-19 21:12:21 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-15 12:38:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
esformatter: {
|
|
|
|
options: {
|
|
|
|
preset: "jquery"
|
|
|
|
},
|
|
|
|
ui: "ui/*.js",
|
|
|
|
tests: "tests/unit/**/*.js",
|
|
|
|
build: {
|
|
|
|
options: {
|
|
|
|
skipHashbang: true
|
|
|
|
},
|
|
|
|
src: "build/**/*.js"
|
|
|
|
},
|
|
|
|
grunt: "Gruntfile.js"
|
2014-02-21 16:25:59 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
bowercopy: {
|
2014-06-10 11:55:45 +00:00
|
|
|
all: {
|
|
|
|
options: {
|
|
|
|
clean: true,
|
2014-06-24 12:48:01 +00:00
|
|
|
ignore: [ "jquery" ],
|
2014-06-10 11:55:45 +00:00
|
|
|
destPrefix: "external"
|
|
|
|
},
|
2014-02-21 16:25:59 +00:00
|
|
|
files: {
|
2014-06-10 11:55:45 +00:00
|
|
|
"qunit/qunit.js": "qunit/qunit/qunit.js",
|
|
|
|
"qunit/qunit.css": "qunit/qunit/qunit.css",
|
|
|
|
"qunit/MIT-LICENSE.txt": "qunit/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js",
|
|
|
|
|
|
|
|
"jshint/jshint.js": "jshint/dist/jshint.js",
|
|
|
|
"jshint/LICENSE": "jshint/LICENSE",
|
|
|
|
|
2014-06-24 12:48:01 +00:00
|
|
|
"jquery/jquery.js": "jquery-1.x/jquery.js",
|
|
|
|
"jquery/MIT-LICENSE.txt": "jquery-1.x/MIT-LICENSE.txt",
|
2014-06-10 12:26:24 +00:00
|
|
|
|
|
|
|
"jquery-1.6.0/jquery.js": "jquery-1.6.0/jquery.js",
|
|
|
|
"jquery-1.6.0/MIT-LICENSE.txt": "jquery-1.6.0/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.6.1/jquery.js": "jquery-1.6.1/jquery.js",
|
|
|
|
"jquery-1.6.1/MIT-LICENSE.txt": "jquery-1.6.1/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.6.2/jquery.js": "jquery-1.6.2/jquery.js",
|
|
|
|
"jquery-1.6.2/MIT-LICENSE.txt": "jquery-1.6.2/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.6.3/jquery.js": "jquery-1.6.3/jquery.js",
|
|
|
|
"jquery-1.6.3/MIT-LICENSE.txt": "jquery-1.6.3/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.6.4/jquery.js": "jquery-1.6.4/jquery.js",
|
|
|
|
"jquery-1.6.4/MIT-LICENSE.txt": "jquery-1.6.4/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.7.0/jquery.js": "jquery-1.7.0/jquery.js",
|
|
|
|
"jquery-1.7.0/MIT-LICENSE.txt": "jquery-1.7.0/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.7.1/jquery.js": "jquery-1.7.1/jquery.js",
|
|
|
|
"jquery-1.7.1/MIT-LICENSE.txt": "jquery-1.7.1/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.7.2/jquery.js": "jquery-1.7.2/jquery.js",
|
|
|
|
"jquery-1.7.2/MIT-LICENSE.txt": "jquery-1.7.2/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.8.0/jquery.js": "jquery-1.8.0/jquery.js",
|
|
|
|
"jquery-1.8.0/MIT-LICENSE.txt": "jquery-1.8.0/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.8.1/jquery.js": "jquery-1.8.1/jquery.js",
|
|
|
|
"jquery-1.8.1/MIT-LICENSE.txt": "jquery-1.8.1/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.8.2/jquery.js": "jquery-1.8.2/jquery.js",
|
|
|
|
"jquery-1.8.2/MIT-LICENSE.txt": "jquery-1.8.2/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.8.3/jquery.js": "jquery-1.8.3/jquery.js",
|
|
|
|
"jquery-1.8.3/MIT-LICENSE.txt": "jquery-1.8.3/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.9.0/jquery.js": "jquery-1.9.0/jquery.js",
|
|
|
|
"jquery-1.9.0/MIT-LICENSE.txt": "jquery-1.9.0/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.9.1/jquery.js": "jquery-1.9.1/jquery.js",
|
|
|
|
"jquery-1.9.1/MIT-LICENSE.txt": "jquery-1.9.1/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.10.0/jquery.js": "jquery-1.10.0/jquery.js",
|
|
|
|
"jquery-1.10.0/MIT-LICENSE.txt": "jquery-1.10.0/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.10.1/jquery.js": "jquery-1.10.1/jquery.js",
|
|
|
|
"jquery-1.10.1/MIT-LICENSE.txt": "jquery-1.10.1/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-1.10.2/jquery.js": "jquery-1.10.2/jquery.js",
|
|
|
|
"jquery-1.10.2/MIT-LICENSE.txt": "jquery-1.10.2/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-2.0.0/jquery.js": "jquery-2.0.0/jquery.js",
|
|
|
|
"jquery-2.0.0/MIT-LICENSE.txt": "jquery-2.0.0/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-2.0.1/jquery.js": "jquery-2.0.1/jquery.js",
|
|
|
|
"jquery-2.0.1/MIT-LICENSE.txt": "jquery-2.0.1/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-2.0.2/jquery.js": "jquery-2.0.2/jquery.js",
|
|
|
|
"jquery-2.0.2/MIT-LICENSE.txt": "jquery-2.0.2/MIT-LICENSE.txt",
|
|
|
|
|
|
|
|
"jquery-2.0.3/jquery.js": "jquery-2.0.3/jquery.js",
|
|
|
|
"jquery-2.0.3/MIT-LICENSE.txt": "jquery-2.0.3/MIT-LICENSE.txt"
|
2014-02-21 16:25:59 +00:00
|
|
|
}
|
2014-06-10 11:55:45 +00:00
|
|
|
}
|
2012-12-21 17:26:56 +00:00
|
|
|
}
|
2012-03-02 15:45:10 +00:00
|
|
|
});
|
|
|
|
|
2013-12-07 16:12:51 +00:00
|
|
|
grunt.registerTask( "default", [ "lint", "test" ]);
|
|
|
|
grunt.registerTask( "lint", [ "asciilint", "jshint", "jscs", "csslint", "htmllint" ]);
|
|
|
|
grunt.registerTask( "test", [ "qunit" ]);
|
|
|
|
grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ]);
|
|
|
|
grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ]);
|
2013-06-24 12:21:55 +00:00
|
|
|
|
2012-03-23 17:33:46 +00:00
|
|
|
};
|