From a9f59462941e33f5a7b3d2c14969236375bcc6d2 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Thu, 14 Nov 2013 10:17:18 -0500 Subject: [PATCH] Use grunt and bower packages as local dependencies. Close gh-1433. --- .gitignore | 2 +- .jshintignore | 2 +- .travis.yml | 2 -- Gruntfile.js | 12 ++++++++++++ README.md | 38 ++++++++++++++++++-------------------- bower.json | 12 ++++++++++++ build/bower-install.js | 13 ------------- build/tasks/build.js | 2 +- package.json | 8 +++++++- test/data/testinit.js | 4 +++- test/index.html | 6 +++--- test/jquery.js | 2 +- 12 files changed, 59 insertions(+), 44 deletions(-) delete mode 100644 build/bower-install.js diff --git a/.gitignore b/.gitignore index ca249a988..35b0b4e56 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,5 @@ dist dist/.destination.json dist/.sizecache.json build/.sizecache.json +bower_modules node_modules -bower_components \ No newline at end of file diff --git a/.jshintignore b/.jshintignore index e520461f7..2df0a13dc 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,7 +1,7 @@ src/intro.js src/outro.js -test/qunit/** test/data/jquery-1.9.1.js +bower_modules test/data/badcall.js test/data/badjson.js test/data/json_obj.js diff --git a/.travis.yml b/.travis.yml index b16e41db3..35048b6bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ language: node_js node_js: - '0.10' -before_install: -- npm install grunt-cli bower -g diff --git a/Gruntfile.js b/Gruntfile.js index a4b94187a..84aa02c89 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,6 +10,7 @@ module.exports = function( grunt ) { } var gzip = require( "gzip-js" ), + path = require( "path" ), srcHintOptions = readOptionalJSON( "src/.jshintrc" ); // The concatenated file won't pass onevar @@ -44,6 +45,17 @@ module.exports = function( grunt ) { } } }, + bower: { + install: { + options: { + targetDir: "bower_modules", + cleanup: true, + layout: function( type ) { + return path.join( type ); + } + } + } + }, jsonlint: { pkg: { src: [ "package.json" ] diff --git a/README.md b/README.md index 8bbcef3d1..475ce6fc6 100644 --- a/README.md +++ b/README.md @@ -29,39 +29,37 @@ if you swing that way. Easy-peasy. How to build your own jQuery ---------------------------- -First, clone a copy of the main jQuery git repo by running: +Clone a copy of the main jQuery git repo by running: ```bash git clone git://github.com/jquery/jquery.git ``` -Install the [grunt-cli](http://gruntjs.com/getting-started#installing-the-cli) and [bower](http://bower.io/) packages if you haven't before. These should be done as global installs: - +Enter the jquery directory and run the build script: ```bash -npm install -g grunt-cli bower +cd jquery && npm run-script build ``` +The built version of jQuery will be put in the `dist/` subdirectory, along with the minified copy and associated map file. -Make sure you have `grunt` and `bower` installed by testing: +If you want create custom build or help with jQuery development, it would be better to install grunt command line interface as a global package: -```bash -grunt -version -bower -version ``` - -Enter the jquery directory and install the Node and Bower dependencies, this time *without* specifying a global(-g) install: - -```bash -cd jquery && npm install +npm install -g grunt-cli +``` +Make sure you have `grunt` installed by testing: +``` +grunt -v ``` -Then, to get a complete, minified (w/ Uglify.js), linted (w/ JSHint) version of jQuery, type the following: - -```bash +Now by running `grunt` command, in the jquery directory, you could build full version of jQuery, just like with `npm run-script build` command: +``` grunt ``` -The built version of jQuery will be put in the `dist/` subdirectory, along with the minified copy and associated map file. - +There are many other tasks avaliable for jQuery Core: +``` +grunt -help +``` ### Modules @@ -135,10 +133,10 @@ Running the Unit Tests Make sure you have the necessary dependencies: ```bash -bower install +npm install ``` -Start `grunt watch` to auto-build jQuery as you work: +Start `grunt watch` or `npm start` to auto-build jQuery as you work: ```bash cd jquery && grunt watch diff --git a/bower.json b/bower.json index 7efb07d32..cf2aeaa2d 100644 --- a/bower.json +++ b/bower.json @@ -19,6 +19,18 @@ "requirejs": "~2.1.8", "qunit": "~1.12.0" }, + "exportsOverride": { + "sizzle": { + "sizzle": "." + }, + + "requirejs": { + "requirejs": "require.js" + }, + "qunit": { + "qunit": "qunit" + } + }, "keywords": [ "jquery", "javascript", diff --git a/build/bower-install.js b/build/bower-install.js deleted file mode 100644 index 6114c4975..000000000 --- a/build/bower-install.js +++ /dev/null @@ -1,13 +0,0 @@ -var which = require( "which" ), - spawn = require( "child_process" ).spawn; - -try { - which.sync( "bower" ); -} catch( error ) { - console.error( "Bower must be installed to build jQuery." ); - console.error( "Please install Bower by running the following command:" ); - console.error( "npm install -g bower" ); - process.exit( 0 ); -} - -spawn( "bower", [ "install" ], { stdio: "inherit" } ); diff --git a/build/tasks/build.js b/build/tasks/build.js index 246d02400..cee296f96 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -26,7 +26,7 @@ module.exports = function( grunt ) { endFile: "src/outro.js" }, paths: { - sizzle: "../bower_components/sizzle/dist/sizzle" + sizzle: "../bower_modules/sizzle/dist/sizzle" }, rawText: {}, onBuildWrite: convert diff --git a/package.json b/package.json index 9a3a25fdb..4e627811e 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,8 @@ "devDependencies": { "archiver": "~0.4.10", "grunt": "~0.4.1", + "grunt-bower-task": "~0.3.2", + "grunt-cli": "~0.1.11", "grunt-compare-size": "~0.4.0", "grunt-contrib-jshint": "~0.7.0", "grunt-contrib-uglify": "~0.2.7", @@ -45,7 +47,11 @@ "which": "~1.0.5" }, "scripts": { - "install": "node build/bower-install", + "build": "npm install && grunt", + + "install": "grunt bower", + + "start": "grunt watch", "test": "grunt" } } diff --git a/test/data/testinit.js b/test/data/testinit.js index d4b2abc16..3d4b723af 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -297,8 +297,10 @@ this.loadTests = function() { if ( dep ) { require( [ dep ], loadDep ); } else { + + // Subproject tests must be last because they replace our test fixture - testSubproject( "Sizzle", "../bower_components/sizzle/test/", /^unit\/.*\.js$/, function() { + testSubproject( "Sizzle", "../bower_modules/sizzle/test/", /^unit\/.*\.js$/, function() { // Call load to build module filter select element QUnit.load(); diff --git a/test/index.html b/test/index.html index c7bb6c42a..deb88790f 100644 --- a/test/index.html +++ b/test/index.html @@ -4,7 +4,7 @@ jQuery Test Suite - + @@ -14,8 +14,8 @@ --> - - + + diff --git a/test/jquery.js b/test/jquery.js index e94f55fe8..9b7b96a1e 100644 --- a/test/jquery.js +++ b/test/jquery.js @@ -32,7 +32,7 @@ require.config({ baseUrl: path, paths: { - sizzle: path + "bower_components/sizzle/dist/sizzle" + sizzle: path + "bower_modules/sizzle/dist/sizzle" } }); src = "src/jquery"; -- 2.39.5