Which version is bigger, 1.0.0-alpha.1 or 1.0.0-beta? Does the release time affect the version number size? If you already know the answer, you don’t have to read any further. Read this article to learn about the NPM version number specification, how version number sizes compare, and the relationship between tags and version numbers.
Introduction to the
The NPM version number follows the Semver specification. The version number is in major.minor.patch format. Major, minor, and patch must start with non-0 and be non-negative.
For example, 1.0.3, 0.2.98 are valid version numbers, while 0.1.02, 1.a.0 are invalid version numbers. In addition, the version number can come with pre-release and build metadata.
An extension of the version number
pre-release
Patch is followed by “-” and a string of identifiers connected by “.”. The format is major.minor.patch-{identifier}.{identifier}.{identifier}.
Identifier must be a non-empty string of numbers, upper – and lower-case letters, or hyphens. Such as: 1.0.3 – alpha. 1
build metadata
Patch or pre-release is followed by a “+” and a string of identifiers linked by a “.” The format is major.minor.patch+{identifier}.{identifier}.{identifier} or Major, minor patch {pre – release} + {identifier}. {identifier}. {identifier}. For example: 1.0.3-alpha.1+001, 1.0.0-beta+exp. Sha.5114f85
Version number label
Common version tags are Latest (default), alpha, beta, Next, RC, experimental.
There are two ways to label a version number. One is to specify a tag at publish time, such as NPM publish –tag alpha. Another option is to run the NPM dist-tag add [email protected] alpha command after publishing.
Version number size comparison
major.minor.patch-[pre-release]+[build-metadata]
The version number size comparison is from left to right to compare major, minor, Patch, and pre-release. Build-metadata has no impact on the priority. Pre-releases have a lower priority than official releases, such as 1.0.1-alpha.1 < 1.0.1, 1.0.0-alpha.1 < 1.0.0-beta < 1.0.0
Is there a relationship between version size and release time? The answer is no.
For example, release 1.0.0-alpha.1, 1.0.0-alpha.3, 1.0.0-alpha. The user installed 1.0.0-alpha.1, when the upgrade version installed 1.0.0-alpha.3.
What is the relationship between version updates and labels? Executing NPM install package or NPM update package is equivalent to executing NPM install package@latest or NPM update package@latest. If the current version of a user is earlier than the latest label, the latest label will be installed during the upgrade. If the current version of a user is later than latest but later than another label, the latest label will be installed.
Such as:
- The user installed 1.0.0-alpha.1(alpha), when 1.0.0(latest) is released, the user upgrades to 1.0.0(latest).
- The user installed 1.0.0-alpha.1(alpha) and released 1.0.0-beta.0(beta). The user upgraded 1.0.0-beta.0(beta).
- 2.0.0-alpha.1(alpha) will be released when the user installs 1.0.0(latest). The updated version will still be 1.0.0(latest).
The version number is recommended
First stable version 1.0.0, and prior to the first stable version 0.*.*.
During the version upgrade, upgrade patch to fix bugs, for example, 1.0.2 -> 1.0.3. If you’re adding a new backwards-compatible feature, upgrade Minor, such as 1.0.2 -> 1.1.2. If you are adding a new feature that is not backward compatible, upgrade major, such as 1.9.9 -> 2.0.0.
test
Whether the following version numbers are valid
– x – y – z – 1.0.1. –
1.0.3 – -….
1.0.3 –
1.0.3–.
Version number size comparison
1.0.3 -. -. – and 1.0.3 –
1.0.0 – alpha + 001 and 1.0.0 – alpha + 002
1.0.0 – alpha. 1 with 1.0.0 – beta. 1
The answer
Install semver tool and test it
link
Semver specification
Semver tool manual