Skip to content
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

ignores dependency range #1287

Closed
3 tasks done
tcurdt opened this issue Mar 28, 2023 · 6 comments
Closed
3 tasks done

ignores dependency range #1287

tcurdt opened this issue Mar 28, 2023 · 6 comments

Comments

@tcurdt
Copy link

tcurdt commented Mar 28, 2023

  • I have searched for similar issues
  • I am using the latest version of npm-check-updates (16.3.7)
  • I am using node >= 14.14

I don't quite understand why this gets reported as available update given the dep range defined.

This seems related to #1054


Steps to Reproduce

Dependencies:

"dependencies": {
    "bootstrap": "4.6.2 <5",
}

Steps:

Current Behavior

$ npx npm-check-updates          
Checking ..../package.json
[====================] 65/65 100%

 bootstrap                      4.6.2 <5  →              ^5

Expected Behavior

$ npx npm-check-updates          
Checking ..../package.json
[====================] 65/65 100%
@raineorshine
Copy link
Owner

raineorshine commented Mar 28, 2023

The main purpose of npm-check-updates is to break existing version ranges.

npm-check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions.

Depending on your use case, you have a couple options:

  • If you would like to upgrade packages while respecting version ranges, use npm update.
  • If you would like to exclude specific packages, use ncu --reject X or add reject: 'X' to your .ncurc.

There have been requests to have npm-check-updates respect version ranges in order to allow more fine-grained control and and automation than npm update provides. While this goes beyond npm-check-updates' original purpose, I believe it is highly congruent and would be a worthy feature. This is being tracked in #1054 as you found out. It is not being worked on currently, but PR's are always welcome.

@tcurdt
Copy link
Author

tcurdt commented Mar 28, 2023

We use it a bit like a dependabot/renovate replacement.
So maybe that's a slightly different use case.

We worked around this for now.
But having proper support for ranges would be super cool.

But let's close this in favour for #1054

@tcurdt tcurdt closed this as completed Mar 28, 2023
@raineorshine
Copy link
Owner

raineorshine commented Aug 12, 2023

Initial support for --target semver added and published in v16.11.0. However, I think it will still clobber explicit version ranges.

@tcurdt What is the expected behavior, that explicit version ranges like 4.6.2 < 5 are ignored completely by ncu --target semver?

@tcurdt
Copy link
Author

tcurdt commented Aug 12, 2023

Well, the initial expectation I had was that for 4.6.2 < 5 it would not suggest updates >= 5.

But I guess a good solution could be to print some kind of indicator in the sense of "halted but new version 5.1 is available".
That could be the default behaviour which would be very close to the original behaviour.
If there is any update or warning I would expect an exit code of 1+.

And then have a cli option to turn off these kind of warnings.
If the warning gets disabled I would expect an exit code of 0 (unless there are other updates available).

That should make it pretty easy to use in CI environments.

Does that make sense?

@raineorshine
Copy link
Owner

Thanks, that's useful. It probably won't have warnings, as npm-check-updates aims for a less verbose output by default, but you will still able able to use some combination of --target semver and --errorLevel 2 to get the exit code behavior you want.

@tcurdt
Copy link
Author

tcurdt commented Aug 12, 2023

It probably won't have warnings, as npm-check-updates aims for a less verbose output by default

I meant just an short indicator of course (hence the "in the sense of") but with the other options in place that would just be the icing on the cake 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants