-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
Fix ^ and ~ range matches on x.y patterns #658
Conversation
👍 |
Fix ^ and ~ range matches on x.y patterns
@guybedford Why are you allowing non-legal semver ranges? The PATCH version is a required field in semver. "2. A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes. X is the major version, Y is the minor version, and Z is the patch version. Each element MUST increase numerically. For instance: 1.9.0 -> 1.10.0 -> 1.11.0." |
test('Basic compatibility', function() { | ||
// project.showLogs = true; | ||
// assert.equal(semver.match('^1.5.2', '1.4.0'), false); | ||
assert.equal(semver.match('~0', '0.1.0'), true); |
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.
~0 is not a legal semver
Hey @lookfirst You seem to be confusing versions and constraints. While http://semver.org defines the spec for versions and the relative order of versions, it says absolutely nothing about a syntax for constraints. This is a long reply to give you some background and explain the reasoning, but the TLDR is that these expressions can be used today with jspm and npm, but before this PR they would behave inconsistently. You can try all of these test cases at Essentially every package managers has invented their own grammar and syntax, and the only thing you can generalize is that they have Not only is there no single standard for ranges, the specs themselves have been moving targets. Looking at npm, the meaning of Lastly package managers need to support non-semver versions, because not all old projects switch (or users need to use old versions), people make mistakes, and others maintainers dislike semver. At the very least exact matches must be supported for non semver versions, but some package managers support ranges on these non semver values also. This sounds very glum, but npm has blazed the trail for JS, not only establishing the conventions for other tools to share, it has the possibly the most massive grammar around.. multiple wildcards, partial versions, multiple range shorthands, disjunction, etc. For another massive grammar you could compare jsemver, which formalized it (although actually that spec is out of date, it's added new prefixes). Coming back to your examples, If you wanted to split hairs then Why does jspm explicitly support Perhaps jspm's chosen subset is too limited, to turn your complaint around completely. It's certainly simpler to extend it conservatively. |
Thanks for the super long response, but that sentence above solidified it all for me. =) I wasn't thinking of it like that, so massive kudos for explaining it all. I definitely learned something today, which I really appreciate! |
No problem - was useful for me too (only read up on this to answer your challenge) 😉 |
Great explanation, I'd been confused about that myself. Thanks @crisptrutski :) |
😨