-
Notifications
You must be signed in to change notification settings - Fork 509
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
v4 #99
Conversation
Made it so that updates didn't break the linting (ie, split up the "lint" commit and squashed against the commits that added the lint failures). |
One important change (worth reading in full):
|
Possible doc clarification? What do you think? diff --git a/README.md b/README.md
index 145132e..93068b8 100644
--- a/README.md
+++ b/README.md
@@ -58,11 +58,12 @@ For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`.
-Comparators can be joined in a range by whitespace to indicate
-**intersection**, or by a double-pipe `||` to indicate **union**.
+Comparators can be joined by whitespace to form a `comparator set`,
+which is satisfied by the **intersection** of all of the comparators
+it includes.
-A range is composed of one or more `comparator sets`, joined by `||`.
-A version matches a range if and only if every comparator in at least
+A range is composed of one or more comparator sets, joined by `||`. A
+version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions |
The purpose for this behavior is twofold. First, prerelease versions | ||
frequently are updated very quickly, and contain many breaking changes | ||
that are (by the author's design) not yet fit for public consumption. | ||
Therefor, by default, they are excluded from range matching semantics. |
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.
'Therefor' → 'Therefore'
I like it! But I would! 🔬 |
Most languages that use tuples use |
I'd like to see an example of a prerelease tag for the tilde operator as well as the caret operator in the README. |
@timoxley @rvagg @domenic @terinjokes @Raynos feedback? |
* `1` := `1.x.x` := `>=1.0.0 <2.0.0` | ||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0` | ||
|
||
#### Tilde Ranges `~1.2.3` `~1.2` `~1` |
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.
This could do with an example including 0.x.y
just to be absolutely clear that the behaviour <1 there is the same as >1, important since ^
is so quirky <1. Perhaps even mention that the behaviour is the same across all majors?
@rvagg Added some doc updates to address your comments. Please keep them coming! We'll probably want to squash all the documentation down before actually merging, though. |
I appreciate the fix to the pre-release behaviour here, effectively turning it in to dev releases which makes sense since they are often "beta" or "alpha". The only place where I've used them differently is in releases of readable-stream which is trying to keep (minor,patch) parity with core so pre-releases offer(ed) flexibility to add intermediate releases. However that's an odd case and that parity isn't absolutely necessary. Still far too much significance placed in <1 for /cc @DamonOehlman |
I'm actually in agreement with you there. It'd be nice if we could just ditch the "0.x is magic" entirely. The "0.x.y is not SemVer" approach in the specification is just way too hazardous, but just as a matter of observed behavior, people frequently DO make breaking changes between |
between `0.2.4` and `0.3.0` releases, which is a common practice. | ||
However, it presumes that there will *not* be breaking changes between | ||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be | ||
additive (but non-breaking), according to commonly observed practices. |
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.
+1 good doc addition. Needs some education effort around this. Probably makes sense to take a more in-depth look at <1 in the nodesource blog semver series (we have a ^
article coming out tomorrow).
What are you using instead of |
@isaacs: fair enough, I can get on board with that I think, we just need to focus on (1) education and (2) making sure package authors have the tools to deal with wayward dependency authors (underscore springs to mind) |
@othiym23 I've started to move my packages to using explicit comparator sets, largely to be explicit about <1 behavior. |
@othiym23 I'm still strongly in favour of Regarding
|
@rvagg @maxogden decides whether to pin or use ranges with dependencies based on his evaluation of packages and their authors. While I don't want to impose that level of discernment on npm users in general, after watching all the arguments about underscore (some of which have made it onto npm issues), I think that training is a much better solution than technology. In fact, that aspect of semver is purely social. |
Note: we've also made And, while node-semver v3 was indeed disruptive, it never went out as part of an "official" npm or node release, so by making node-semver v4 follow the same |
This is something worth thinking about, since peer dependencies should be deprecated / deleted so its cool to add back compat hacks to them. |
|
||
For example, the range `>1.2.3-alpha.3` would be allowed to match the | ||
version `1.2.3-alpha.7`, but it would *not* be satisfied by | ||
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater |
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.
It's not clear whether >1.2.3-alpha.3
matches 3.4.5
.
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.
Yes, it would. I'll add a bit to that effect tomorrow morning.
this change looks ok. It's a pity that <1 semantics are really messy but the community is really messy. There might be value in a best practices paragraph in the README. ## Best practices
When authoring a library it's recommended that you follow the semver specification.
Because the semver specification has a special case for version <1 it's recommended
that you start authoring modules at v1.0.0 from the start and follow the semver specification
from there on. |
There is a seperate issue we can talk about which is make The version range <1.0.0 causes a lot of complexity, bikeshedding, opinion and subtle bugs. If the |
I like this idea, but indeed, this is an issue for npm, not |
As I start to think more about the education effort involved here I come back to my concerns about maintaining three separate behaviours for For the same reason I'm strongly in disagreement with adding a new range specifier, two is more than enough and anybody with strong enough opinions can just use explicit ranges. Same goes for adding special behaviour for peerDependencies unfortunately, they are hard enough to grok as it is without overloading even more special-casing. @othiym23 perhaps you could add a |
Re "Best practices" npm init already has been defaulting to 1.0.0 for some time now, and we've seen a significant (but still slow) growth in 1.x publishes. Not sure if that's just normal growth, or an effect of init, but we'll see. |
I'm in agreement with @rvagg that special-casing peerDeps (more) is a pretty bad idea. They should be reduced in their relevance to a mere warning, but that's an issue for a different repo ;) |
For those following this issue, we're going to land this PR and publish it as |
Simplify range expansions to remove -0 everywhere. Only allow -prerelease versions that have a -prerelease tag on a version in the range with the same exact X.Y.Z tuple.
Document partial versions in hyphen ranges (Fix #76)
Squashed all the documentation into a single commit, and organized a few other things in the history. |
Published version 4.0.0 to npm as So, we can ship this in a npm 2 beta, and get some proper play-testing with the new semantics. If there's any more significant breaking changes necessary, we probably won't run out of integers, like @othiym23 said :) |
|
^
behavior to SemVer 2.x.