-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for npm-shrinkwrap.json #26
Conversation
Testing with some Real World usage right now, getting a list for cleanup... |
@mixonic 👍 Thanks, that's a lot of work. I will review and merge asap. |
@quaertym Would you also be open to another PR after this that makes creating fixture directory/file-structures on a per-test basis possible? We started pushing the limits of the fixtures when we put this together. |
We have a followup for this after ember-cli/ember-cli#3771 lands, which you review as a diff at https://github.com/201-created/ember-cli-dependency-checker/compare/add-shrinkwrap...201-created:using-node-modules-path. This patch will add support for arbitrary But we would like to land this first. |
LGTM |
@quaertym I'd like to get this and the followup to it merged this week while we have it fresh in our heads, please let me know if we need to make any changes! |
module.exports = { | ||
name: 'ember-cli-dependency-checker', | ||
|
||
included: function(app) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quaertym updated for one comment and addressed two others. |
Add support for npm-shrinkwrap.json
@mixonic Thanks 👍 |
🎆 |
}; | ||
|
||
ShrinkwrapPackage.prototype.updateRequired = function() { | ||
return this.versionSpecified !== this.versionInstalled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mixonic Do you think we should change this updateRequired
function with this https://github.com/quaertym/ember-cli-dependency-checker/blob/master/lib/package.js#L18-19?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe shrinkwrap will output a file with a range, so it seems unlikely to make a difference in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good to know.
The dependency checker is slightly naive, in that it presumes dependencies of dependencies do not require confirmation. We're only talking NPM here.
In practice, we've often run into cases where dependency X has a variable version specified, for example:
When
popup-service
releases1.0.1
, it is easy to end up with some npm installs having1.0.0
on disk and others having1.0.1
. The checker has no way to confirm what version should be installed, as that information is not stored inpackage.json
.Even worse is when
1.0.1
has a bug, but there is no way to force1.0.0
without forkingtorii
.The
npm shrinkwrap
command outputs a summary of what dependencies are currently innode_modules/
. There is no way to confirm that what you havenode_modules/
matchesnpm-shrinkwrap.json
, but removing thenode_modules/
directory and runningnpm install
will result inthe versions of
npm-shrinkwrap.json
being used.These patches add a new dependency checker to the
bower.json
andpackage.json
checkers, one that activates whennpm-shrinkwrap.json
is present and uses it to confirm the contents of thenode_modules/
directory is correct.The ideal way to work with this change is to run the
npm shrinkwrap
command and commit the resultingnpm-shinkwrap.json
command after everynpm install
of a dependency. When other developers (or a build box) pull down the changes theember
command will error if their nested dependencies are incorrect. The suggested resolution to failures is torm -rf node_modules/
and runnpm install
. With a blanknode_modules/
directory, npm will respect the pinned versions innpm-shrinkwrap.json
.See also the revised README.md.