@aws-amplify/graphql-model-transformer 2.1.0 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/lib/graphql-model-transformer.d.ts.map +1 -1
- package/lib/graphql-model-transformer.js +2 -1
- package/lib/graphql-model-transformer.js.map +1 -1
- package/lib/rds-lambda.zip +0 -0
- package/lib/rds-notification-lambda.zip +0 -0
- package/lib/rds-patching-lambda.zip +0 -0
- package/lib/resources/rds-model-resource-generator.d.ts.map +1 -1
- package/lib/resources/rds-model-resource-generator.js +1 -2
- package/lib/resources/rds-model-resource-generator.js.map +1 -1
- package/package.json +7 -7
- package/publish-notification-lambda/node_modules/.package-lock.json +11 -11
- package/publish-notification-lambda/node_modules/@types/node/README.md +1 -1
- package/publish-notification-lambda/node_modules/@types/node/package.json +2 -2
- package/publish-notification-lambda/node_modules/archiver/CHANGELOG.md +18 -0
- package/publish-notification-lambda/node_modules/archiver/package.json +7 -7
- package/publish-notification-lambda/node_modules/tslib/package.json +2 -2
- package/publish-notification-lambda/package-lock.json +11 -11
- package/rds-lambda/node_modules/.package-lock.json +407 -362
- package/rds-lambda/node_modules/@babel/code-frame/package.json +3 -2
- package/rds-lambda/node_modules/@babel/core/package.json +9 -9
- package/rds-lambda/node_modules/@babel/helpers/package.json +5 -5
- package/rds-lambda/node_modules/@babel/highlight/package.json +1 -1
- package/rds-lambda/node_modules/@babel/parser/package.json +3 -3
- package/rds-lambda/node_modules/@babel/traverse/package.json +4 -4
- package/rds-lambda/node_modules/@babel/types/lib/index.js.flow +10 -10
- package/rds-lambda/node_modules/@babel/types/package.json +2 -2
- package/rds-lambda/node_modules/@jest/console/package.json +7 -7
- package/rds-lambda/node_modules/@jest/core/package.json +25 -25
- package/rds-lambda/node_modules/@jest/environment/package.json +6 -6
- package/rds-lambda/node_modules/@jest/expect/package.json +5 -5
- package/rds-lambda/node_modules/@jest/expect-utils/package.json +5 -5
- package/rds-lambda/node_modules/@jest/fake-timers/package.json +8 -8
- package/rds-lambda/node_modules/@jest/globals/package.json +7 -7
- package/rds-lambda/node_modules/@jest/reporters/node_modules/istanbul-lib-instrument/CHANGELOG.md +642 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/istanbul-lib-instrument/LICENSE +24 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/istanbul-lib-instrument/README.md +22 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/istanbul-lib-instrument/package.json +50 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/lru-cache/LICENSE +15 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/lru-cache/README.md +166 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/lru-cache/package.json +34 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/semver/LICENSE +15 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/semver/README.md +637 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/semver/package.json +87 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/semver/range.bnf +16 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/yallist/LICENSE +15 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/yallist/README.md +204 -0
- package/rds-lambda/node_modules/@jest/reporters/node_modules/yallist/package.json +29 -0
- package/rds-lambda/node_modules/@jest/reporters/package.json +14 -14
- package/rds-lambda/node_modules/@jest/schemas/package.json +3 -3
- package/rds-lambda/node_modules/@jest/source-map/package.json +3 -3
- package/rds-lambda/node_modules/@jest/test-result/package.json +7 -7
- package/rds-lambda/node_modules/@jest/test-sequencer/package.json +6 -6
- package/rds-lambda/node_modules/@jest/transform/package.json +8 -8
- package/rds-lambda/node_modules/@jest/types/package.json +4 -4
- package/rds-lambda/node_modules/@types/jest/README.md +1 -1
- package/rds-lambda/node_modules/@types/jest/package.json +2 -2
- package/rds-lambda/node_modules/@types/node/README.md +1 -1
- package/rds-lambda/node_modules/@types/node/package.json +2 -2
- package/rds-lambda/node_modules/archiver/CHANGELOG.md +18 -0
- package/rds-lambda/node_modules/archiver/package.json +7 -7
- package/rds-lambda/node_modules/babel-jest/README.md +1 -1
- package/rds-lambda/node_modules/babel-jest/package.json +6 -6
- package/rds-lambda/node_modules/babel-plugin-jest-hoist/README.md +1 -1
- package/rds-lambda/node_modules/babel-plugin-jest-hoist/package.json +3 -3
- package/rds-lambda/node_modules/babel-preset-jest/README.md +1 -1
- package/rds-lambda/node_modules/babel-preset-jest/package.json +4 -4
- package/rds-lambda/node_modules/caniuse-lite/package.json +1 -1
- package/rds-lambda/node_modules/diff-sequences/package.json +3 -3
- package/rds-lambda/node_modules/electron-to-chromium/chromium-versions.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/full-chromium-versions.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/full-versions.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/package.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/versions.json +1 -1
- package/rds-lambda/node_modules/expect/package.json +9 -10
- package/rds-lambda/node_modules/jest/package.json +6 -6
- package/rds-lambda/node_modules/jest-changed-files/package.json +4 -3
- package/rds-lambda/node_modules/jest-circus/README.md +1 -1
- package/rds-lambda/node_modules/jest-circus/package.json +14 -14
- package/rds-lambda/node_modules/jest-cli/package.json +10 -10
- package/rds-lambda/node_modules/jest-config/package.json +15 -15
- package/rds-lambda/node_modules/jest-diff/package.json +7 -7
- package/rds-lambda/node_modules/jest-docblock/package.json +3 -3
- package/rds-lambda/node_modules/jest-each/README.md +1 -1
- package/rds-lambda/node_modules/jest-each/package.json +7 -7
- package/rds-lambda/node_modules/jest-environment-node/package.json +9 -9
- package/rds-lambda/node_modules/jest-get-type/package.json +3 -3
- package/rds-lambda/node_modules/jest-haste-map/package.json +7 -7
- package/rds-lambda/node_modules/jest-leak-detector/package.json +5 -5
- package/rds-lambda/node_modules/jest-matcher-utils/README.md +1 -1
- package/rds-lambda/node_modules/jest-matcher-utils/package.json +7 -7
- package/rds-lambda/node_modules/jest-message-util/package.json +5 -5
- package/rds-lambda/node_modules/jest-mock/package.json +5 -5
- package/rds-lambda/node_modules/jest-regex-util/package.json +3 -3
- package/rds-lambda/node_modules/jest-resolve/package.json +6 -6
- package/rds-lambda/node_modules/jest-resolve-dependencies/package.json +10 -10
- package/rds-lambda/node_modules/jest-runner/package.json +20 -20
- package/rds-lambda/node_modules/jest-runtime/package.json +19 -19
- package/rds-lambda/node_modules/jest-snapshot/package.json +14 -14
- package/rds-lambda/node_modules/jest-util/package.json +4 -4
- package/rds-lambda/node_modules/jest-validate/package.json +6 -6
- package/rds-lambda/node_modules/jest-watcher/package.json +7 -7
- package/rds-lambda/node_modules/jest-worker/README.md +1 -1
- package/rds-lambda/node_modules/jest-worker/package.json +5 -5
- package/rds-lambda/node_modules/pretty-format/package.json +5 -5
- package/rds-lambda/node_modules/tslib/package.json +2 -2
- package/rds-lambda/package-lock.json +410 -365
- package/rds-patching-lambda/node_modules/.package-lock.json +11 -11
- package/rds-patching-lambda/node_modules/@types/node/README.md +1 -1
- package/rds-patching-lambda/node_modules/@types/node/package.json +2 -2
- package/rds-patching-lambda/node_modules/archiver/CHANGELOG.md +18 -0
- package/rds-patching-lambda/node_modules/archiver/package.json +7 -7
- package/rds-patching-lambda/node_modules/tslib/package.json +2 -2
- package/rds-patching-lambda/package-lock.json +11 -11
- package/src/__tests__/__snapshots__/model-transformer.test.ts.snap +23 -23
- package/src/__tests__/model-transformer.test.ts +2 -2
- package/src/graphql-model-transformer.ts +2 -1
- package/src/resources/rds-model-resource-generator.ts +1 -2
- package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,637 @@
|
|
1
|
+
semver(1) -- The semantic versioner for npm
|
2
|
+
===========================================
|
3
|
+
|
4
|
+
## Install
|
5
|
+
|
6
|
+
```bash
|
7
|
+
npm install semver
|
8
|
+
````
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
As a node module:
|
13
|
+
|
14
|
+
```js
|
15
|
+
const semver = require('semver')
|
16
|
+
|
17
|
+
semver.valid('1.2.3') // '1.2.3'
|
18
|
+
semver.valid('a.b.c') // null
|
19
|
+
semver.clean(' =v1.2.3 ') // '1.2.3'
|
20
|
+
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
21
|
+
semver.gt('1.2.3', '9.8.7') // false
|
22
|
+
semver.lt('1.2.3', '9.8.7') // true
|
23
|
+
semver.minVersion('>=1.0.0') // '1.0.0'
|
24
|
+
semver.valid(semver.coerce('v2')) // '2.0.0'
|
25
|
+
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
26
|
+
```
|
27
|
+
|
28
|
+
You can also just load the module for the function that you care about, if
|
29
|
+
you'd like to minimize your footprint.
|
30
|
+
|
31
|
+
```js
|
32
|
+
// load the whole API at once in a single object
|
33
|
+
const semver = require('semver')
|
34
|
+
|
35
|
+
// or just load the bits you need
|
36
|
+
// all of them listed here, just pick and choose what you want
|
37
|
+
|
38
|
+
// classes
|
39
|
+
const SemVer = require('semver/classes/semver')
|
40
|
+
const Comparator = require('semver/classes/comparator')
|
41
|
+
const Range = require('semver/classes/range')
|
42
|
+
|
43
|
+
// functions for working with versions
|
44
|
+
const semverParse = require('semver/functions/parse')
|
45
|
+
const semverValid = require('semver/functions/valid')
|
46
|
+
const semverClean = require('semver/functions/clean')
|
47
|
+
const semverInc = require('semver/functions/inc')
|
48
|
+
const semverDiff = require('semver/functions/diff')
|
49
|
+
const semverMajor = require('semver/functions/major')
|
50
|
+
const semverMinor = require('semver/functions/minor')
|
51
|
+
const semverPatch = require('semver/functions/patch')
|
52
|
+
const semverPrerelease = require('semver/functions/prerelease')
|
53
|
+
const semverCompare = require('semver/functions/compare')
|
54
|
+
const semverRcompare = require('semver/functions/rcompare')
|
55
|
+
const semverCompareLoose = require('semver/functions/compare-loose')
|
56
|
+
const semverCompareBuild = require('semver/functions/compare-build')
|
57
|
+
const semverSort = require('semver/functions/sort')
|
58
|
+
const semverRsort = require('semver/functions/rsort')
|
59
|
+
|
60
|
+
// low-level comparators between versions
|
61
|
+
const semverGt = require('semver/functions/gt')
|
62
|
+
const semverLt = require('semver/functions/lt')
|
63
|
+
const semverEq = require('semver/functions/eq')
|
64
|
+
const semverNeq = require('semver/functions/neq')
|
65
|
+
const semverGte = require('semver/functions/gte')
|
66
|
+
const semverLte = require('semver/functions/lte')
|
67
|
+
const semverCmp = require('semver/functions/cmp')
|
68
|
+
const semverCoerce = require('semver/functions/coerce')
|
69
|
+
|
70
|
+
// working with ranges
|
71
|
+
const semverSatisfies = require('semver/functions/satisfies')
|
72
|
+
const semverMaxSatisfying = require('semver/ranges/max-satisfying')
|
73
|
+
const semverMinSatisfying = require('semver/ranges/min-satisfying')
|
74
|
+
const semverToComparators = require('semver/ranges/to-comparators')
|
75
|
+
const semverMinVersion = require('semver/ranges/min-version')
|
76
|
+
const semverValidRange = require('semver/ranges/valid')
|
77
|
+
const semverOutside = require('semver/ranges/outside')
|
78
|
+
const semverGtr = require('semver/ranges/gtr')
|
79
|
+
const semverLtr = require('semver/ranges/ltr')
|
80
|
+
const semverIntersects = require('semver/ranges/intersects')
|
81
|
+
const simplifyRange = require('semver/ranges/simplify')
|
82
|
+
const rangeSubset = require('semver/ranges/subset')
|
83
|
+
```
|
84
|
+
|
85
|
+
As a command-line utility:
|
86
|
+
|
87
|
+
```
|
88
|
+
$ semver -h
|
89
|
+
|
90
|
+
A JavaScript implementation of the https://semver.org/ specification
|
91
|
+
Copyright Isaac Z. Schlueter
|
92
|
+
|
93
|
+
Usage: semver [options] <version> [<version> [...]]
|
94
|
+
Prints valid versions sorted by SemVer precedence
|
95
|
+
|
96
|
+
Options:
|
97
|
+
-r --range <range>
|
98
|
+
Print versions that match the specified range.
|
99
|
+
|
100
|
+
-i --increment [<level>]
|
101
|
+
Increment a version by the specified level. Level can
|
102
|
+
be one of: major, minor, patch, premajor, preminor,
|
103
|
+
prepatch, or prerelease. Default level is 'patch'.
|
104
|
+
Only one version may be specified.
|
105
|
+
|
106
|
+
--preid <identifier>
|
107
|
+
Identifier to be used to prefix premajor, preminor,
|
108
|
+
prepatch or prerelease version increments.
|
109
|
+
|
110
|
+
-l --loose
|
111
|
+
Interpret versions and ranges loosely
|
112
|
+
|
113
|
+
-n <0|1>
|
114
|
+
This is the base to be used for the prerelease identifier.
|
115
|
+
|
116
|
+
-p --include-prerelease
|
117
|
+
Always include prerelease versions in range matching
|
118
|
+
|
119
|
+
-c --coerce
|
120
|
+
Coerce a string into SemVer if possible
|
121
|
+
(does not imply --loose)
|
122
|
+
|
123
|
+
--rtl
|
124
|
+
Coerce version strings right to left
|
125
|
+
|
126
|
+
--ltr
|
127
|
+
Coerce version strings left to right (default)
|
128
|
+
|
129
|
+
Program exits successfully if any valid version satisfies
|
130
|
+
all supplied ranges, and prints all satisfying versions.
|
131
|
+
|
132
|
+
If no satisfying versions are found, then exits failure.
|
133
|
+
|
134
|
+
Versions are printed in ascending order, so supplying
|
135
|
+
multiple versions to the utility will just sort them.
|
136
|
+
```
|
137
|
+
|
138
|
+
## Versions
|
139
|
+
|
140
|
+
A "version" is described by the `v2.0.0` specification found at
|
141
|
+
<https://semver.org/>.
|
142
|
+
|
143
|
+
A leading `"="` or `"v"` character is stripped off and ignored.
|
144
|
+
|
145
|
+
## Ranges
|
146
|
+
|
147
|
+
A `version range` is a set of `comparators` which specify versions
|
148
|
+
that satisfy the range.
|
149
|
+
|
150
|
+
A `comparator` is composed of an `operator` and a `version`. The set
|
151
|
+
of primitive `operators` is:
|
152
|
+
|
153
|
+
* `<` Less than
|
154
|
+
* `<=` Less than or equal to
|
155
|
+
* `>` Greater than
|
156
|
+
* `>=` Greater than or equal to
|
157
|
+
* `=` Equal. If no operator is specified, then equality is assumed,
|
158
|
+
so this operator is optional, but MAY be included.
|
159
|
+
|
160
|
+
For example, the comparator `>=1.2.7` would match the versions
|
161
|
+
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
162
|
+
or `1.1.0`. The comparator `>1` is equivalent to `>=2.0.0` and
|
163
|
+
would match the versions `2.0.0` and `3.1.0`, but not the versions
|
164
|
+
`1.0.1` or `1.1.0`.
|
165
|
+
|
166
|
+
Comparators can be joined by whitespace to form a `comparator set`,
|
167
|
+
which is satisfied by the **intersection** of all of the comparators
|
168
|
+
it includes.
|
169
|
+
|
170
|
+
A range is composed of one or more comparator sets, joined by `||`. A
|
171
|
+
version matches a range if and only if every comparator in at least
|
172
|
+
one of the `||`-separated comparator sets is satisfied by the version.
|
173
|
+
|
174
|
+
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
175
|
+
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
176
|
+
or `1.1.0`.
|
177
|
+
|
178
|
+
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
179
|
+
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
180
|
+
|
181
|
+
### Prerelease Tags
|
182
|
+
|
183
|
+
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
184
|
+
it will only be allowed to satisfy comparator sets if at least one
|
185
|
+
comparator with the same `[major, minor, patch]` tuple also has a
|
186
|
+
prerelease tag.
|
187
|
+
|
188
|
+
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
189
|
+
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
190
|
+
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
191
|
+
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
192
|
+
range only accepts prerelease tags on the `1.2.3` version. The
|
193
|
+
version `3.4.5` *would* satisfy the range, because it does not have a
|
194
|
+
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
195
|
+
|
196
|
+
The purpose for this behavior is twofold. First, prerelease versions
|
197
|
+
frequently are updated very quickly, and contain many breaking changes
|
198
|
+
that are (by the author's design) not yet fit for public consumption.
|
199
|
+
Therefore, by default, they are excluded from range matching
|
200
|
+
semantics.
|
201
|
+
|
202
|
+
Second, a user who has opted into using a prerelease version has
|
203
|
+
clearly indicated the intent to use *that specific* set of
|
204
|
+
alpha/beta/rc versions. By including a prerelease tag in the range,
|
205
|
+
the user is indicating that they are aware of the risk. However, it
|
206
|
+
is still not appropriate to assume that they have opted into taking a
|
207
|
+
similar risk on the *next* set of prerelease versions.
|
208
|
+
|
209
|
+
Note that this behavior can be suppressed (treating all prerelease
|
210
|
+
versions as if they were normal versions, for the purpose of range
|
211
|
+
matching) by setting the `includePrerelease` flag on the options
|
212
|
+
object to any
|
213
|
+
[functions](https://github.com/npm/node-semver#functions) that do
|
214
|
+
range matching.
|
215
|
+
|
216
|
+
#### Prerelease Identifiers
|
217
|
+
|
218
|
+
The method `.inc` takes an additional `identifier` string argument that
|
219
|
+
will append the value of the string as a prerelease identifier:
|
220
|
+
|
221
|
+
```javascript
|
222
|
+
semver.inc('1.2.3', 'prerelease', 'beta')
|
223
|
+
// '1.2.4-beta.0'
|
224
|
+
```
|
225
|
+
|
226
|
+
command-line example:
|
227
|
+
|
228
|
+
```bash
|
229
|
+
$ semver 1.2.3 -i prerelease --preid beta
|
230
|
+
1.2.4-beta.0
|
231
|
+
```
|
232
|
+
|
233
|
+
Which then can be used to increment further:
|
234
|
+
|
235
|
+
```bash
|
236
|
+
$ semver 1.2.4-beta.0 -i prerelease
|
237
|
+
1.2.4-beta.1
|
238
|
+
```
|
239
|
+
|
240
|
+
#### Prerelease Identifier Base
|
241
|
+
|
242
|
+
The method `.inc` takes an optional parameter 'identifierBase' string
|
243
|
+
that will let you let your prerelease number as zero-based or one-based.
|
244
|
+
Set to `false` to omit the prerelease number altogether.
|
245
|
+
If you do not specify this parameter, it will default to zero-based.
|
246
|
+
|
247
|
+
```javascript
|
248
|
+
semver.inc('1.2.3', 'prerelease', 'beta', '1')
|
249
|
+
// '1.2.4-beta.1'
|
250
|
+
```
|
251
|
+
|
252
|
+
```javascript
|
253
|
+
semver.inc('1.2.3', 'prerelease', 'beta', false)
|
254
|
+
// '1.2.4-beta'
|
255
|
+
```
|
256
|
+
|
257
|
+
command-line example:
|
258
|
+
|
259
|
+
```bash
|
260
|
+
$ semver 1.2.3 -i prerelease --preid beta -n 1
|
261
|
+
1.2.4-beta.1
|
262
|
+
```
|
263
|
+
|
264
|
+
```bash
|
265
|
+
$ semver 1.2.3 -i prerelease --preid beta -n false
|
266
|
+
1.2.4-beta
|
267
|
+
```
|
268
|
+
|
269
|
+
### Advanced Range Syntax
|
270
|
+
|
271
|
+
Advanced range syntax desugars to primitive comparators in
|
272
|
+
deterministic ways.
|
273
|
+
|
274
|
+
Advanced ranges may be combined in the same way as primitive
|
275
|
+
comparators using white space or `||`.
|
276
|
+
|
277
|
+
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
278
|
+
|
279
|
+
Specifies an inclusive set.
|
280
|
+
|
281
|
+
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
282
|
+
|
283
|
+
If a partial version is provided as the first version in the inclusive
|
284
|
+
range, then the missing pieces are replaced with zeroes.
|
285
|
+
|
286
|
+
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
287
|
+
|
288
|
+
If a partial version is provided as the second version in the
|
289
|
+
inclusive range, then all versions that start with the supplied parts
|
290
|
+
of the tuple are accepted, but nothing that would be greater than the
|
291
|
+
provided tuple parts.
|
292
|
+
|
293
|
+
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0`
|
294
|
+
* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0`
|
295
|
+
|
296
|
+
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
297
|
+
|
298
|
+
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
299
|
+
numeric values in the `[major, minor, patch]` tuple.
|
300
|
+
|
301
|
+
* `*` := `>=0.0.0` (Any non-prerelease version satisfies, unless
|
302
|
+
`includePrerelease` is specified, in which case any version at all
|
303
|
+
satisfies)
|
304
|
+
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
|
305
|
+
* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)
|
306
|
+
|
307
|
+
A partial version range is treated as an X-Range, so the special
|
308
|
+
character is in fact optional.
|
309
|
+
|
310
|
+
* `""` (empty string) := `*` := `>=0.0.0`
|
311
|
+
* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0`
|
312
|
+
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0`
|
313
|
+
|
314
|
+
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
315
|
+
|
316
|
+
Allows patch-level changes if a minor version is specified on the
|
317
|
+
comparator. Allows minor-level changes if not.
|
318
|
+
|
319
|
+
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0`
|
320
|
+
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`)
|
321
|
+
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`)
|
322
|
+
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0`
|
323
|
+
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`)
|
324
|
+
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`)
|
325
|
+
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in
|
326
|
+
the `1.2.3` version will be allowed, if they are greater than or
|
327
|
+
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
328
|
+
`1.2.4-beta.2` would not, because it is a prerelease of a
|
329
|
+
different `[major, minor, patch]` tuple.
|
330
|
+
|
331
|
+
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
332
|
+
|
333
|
+
Allows changes that do not modify the left-most non-zero element in the
|
334
|
+
`[major, minor, patch]` tuple. In other words, this allows patch and
|
335
|
+
minor updates for versions `1.0.0` and above, patch updates for
|
336
|
+
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
337
|
+
|
338
|
+
Many authors treat a `0.x` version as if the `x` were the major
|
339
|
+
"breaking-change" indicator.
|
340
|
+
|
341
|
+
Caret ranges are ideal when an author may make breaking changes
|
342
|
+
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
343
|
+
However, it presumes that there will *not* be breaking changes between
|
344
|
+
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
345
|
+
additive (but non-breaking), according to commonly observed practices.
|
346
|
+
|
347
|
+
* `^1.2.3` := `>=1.2.3 <2.0.0-0`
|
348
|
+
* `^0.2.3` := `>=0.2.3 <0.3.0-0`
|
349
|
+
* `^0.0.3` := `>=0.0.3 <0.0.4-0`
|
350
|
+
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in
|
351
|
+
the `1.2.3` version will be allowed, if they are greater than or
|
352
|
+
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
353
|
+
`1.2.4-beta.2` would not, because it is a prerelease of a
|
354
|
+
different `[major, minor, patch]` tuple.
|
355
|
+
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the
|
356
|
+
`0.0.3` version *only* will be allowed, if they are greater than or
|
357
|
+
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
358
|
+
|
359
|
+
When parsing caret ranges, a missing `patch` value desugars to the
|
360
|
+
number `0`, but will allow flexibility within that value, even if the
|
361
|
+
major and minor versions are both `0`.
|
362
|
+
|
363
|
+
* `^1.2.x` := `>=1.2.0 <2.0.0-0`
|
364
|
+
* `^0.0.x` := `>=0.0.0 <0.1.0-0`
|
365
|
+
* `^0.0` := `>=0.0.0 <0.1.0-0`
|
366
|
+
|
367
|
+
A missing `minor` and `patch` values will desugar to zero, but also
|
368
|
+
allow flexibility within those values, even if the major version is
|
369
|
+
zero.
|
370
|
+
|
371
|
+
* `^1.x` := `>=1.0.0 <2.0.0-0`
|
372
|
+
* `^0.x` := `>=0.0.0 <1.0.0-0`
|
373
|
+
|
374
|
+
### Range Grammar
|
375
|
+
|
376
|
+
Putting all this together, here is a Backus-Naur grammar for ranges,
|
377
|
+
for the benefit of parser authors:
|
378
|
+
|
379
|
+
```bnf
|
380
|
+
range-set ::= range ( logical-or range ) *
|
381
|
+
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
382
|
+
range ::= hyphen | simple ( ' ' simple ) * | ''
|
383
|
+
hyphen ::= partial ' - ' partial
|
384
|
+
simple ::= primitive | partial | tilde | caret
|
385
|
+
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
386
|
+
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
387
|
+
xr ::= 'x' | 'X' | '*' | nr
|
388
|
+
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
389
|
+
tilde ::= '~' partial
|
390
|
+
caret ::= '^' partial
|
391
|
+
qualifier ::= ( '-' pre )? ( '+' build )?
|
392
|
+
pre ::= parts
|
393
|
+
build ::= parts
|
394
|
+
parts ::= part ( '.' part ) *
|
395
|
+
part ::= nr | [-0-9A-Za-z]+
|
396
|
+
```
|
397
|
+
|
398
|
+
## Functions
|
399
|
+
|
400
|
+
All methods and classes take a final `options` object argument. All
|
401
|
+
options in this object are `false` by default. The options supported
|
402
|
+
are:
|
403
|
+
|
404
|
+
- `loose` Be more forgiving about not-quite-valid semver strings.
|
405
|
+
(Any resulting output will always be 100% strict compliant, of
|
406
|
+
course.) For backwards compatibility reasons, if the `options`
|
407
|
+
argument is a boolean value instead of an object, it is interpreted
|
408
|
+
to be the `loose` param.
|
409
|
+
- `includePrerelease` Set to suppress the [default
|
410
|
+
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
411
|
+
excluding prerelease tagged versions from ranges unless they are
|
412
|
+
explicitly opted into.
|
413
|
+
|
414
|
+
Strict-mode Comparators and Ranges will be strict about the SemVer
|
415
|
+
strings that they parse.
|
416
|
+
|
417
|
+
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
418
|
+
* `inc(v, release)`: Return the version incremented by the release
|
419
|
+
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
420
|
+
`prepatch`, or `prerelease`), or null if it's not valid
|
421
|
+
* `premajor` in one call will bump the version up to the next major
|
422
|
+
version and down to a prerelease of that major version.
|
423
|
+
`preminor`, and `prepatch` work the same way.
|
424
|
+
* If called from a non-prerelease version, the `prerelease` will work the
|
425
|
+
same as `prepatch`. It increments the patch version, then makes a
|
426
|
+
prerelease. If the input version is already a prerelease it simply
|
427
|
+
increments it.
|
428
|
+
* `prerelease(v)`: Returns an array of prerelease components, or null
|
429
|
+
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
430
|
+
* `major(v)`: Return the major version number.
|
431
|
+
* `minor(v)`: Return the minor version number.
|
432
|
+
* `patch(v)`: Return the patch version number.
|
433
|
+
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
434
|
+
or comparators intersect.
|
435
|
+
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
436
|
+
a `SemVer` object or `null`.
|
437
|
+
|
438
|
+
### Comparison
|
439
|
+
|
440
|
+
* `gt(v1, v2)`: `v1 > v2`
|
441
|
+
* `gte(v1, v2)`: `v1 >= v2`
|
442
|
+
* `lt(v1, v2)`: `v1 < v2`
|
443
|
+
* `lte(v1, v2)`: `v1 <= v2`
|
444
|
+
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
445
|
+
even if they're not the exact same string. You already know how to
|
446
|
+
compare strings.
|
447
|
+
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
448
|
+
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
449
|
+
the corresponding function above. `"==="` and `"!=="` do simple
|
450
|
+
string comparison, but are included for completeness. Throws if an
|
451
|
+
invalid comparison string is provided.
|
452
|
+
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
453
|
+
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
454
|
+
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
455
|
+
in descending order when passed to `Array.sort()`.
|
456
|
+
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
457
|
+
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
458
|
+
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
459
|
+
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
460
|
+
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
461
|
+
or null if the versions are the same.
|
462
|
+
|
463
|
+
### Comparators
|
464
|
+
|
465
|
+
* `intersects(comparator)`: Return true if the comparators intersect
|
466
|
+
|
467
|
+
### Ranges
|
468
|
+
|
469
|
+
* `validRange(range)`: Return the valid range or null if it's not valid
|
470
|
+
* `satisfies(version, range)`: Return true if the version satisfies the
|
471
|
+
range.
|
472
|
+
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
473
|
+
that satisfies the range, or `null` if none of them do.
|
474
|
+
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
475
|
+
that satisfies the range, or `null` if none of them do.
|
476
|
+
* `minVersion(range)`: Return the lowest version that can possibly match
|
477
|
+
the given range.
|
478
|
+
* `gtr(version, range)`: Return `true` if version is greater than all the
|
479
|
+
versions possible in the range.
|
480
|
+
* `ltr(version, range)`: Return `true` if version is less than all the
|
481
|
+
versions possible in the range.
|
482
|
+
* `outside(version, range, hilo)`: Return true if the version is outside
|
483
|
+
the bounds of the range in either the high or low direction. The
|
484
|
+
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
485
|
+
the function called by `gtr` and `ltr`.)
|
486
|
+
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
487
|
+
* `simplifyRange(versions, range)`: Return a "simplified" range that
|
488
|
+
matches the same items in `versions` list as the range specified. Note
|
489
|
+
that it does *not* guarantee that it would match the same versions in all
|
490
|
+
cases, only for the set of versions provided. This is useful when
|
491
|
+
generating ranges by joining together multiple versions with `||`
|
492
|
+
programmatically, to provide the user with something a bit more
|
493
|
+
ergonomic. If the provided range is shorter in string-length than the
|
494
|
+
generated range, then that is returned.
|
495
|
+
* `subset(subRange, superRange)`: Return `true` if the `subRange` range is
|
496
|
+
entirely contained by the `superRange` range.
|
497
|
+
|
498
|
+
Note that, since ranges may be non-contiguous, a version might not be
|
499
|
+
greater than a range, less than a range, *or* satisfy a range! For
|
500
|
+
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
501
|
+
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
502
|
+
range (because `2.0.1` satisfies, which is higher), nor less than the
|
503
|
+
range (since `1.2.8` satisfies, which is lower), and it also does not
|
504
|
+
satisfy the range.
|
505
|
+
|
506
|
+
If you want to know if a version satisfies or does not satisfy a
|
507
|
+
range, use the `satisfies(version, range)` function.
|
508
|
+
|
509
|
+
### Coercion
|
510
|
+
|
511
|
+
* `coerce(version, options)`: Coerces a string to semver if possible
|
512
|
+
|
513
|
+
This aims to provide a very forgiving translation of a non-semver string to
|
514
|
+
semver. It looks for the first digit in a string, and consumes all
|
515
|
+
remaining characters which satisfy at least a partial semver (e.g., `1`,
|
516
|
+
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
|
517
|
+
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
|
518
|
+
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
519
|
+
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
|
520
|
+
is not valid). The maximum length for any semver component considered for
|
521
|
+
coercion is 16 characters; longer components will be ignored
|
522
|
+
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
523
|
+
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
524
|
+
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
525
|
+
|
526
|
+
If the `options.rtl` flag is set, then `coerce` will return the right-most
|
527
|
+
coercible tuple that does not share an ending index with a longer coercible
|
528
|
+
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
|
529
|
+
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
|
530
|
+
any other overlapping SemVer tuple.
|
531
|
+
|
532
|
+
### Clean
|
533
|
+
|
534
|
+
* `clean(version)`: Clean a string to be a valid semver if possible
|
535
|
+
|
536
|
+
This will return a cleaned and trimmed semver version. If the provided
|
537
|
+
version is not valid a null will be returned. This does not work for
|
538
|
+
ranges.
|
539
|
+
|
540
|
+
ex.
|
541
|
+
* `s.clean(' = v 2.1.5foo')`: `null`
|
542
|
+
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
543
|
+
* `s.clean(' = v 2.1.5-foo')`: `null`
|
544
|
+
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
545
|
+
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
546
|
+
* `s.clean(' =v2.1.5')`: `2.1.5`
|
547
|
+
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
548
|
+
* `s.clean('~1.0.0')`: `null`
|
549
|
+
|
550
|
+
## Constants
|
551
|
+
|
552
|
+
As a convenience, helper constants are exported to provide information about what `node-semver` supports:
|
553
|
+
|
554
|
+
### `RELEASE_TYPES`
|
555
|
+
|
556
|
+
- major
|
557
|
+
- premajor
|
558
|
+
- minor
|
559
|
+
- preminor
|
560
|
+
- patch
|
561
|
+
- prepatch
|
562
|
+
- prerelease
|
563
|
+
|
564
|
+
```
|
565
|
+
const semver = require('semver');
|
566
|
+
|
567
|
+
if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) {
|
568
|
+
console.log('This is a valid release type!');
|
569
|
+
} else {
|
570
|
+
console.warn('This is NOT a valid release type!');
|
571
|
+
}
|
572
|
+
```
|
573
|
+
|
574
|
+
### `SEMVER_SPEC_VERSION`
|
575
|
+
|
576
|
+
2.0.0
|
577
|
+
|
578
|
+
```
|
579
|
+
const semver = require('semver');
|
580
|
+
|
581
|
+
console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION);
|
582
|
+
```
|
583
|
+
|
584
|
+
## Exported Modules
|
585
|
+
|
586
|
+
<!--
|
587
|
+
TODO: Make sure that all of these items are documented (classes aren't,
|
588
|
+
eg), and then pull the module name into the documentation for that specific
|
589
|
+
thing.
|
590
|
+
-->
|
591
|
+
|
592
|
+
You may pull in just the part of this semver utility that you need, if you
|
593
|
+
are sensitive to packing and tree-shaking concerns. The main
|
594
|
+
`require('semver')` export uses getter functions to lazily load the parts
|
595
|
+
of the API that are used.
|
596
|
+
|
597
|
+
The following modules are available:
|
598
|
+
|
599
|
+
* `require('semver')`
|
600
|
+
* `require('semver/classes')`
|
601
|
+
* `require('semver/classes/comparator')`
|
602
|
+
* `require('semver/classes/range')`
|
603
|
+
* `require('semver/classes/semver')`
|
604
|
+
* `require('semver/functions/clean')`
|
605
|
+
* `require('semver/functions/cmp')`
|
606
|
+
* `require('semver/functions/coerce')`
|
607
|
+
* `require('semver/functions/compare')`
|
608
|
+
* `require('semver/functions/compare-build')`
|
609
|
+
* `require('semver/functions/compare-loose')`
|
610
|
+
* `require('semver/functions/diff')`
|
611
|
+
* `require('semver/functions/eq')`
|
612
|
+
* `require('semver/functions/gt')`
|
613
|
+
* `require('semver/functions/gte')`
|
614
|
+
* `require('semver/functions/inc')`
|
615
|
+
* `require('semver/functions/lt')`
|
616
|
+
* `require('semver/functions/lte')`
|
617
|
+
* `require('semver/functions/major')`
|
618
|
+
* `require('semver/functions/minor')`
|
619
|
+
* `require('semver/functions/neq')`
|
620
|
+
* `require('semver/functions/parse')`
|
621
|
+
* `require('semver/functions/patch')`
|
622
|
+
* `require('semver/functions/prerelease')`
|
623
|
+
* `require('semver/functions/rcompare')`
|
624
|
+
* `require('semver/functions/rsort')`
|
625
|
+
* `require('semver/functions/satisfies')`
|
626
|
+
* `require('semver/functions/sort')`
|
627
|
+
* `require('semver/functions/valid')`
|
628
|
+
* `require('semver/ranges/gtr')`
|
629
|
+
* `require('semver/ranges/intersects')`
|
630
|
+
* `require('semver/ranges/ltr')`
|
631
|
+
* `require('semver/ranges/max-satisfying')`
|
632
|
+
* `require('semver/ranges/min-satisfying')`
|
633
|
+
* `require('semver/ranges/min-version')`
|
634
|
+
* `require('semver/ranges/outside')`
|
635
|
+
* `require('semver/ranges/to-comparators')`
|
636
|
+
* `require('semver/ranges/valid')`
|
637
|
+
|