qb 0.1.42 → 0.1.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qb/version.rb +1 -1
- data/library/qb_facts.py +16 -0
- data/node_modules/.bin/semver +1 -0
- data/node_modules/semver/LICENSE +15 -0
- data/node_modules/semver/README.md +350 -0
- data/node_modules/semver/bin/semver +133 -0
- data/node_modules/semver/package.json +22 -0
- data/node_modules/semver/range.bnf +16 -0
- data/node_modules/semver/semver.js +1203 -0
- data/package.json +11 -0
- data/plugins/filter_plugins/version.py +63 -0
- data/qb.gemspec +53 -2
- data/roles/qb.release_yarn/defaults/main.yml +4 -0
- data/{dev/scratch/empty → roles/qb.release_yarn}/meta/main.yml +1 -1
- data/{dev/scratch/stdio → roles/qb.release_yarn}/meta/qb.yml +17 -12
- data/roles/qb.release_yarn/tasks/main.yml +74 -0
- metadata +15 -49
- data/.gitignore +0 -176
- data/.gitmodules +0 -18
- data/.qb-options.yml +0 -8
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/Gemfile +0 -6
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/print-error +0 -24
- data/bin/qb +0 -16
- data/bin/rake +0 -3
- data/bin/setup +0 -9
- data/bin/ungem +0 -19
- data/dev/ansible.cfg +0 -5
- data/dev/hosts +0 -2
- data/dev/requirements.yml +0 -12
- data/dev/scratch/README.md +0 -5
- data/dev/scratch/ansible_module/defaults/main.yml +0 -2
- data/dev/scratch/ansible_module/library/test +0 -22
- data/dev/scratch/ansible_module/meta/main.yml +0 -8
- data/dev/scratch/ansible_module/meta/qb.yml +0 -44
- data/dev/scratch/ansible_module/tasks/main.yml +0 -9
- data/dev/scratch/case.rb +0 -38
- data/dev/scratch/empty/defaults/main.yml +0 -2
- data/dev/scratch/empty/meta/qb.yml +0 -44
- data/dev/scratch/empty/tasks/main.yml +0 -2
- data/dev/scratch/options/Gemfile +0 -3
- data/dev/scratch/options/Gemfile.lock +0 -13
- data/dev/scratch/options/aliases/README.md +0 -3
- data/dev/scratch/options/aliases/optparse.rb +0 -32
- data/dev/scratch/options/types/README.md +0 -1
- data/dev/scratch/options/types/opts.yml +0 -13
- data/dev/scratch/options/types/slop.rb +0 -104
- data/dev/scratch/stateSpec.js +0 -50
- data/dev/scratch/stdio/defaults/main.yml +0 -4
- data/dev/scratch/stdio/library/test +0 -34
- data/dev/scratch/stdio/meta/main.yml +0 -8
- data/dev/scratch/stdio/tasks/main.yml +0 -5
- data/dev/scratch/stream/defaults/main.yml +0 -2
- data/dev/scratch/stream/meta/main.yml +0 -7
- data/dev/scratch/stream/meta/qb.yml +0 -44
- data/dev/scratch/stream/tasks/main.yml +0 -4
- data/dev/setup.yml +0 -61
- data/temp.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74c6a3c36cd384fdfc27f9981d1f29cbbebe12e5
|
4
|
+
data.tar.gz: db0de68c734846dbf0e0c8ffe62434d4a27509dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2938dd933b2b6a404c698a810746941076b5e6e375dac8d403b677d7bd3fca718b112610e2991bd09ae8f2e56a9a30b939bac71c999f6608c77ec08c8dfaeee
|
7
|
+
data.tar.gz: 840aa9e099fdbbf415e4ed5d345f990b7d785617d81071980dcd2ec64d92f705331f250135e1e1245052fe7d37fee04eaecaa8b4119d463ac99ed8dc52dc80fa
|
data/lib/qb/version.rb
CHANGED
data/library/qb_facts.py
CHANGED
@@ -16,9 +16,19 @@ def gemspec_path(dir):
|
|
16
16
|
# this shouldn't really happen, but i don't want to stop the show...
|
17
17
|
return paths[0]
|
18
18
|
|
19
|
+
|
19
20
|
def is_gem(dir):
|
20
21
|
return dir and bool(gemspec_path(dir))
|
21
22
|
|
23
|
+
|
24
|
+
def package_json_path(dir):
|
25
|
+
return os.path.join(dir, 'package.json')
|
26
|
+
|
27
|
+
|
28
|
+
def has_package_json(dir):
|
29
|
+
return os.path.isfile(package_json_path(dir))
|
30
|
+
|
31
|
+
|
22
32
|
def main():
|
23
33
|
module = AnsibleModule(
|
24
34
|
argument_spec = dict(
|
@@ -61,6 +71,12 @@ def main():
|
|
61
71
|
|
62
72
|
facts['qb_gem_info'] = gem_info
|
63
73
|
|
74
|
+
if has_package_json(qb_dir):
|
75
|
+
f = open(package_json_path(qb_dir))
|
76
|
+
package_json = json.loads(f.read())
|
77
|
+
f.close()
|
78
|
+
facts['qb_package_json'] = package_json
|
79
|
+
|
64
80
|
changed = False
|
65
81
|
|
66
82
|
module.exit_json(
|
@@ -0,0 +1 @@
|
|
1
|
+
../semver/bin/semver
|
@@ -0,0 +1,15 @@
|
|
1
|
+
The ISC License
|
2
|
+
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
4
|
+
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
@@ -0,0 +1,350 @@
|
|
1
|
+
semver(1) -- The semantic versioner for npm
|
2
|
+
===========================================
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
|
6
|
+
$ npm install semver
|
7
|
+
$ node
|
8
|
+
var semver = require('semver')
|
9
|
+
|
10
|
+
semver.valid('1.2.3') // '1.2.3'
|
11
|
+
semver.valid('a.b.c') // null
|
12
|
+
semver.clean(' =v1.2.3 ') // '1.2.3'
|
13
|
+
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
14
|
+
semver.gt('1.2.3', '9.8.7') // false
|
15
|
+
semver.lt('1.2.3', '9.8.7') // true
|
16
|
+
|
17
|
+
As a command-line utility:
|
18
|
+
|
19
|
+
$ semver -h
|
20
|
+
|
21
|
+
SemVer 5.1.0
|
22
|
+
|
23
|
+
A JavaScript implementation of the http://semver.org/ specification
|
24
|
+
Copyright Isaac Z. Schlueter
|
25
|
+
|
26
|
+
Usage: semver [options] <version> [<version> [...]]
|
27
|
+
Prints valid versions sorted by SemVer precedence
|
28
|
+
|
29
|
+
Options:
|
30
|
+
-r --range <range>
|
31
|
+
Print versions that match the specified range.
|
32
|
+
|
33
|
+
-i --increment [<level>]
|
34
|
+
Increment a version by the specified level. Level can
|
35
|
+
be one of: major, minor, patch, premajor, preminor,
|
36
|
+
prepatch, or prerelease. Default level is 'patch'.
|
37
|
+
Only one version may be specified.
|
38
|
+
|
39
|
+
--preid <identifier>
|
40
|
+
Identifier to be used to prefix premajor, preminor,
|
41
|
+
prepatch or prerelease version increments.
|
42
|
+
|
43
|
+
-l --loose
|
44
|
+
Interpret versions and ranges loosely
|
45
|
+
|
46
|
+
Program exits successfully if any valid version satisfies
|
47
|
+
all supplied ranges, and prints all satisfying versions.
|
48
|
+
|
49
|
+
If no satisfying versions are found, then exits failure.
|
50
|
+
|
51
|
+
Versions are printed in ascending order, so supplying
|
52
|
+
multiple versions to the utility will just sort them.
|
53
|
+
|
54
|
+
## Versions
|
55
|
+
|
56
|
+
A "version" is described by the `v2.0.0` specification found at
|
57
|
+
<http://semver.org/>.
|
58
|
+
|
59
|
+
A leading `"="` or `"v"` character is stripped off and ignored.
|
60
|
+
|
61
|
+
## Ranges
|
62
|
+
|
63
|
+
A `version range` is a set of `comparators` which specify versions
|
64
|
+
that satisfy the range.
|
65
|
+
|
66
|
+
A `comparator` is composed of an `operator` and a `version`. The set
|
67
|
+
of primitive `operators` is:
|
68
|
+
|
69
|
+
* `<` Less than
|
70
|
+
* `<=` Less than or equal to
|
71
|
+
* `>` Greater than
|
72
|
+
* `>=` Greater than or equal to
|
73
|
+
* `=` Equal. If no operator is specified, then equality is assumed,
|
74
|
+
so this operator is optional, but MAY be included.
|
75
|
+
|
76
|
+
For example, the comparator `>=1.2.7` would match the versions
|
77
|
+
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
78
|
+
or `1.1.0`.
|
79
|
+
|
80
|
+
Comparators can be joined by whitespace to form a `comparator set`,
|
81
|
+
which is satisfied by the **intersection** of all of the comparators
|
82
|
+
it includes.
|
83
|
+
|
84
|
+
A range is composed of one or more comparator sets, joined by `||`. A
|
85
|
+
version matches a range if and only if every comparator in at least
|
86
|
+
one of the `||`-separated comparator sets is satisfied by the version.
|
87
|
+
|
88
|
+
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
89
|
+
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
90
|
+
or `1.1.0`.
|
91
|
+
|
92
|
+
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
93
|
+
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
94
|
+
|
95
|
+
### Prerelease Tags
|
96
|
+
|
97
|
+
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
98
|
+
it will only be allowed to satisfy comparator sets if at least one
|
99
|
+
comparator with the same `[major, minor, patch]` tuple also has a
|
100
|
+
prerelease tag.
|
101
|
+
|
102
|
+
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
103
|
+
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
104
|
+
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
105
|
+
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
106
|
+
range only accepts prerelease tags on the `1.2.3` version. The
|
107
|
+
version `3.4.5` *would* satisfy the range, because it does not have a
|
108
|
+
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
109
|
+
|
110
|
+
The purpose for this behavior is twofold. First, prerelease versions
|
111
|
+
frequently are updated very quickly, and contain many breaking changes
|
112
|
+
that are (by the author's design) not yet fit for public consumption.
|
113
|
+
Therefore, by default, they are excluded from range matching
|
114
|
+
semantics.
|
115
|
+
|
116
|
+
Second, a user who has opted into using a prerelease version has
|
117
|
+
clearly indicated the intent to use *that specific* set of
|
118
|
+
alpha/beta/rc versions. By including a prerelease tag in the range,
|
119
|
+
the user is indicating that they are aware of the risk. However, it
|
120
|
+
is still not appropriate to assume that they have opted into taking a
|
121
|
+
similar risk on the *next* set of prerelease versions.
|
122
|
+
|
123
|
+
#### Prerelease Identifiers
|
124
|
+
|
125
|
+
The method `.inc` takes an additional `identifier` string argument that
|
126
|
+
will append the value of the string as a prerelease identifier:
|
127
|
+
|
128
|
+
```javascript
|
129
|
+
> semver.inc('1.2.3', 'prerelease', 'beta')
|
130
|
+
'1.2.4-beta.0'
|
131
|
+
```
|
132
|
+
|
133
|
+
command-line example:
|
134
|
+
|
135
|
+
```shell
|
136
|
+
$ semver 1.2.3 -i prerelease --preid beta
|
137
|
+
1.2.4-beta.0
|
138
|
+
```
|
139
|
+
|
140
|
+
Which then can be used to increment further:
|
141
|
+
|
142
|
+
```shell
|
143
|
+
$ semver 1.2.4-beta.0 -i prerelease
|
144
|
+
1.2.4-beta.1
|
145
|
+
```
|
146
|
+
|
147
|
+
### Advanced Range Syntax
|
148
|
+
|
149
|
+
Advanced range syntax desugars to primitive comparators in
|
150
|
+
deterministic ways.
|
151
|
+
|
152
|
+
Advanced ranges may be combined in the same way as primitive
|
153
|
+
comparators using white space or `||`.
|
154
|
+
|
155
|
+
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
156
|
+
|
157
|
+
Specifies an inclusive set.
|
158
|
+
|
159
|
+
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
160
|
+
|
161
|
+
If a partial version is provided as the first version in the inclusive
|
162
|
+
range, then the missing pieces are replaced with zeroes.
|
163
|
+
|
164
|
+
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
165
|
+
|
166
|
+
If a partial version is provided as the second version in the
|
167
|
+
inclusive range, then all versions that start with the supplied parts
|
168
|
+
of the tuple are accepted, but nothing that would be greater than the
|
169
|
+
provided tuple parts.
|
170
|
+
|
171
|
+
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
172
|
+
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
173
|
+
|
174
|
+
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
175
|
+
|
176
|
+
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
177
|
+
numeric values in the `[major, minor, patch]` tuple.
|
178
|
+
|
179
|
+
* `*` := `>=0.0.0` (Any version satisfies)
|
180
|
+
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
181
|
+
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
182
|
+
|
183
|
+
A partial version range is treated as an X-Range, so the special
|
184
|
+
character is in fact optional.
|
185
|
+
|
186
|
+
* `""` (empty string) := `*` := `>=0.0.0`
|
187
|
+
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
188
|
+
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
189
|
+
|
190
|
+
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
191
|
+
|
192
|
+
Allows patch-level changes if a minor version is specified on the
|
193
|
+
comparator. Allows minor-level changes if not.
|
194
|
+
|
195
|
+
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
196
|
+
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
197
|
+
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
198
|
+
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
199
|
+
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
200
|
+
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
201
|
+
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
202
|
+
the `1.2.3` version will be allowed, if they are greater than or
|
203
|
+
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
204
|
+
`1.2.4-beta.2` would not, because it is a prerelease of a
|
205
|
+
different `[major, minor, patch]` tuple.
|
206
|
+
|
207
|
+
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
208
|
+
|
209
|
+
Allows changes that do not modify the left-most non-zero digit in the
|
210
|
+
`[major, minor, patch]` tuple. In other words, this allows patch and
|
211
|
+
minor updates for versions `1.0.0` and above, patch updates for
|
212
|
+
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
213
|
+
|
214
|
+
Many authors treat a `0.x` version as if the `x` were the major
|
215
|
+
"breaking-change" indicator.
|
216
|
+
|
217
|
+
Caret ranges are ideal when an author may make breaking changes
|
218
|
+
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
219
|
+
However, it presumes that there will *not* be breaking changes between
|
220
|
+
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
221
|
+
additive (but non-breaking), according to commonly observed practices.
|
222
|
+
|
223
|
+
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
224
|
+
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
225
|
+
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
226
|
+
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
227
|
+
the `1.2.3` version will be allowed, if they are greater than or
|
228
|
+
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
229
|
+
`1.2.4-beta.2` would not, because it is a prerelease of a
|
230
|
+
different `[major, minor, patch]` tuple.
|
231
|
+
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
232
|
+
`0.0.3` version *only* will be allowed, if they are greater than or
|
233
|
+
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
234
|
+
|
235
|
+
When parsing caret ranges, a missing `patch` value desugars to the
|
236
|
+
number `0`, but will allow flexibility within that value, even if the
|
237
|
+
major and minor versions are both `0`.
|
238
|
+
|
239
|
+
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
240
|
+
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
241
|
+
* `^0.0` := `>=0.0.0 <0.1.0`
|
242
|
+
|
243
|
+
A missing `minor` and `patch` values will desugar to zero, but also
|
244
|
+
allow flexibility within those values, even if the major version is
|
245
|
+
zero.
|
246
|
+
|
247
|
+
* `^1.x` := `>=1.0.0 <2.0.0`
|
248
|
+
* `^0.x` := `>=0.0.0 <1.0.0`
|
249
|
+
|
250
|
+
### Range Grammar
|
251
|
+
|
252
|
+
Putting all this together, here is a Backus-Naur grammar for ranges,
|
253
|
+
for the benefit of parser authors:
|
254
|
+
|
255
|
+
```bnf
|
256
|
+
range-set ::= range ( logical-or range ) *
|
257
|
+
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
258
|
+
range ::= hyphen | simple ( ' ' simple ) * | ''
|
259
|
+
hyphen ::= partial ' - ' partial
|
260
|
+
simple ::= primitive | partial | tilde | caret
|
261
|
+
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial
|
262
|
+
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
263
|
+
xr ::= 'x' | 'X' | '*' | nr
|
264
|
+
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
265
|
+
tilde ::= '~' partial
|
266
|
+
caret ::= '^' partial
|
267
|
+
qualifier ::= ( '-' pre )? ( '+' build )?
|
268
|
+
pre ::= parts
|
269
|
+
build ::= parts
|
270
|
+
parts ::= part ( '.' part ) *
|
271
|
+
part ::= nr | [-0-9A-Za-z]+
|
272
|
+
```
|
273
|
+
|
274
|
+
## Functions
|
275
|
+
|
276
|
+
All methods and classes take a final `loose` boolean argument that, if
|
277
|
+
true, will be more forgiving about not-quite-valid semver strings.
|
278
|
+
The resulting output will always be 100% strict, of course.
|
279
|
+
|
280
|
+
Strict-mode Comparators and Ranges will be strict about the SemVer
|
281
|
+
strings that they parse.
|
282
|
+
|
283
|
+
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
284
|
+
* `inc(v, release)`: Return the version incremented by the release
|
285
|
+
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
286
|
+
`prepatch`, or `prerelease`), or null if it's not valid
|
287
|
+
* `premajor` in one call will bump the version up to the next major
|
288
|
+
version and down to a prerelease of that major version.
|
289
|
+
`preminor`, and `prepatch` work the same way.
|
290
|
+
* If called from a non-prerelease version, the `prerelease` will work the
|
291
|
+
same as `prepatch`. It increments the patch version, then makes a
|
292
|
+
prerelease. If the input version is already a prerelease it simply
|
293
|
+
increments it.
|
294
|
+
* `prerelease(v)`: Returns an array of prerelease components, or null
|
295
|
+
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
296
|
+
* `major(v)`: Return the major version number.
|
297
|
+
* `minor(v)`: Return the minor version number.
|
298
|
+
* `patch(v)`: Return the patch version number.
|
299
|
+
|
300
|
+
### Comparison
|
301
|
+
|
302
|
+
* `gt(v1, v2)`: `v1 > v2`
|
303
|
+
* `gte(v1, v2)`: `v1 >= v2`
|
304
|
+
* `lt(v1, v2)`: `v1 < v2`
|
305
|
+
* `lte(v1, v2)`: `v1 <= v2`
|
306
|
+
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
307
|
+
even if they're not the exact same string. You already know how to
|
308
|
+
compare strings.
|
309
|
+
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
310
|
+
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
311
|
+
the corresponding function above. `"==="` and `"!=="` do simple
|
312
|
+
string comparison, but are included for completeness. Throws if an
|
313
|
+
invalid comparison string is provided.
|
314
|
+
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
315
|
+
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
316
|
+
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
317
|
+
in descending order when passed to `Array.sort()`.
|
318
|
+
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
319
|
+
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
320
|
+
or null if the versions are the same.
|
321
|
+
|
322
|
+
|
323
|
+
### Ranges
|
324
|
+
|
325
|
+
* `validRange(range)`: Return the valid range or null if it's not valid
|
326
|
+
* `satisfies(version, range)`: Return true if the version satisfies the
|
327
|
+
range.
|
328
|
+
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
329
|
+
that satisfies the range, or `null` if none of them do.
|
330
|
+
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
331
|
+
that satisfies the range, or `null` if none of them do.
|
332
|
+
* `gtr(version, range)`: Return `true` if version is greater than all the
|
333
|
+
versions possible in the range.
|
334
|
+
* `ltr(version, range)`: Return `true` if version is less than all the
|
335
|
+
versions possible in the range.
|
336
|
+
* `outside(version, range, hilo)`: Return true if the version is outside
|
337
|
+
the bounds of the range in either the high or low direction. The
|
338
|
+
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
339
|
+
the function called by `gtr` and `ltr`.)
|
340
|
+
|
341
|
+
Note that, since ranges may be non-contiguous, a version might not be
|
342
|
+
greater than a range, less than a range, *or* satisfy a range! For
|
343
|
+
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
344
|
+
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
345
|
+
range (because `2.0.1` satisfies, which is higher), nor less than the
|
346
|
+
range (since `1.2.8` satisfies, which is lower), and it also does not
|
347
|
+
satisfy the range.
|
348
|
+
|
349
|
+
If you want to know if a version satisfies or does not satisfy a
|
350
|
+
range, use the `satisfies(version, range)` function.
|
@@ -0,0 +1,133 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
// Standalone semver comparison program.
|
3
|
+
// Exits successfully and prints matching version(s) if
|
4
|
+
// any supplied version is valid and passes all tests.
|
5
|
+
|
6
|
+
var argv = process.argv.slice(2)
|
7
|
+
, versions = []
|
8
|
+
, range = []
|
9
|
+
, gt = []
|
10
|
+
, lt = []
|
11
|
+
, eq = []
|
12
|
+
, inc = null
|
13
|
+
, version = require("../package.json").version
|
14
|
+
, loose = false
|
15
|
+
, identifier = undefined
|
16
|
+
, semver = require("../semver")
|
17
|
+
, reverse = false
|
18
|
+
|
19
|
+
main()
|
20
|
+
|
21
|
+
function main () {
|
22
|
+
if (!argv.length) return help()
|
23
|
+
while (argv.length) {
|
24
|
+
var a = argv.shift()
|
25
|
+
var i = a.indexOf('=')
|
26
|
+
if (i !== -1) {
|
27
|
+
a = a.slice(0, i)
|
28
|
+
argv.unshift(a.slice(i + 1))
|
29
|
+
}
|
30
|
+
switch (a) {
|
31
|
+
case "-rv": case "-rev": case "--rev": case "--reverse":
|
32
|
+
reverse = true
|
33
|
+
break
|
34
|
+
case "-l": case "--loose":
|
35
|
+
loose = true
|
36
|
+
break
|
37
|
+
case "-v": case "--version":
|
38
|
+
versions.push(argv.shift())
|
39
|
+
break
|
40
|
+
case "-i": case "--inc": case "--increment":
|
41
|
+
switch (argv[0]) {
|
42
|
+
case "major": case "minor": case "patch": case "prerelease":
|
43
|
+
case "premajor": case "preminor": case "prepatch":
|
44
|
+
inc = argv.shift()
|
45
|
+
break
|
46
|
+
default:
|
47
|
+
inc = "patch"
|
48
|
+
break
|
49
|
+
}
|
50
|
+
break
|
51
|
+
case "--preid":
|
52
|
+
identifier = argv.shift()
|
53
|
+
break
|
54
|
+
case "-r": case "--range":
|
55
|
+
range.push(argv.shift())
|
56
|
+
break
|
57
|
+
case "-h": case "--help": case "-?":
|
58
|
+
return help()
|
59
|
+
default:
|
60
|
+
versions.push(a)
|
61
|
+
break
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
versions = versions.filter(function (v) {
|
66
|
+
return semver.valid(v, loose)
|
67
|
+
})
|
68
|
+
if (!versions.length) return fail()
|
69
|
+
if (inc && (versions.length !== 1 || range.length))
|
70
|
+
return failInc()
|
71
|
+
|
72
|
+
for (var i = 0, l = range.length; i < l ; i ++) {
|
73
|
+
versions = versions.filter(function (v) {
|
74
|
+
return semver.satisfies(v, range[i], loose)
|
75
|
+
})
|
76
|
+
if (!versions.length) return fail()
|
77
|
+
}
|
78
|
+
return success(versions)
|
79
|
+
}
|
80
|
+
|
81
|
+
function failInc () {
|
82
|
+
console.error("--inc can only be used on a single version with no range")
|
83
|
+
fail()
|
84
|
+
}
|
85
|
+
|
86
|
+
function fail () { process.exit(1) }
|
87
|
+
|
88
|
+
function success () {
|
89
|
+
var compare = reverse ? "rcompare" : "compare"
|
90
|
+
versions.sort(function (a, b) {
|
91
|
+
return semver[compare](a, b, loose)
|
92
|
+
}).map(function (v) {
|
93
|
+
return semver.clean(v, loose)
|
94
|
+
}).map(function (v) {
|
95
|
+
return inc ? semver.inc(v, inc, loose, identifier) : v
|
96
|
+
}).forEach(function (v,i,_) { console.log(v) })
|
97
|
+
}
|
98
|
+
|
99
|
+
function help () {
|
100
|
+
console.log(["SemVer " + version
|
101
|
+
,""
|
102
|
+
,"A JavaScript implementation of the http://semver.org/ specification"
|
103
|
+
,"Copyright Isaac Z. Schlueter"
|
104
|
+
,""
|
105
|
+
,"Usage: semver [options] <version> [<version> [...]]"
|
106
|
+
,"Prints valid versions sorted by SemVer precedence"
|
107
|
+
,""
|
108
|
+
,"Options:"
|
109
|
+
,"-r --range <range>"
|
110
|
+
," Print versions that match the specified range."
|
111
|
+
,""
|
112
|
+
,"-i --increment [<level>]"
|
113
|
+
," Increment a version by the specified level. Level can"
|
114
|
+
," be one of: major, minor, patch, premajor, preminor,"
|
115
|
+
," prepatch, or prerelease. Default level is 'patch'."
|
116
|
+
," Only one version may be specified."
|
117
|
+
,""
|
118
|
+
,"--preid <identifier>"
|
119
|
+
," Identifier to be used to prefix premajor, preminor,"
|
120
|
+
," prepatch or prerelease version increments."
|
121
|
+
,""
|
122
|
+
,"-l --loose"
|
123
|
+
," Interpret versions and ranges loosely"
|
124
|
+
,""
|
125
|
+
,"Program exits successfully if any valid version satisfies"
|
126
|
+
,"all supplied ranges, and prints all satisfying versions."
|
127
|
+
,""
|
128
|
+
,"If no satisfying versions are found, then exits failure."
|
129
|
+
,""
|
130
|
+
,"Versions are printed in ascending order, so supplying"
|
131
|
+
,"multiple versions to the utility will just sort them."
|
132
|
+
].join("\n"))
|
133
|
+
}
|