Skip to content

Commit

Permalink
Manage bower dependencies with grunt-bowercopy
Browse files Browse the repository at this point in the history
Tracked bower dependencies are located at "src/sizzle" and "test/libs".
The source-destination mapping is in the Gruntfile.

When updating a bower dependency, update the version in bower.json, run
`grunt bower`, and then commit the result. When adding a dependency,
update the bowercopy task accordingly.

Fixes #14615.
Closes jquerygh-1452.
  • Loading branch information
timmywil committed Dec 6, 2013
1 parent ed20e7c commit f9ad13c
Show file tree
Hide file tree
Showing 26 changed files with 18,307 additions and 54 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
dist
/dist
.project
.settings
*~
*.diff
*.patch
/*.html
.DS_Store
.bower.json
.sizecache.json
dist/.destination.json
dist/.sizecache.json
build/.sizecache.json
bower_components
bower_modules
node_modules
2 changes: 1 addition & 1 deletion .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"disallowKeywordsOnNewLine": [ "else" ],
"requireLineFeedAtFileEnd": true,

"excludeFiles": [ "src/intro.js", "src/outro.js" ]
"excludeFiles": [ "src/intro.js", "src/outro.js", "src/sizzle/**/*" ]
}
3 changes: 2 additions & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
src/intro.js
src/outro.js
src/sizzle/**/*
test/libs/**/*
test/data/jquery-1.9.1.js
bower_modules
test/data/badcall.js
test/data/badjson.js
test/data/json_obj.js
Expand Down
27 changes: 19 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = function( grunt ) {
}

var gzip = require( "gzip-js" ),
path = require( "path" ),
srcHintOptions = readOptionalJSON( "src/.jshintrc" );

// The concatenated file won't pass onevar
Expand Down Expand Up @@ -47,14 +46,23 @@ module.exports = function( grunt ) {
}
}
},
bower: {
install: {
bowercopy: {
options: {
clean: true
},
src: {
files: {
"src/sizzle": "sizzle"
}
},
tests: {
options: {
targetDir: "bower_modules",
cleanup: true,
layout: function( type ) {
return path.join( type );
}
destPrefix: "test/libs"
},
files: {
"qunit": "qunit/qunit",
"require.js": "requirejs/require.js",
"sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js"
}
}
},
Expand Down Expand Up @@ -139,6 +147,9 @@ module.exports = function( grunt ) {
// Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" );

// Alias bower to bowercopy
grunt.registerTask( "bower", "bowercopy" );

// Short list as a high frequency watch task
grunt.registerTask( "dev", [ "build:*:*", "jshint", "jscs" ] );

Expand Down
15 changes: 0 additions & 15 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@
"qunit": "~1.12.0",
"sinon": "~1.7.3"
},
"exportsOverride": {
"sizzle": {
"sizzle": "."
},

"requirejs": {
"requirejs": "require.js"
},
"qunit": {
"qunit": "qunit"
},
"sinon": {
"sinon": "**/*.js"
}
},
"keywords": [
"jquery",
"javascript",
Expand Down
17 changes: 3 additions & 14 deletions build/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ var releaseVersion,
pkg,
branch,

sizzleLoc = "bower_modules/sizzle",

scpURL = "[email protected]:/var/www/html/code.jquery.com/",
cdnURL = "http://code.origin.jquery.com/",
repoURL = "[email protected]:jquery/jquery.git",
Expand Down Expand Up @@ -103,9 +101,6 @@ function initialize( next ) {
if ( !exists( "package.json" ) ) {
die( "No package.json in this directory" );
}
if ( !exists( sizzleLoc ) ) {
die( "Sizzle expected to exist at " + sizzleLoc );
}
pkg = readJSON( "package.json" );

console.log( "Current version is " + pkg.version + "; generating release " + releaseVersion );
Expand Down Expand Up @@ -309,15 +304,9 @@ function commitDistFiles( next ) {
// Add files to be committed
git( [ "add", "package.json" ], function() {
git( [ "commit", "-m", "Remove scripts property from package.json" ], function() {
// Add sizzle in a separate commit to avoid a big diff
// Use force to add normally ignored files
git( [ "add", "-f", sizzleLoc ], function() {
git( [ "commit", "-m", "Add sizzle" ], function() {
// Add jquery files for distribution in a final commit
git( [ "add", "-f", devFile, minFile, mapFile ], function() {
git( [ "commit", "-m", releaseVersion ], next, debug );
}, debug );
}, debug );
// Add jquery files for distribution in a final commit
git( [ "add", "-f", devFile, minFile, mapFile ], function() {
git( [ "commit", "-m", releaseVersion ], next, debug );
}, debug );
}, debug );
}, debug );
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function( grunt ) {
endFile: "src/outro.js"
},
paths: {
sizzle: "../bower_modules/sizzle/dist/sizzle"
sizzle: "sizzle/dist/sizzle"
},
rawText: {},
onBuildWrite: convert
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"devDependencies": {
"archiver": "~0.4.10",
"grunt": "~0.4.1",
"grunt-bower-task": "~0.3.2",
"grunt-bowercopy": "~0.4.1",
"grunt-cli": "~0.1.11",
"grunt-compare-size": "~0.4.0",
"grunt-contrib-jshint": "~0.7.0",
Expand All @@ -48,9 +48,6 @@
},
"scripts": {
"build": "npm install && grunt",

"install": "grunt bower",

"start": "grunt watch",
"test": "grunt"
}
Expand Down
Loading

0 comments on commit f9ad13c

Please sign in to comment.