Skip to content

Commit 3c4ba2a

Browse files
committed
Switch to uber/npm-shrinkwrap for npm-shrinkwrap.json generation
Instead of our homegrown grunt/shrinkwrap.js Fixes twbs#13483. New npm-shrinkwrap.json is human-readable but still in a consistent/stable format. Should aid debugging, produce better diffs, and be less prone to merge conflicts
1 parent d37b0ff commit 3c4ba2a

File tree

8 files changed

+3607
-53
lines changed

8 files changed

+3607
-53
lines changed

Gruntfile.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ module.exports = function (grunt) {
1717

1818
var fs = require('fs');
1919
var path = require('path');
20+
var npmShrinkwrap = require('npm-shrinkwrap');
2021
var generateGlyphiconsData = require('./grunt/bs-glyphicons-data-generator.js');
2122
var BsLessdocParser = require('./grunt/bs-lessdoc-parser.js');
2223
var generateRawFiles = require('./grunt/bs-raw-files-generator.js');
23-
var updateShrinkwrap = require('./grunt/shrinkwrap.js');
2424

2525
// Project configuration.
2626
grunt.initConfig({
@@ -387,9 +387,6 @@ module.exports = function (grunt) {
387387
exec: {
388388
npmUpdate: {
389389
command: 'npm update'
390-
},
391-
npmShrinkWrap: {
392-
command: 'npm shrinkwrap --dev'
393390
}
394391
}
395392
});
@@ -463,7 +460,19 @@ module.exports = function (grunt) {
463460
generateRawFiles(grunt, banner);
464461
});
465462

466-
// Task for updating the npm packages used by the Travis build.
467-
grunt.registerTask('update-shrinkwrap', ['exec:npmUpdate', 'exec:npmShrinkWrap', '_update-shrinkwrap']);
468-
grunt.registerTask('_update-shrinkwrap', function () { updateShrinkwrap.call(this, grunt); });
463+
// Task for updating the cached npm packages used by the Travis build (which are controlled by test-infra/npm-shrinkwrap.json).
464+
// This task should be run and the updated file should be committed whenever Bootstrap's dependencies change.
465+
grunt.registerTask('update-shrinkwrap', ['exec:npmUpdate', '_update-shrinkwrap']);
466+
grunt.registerTask('_update-shrinkwrap', function () {
467+
var done = this.async();
468+
npmShrinkwrap({ dev: true, dirname: __dirname }, function (err) {
469+
if (err) {
470+
grunt.fail.warn(err)
471+
}
472+
var dest = 'test-infra/npm-shrinkwrap.json';
473+
fs.renameSync('npm-shrinkwrap.json', dest);
474+
grunt.log.writeln('File ' + dest.cyan + ' updated.');
475+
done();
476+
});
477+
});
469478
};

grunt/shrinkwrap.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
},
3232
"devDependencies": {
3333
"btoa": "~1.1.2",
34-
"canonical-json": "~0.0.4",
3534
"glob": "~4.0.2",
3635
"grunt": "~0.4.5",
3736
"grunt-autoprefixer": "~0.7.5",
@@ -57,6 +56,7 @@
5756
"grunt-sed": "~0.1.1",
5857
"load-grunt-tasks": "~0.5.0",
5958
"markdown": "~0.5.0",
59+
"npm-shrinkwrap": "~3.1.3",
6060
"time-grunt": "~0.3.2"
6161
},
6262
"engines": {

test-infra/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Similar to git, `s3_cache.py` makes the assumption that [SHA-256 will effectivel
1515
### For Bootstrap specifically
1616
`s3_cache.py` is used to cache the npm packages that our Grunt tasks depend on and the RubyGems that Jekyll depends on. (Jekyll is needed to compile our docs to HTML so that we can run them thru an HTML5 validator.)
1717

18-
For npm, the `node_modules` directory is cached based on our `npm-shrinkwrap.canonical.json` file.
18+
For npm, the `node_modules` directory is cached based on our `npm-shrinkwrap.json` file.
1919

2020
For RubyGems, the `gemdir` of the current RVM-selected Ruby is cached based on the `pseudo_Gemfile.lock` file generated by our Travis build script.
2121
`pseudo_Gemfile.lock` contains the versions of Ruby and Jekyll that we're using (read our `.travis.yml` for details).

test-infra/S3Cachefile.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"npm-modules": {
3-
"key": "./npm-shrinkwrap.canonical.json",
3+
"key": "./npm-shrinkwrap.json",
44
"cache": "../node_modules",
55
"generate": "./uncached-npm-install.sh"
66
},

test-infra/npm-shrinkwrap.canonical.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)