semver 3.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +3 -3
- package/README.md +163 -46
- package/bin/semver +9 -1
- package/{foot.js → foot.js.txt} +0 -0
- package/{head.js → head.js.txt} +0 -0
- package/package.json +1 -1
- package/semver.browser.js +174 -89
- package/semver.browser.js.gz +0 -0
- package/semver.js +174 -89
- package/semver.min.js +1 -1
- package/semver.min.js.gz +0 -0
- package/test/clean.js +5 -1
- package/test/gtr.js +2 -2
- package/test/index.js +167 -102
- package/test/ltr.js +10 -4
- package/test/no-module.js +2 -2
package/Makefile
CHANGED
|
@@ -8,12 +8,12 @@ all: $(files)
|
|
|
8
8
|
clean:
|
|
9
9
|
rm -f $(files)
|
|
10
10
|
|
|
11
|
-
semver.browser.js: head.js semver.js foot.js
|
|
12
|
-
( cat head.js; \
|
|
11
|
+
semver.browser.js: head.js.txt semver.js foot.js.txt
|
|
12
|
+
( cat head.js.txt; \
|
|
13
13
|
cat semver.js | \
|
|
14
14
|
egrep -v '^ *\/\* nomin \*\/' | \
|
|
15
15
|
perl -pi -e 's/debug\([^\)]+\)//g'; \
|
|
16
|
-
cat foot.js ) > semver.browser.js
|
|
16
|
+
cat foot.js.txt ) > semver.browser.js
|
|
17
17
|
|
|
18
18
|
semver.min.js: semver.browser.js
|
|
19
19
|
uglifyjs -m <semver.browser.js >semver.min.js
|
package/README.md
CHANGED
|
@@ -41,53 +41,170 @@ A leading `"="` or `"v"` character is stripped off and ignored.
|
|
|
41
41
|
|
|
42
42
|
## Ranges
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
A `version range` is a set of `comparators` which specify versions
|
|
45
|
+
that satisfy the range.
|
|
46
|
+
|
|
47
|
+
A `comparator` is composed of an `operator` and a `version`. The set
|
|
48
|
+
of primitive `operators` is:
|
|
49
|
+
|
|
50
|
+
* `<` Less than
|
|
51
|
+
* `<=` Less than or equal to
|
|
52
|
+
* `>` Greater than
|
|
53
|
+
* `>=` Greater than or equal to
|
|
54
|
+
* `=` Equal. If no operator is specified, then equality is assumed,
|
|
55
|
+
so this operator is optional, but MAY be included.
|
|
56
|
+
|
|
57
|
+
For example, the comparator `>=1.2.7` would match the versions
|
|
58
|
+
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
|
59
|
+
or `1.1.0`.
|
|
60
|
+
|
|
61
|
+
Comparators can be joined by whitespace to form a `comparator set`,
|
|
62
|
+
which is satisfied by the **intersection** of all of the comparators
|
|
63
|
+
it includes.
|
|
64
|
+
|
|
65
|
+
A range is composed of one or more comparator sets, joined by `||`. A
|
|
66
|
+
version matches a range if and only if every comparator in at least
|
|
67
|
+
one of the `||`-separated comparator sets is satisfied by the version.
|
|
68
|
+
|
|
69
|
+
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
|
70
|
+
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
|
71
|
+
or `1.1.0`.
|
|
72
|
+
|
|
73
|
+
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
|
74
|
+
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
|
75
|
+
|
|
76
|
+
### Prerelease Tags
|
|
77
|
+
|
|
78
|
+
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
|
79
|
+
it will only be allowed to satisfy comparator sets if at least one
|
|
80
|
+
comparator with the same `[major, minor, patch]` tuple also has a
|
|
81
|
+
prerelease tag.
|
|
82
|
+
|
|
83
|
+
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
|
84
|
+
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
|
85
|
+
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
|
86
|
+
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
|
87
|
+
range only accepts prerelease tags on the `1.2.3` version. The
|
|
88
|
+
version `3.4.5` *would* satisfy the range, because it does not have a
|
|
89
|
+
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
|
90
|
+
|
|
91
|
+
The purpose for this behavior is twofold. First, prerelease versions
|
|
92
|
+
frequently are updated very quickly, and contain many breaking changes
|
|
93
|
+
that are (by the author's design) not yet fit for public consumption.
|
|
94
|
+
Therefore, by default, they are excluded from range matching
|
|
95
|
+
semantics.
|
|
96
|
+
|
|
97
|
+
Second, a user who has opted into using a prerelease version has
|
|
98
|
+
clearly indicated the intent to use *that specific* set of
|
|
99
|
+
alpha/beta/rc versions. By including a prerelease tag in the range,
|
|
100
|
+
the user is indicating that they are aware of the risk. However, it
|
|
101
|
+
is still not appropriate to assume that they have opted into taking a
|
|
102
|
+
similar risk on the *next* set of prerelease versions.
|
|
103
|
+
|
|
104
|
+
### Advanced Range Syntax
|
|
105
|
+
|
|
106
|
+
Advanced range syntax desugars to primitive comparators in
|
|
107
|
+
deterministic ways.
|
|
108
|
+
|
|
109
|
+
Advanced ranges may be combined in the same way as primitive
|
|
110
|
+
comparators using white space or `||`.
|
|
111
|
+
|
|
112
|
+
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
|
113
|
+
|
|
114
|
+
Specifies an inclusive set.
|
|
115
|
+
|
|
59
116
|
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* `1.x` := `>=1.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* `""` (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
117
|
+
|
|
118
|
+
If a partial version is provided as the first version in the inclusive
|
|
119
|
+
range, then the missing pieces are replaced with zeroes.
|
|
120
|
+
|
|
121
|
+
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
|
122
|
+
|
|
123
|
+
If a partial version is provided as the second version in the
|
|
124
|
+
inclusive range, then all versions that start with the supplied parts
|
|
125
|
+
of the tuple are accepted, but nothing that would be greater than the
|
|
126
|
+
provided tuple parts.
|
|
127
|
+
|
|
128
|
+
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
|
129
|
+
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
|
130
|
+
|
|
131
|
+
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
|
132
|
+
|
|
133
|
+
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
|
134
|
+
numeric values in the `[major, minor, patch]` tuple.
|
|
135
|
+
|
|
136
|
+
* `*` := `>=0.0.0` (Any version satisfies)
|
|
137
|
+
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
|
138
|
+
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
|
139
|
+
|
|
140
|
+
A partial version range is treated as an X-Range, so the special
|
|
141
|
+
character is in fact optional.
|
|
142
|
+
|
|
143
|
+
* `""` (empty string) := `*` := `>=0.0.0`
|
|
144
|
+
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
|
145
|
+
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
|
146
|
+
|
|
147
|
+
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
|
148
|
+
|
|
149
|
+
Allows patch-level changes if a minor version is specified on the
|
|
150
|
+
comparator. Allows minor-level changes if not.
|
|
151
|
+
|
|
152
|
+
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
|
153
|
+
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
|
154
|
+
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
|
155
|
+
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
|
156
|
+
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
|
157
|
+
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
|
158
|
+
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
|
159
|
+
the `1.2.3` version will be allowed, if they are greater than or
|
|
160
|
+
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
|
161
|
+
`1.2.4-beta.2` would not, because it is a prerelease of a
|
|
162
|
+
different `[major, minor, patch]` tuple.
|
|
163
|
+
|
|
164
|
+
Note: this is the same as the `~>` operator in rubygems.
|
|
165
|
+
|
|
166
|
+
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
|
167
|
+
|
|
168
|
+
Allows changes that do not modify the left-most non-zero digit in the
|
|
169
|
+
`[major, minor, patch]` tuple. In other words, this allows patch and
|
|
170
|
+
minor updates for versions `1.0.0` and above, patch updates for
|
|
171
|
+
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
|
172
|
+
|
|
173
|
+
Many authors treat a `0.x` version as if the `x` were the major
|
|
174
|
+
"breaking-change" indicator.
|
|
175
|
+
|
|
176
|
+
Caret ranges are ideal when an author may make breaking changes
|
|
177
|
+
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
|
178
|
+
However, it presumes that there will *not* be breaking changes between
|
|
179
|
+
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
|
180
|
+
additive (but non-breaking), according to commonly observed practices.
|
|
181
|
+
|
|
182
|
+
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
|
183
|
+
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
|
184
|
+
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
|
185
|
+
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
|
186
|
+
the `1.2.3` version will be allowed, if they are greater than or
|
|
187
|
+
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
|
188
|
+
`1.2.4-beta.2` would not, because it is a prerelease of a
|
|
189
|
+
different `[major, minor, patch]` tuple.
|
|
190
|
+
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
|
191
|
+
`0.0.3` version *only* will be allowed, if they are greater than or
|
|
192
|
+
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
|
193
|
+
|
|
194
|
+
When parsing caret ranges, a missing `patch` value desugars to the
|
|
195
|
+
number `0`, but will allow flexibility within that value, even if the
|
|
196
|
+
major and minor versions are both `0`.
|
|
197
|
+
|
|
198
|
+
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
|
199
|
+
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
|
200
|
+
* `^0.0` := `>=0.0.0 <0.1.0`
|
|
201
|
+
|
|
202
|
+
A missing `minor` and `patch` values will desugar to zero, but also
|
|
203
|
+
allow flexibility within those values, even if the major version is
|
|
204
|
+
zero.
|
|
205
|
+
|
|
206
|
+
* `^1.x` := `>=1.0.0 <2.0.0`
|
|
207
|
+
* `^0.x` := `>=0.0.0 <1.0.0`
|
|
91
208
|
|
|
92
209
|
## Functions
|
|
93
210
|
|
package/bin/semver
CHANGED
|
@@ -12,6 +12,7 @@ var argv = process.argv.slice(2)
|
|
|
12
12
|
, inc = null
|
|
13
13
|
, version = require("../package.json").version
|
|
14
14
|
, loose = false
|
|
15
|
+
, identifier = undefined
|
|
15
16
|
, semver = require("../semver")
|
|
16
17
|
, reverse = false
|
|
17
18
|
|
|
@@ -47,6 +48,9 @@ function main () {
|
|
|
47
48
|
break
|
|
48
49
|
}
|
|
49
50
|
break
|
|
51
|
+
case "--preid":
|
|
52
|
+
identifier = argv.shift()
|
|
53
|
+
break
|
|
50
54
|
case "-r": case "--range":
|
|
51
55
|
range.push(argv.shift())
|
|
52
56
|
break
|
|
@@ -88,7 +92,7 @@ function success () {
|
|
|
88
92
|
}).map(function (v) {
|
|
89
93
|
return semver.clean(v, loose)
|
|
90
94
|
}).map(function (v) {
|
|
91
|
-
return inc ? semver.inc(v, inc, loose) : v
|
|
95
|
+
return inc ? semver.inc(v, inc, loose, identifier) : v
|
|
92
96
|
}).forEach(function (v,i,_) { console.log(v) })
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -111,6 +115,10 @@ function help () {
|
|
|
111
115
|
," prepatch, or prerelease. Default level is 'patch'."
|
|
112
116
|
," Only one version may be specified."
|
|
113
117
|
,""
|
|
118
|
+
,"--preid <identifier>"
|
|
119
|
+
," Identifier to be used to prefix premajor, preminor,"
|
|
120
|
+
," prepatch or prerelease version increments."
|
|
121
|
+
,""
|
|
114
122
|
,"-l --loose"
|
|
115
123
|
," Interpret versions and ranges loosely"
|
|
116
124
|
,""
|
package/{foot.js → foot.js.txt}
RENAMED
|
File without changes
|
package/{head.js → head.js.txt}
RENAMED
|
File without changes
|