Np: Semver prerelease format is invalid

Created on 5 Dec 2016  路  2Comments  路  Source: sindresorhus/np

Don't want to be that guy, but how close to the semver.org spec are you attempting to be (if at all)? I _believe_ that pre-release versions shouldn't start with a leading 0:

Numeric identifiers MUST NOT include leading zeroes.

_From item 9_

To my understanding, versions like 3.0.0-0 would then be invalid (as in your example in the readme).

I came across this while testing np versions with a semver constraint that I wrote. There's an interesting discussion on this here: https://github.com/mojombo/semver/issues/181#issuecomment-153457226

This is most certainly pedantic, but I'd love to hear your stance on the matter (or if I'm completely wrong) 馃檪.

Most helpful comment

semver.org does include 1.0.0-0.3.7 in its pre-release examples, so I believe they are taking "leading zeros" to mean 1.0.0-00.3.7 would be invalid but an actual zero version is ok. The doc is fuzzy though.

I think it would conform more closely to the _spirit_ of the the spec to use/add named pre-releases rather than just numbers:

3.0.0-alpha.0
3.0.0-beta.0
3.0.0-rc.0

While 3.0.0-0 seems technically valid it's unavoidably ambiguous. When people use that format I often suspect they should really be using the build metadata format of 3.0.0+0 (but without knowing the background of every project you never really know :)).

All 2 comments

I'm all for staying true to semver, but node-semver seems to consider 3.0.0-0 as valid: https://runkit.com/sindresorhus/semver-example Maybe try discussing it there first? Happy to adapt to whatever the outcome of that discussion results in.

semver.org does include 1.0.0-0.3.7 in its pre-release examples, so I believe they are taking "leading zeros" to mean 1.0.0-00.3.7 would be invalid but an actual zero version is ok. The doc is fuzzy though.

I think it would conform more closely to the _spirit_ of the the spec to use/add named pre-releases rather than just numbers:

3.0.0-alpha.0
3.0.0-beta.0
3.0.0-rc.0

While 3.0.0-0 seems technically valid it's unavoidably ambiguous. When people use that format I often suspect they should really be using the build metadata format of 3.0.0+0 (but without knowing the background of every project you never really know :)).

Was this page helpful?
0 / 5 - 0 ratings