GithubHelp home page GithubHelp logo

Comments (20)

KotlinIsland avatar KotlinIsland commented on July 17, 2024 1

@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.

IanVS avatar IanVS commented on July 17, 2024 1

Ok thanks, I opened https://github.com/npm/feedback/discussions/995.

from node-semver.

KotlinIsland avatar KotlinIsland commented on July 17, 2024 1

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.

mbtools avatar mbtools commented on July 17, 2024

It works now...

image

When you tested it, there was no stable version >=5.2.0-beta. Now there's 5.2.2 (latest) available.

image

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.

ljharb avatar ljharb commented on July 17, 2024

@KotlinIsland ^5 || ^5.0.0-0?

from node-semver.

KotlinIsland avatar KotlinIsland commented on July 17, 2024

^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.

ljharb avatar ljharb commented on July 17, 2024

@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.

mbtools avatar mbtools commented on July 17, 2024

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.

DetachHead avatar DetachHead commented on July 17, 2024

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.

mbtools avatar mbtools commented on July 17, 2024

@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.

DetachHead avatar DetachHead commented on July 17, 2024

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.

ljharb avatar ljharb commented on July 17, 2024

npm’s does not support it; prereleases aren’t meant to be used in that way.

from node-semver.

DetachHead avatar DetachHead commented on July 17, 2024

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.

ljharb avatar ljharb commented on July 17, 2024

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.

DetachHead avatar DetachHead commented on July 17, 2024

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.

ljharb avatar ljharb commented on July 17, 2024

Then you’d use overrides for your testing.

from node-semver.

IanVS avatar IanVS commented on July 17, 2024

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.

ljharb avatar ljharb commented on July 17, 2024

There isn't one; you'd need to file an npm support ticket.

from node-semver.

mbtools avatar mbtools commented on July 17, 2024

close this?

from node-semver.

KotlinIsland avatar KotlinIsland commented on July 17, 2024

erm, that discussion is completely different to this issue...

from node-semver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.