]> source.dussan.org Git - jquery.git/commitdiff
Initial grunt implementation
authorRick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
Wed, 18 Apr 2012 20:07:35 +0000 (16:07 -0400)
committerRick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
Wed, 18 Apr 2012 20:07:35 +0000 (16:07 -0400)
.gitignore
grunt.js [new file with mode: 0644]
package.json [new file with mode: 0644]

index b3c04725066a65df1b12b5004866d10711ba2a19..ce1cd6ecc7119b1a4ce431a463ef2dc285d87ced 100644 (file)
@@ -7,4 +7,5 @@ dist
 *.patch
 /*.html
 .DS_Store
-build/.sizecache.json
+dist/.sizecache.json
+node_modules
diff --git a/grunt.js b/grunt.js
new file mode 100644 (file)
index 0000000..759b43c
--- /dev/null
+++ b/grunt.js
@@ -0,0 +1,159 @@
+/*global config:true, task:true*/
+module.exports = function( grunt ) {
+
+       var task = grunt.task;
+       var file = grunt.file;
+       var utils = grunt.utils;
+       var log = grunt.log;
+       var verbose = grunt.verbose;
+       var fail = grunt.fail;
+       var option = grunt.option;
+       var config = grunt.config;
+       var template = grunt.template;
+
+       grunt.initConfig({
+               pkg: "<json:package.json>",
+               meta: {
+                       banner: "/*! jQuery v@<%= pkg.version %> jquery.com | jquery.org/license */"
+               },
+               compare_size: {
+                       files: [
+                               "dist/jquery.js",
+                               "dist/jquery.min.js"
+                       ]
+               },
+               selector: {
+                       "src/selector.js": [
+                               "src/sizzle-jquery.js",
+                               "src/sizzle/sizzle.js"
+                       ]
+               },
+               build: {
+                       "dist/jquery.js": [
+                               "src/intro.js",
+                               "src/core.js",
+                               "src/callbacks.js",
+                               "src/deferred.js",
+                               "src/support.js",
+                               "src/data.js",
+                               "src/queue.js",
+                               "src/attributes.js",
+                               "src/event.js",
+                               "src/selector.js",
+                               "src/traversing.js",
+                               "src/manipulation.js",
+                               "src/css.js",
+                               "src/ajax.js",
+                               "src/ajax/jsonp.js",
+                               "src/ajax/script.js",
+                               "src/ajax/xhr.js",
+                               "src/effects.js",
+                               "src/offset.js",
+                               "src/dimensions.js",
+                               "src/exports.js",
+                               "src/outro.js"
+                       ]
+               },
+               min: {
+                       "dist/jquery.min.js": [ "<banner>", "dist/jquery.js" ]
+               },
+               lint: {
+                       files: [ "grunt.js", "dist/jquery.js" ]
+               },
+               watch: {
+                       files: "<config:lint.files>",
+                       tasks: "concat lint"
+               },
+               jshint: {
+                       options: {
+                               evil: true,
+                               browser: true,
+                               wsh: true,
+                               eqnull: true,
+                               expr: true,
+                               curly: true,
+                               trailing: true,
+                               undef: true,
+                               smarttabs: true,
+                               predef: [
+                                       "define",
+                                       "DOMParser",
+                                       "WebKitPoint",
+                                       "__dirname"
+                               ],
+                               maxerr: 100
+                       },
+                       globals: {
+                               jQuery: true,
+                               global: true,
+                               module: true,
+                               exports: true,
+                               require: true,
+                               file: true,
+                               log: true,
+                               console: true
+                       }
+               },
+               uglify: {}
+       });
+
+       // Default grunt.
+       grunt.registerTask( "default", "selector build lint min compare_size" );
+
+  grunt.loadNpmTasks("grunt-compare-size");
+
+       // Build src/selector.js
+       grunt.registerMultiTask( "selector", "Build src/selector.js", function() {
+
+               var name = this.file.dest,
+                               files = this.file.src,
+                               sizzle = {
+                                       api: file.read( files[0] ),
+                                       src: file.read( files[1] )
+                               },
+                               compiled;
+
+               // sizzle-jquery.js -> sizzle after "EXPOSE", replace window.Sizzle
+               compiled = sizzle.src.replace( "window.Sizzle = Sizzle;", sizzle.api );
+               verbose.write("Injected sizzle-jquery.js into sizzle.js");
+
+               // Write concatenated source to file
+               file.write( name, compiled );
+
+               // Fail task if errors were logged.
+               if ( this.errorCount ) {
+                       return false;
+               }
+
+               // Otherwise, print a success message.
+               log.writeln( "File '" + name + "' created." );
+       });
+
+
+       // Special concat/build task to handle various jQuery build requirements
+       grunt.registerMultiTask( "build", "Concatenate source, embed date/version", function() {
+               // Concat specified files.
+               var compiled = "",
+                               name = this.file.dest;
+
+               this.file.src.forEach(function( filepath ) {
+                       compiled += file.read( filepath ).replace( /.function..jQuery...\{/g, "" ).replace( /\}...jQuery..;/g, "" );
+               });
+
+               // Embed Date
+               // Embed Version
+               compiled = compiled.replace( "@DATE", new Date() )
+                                                                       .replace( "@VERSION", config("pkg.version") );
+
+               // Write concatenated source to file
+               file.write( name, compiled );
+
+               // Fail task if errors were logged.
+               if ( this.errorCount ) {
+                       return false;
+               }
+
+               // Otherwise, print a success message.
+               log.writeln( "File '" + name + "' created." );
+       });
+};
diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..55d96b9
--- /dev/null
@@ -0,0 +1,32 @@
+{
+  "name": "jquery",
+  "title": "jQuery",
+  "description": "New Wave JavaScript",
+  "version": "1.8.0",
+  "homepage": "http://jquery.com",
+  "author": {
+    "name": "John Resig"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/jquery/jquery.git"
+  },
+  "bugs": {
+    "url": "http://bugs.jquery.com"
+  },
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": "http://jquery.com/blob/master/MIT-LICENSE.txt"
+    },
+    {
+      "type": "GPL",
+      "url": "http://jquery.com/blob/master/GPL-LICENSE.txt"
+    }
+  ],
+  "dependencies": {},
+  "devDependencies": {
+    "grunt-compare-size": ">=0.1.0"
+  },
+  "keywords": []
+}