2012-04-18 20:07:35 +00:00
|
|
|
module.exports = function( grunt ) {
|
2012-10-16 14:10:17 +00:00
|
|
|
"use strict";
|
|
|
|
|
2013-09-12 20:51:59 +00:00
|
|
|
function readOptionalJSON( filepath ) {
|
2016-02-10 11:54:25 +00:00
|
|
|
var stripJSONComments = require( "strip-json-comments" ),
|
|
|
|
data = {};
|
2013-09-12 20:51:59 +00:00
|
|
|
try {
|
2015-08-01 23:48:54 +00:00
|
|
|
data = JSON.parse( stripJSONComments(
|
|
|
|
fs.readFileSync( filepath, { encoding: "utf8" } )
|
|
|
|
) );
|
2013-11-09 22:12:06 +00:00
|
|
|
} catch ( e ) {}
|
2013-09-12 20:51:59 +00:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2015-08-01 23:48:54 +00:00
|
|
|
var fs = require( "fs" ),
|
|
|
|
gzip = require( "gzip-js" ),
|
2016-07-11 17:21:57 +00:00
|
|
|
oldNode = /^v0\./.test( process.version );
|
2015-08-03 18:28:37 +00:00
|
|
|
|
2016-07-11 17:21:57 +00:00
|
|
|
// Support: Node.js <4
|
|
|
|
// Skip running tasks that dropped support for Node.js 0.10 & 0.12
|
|
|
|
// in those Node versions.
|
|
|
|
function runIfNewNode( task ) {
|
|
|
|
return oldNode ? "print_old_node_message:" + task : task;
|
|
|
|
}
|
2013-04-09 16:48:34 +00:00
|
|
|
|
2015-11-12 18:18:59 +00:00
|
|
|
if ( !grunt.option( "filename" ) ) {
|
|
|
|
grunt.option( "filename", "jquery.js" );
|
|
|
|
}
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
grunt.initConfig( {
|
2013-11-09 22:12:06 +00:00
|
|
|
pkg: grunt.file.readJSON( "package.json" ),
|
|
|
|
dst: readOptionalJSON( "dist/.destination.json" ),
|
2014-07-17 17:25:59 +00:00
|
|
|
"compare_size": {
|
2013-03-25 04:47:46 +00:00
|
|
|
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
|
|
|
options: {
|
|
|
|
compress: {
|
|
|
|
gz: function( contents ) {
|
|
|
|
return gzip.zip( contents, {} ).length;
|
|
|
|
}
|
|
|
|
},
|
2013-10-15 20:14:10 +00:00
|
|
|
cache: "build/.sizecache.json"
|
2013-03-25 04:47:46 +00:00
|
|
|
}
|
2012-04-18 20:07:35 +00:00
|
|
|
},
|
2015-06-01 21:25:38 +00:00
|
|
|
babel: {
|
|
|
|
options: {
|
|
|
|
sourceMap: "inline",
|
|
|
|
retainLines: true
|
|
|
|
},
|
|
|
|
nodeSmokeTests: {
|
|
|
|
files: {
|
|
|
|
"test/node_smoke_tests/lib/ensure_iterability.js":
|
|
|
|
"test/node_smoke_tests/lib/ensure_iterability_es6.js"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2012-04-18 20:07:35 +00:00
|
|
|
build: {
|
2013-04-18 17:19:22 +00:00
|
|
|
all: {
|
2013-01-26 18:38:04 +00:00
|
|
|
dest: "dist/jquery.js",
|
2013-08-15 18:15:49 +00:00
|
|
|
minimum: [
|
|
|
|
"core",
|
|
|
|
"selector"
|
|
|
|
],
|
2015-08-16 06:59:58 +00:00
|
|
|
|
2013-08-15 18:15:49 +00:00
|
|
|
// Exclude specified modules if the module matching the key is removed
|
|
|
|
removeWith: {
|
2014-06-02 16:39:11 +00:00
|
|
|
ajax: [ "manipulation/_evalUrl", "event/ajax" ],
|
2013-08-15 18:15:49 +00:00
|
|
|
callbacks: [ "deferred" ],
|
|
|
|
css: [ "effects", "dimensions", "offset" ],
|
2015-10-09 19:52:29 +00:00
|
|
|
"css/showHide": [ "effects" ],
|
2016-01-19 19:47:52 +00:00
|
|
|
deferred: {
|
|
|
|
remove: [ "ajax", "effects", "queue", "core/ready" ],
|
|
|
|
include: [ "core/ready-no-deferred" ]
|
|
|
|
},
|
2013-08-26 22:54:13 +00:00
|
|
|
sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
|
2013-08-15 18:15:49 +00:00
|
|
|
}
|
2013-01-26 18:38:04 +00:00
|
|
|
}
|
2012-04-18 20:07:35 +00:00
|
|
|
},
|
2014-07-17 16:02:59 +00:00
|
|
|
npmcopy: {
|
2014-06-10 19:32:25 +00:00
|
|
|
all: {
|
2013-11-14 15:17:18 +00:00
|
|
|
options: {
|
2014-06-10 19:32:25 +00:00
|
|
|
destPrefix: "external"
|
2013-12-06 20:55:55 +00:00
|
|
|
},
|
|
|
|
files: {
|
2014-06-10 19:32:25 +00:00
|
|
|
"sizzle/dist": "sizzle/dist",
|
2014-07-01 20:50:27 +00:00
|
|
|
"sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
|
2014-06-10 19:32:25 +00:00
|
|
|
|
2014-12-29 19:14:13 +00:00
|
|
|
"npo/npo.js": "native-promise-only/npo.js",
|
|
|
|
|
2014-07-17 16:02:59 +00:00
|
|
|
"qunit/qunit.js": "qunitjs/qunit/qunit.js",
|
|
|
|
"qunit/qunit.css": "qunitjs/qunit/qunit.css",
|
2014-12-15 17:30:43 +00:00
|
|
|
"qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
|
2014-06-10 19:32:25 +00:00
|
|
|
|
2015-05-10 23:39:26 +00:00
|
|
|
"qunit-assert-step/qunit-assert-step.js":
|
|
|
|
"qunit-assert-step/qunit-assert-step.js",
|
|
|
|
"qunit-assert-step/MIT-LICENSE.txt":
|
|
|
|
"qunit-assert-step/MIT-LICENSE.txt",
|
|
|
|
|
2014-06-10 19:32:25 +00:00
|
|
|
"requirejs/require.js": "requirejs/require.js",
|
|
|
|
|
2016-01-27 11:54:39 +00:00
|
|
|
"sinon/sinon.js": "sinon/pkg/sinon.js",
|
2014-06-10 19:32:25 +00:00
|
|
|
"sinon/LICENSE.txt": "sinon/LICENSE"
|
2013-11-14 15:17:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-07-19 13:53:57 +00:00
|
|
|
jsonlint: {
|
|
|
|
pkg: {
|
|
|
|
src: [ "package.json" ]
|
|
|
|
}
|
|
|
|
},
|
2016-05-10 09:06:37 +00:00
|
|
|
eslint: {
|
|
|
|
options: {
|
|
|
|
|
|
|
|
// See https://github.com/sindresorhus/grunt-eslint/issues/119
|
|
|
|
quiet: true
|
2013-09-06 18:31:18 +00:00
|
|
|
},
|
2016-05-10 09:06:37 +00:00
|
|
|
all: ".",
|
2016-06-22 15:41:57 +00:00
|
|
|
dist: "dist/jquery.js",
|
2016-05-10 09:06:37 +00:00
|
|
|
dev: [ "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" ]
|
2013-09-12 20:51:59 +00:00
|
|
|
},
|
2012-12-13 01:19:18 +00:00
|
|
|
testswarm: {
|
2014-07-17 17:25:59 +00:00
|
|
|
tests: [
|
2015-07-29 22:54:00 +00:00
|
|
|
|
|
|
|
// A special module with basic tests, meant for
|
|
|
|
// not fully supported environments like Android 2.3,
|
|
|
|
// jsdom or PhantomJS. We run it everywhere, though,
|
|
|
|
// to make sure tests are not broken.
|
|
|
|
"basic",
|
|
|
|
|
2014-07-17 17:25:59 +00:00
|
|
|
"ajax",
|
2015-05-19 21:48:42 +00:00
|
|
|
"animation",
|
2014-07-17 17:25:59 +00:00
|
|
|
"attributes",
|
|
|
|
"callbacks",
|
|
|
|
"core",
|
|
|
|
"css",
|
|
|
|
"data",
|
|
|
|
"deferred",
|
2015-10-20 16:30:01 +00:00
|
|
|
"deprecated",
|
2014-07-17 17:25:59 +00:00
|
|
|
"dimensions",
|
|
|
|
"effects",
|
|
|
|
"event",
|
|
|
|
"manipulation",
|
|
|
|
"offset",
|
|
|
|
"queue",
|
|
|
|
"selector",
|
|
|
|
"serialize",
|
|
|
|
"support",
|
2015-05-18 21:11:21 +00:00
|
|
|
"traversing",
|
|
|
|
"tween"
|
2014-07-17 17:25:59 +00:00
|
|
|
]
|
2012-12-13 01:19:18 +00:00
|
|
|
},
|
2012-04-18 20:07:35 +00:00
|
|
|
watch: {
|
2016-05-10 09:06:37 +00:00
|
|
|
files: [ "<%= eslint.dev %>" ],
|
2014-12-30 02:07:03 +00:00
|
|
|
tasks: [ "dev" ]
|
2012-04-18 20:07:35 +00:00
|
|
|
},
|
2012-10-11 13:38:44 +00:00
|
|
|
uglify: {
|
2012-12-19 04:02:50 +00:00
|
|
|
all: {
|
|
|
|
files: {
|
2015-11-12 18:18:59 +00:00
|
|
|
"dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
|
|
|
|
"dist/<%= grunt.option('filename') %>"
|
2012-12-19 04:02:50 +00:00
|
|
|
},
|
|
|
|
options: {
|
2013-11-09 22:12:06 +00:00
|
|
|
preserveComments: false,
|
2014-07-17 18:15:19 +00:00
|
|
|
sourceMap: true,
|
2016-01-11 16:42:33 +00:00
|
|
|
ASCIIOnly: true,
|
2015-11-12 18:18:59 +00:00
|
|
|
sourceMapName:
|
|
|
|
"dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
|
2013-04-18 17:19:22 +00:00
|
|
|
report: "min",
|
2012-12-19 04:02:50 +00:00
|
|
|
beautify: {
|
2014-07-17 17:25:59 +00:00
|
|
|
"ascii_only": true
|
2013-04-10 18:46:31 +00:00
|
|
|
},
|
2013-11-09 22:12:06 +00:00
|
|
|
banner: "/*! jQuery v<%= pkg.version %> | " +
|
2015-01-01 19:34:48 +00:00
|
|
|
"(c) jQuery Foundation | jquery.org/license */",
|
2013-04-18 13:16:59 +00:00
|
|
|
compress: {
|
2014-07-17 17:25:59 +00:00
|
|
|
"hoist_funs": false,
|
2013-10-15 21:59:58 +00:00
|
|
|
loops: false,
|
|
|
|
unused: false
|
2012-12-19 04:02:50 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-11 13:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-04-18 20:07:35 +00:00
|
|
|
|
2012-12-19 04:02:50 +00:00
|
|
|
// Load grunt tasks from NPM packages
|
2016-07-11 17:21:57 +00:00
|
|
|
// Support: Node.js <4
|
|
|
|
// Don't load the eslint task in old Node.js, it won't parse.
|
|
|
|
require( "load-grunt-tasks" )( grunt, {
|
|
|
|
pattern: oldNode ? [ "grunt-*", "!grunt-eslint" ] : [ "grunt-*" ]
|
|
|
|
} );
|
2013-08-16 13:48:00 +00:00
|
|
|
|
|
|
|
// Integrate jQuery specific tasks
|
|
|
|
grunt.loadTasks( "build/tasks" );
|
2012-12-19 04:02:50 +00:00
|
|
|
|
2016-07-11 17:21:57 +00:00
|
|
|
grunt.registerTask( "print_old_node_message", function() {
|
|
|
|
var task = [].slice.call( arguments ).join( ":" );
|
|
|
|
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
|
|
|
|
} );
|
2013-07-19 13:53:57 +00:00
|
|
|
|
2016-07-11 17:21:57 +00:00
|
|
|
grunt.registerTask( "lint", [
|
|
|
|
"jsonlint",
|
|
|
|
runIfNewNode( "eslint:all" )
|
|
|
|
] );
|
|
|
|
|
|
|
|
grunt.registerTask( "test_fast", [ runIfNewNode( "node_smoke_tests" ) ] );
|
2014-09-11 20:18:34 +00:00
|
|
|
|
2015-08-03 18:28:37 +00:00
|
|
|
grunt.registerTask( "test", [ "test_fast" ].concat(
|
2016-07-11 17:21:57 +00:00
|
|
|
[ runIfNewNode( "promises_aplus_tests" ) ]
|
2015-08-03 18:28:37 +00:00
|
|
|
) );
|
2014-12-30 02:07:03 +00:00
|
|
|
|
|
|
|
// Short list as a high frequency watch task
|
2016-05-10 09:06:37 +00:00
|
|
|
grunt.registerTask( "dev", [
|
|
|
|
"build:*:*",
|
2016-07-11 17:21:57 +00:00
|
|
|
runIfNewNode( "newer:eslint:dev" ),
|
2016-05-10 09:06:37 +00:00
|
|
|
"uglify",
|
|
|
|
"remove_map_comment",
|
|
|
|
"dist:*"
|
|
|
|
]
|
|
|
|
);
|
2014-09-11 20:18:34 +00:00
|
|
|
|
2016-07-11 17:21:57 +00:00
|
|
|
grunt.registerTask( "default", [
|
|
|
|
"dev",
|
|
|
|
runIfNewNode( "eslint:dist" ),
|
|
|
|
"test_fast",
|
|
|
|
"compare_size"
|
|
|
|
] );
|
|
|
|
|
|
|
|
grunt.registerTask( "precommit_lint", [
|
|
|
|
"newer:jsonlint",
|
|
|
|
runIfNewNode( "newer:eslint:all" )
|
|
|
|
] );
|
2012-04-18 20:07:35 +00:00
|
|
|
};
|