Skip to content
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

^ should not allow prerelease versions #64

Closed
isaacs opened this issue Feb 26, 2014 · 8 comments
Closed

^ should not allow prerelease versions #64

isaacs opened this issue Feb 26, 2014 · 8 comments

Comments

@isaacs
Copy link
Contributor

isaacs commented Feb 26, 2014

Expected:

satisfies('1.2.3', '^1.2.2') // true
satisfies('1.2.3-a', '^1.2.2') // false
satisfies('1.2.3-b', '^1.2.3-a') // true
satisfies('1.2.4-a', '^1.2.3-a') // false

^x.y.z-pre should match >= prereleases on x.y.z, but not on any other version.
^x.y.z should not match any prerelease versions, period.

@isaacs
Copy link
Contributor Author

isaacs commented Feb 26, 2014

This is tricky, because the code just replaces caret ranges with >= and < ranges.

Maybe the way to do this is to add another kind of operator that says "don't allow pre-releases within a given range", but that just feels awful and hacky, even for SemVer.

@paulbdavis
Copy link

Would it be easier to test for the presence of a - in the version, and only then allow prerelease versions?

Perhaps a fixed suffix (that could apply to all operators?) would signify that prerelease versions are acceptable.

@timoxley
Copy link

^ should not allow prerelease versions by default. Same probably even goes for *.

If somebody wants prerelease they should be opting into that chain explicitly. i.e. under what scenarios would you want to automatically go from stable to prerelease?

@tomgco
Copy link

tomgco commented Mar 6, 2014

@timoxley I agree with you, pre-releases are described under semver point 9 are unstable and should not be automatically updated (Unless an opt-in operator existed, and used).

I am all for a comprehensive fix to match ^x.y.z-pre. However with the inclusion of ^ as the default npm install --save operator, I am starting to see some -pre / -rcN versions creep into our shrink-wraps. Would it be possible to expedite this bug as it could be causing version creep in production applications for many users of 0.10.26?

@isaacs
Copy link
Contributor Author

isaacs commented Mar 7, 2014

@tomgco Well, the default of ~ is the same.

$ semver -r '~1.2.3' '1.2.3-pre' '1.2.4-pre'
1.2.3-pre
1.2.4-pre

Both ~ and ^ should exclude prereleases by default.

@isaacs isaacs mentioned this issue Mar 31, 2014
@boljen
Copy link

boljen commented Jun 11, 2014

What about simply splitting the version and pre-release into two separate ranges? This would be a little more tricky to implement and less efficient but It does give back a lot more flexibility. People wouldn't want alpha-versions in production, but they might want release candidates.

An example could be a range defined like this:

x           // matches only stable versions
x-*         // matches all (pre-)release versions
x-^rc       // matches all (pre-)release versions of at least rc stability
x-beta.*    // matches only pre-release versions with beta stability

@kaelzhang
Copy link

We are heavily using prerelease versions and private registry to handle all our test processes. Will it be another major version of semver, i.e. 4.0.0 ?

mark-kubacki added a commit to mark-kubacki/semver that referenced this issue Aug 6, 2014
and reject pre-release versions. The exception is 'accept' if a bound has the
same prefix as a given version.

See also: npm/node-semver#64
kaelzhang pushed a commit to kaelzhang/node-semver-extra that referenced this issue Aug 10, 2014
@isaacs
Copy link
Contributor Author

isaacs commented Sep 9, 2014

Fixed by #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants