OSDN Git Service

Regular updates
[twpd/master.git] / semver.md
1 ---
2 title: Semver
3 layout: 2017/sheet
4 updated: 2019-12-31
5 weight: -3
6 ---
7
8 ### Semver
9
10 Given a version number `MAJOR.MINOR.PATCH`:
11 {: .-setup}
12
13 | `MAJOR` | incompatible API changes                 |
14 | `MINOR` | add functionality (backwards-compatible) |
15 | `PATCH` | bug fixes (backwards-compatible)         |
16
17 ### Simple ranges
18
19       1.2.3
20      =1.2.3
21      >1.2.3
22      <1.2.3
23     >=1.2.3
24
25 Note that suffixed versions (`1.2.3-rc1`) are not matched.
26
27 ### Ranges
28
29 | Range    | Description         | Notes              |
30 | ---      | ---                 | ---                |
31 | `~1.2.3` | is `>=1.2.3 <1.3.0` |                    |
32 | ---      | ---                 | ---                |
33 | `^1.2.3` | is `>=1.2.3 <2.0.0` |                    |
34 | `^0.2.3` | is `>=0.2.3 <0.3.0` | (0.x.x is special) |
35 | `^0.0.1` | is  `=0.0.1`        | (0.0.x is special) |
36 | ---      | ---                 | ---                |
37 | `^1.2`   | is `>=1.2.0 <2.0.0` | (like ^1.2.0)      |
38 | `~1.2`   | is `>=1.2.0 <1.3.0` | (like ~1.2.0)      |
39 | ---      | ---                 | ---                |
40 | `^1`     | is `>=1.0.0 <2.0.0` |                    |
41 | `~1`     | same                |                    |
42 | `1.x`    | same                |                    |
43 | `1.*`    | same                |                    |
44 | `1`      | same                |                    |
45 | ---      | ---                 | ---                |
46 | `*`      | any version         |                    |
47 | `x`      | same                |                    |
48 {: .-shortcuts}
49
50 ### Hyphenated ranges
51
52 | Range              | Description           |
53 | ---                | ---                   |
54 | `1.2.3 - 2.3.4`    | is `>=1.2.3 <=2.3.4`  |
55
56 #### Partial right
57
58 | Range              | Description           |
59 | ---                | ---                   |
60 | `1.2.3 - 2.3`      | is `>=1.2.3 <2.4.0`   |
61 | `1.2.3 - 2`        | is `>=1.2.3 <3.0.0`   |
62
63 #### Partial left
64
65 | Range              | Description           |
66 | ---                | ---                   |
67 | `1.2 - 2.3.0`      | is `1.2.0 - 2.3.0`    |
68
69 When the right is partial (eg, `2.3`), missing pieces are assumed to be `x` (eg, `2.3.x`).
70
71 When the left is partial (eg, `1.2`), missing pieces are assumed to be `0` (eg, `1.2.0`).
72
73 ### Combining ranges
74
75 | Range              | Description           |
76 | ---                | ---                   |
77 | `>=0.14 <16`       | And (space-separated) |
78 | `0.14.x || 15.x.x` | Or (pipe-separated)   |
79
80 ### Pre-releases
81
82     1.2.3-prerelease+build
83
84 ### Explanation
85
86 | `^` | means "compatible with" |
87 | `~` | means "reasonably close to" |
88 | `0.x.x` | is for "initial development" |
89 | `1.x.x` | means public API is defined |
90 {: .-shortcuts}
91
92 ## References
93 {: .-one-column}
94
95  * <http://semver.org/>
96  * <https://docs.npmjs.com/misc/semver>