-
Notifications
You must be signed in to change notification settings - Fork 332
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
Option to bump existing ranges to reflect latest semver version #581
Comments
Thank you for the detailed explanation! And thank you for looking through existing issues. I marked this as an enhancement and am open to PR's As a side note, I'm somewhat unclear what benefit there is to having the number changed in the package.json when the version range gives you the control you are looking for. This likely does not change the status of this ticket, but I thought I would mention that this came up for me. |
Bumping the ranges ensures that when user updates our package, its dependencies will be upgraded to latest versions (otherwise if ranges are not updated, npm won't do deep update). Repeatedly I deal with a situation when some dependency of my project introduces accidentally a bug, and then quickly follows with a fix (note that buggy version cannot be removed from npm), then it's always recommended to bump the range so it gives no chance for buggy version to be installed. |
Does this help?
|
Not really, as it's not about how packages are being installed for maintainer of a package, but for projects that rely on it. It's impossible to enforce users of my package (and packages that depend on it), to run Also just for maintainers |
Good point! I will keep this open for the feature as requested. |
Big +1 on my part! This is my goal and I believe it should be a flag called I have a use case:
TLDR;So in conclusion I think a command |
Sounds reasonable! Just need someone willing to work on this. I'm working on other things at the moment. |
@raineorshine i can cry and make a PR for you!! 🙃 Can I request a little guidance on where you suggest me adding new code ? |
I have a few questions for clarification.
So you're looking for a flag that:
@medikoo Is this the same as what you are looking for? Is
I'm a little confused by this:
This can be accomplished with an {
"reject": ["mypackage"]
}
Upgrading |
Sorry, I was confused and thought the name of the "middle" number was "major". The current behaviour of NCU:
This updates everything to latest "minor" (the middle one) version and it's currently my most used command. This means, with these flags in
This is the reason I was a bit confused on the naming, since we need to write major but it only upgrades minor versions, or is this a bug?
I'm not 100% sure what you mean by this. But, I believe The behaviour I want with a new command:
I want it to upgrade everything as indicated in This means, with these flags in
I think saving an extra special file just for when hard coding a package version is too confusing when working with teams. If authors can just have a single script like so:
This way the source of all truth is just the package version range, and no extra files are needed that add clutter and can lead to discrepancies more easily. I feel that NCU would basically offer:
NCU is so nice, especially in monorepos. |
@raineorshine ☝️ this is exactly the behavior I had in mind with this proposal. |
It was intended to convey that it locks upgrades to the current "major" version. I can see how it could be interpreted the other way though.
Yes, aside from
This makes total sense. It's an interesting use case, as it wasn't the original intent of the library, but it is entirely coherent.
Ha. I am enjoying your hyperbolism. I think |
Sure!
Then export a Unit tests can be added with the other |
@raineorshine I'll try to see if I can get a PR working.
Just for clarity's sake.
I hope it's not just in my head, but I think we'll avoid a loot of confusion with the latter as opposed to the former. I hope you can agree with my opinion, let me know if I can get the green light on that naming scheme! |
You have a point. I would suggest one of the following two options:
Open to feedback. |
@raineorshine However, I re-read your previous comment and you mention:
and I think I kind of overlooked this: you want to also come up with alternatives for those @medikoo do you have any opinion on naming? |
Yes, I believe they should go under the same flag.
Yes! Agree |
@mesqueeb Any update? Thanks! FYI I am currently planning for the next major release consolidating |
Sounds exciting @raineorshine! I just tried v8.0.5 and could not find |
I'll try to get to it eventually, but am a bit swamped in a couple of pending releases for some projects. 😰 if it's not yet implemented in a few weeks I'll probably eventually try my hand at it. seems like a fun journey! |
@raineorshine more common approach is to keep them open with First label has also special handling on GitHub website, as GitHub naturally provides a link to those issues at top of the list. |
Thank you for the tip. I think that is a good suggestion, although I have some concerns of using those labels. I'm hesitant to label all suggested enhancements as |
@raineorshine I agree with all your points. I personally would add If some enhancement is not welcome I believe either should be closed with something as To me closing an issue, means that case is closed and not intended to be revisited. |
That's fair. I think it mostly depends on someone coming along with enough motivation. For ideas that genuinely don't have a place in
I'll make sure to mark such issues with |
Re-opening due to ongoing interest. Open to PR's for |
As of /** Custom target.
@param dependencyName The name of the dependency.
@param parsedVersion A parsed Semver object from semver-utils.
(See https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
@returns One of the valid target values (specified in the table above).
*/
target: (dependencyName, [{ semver, version, operator, major, minor, patch, release, build }]) => {
if (major === 0) return 'minor'
return 'latest'
} You can hack together your own semver-like target logic, but the intention is to eventually add a |
Hello, is that still the problem? I believe |
@pgrzesik They're a bit different. The solution will add a new |
IMHO this behavior should be the default, without providing extra arguments. |
My use-case: I want to upgrade most packages to latest major. However there are some packages that I can't upgrade to latest major without big refactoring. At first I thought I can solve it by using However a pretty big issue with this is that now I don't have a clear visibility on what packages are updated. And when my build fails I can't do the "doctor" command to figure out which update broke the build. So yeah, for these reasons +1 from me for this feature, and for now as a workaround I'll be reverting ranges after NCU by hand. |
@Maxim-Mazurok To pin a dependency version, you can add it to the Obviously this is an aside from the |
@raineorshine I understand that, however I do want to receive minor and patch updates. What I came up with at the end is to have npm script that first runs ncu --upgrade and then npm install my-dep@5 otherdep@7 etc. |
@Maxim-Mazurok Ah, I see. I'm glad you found a workaround. You can also use a custom |
#573 seems related, and #159 seems about same thing
I'm after an option that will bump existing ranges in
package.json
, so they point to the latest version (within a reflected range).Currently
ncu
does that well, only if we use^
and rely on latest major of given dependency.However if there's a package where we rely on non-latest major, it automatically updates to latest major (which I find unwanted, as any major version upgrade should rather be done manually ensuring breaking changes are handled).
Explaining on example
There's a package where:
3.2.5
2.8.5
2.4.8
Case 1
Range in is package.json is
^2.4.5
.I'd love ncu to upgrade the range to
^2.8.5
(and not^3.2.5
as it does now).Case 2
Range in is package.json is
~2.4.5
.I'd love ncu to upgrade the range to
~2.4.8
(and not^3.2.5
as it does now).In #159 it was suggested that
npm update
does that. That's not truenpm update
updates package.json only if:node_modules
So in above scenario if in
node_modules
package is already installed at2.8.5
(or is not installed at all), there's no way to forcenpm update
to update the range inpackage.json
.The text was updated successfully, but these errors were encountered: