Comments (20)
@mbtools So in my case, I want to support both the stable version of 5
, and the current pre-releases of 5
. How can I select that?
from node-semver.
Ok thanks, I opened https://github.com/npm/feedback/discussions/995.
from node-semver.
But it's all good, I've raised one myself https://github.com/npm/feedback/discussions/999, please upvote it so that this feature can be fixed.
from node-semver.
It works now...
When you tested it, there was no stable version >=5.2.0-beta
. Now there's 5.2.2
(latest) available.
First, the website is determining maxVersion
:
maxVersion = latest
if (!semver.satisfies(maxVersion, VersionRange)) maxVersion = null
And then uses the following for compiling the list:
(semver.satisfies(version, range) && (!maxVersion || semver.lte(version, maxVersion))
As you can see, if there exist pre-releases at the end of the version history (in your case 5.2.0-beta, 5.2.0-dev...) then "latest" (in your case 5.1.6) will not satisfy the range and the pre-releases are not included. In other words, in your case "latest" stable release was lower than the pre-releases you were looking for. Works as designed.
from node-semver.
@KotlinIsland ^5 || ^5.0.0-0
?
from node-semver.
^5 || ^5.0.0-0
@ljharb I want the current pre-releases, so 5.3
. not the pre-releases for 5.0
from node-semver.
@KotlinIsland then you have to explicitly do ^5 || ^5.3.0-0
, and you'll have to add one for each new minor (and removing the old minor would be a breaking change if this is in a peer dep). There's no way to target "the latest minor's prereleases" as a moving window.
from node-semver.
Also please don't confuse the testsite with the functions of the semver
package. They are not the same (see the additional maxVersion
logic above).
Calling satisfied
independently gives you the expected result:
const satisfies = require('../../functions/satisfies')
const versions = [
['5.0.0'],
['5.0.2'],
['5.0.3'],
['5.0.4'],
['5.1.0-beta'],
['5.1.0-dev.1'],
['5.1.0-dev.2'],
['5.1.3'],
['5.1.5'],
['5.1.6'],
['5.2.0-dev.1'],
['5.2.0-dev.2'],
]
versions.forEach(([version]) => {
if (satisfies(version, '^5 || >=5.2.0-beta')) {
console.log(version)
}
})
Output:
5.0.0
5.0.2
5.0.3
5.0.4
5.1.3
5.1.5
5.1.6
5.2.0-dev.1
5.2.0-dev.2
from node-semver.
Also please don't confuse the testsite with the functions of the semver package. They are not the same
What's the point of it then?
from node-semver.
@DetachHead I called it "test site" but it's simply an app based on this package and unrelated to any tests here. So better to ask the owners of the site why they implemented "more"
from node-semver.
I see. Where should I raise that? imo this system seems far too convoluted for simple use cases, so for the test site to behave slightly differently to the actual thing is a very big problem because it just amplifies the confusion.
All I want to do is allow any version, including prereleases, within a specified range lol, surprised that isn't possible especially when other implementations of semver support it (eg. python's poetry)
from node-semver.
npm’s does not support it; prereleases aren’t meant to be used in that way.
from node-semver.
what's the point of prereleases if they can't be used? most of the time when i try to use a pre-release version of a dependency, i can't because i have another dependency that depends on the same package but doesn't allow prereleases
from node-semver.
To test with them, primarily - not for users to use them directly.
in an ecosystem where the thing you’re testing is a prerelease, basically the only time it’s useful is for prereleases of a major. Non-majors aren’t supposed to break anything so the caution of a prerelease is rarely warranted.
from node-semver.
i don't necessarily want to enforce a pre-release version of a dependency onto users, i simply want to test a pre-release version of a dependency in my own project. however one of my other dependencies depends on the release version of that dependency, so it results in a dependency resolution conflict
from node-semver.
Then you’d use overrides for your testing.
from node-semver.
Where should I raise that?
I'm also wondering where the source / issue tracker of the semver calculator is. I noticed today that pre-releases are no longer included at all on the site, and I'm really curious why.
from node-semver.
There isn't one; you'd need to file an npm support ticket.
from node-semver.
close this?
from node-semver.
erm, that discussion is completely different to this issue...
from node-semver.
Related Issues (20)
- Vulnerabilities in semver package HOT 1
- [BUG] Inc function give incorrect version when bumping subsequent pre versions HOT 4
- me
- [ENHANCEMENT] minimum versions or minimum version in relation to HOT 12
- [BUG] BNF does not match the implementation HOT 3
- [QUESTION] Range class represents a range-set? HOT 1
- [BUG] Version without bugfix is considered invalid HOT 1
- [BUG] RC version without dash passes `validSemver` but fails on `semverCompare` HOT 4
- > ### Is there an existing issue for this?
- [BUG?] Remove redundant conditions from `Range` HOT 1
- [BUG] this.build missing from format() HOT 2
- [BUG] semver.valid does not reject multiple hyphens in pre-release section HOT 1
- [QUESTION] Inconsistent definition of version prefix HOT 3
- [BUG] limit version prefix to optional `v` HOT 4
- [BUG] Intersects returns `false` when it shouldn't HOT 2
- wild card entry specialtilde ( * ) bug HOT 1
- [BUG] `subset('>=17.2.0', '^17.2.0 || >17')` should be `true`
- [ENHANCEMENT] Publish package as standard JS modules HOT 13
- [ENHANCEMENT] Support for unicode symbols ≥ and ≤ HOT 4
- [QUESTION] Very confusing behavior for pre-release range matching HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-semver.