-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
feat(config): add in-range #3397
Conversation
This adds a flag for `npm outdated` to use to limit output either to packages that have updates in-range of the current package's requirements, or those that have no updates in-range of the current package's requirements. It also adds to the normal (i.e. non JSON or parseable) output directing folks to use `npm explain` for more info. This is because the output of `npm outdated` is misleading, sometimes saying an available version is present when there is another package in the tree responsible for keeping the version where it is.
35a35db
to
fa92cb2
Compare
lib/outdated.js
Outdated
const include = | ||
this.npm.config.get('in-range') === null || | ||
(this.npm.config.get('in-range') === true && wanted === latest) || | ||
(this.npm.config.get('in-range') === false && wanted !== latest) |
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.
So, iiuc, "in-range" means "only show where wanted is latest". My expectation was that it would be "only show where the wanted version is within my dep range". Maybe I'm misreading this?
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.
So, like, if the current is 1.0.0
, wanted is 1.0.1
, but latest is 2.0.0
, I'd expect npm outdated --in-range
to show that.
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.
Actually, in that case, I'd also expect it to show up for npm outdated --no-in-range
, because there's an out-of-range version I could install.
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 wanted a way to filter between the red and the yellow outputs in pretty print.
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.
Ultimately "what could I fix with npm update
and what would need a package.json change?"
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.
My expectation was that it would be "only show where the wanted version is within my dep range
YES this is the intent. "What could I fix with npm update
"
Also related: this is what I assume is being communicated by the red and yellow output colors here.
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.
LGTM 👍
@ruyadorno I think I'm actually gonna close this, or move it back to draft cause the discussion seems to be warranted here about what problem(s) we're actually solving. |
When running `npm outdated` setting `--in-range` will limit output to only | ||
those packages with existing versions in range of the current project's | ||
dependencies. `--no-in-range` will limit output to only those packages with | ||
updates that are out of range of the current project's dependencies. | ||
|
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.
so with these options, how do i override NPM_CONFIG_IN_RANGE=false npm outdated
(or true)? do i have to do --in-range=null
?
Generally a boolean isn't a great choice when there's three options, so perhaps an enum would be clearer here?
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.
@ljharb see the discussion on the if statements above, it is as you say checking for the default null
vs an explicit true or false. I agree it's not ideal and that discussion is why this PR went back to draft status to be discussed and solved as part of a better solution that lets npm update --dry-run
solve the "What can be updated problem" first.
Per today's RFC call, here's my thoughts: there's really two mental models - two use cases - that i think people are using
It might be useful for the default view of |
The tracking issue for 'make reify dry run things good' is here #1999 |
Closing: we are going to queue up |
@darcyclarke Does that solve #3409, which was closed in favour of this PR? |
Yes this will fall under that same umbrella. |
This adds a flag for
npm outdated
to use to limit output either topackages that have updates in-range of the current package's
requirements, or those that have no updates in-range of the current
package's requirements.
It also adds to the normal (i.e. non JSON or parseable) output directing
folks to use
npm explain
for more info. This is because the output ofnpm outdated
is misleading, sometimes saying an available version ispresent when there is another package in the tree responsible for
keeping the version where it is.