cheatsheets/semver.md

96 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2014-07-15 07:56:24 +00:00
---
title: Semver
2020-07-04 13:33:09 +00:00
updated: 2019-12-31
2017-08-29 17:44:38 +00:00
weight: -3
2014-07-15 07:56:24 +00:00
---
2017-08-29 17:44:38 +00:00
### Semver
2014-07-15 07:56:24 +00:00
Given a version number `MAJOR.MINOR.PATCH`:
2017-08-29 17:44:38 +00:00
{: .-setup}
2014-07-15 07:56:24 +00:00
2017-08-29 17:44:38 +00:00
| `MAJOR` | incompatible API changes |
| `MINOR` | add functionality (backwards-compatible) |
| `PATCH` | bug fixes (backwards-compatible) |
2014-07-15 07:56:24 +00:00
### Simple ranges
1.2.3
=1.2.3
>1.2.3
<1.2.3
>=1.2.3
Note that suffixed versions (`1.2.3-rc1`) are not matched.
### Ranges
2017-08-29 17:44:38 +00:00
| Range | Description | Notes |
| --- | --- | --- |
| `~1.2.3` | is `>=1.2.3 <1.3.0` | |
| --- | --- | --- |
| `^1.2.3` | is `>=1.2.3 <2.0.0` | |
| `^0.2.3` | is `>=0.2.3 <0.3.0` | (0.x.x is special) |
| `^0.0.1` | is `=0.0.1` | (0.0.x is special) |
| --- | --- | --- |
| `^1.2` | is `>=1.2.0 <2.0.0` | (like ^1.2.0) |
| `~1.2` | is `>=1.2.0 <1.3.0` | (like ~1.2.0) |
| --- | --- | --- |
| `^1` | is `>=1.0.0 <2.0.0` | |
| `~1` | same | |
| `1.x` | same | |
| `1.*` | same | |
| `1` | same | |
| --- | --- | --- |
| `*` | any version | |
| `x` | same | |
{: .-shortcuts}
2014-07-15 07:56:24 +00:00
### Hyphenated ranges
| Range | Description |
| --- | --- |
| `1.2.3 - 2.3.4` | is `>=1.2.3 <=2.3.4` |
#### Partial right
| Range | Description |
| --- | --- |
| `1.2.3 - 2.3` | is `>=1.2.3 <2.4.0` |
| `1.2.3 - 2` | is `>=1.2.3 <3.0.0` |
#### Partial left
| Range | Description |
| --- | --- |
| `1.2 - 2.3.0` | is `1.2.0 - 2.3.0` |
When the right is partial (eg, `2.3`), missing pieces are assumed to be `x` (eg, `2.3.x`).
When the left is partial (eg, `1.2`), missing pieces are assumed to be `0` (eg, `1.2.0`).
### Combining ranges
| Range | Description |
| --- | --- |
| `>=0.14 <16` | And (space-separated) |
| `0.14.x || 15.x.x` | Or (pipe-separated) |
2014-07-15 07:56:24 +00:00
### Pre-releases
1.2.3-prerelease+build
### Explanation
2017-08-29 17:44:38 +00:00
| `^` | means "compatible with" |
| `~` | means "reasonably close to" |
| `0.x.x` | is for "initial development" |
| `1.x.x` | means public API is defined |
{: .-shortcuts}
2014-07-15 07:56:24 +00:00
2017-08-29 17:44:38 +00:00
## References
{: .-one-column}
2014-07-15 07:56:24 +00:00
* <https://semver.org/>
* <https://docs.npmjs.com/misc/semver>