@basemaps/lambda-tiler 6.39.0 → 6.41.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/CHANGELOG.md +51 -0
- package/build/__tests__/config.data.d.ts.map +1 -1
- package/build/__tests__/config.data.js +142 -1
- package/build/__tests__/config.data.js.map +1 -1
- package/build/__tests__/wmts.capability.test.js +105 -79
- package/build/__tests__/wmts.capability.test.js.map +1 -1
- package/build/__tests__/xyz.util.d.ts.map +1 -1
- package/build/__tests__/xyz.util.js +6 -2
- package/build/__tests__/xyz.util.js.map +1 -1
- package/build/cli/render.tile.d.ts +2 -0
- package/build/cli/render.tile.d.ts.map +1 -0
- package/build/cli/render.tile.js +36 -0
- package/build/cli/render.tile.js.map +1 -0
- package/build/routes/__tests__/attribution.test.js +62 -2
- package/build/routes/__tests__/attribution.test.js.map +1 -1
- package/build/routes/__tests__/wmts.test.js +50 -8
- package/build/routes/__tests__/wmts.test.js.map +1 -1
- package/build/routes/attribution.d.ts +11 -0
- package/build/routes/attribution.d.ts.map +1 -1
- package/build/routes/attribution.js +32 -28
- package/build/routes/attribution.js.map +1 -1
- package/build/routes/tile.json.d.ts.map +1 -1
- package/build/routes/tile.json.js +2 -1
- package/build/routes/tile.json.js.map +1 -1
- package/build/routes/tile.style.json.d.ts.map +1 -1
- package/build/routes/tile.style.json.js +2 -1
- package/build/routes/tile.style.json.js.map +1 -1
- package/build/routes/tile.wmts.d.ts.map +1 -1
- package/build/routes/tile.wmts.js +12 -7
- package/build/routes/tile.wmts.js.map +1 -1
- package/build/routes/tile.xyz.raster.d.ts.map +1 -1
- package/build/routes/tile.xyz.raster.js +5 -1
- package/build/routes/tile.xyz.raster.js.map +1 -1
- package/build/util/__test__/filter.test.d.ts +2 -0
- package/build/util/__test__/filter.test.d.ts.map +1 -0
- package/build/util/__test__/filter.test.js +64 -0
- package/build/util/__test__/filter.test.js.map +1 -0
- package/build/util/config.loader.d.ts.map +1 -1
- package/build/util/config.loader.js +2 -3
- package/build/util/config.loader.js.map +1 -1
- package/build/util/filter.d.ts +15 -0
- package/build/util/filter.d.ts.map +1 -0
- package/build/util/filter.js +59 -0
- package/build/util/filter.js.map +1 -0
- package/build/util/validate.d.ts.map +1 -1
- package/build/util/validate.js +4 -3
- package/build/util/validate.js.map +1 -1
- package/build/wmts.capability.d.ts +61 -28
- package/build/wmts.capability.d.ts.map +1 -1
- package/build/wmts.capability.js +175 -99
- package/build/wmts.capability.js.map +1 -1
- package/dist/index.js +110 -82
- package/dist/node_modules/.package-lock.json +17 -17
- package/dist/node_modules/detect-libc/README.md +4 -1
- package/dist/node_modules/detect-libc/index.d.ts +3 -0
- package/dist/node_modules/detect-libc/lib/detect-libc.js +105 -4
- package/dist/node_modules/detect-libc/lib/filesystem.js +41 -0
- package/dist/node_modules/detect-libc/lib/process.js +3 -0
- package/dist/node_modules/detect-libc/package.json +7 -3
- package/dist/node_modules/minimist/.eslintrc +25 -50
- package/dist/node_modules/minimist/CHANGELOG.md +87 -1
- package/dist/node_modules/minimist/README.md +14 -10
- package/dist/node_modules/minimist/example/parse.js +2 -0
- package/dist/node_modules/minimist/index.js +256 -242
- package/dist/node_modules/minimist/package.json +73 -73
- package/dist/node_modules/minimist/test/all_bool.js +26 -24
- package/dist/node_modules/minimist/test/bool.js +146 -147
- package/dist/node_modules/minimist/test/dash.js +33 -21
- package/dist/node_modules/minimist/test/default_bool.js +26 -24
- package/dist/node_modules/minimist/test/dotted.js +13 -11
- package/dist/node_modules/minimist/test/kv_short.js +26 -10
- package/dist/node_modules/minimist/test/long.js +28 -26
- package/dist/node_modules/minimist/test/num.js +30 -28
- package/dist/node_modules/minimist/test/parse.js +169 -157
- package/dist/node_modules/minimist/test/parse_modified.js +7 -5
- package/dist/node_modules/minimist/test/proto.js +41 -37
- package/dist/node_modules/minimist/test/short.js +57 -55
- package/dist/node_modules/minimist/test/stop_early.js +10 -8
- package/dist/node_modules/minimist/test/unknown.js +83 -81
- package/dist/node_modules/minimist/test/whitespace.js +6 -4
- package/dist/node_modules/node-abi/.circleci/config.yml +2 -2
- package/dist/node_modules/node-abi/.github/CODEOWNERS +1 -0
- package/dist/node_modules/node-abi/.github/workflows/semantic.yml +26 -0
- package/dist/node_modules/node-abi/.github/workflows/update-abi.yml +5 -4
- package/dist/node_modules/node-abi/README.md +5 -3
- package/dist/node_modules/node-abi/abi_registry.json +32 -1
- package/dist/node_modules/node-abi/package.json +4 -4
- package/dist/node_modules/node-abi/scripts/update-abi-registry.js +2 -2
- package/dist/node_modules/readable-stream/README.md +1 -1
- package/dist/node_modules/readable-stream/lib/_stream_duplex.js +12 -25
- package/dist/node_modules/readable-stream/lib/_stream_passthrough.js +2 -4
- package/dist/node_modules/readable-stream/lib/_stream_readable.js +176 -273
- package/dist/node_modules/readable-stream/lib/_stream_transform.js +26 -37
- package/dist/node_modules/readable-stream/lib/_stream_writable.js +118 -174
- package/dist/node_modules/readable-stream/lib/internal/streams/async_iterator.js +10 -37
- package/dist/node_modules/readable-stream/lib/internal/streams/buffer_list.js +20 -47
- package/dist/node_modules/readable-stream/lib/internal/streams/destroy.js +8 -17
- package/dist/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +1 -19
- package/dist/node_modules/readable-stream/lib/internal/streams/from.js +12 -24
- package/dist/node_modules/readable-stream/lib/internal/streams/pipeline.js +5 -16
- package/dist/node_modules/readable-stream/lib/internal/streams/state.js +2 -7
- package/dist/node_modules/readable-stream/package.json +1 -1
- package/dist/node_modules/semver/README.md +70 -1
- package/dist/node_modules/semver/bin/semver.js +16 -2
- package/dist/node_modules/semver/classes/comparator.js +39 -34
- package/dist/node_modules/semver/classes/range.js +45 -28
- package/dist/node_modules/semver/classes/semver.js +32 -17
- package/dist/node_modules/semver/functions/coerce.js +1 -1
- package/dist/node_modules/semver/functions/diff.js +58 -16
- package/dist/node_modules/semver/functions/inc.js +3 -2
- package/dist/node_modules/semver/functions/parse.js +5 -22
- package/dist/node_modules/semver/index.js +1 -0
- package/dist/node_modules/semver/internal/constants.js +20 -2
- package/dist/node_modules/semver/internal/parse-options.js +14 -10
- package/dist/node_modules/semver/internal/re.js +34 -4
- package/dist/node_modules/semver/package.json +8 -7
- package/dist/node_modules/semver/ranges/intersects.js +1 -1
- package/dist/node_modules/semver/ranges/subset.js +6 -3
- package/dist/package-lock.json +18 -349
- package/dist/package.json +1 -2
- package/package.json +9 -10
- package/src/__tests__/config.data.ts +142 -1
- package/src/__tests__/wmts.capability.test.ts +117 -79
- package/src/__tests__/xyz.util.ts +6 -2
- package/src/cli/render.tile.ts +41 -0
- package/src/routes/__tests__/attribution.test.ts +64 -2
- package/src/routes/__tests__/wmts.test.ts +70 -9
- package/src/routes/attribution.ts +28 -28
- package/src/routes/tile.json.ts +2 -1
- package/src/routes/tile.style.json.ts +2 -1
- package/src/routes/tile.wmts.ts +13 -6
- package/src/routes/tile.xyz.raster.ts +4 -1
- package/src/util/__test__/filter.test.ts +80 -0
- package/src/util/config.loader.ts +1 -2
- package/src/util/filter.ts +60 -0
- package/src/util/validate.ts +4 -3
- package/src/wmts.capability.ts +216 -123
- package/tsconfig.tsbuildinfo +1 -1
- package/test-dump.js +0 -6
- package/test-imagery.js +0 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Ported from https://github.com/mafintosh/pump with
|
|
2
2
|
// permission from the author, Mathias Buus (@mafintosh).
|
|
3
|
+
|
|
3
4
|
'use strict';
|
|
4
5
|
|
|
5
6
|
var eos;
|
|
6
|
-
|
|
7
7
|
function once(callback) {
|
|
8
8
|
var called = false;
|
|
9
9
|
return function () {
|
|
@@ -12,20 +12,16 @@ function once(callback) {
|
|
|
12
12
|
callback.apply(void 0, arguments);
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
16
15
|
var _require$codes = require('../../../errors').codes,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
|
|
17
|
+
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
|
|
20
18
|
function noop(err) {
|
|
21
19
|
// Rethrow the error if it exists to avoid swallowing it
|
|
22
20
|
if (err) throw err;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
function isRequest(stream) {
|
|
26
23
|
return stream.setHeader && typeof stream.abort === 'function';
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
function destroyer(stream, reading, writing, callback) {
|
|
30
26
|
callback = once(callback);
|
|
31
27
|
var closed = false;
|
|
@@ -45,40 +41,34 @@ function destroyer(stream, reading, writing, callback) {
|
|
|
45
41
|
return function (err) {
|
|
46
42
|
if (closed) return;
|
|
47
43
|
if (destroyed) return;
|
|
48
|
-
destroyed = true;
|
|
44
|
+
destroyed = true;
|
|
49
45
|
|
|
46
|
+
// request.destroy just do .end - .abort is what we want
|
|
50
47
|
if (isRequest(stream)) return stream.abort();
|
|
51
48
|
if (typeof stream.destroy === 'function') return stream.destroy();
|
|
52
49
|
callback(err || new ERR_STREAM_DESTROYED('pipe'));
|
|
53
50
|
};
|
|
54
51
|
}
|
|
55
|
-
|
|
56
52
|
function call(fn) {
|
|
57
53
|
fn();
|
|
58
54
|
}
|
|
59
|
-
|
|
60
55
|
function pipe(from, to) {
|
|
61
56
|
return from.pipe(to);
|
|
62
57
|
}
|
|
63
|
-
|
|
64
58
|
function popCallback(streams) {
|
|
65
59
|
if (!streams.length) return noop;
|
|
66
60
|
if (typeof streams[streams.length - 1] !== 'function') return noop;
|
|
67
61
|
return streams.pop();
|
|
68
62
|
}
|
|
69
|
-
|
|
70
63
|
function pipeline() {
|
|
71
64
|
for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
65
|
streams[_key] = arguments[_key];
|
|
73
66
|
}
|
|
74
|
-
|
|
75
67
|
var callback = popCallback(streams);
|
|
76
68
|
if (Array.isArray(streams[0])) streams = streams[0];
|
|
77
|
-
|
|
78
69
|
if (streams.length < 2) {
|
|
79
70
|
throw new ERR_MISSING_ARGS('streams');
|
|
80
71
|
}
|
|
81
|
-
|
|
82
72
|
var error;
|
|
83
73
|
var destroys = streams.map(function (stream, i) {
|
|
84
74
|
var reading = i < streams.length - 1;
|
|
@@ -93,5 +83,4 @@ function pipeline() {
|
|
|
93
83
|
});
|
|
94
84
|
return streams.reduce(pipe);
|
|
95
85
|
}
|
|
96
|
-
|
|
97
86
|
module.exports = pipeline;
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
|
|
4
|
-
|
|
5
4
|
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
6
5
|
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
10
8
|
var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
11
|
-
|
|
12
9
|
if (hwm != null) {
|
|
13
10
|
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
|
14
11
|
var name = isDuplex ? duplexKey : 'highWaterMark';
|
|
15
12
|
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
return Math.floor(hwm);
|
|
19
|
-
}
|
|
20
|
-
|
|
15
|
+
}
|
|
21
16
|
|
|
17
|
+
// Default value
|
|
22
18
|
return state.objectMode ? 16 : 16 * 1024;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
module.exports = {
|
|
26
21
|
getHighWaterMark: getHighWaterMark
|
|
27
22
|
};
|
|
@@ -110,6 +110,9 @@ Options:
|
|
|
110
110
|
-l --loose
|
|
111
111
|
Interpret versions and ranges loosely
|
|
112
112
|
|
|
113
|
+
-n <0|1>
|
|
114
|
+
This is the base to be used for the prerelease identifier.
|
|
115
|
+
|
|
113
116
|
-p --include-prerelease
|
|
114
117
|
Always include prerelease versions in range matching
|
|
115
118
|
|
|
@@ -156,7 +159,9 @@ of primitive `operators` is:
|
|
|
156
159
|
|
|
157
160
|
For example, the comparator `>=1.2.7` would match the versions
|
|
158
161
|
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
|
159
|
-
or `1.1.0`.
|
|
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`.
|
|
160
165
|
|
|
161
166
|
Comparators can be joined by whitespace to form a `comparator set`,
|
|
162
167
|
which is satisfied by the **intersection** of all of the comparators
|
|
@@ -232,6 +237,35 @@ $ semver 1.2.4-beta.0 -i prerelease
|
|
|
232
237
|
1.2.4-beta.1
|
|
233
238
|
```
|
|
234
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
|
+
|
|
235
269
|
### Advanced Range Syntax
|
|
236
270
|
|
|
237
271
|
Advanced range syntax desugars to primitive comparators in
|
|
@@ -513,6 +547,40 @@ ex.
|
|
|
513
547
|
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
|
514
548
|
* `s.clean('~1.0.0')`: `null`
|
|
515
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
|
+
|
|
516
584
|
## Exported Modules
|
|
517
585
|
|
|
518
586
|
<!--
|
|
@@ -566,3 +634,4 @@ The following modules are available:
|
|
|
566
634
|
* `require('semver/ranges/outside')`
|
|
567
635
|
* `require('semver/ranges/to-comparators')`
|
|
568
636
|
* `require('semver/ranges/valid')`
|
|
637
|
+
|
|
@@ -23,7 +23,10 @@ let rtl = false
|
|
|
23
23
|
|
|
24
24
|
let identifier
|
|
25
25
|
|
|
26
|
+
let identifierBase
|
|
27
|
+
|
|
26
28
|
const semver = require('../')
|
|
29
|
+
const parseOptions = require('../internal/parse-options')
|
|
27
30
|
|
|
28
31
|
let reverse = false
|
|
29
32
|
|
|
@@ -71,6 +74,12 @@ const main = () => {
|
|
|
71
74
|
case '-r': case '--range':
|
|
72
75
|
range.push(argv.shift())
|
|
73
76
|
break
|
|
77
|
+
case '-n':
|
|
78
|
+
identifierBase = argv.shift()
|
|
79
|
+
if (identifierBase === 'false') {
|
|
80
|
+
identifierBase = false
|
|
81
|
+
}
|
|
82
|
+
break
|
|
74
83
|
case '-c': case '--coerce':
|
|
75
84
|
coerce = true
|
|
76
85
|
break
|
|
@@ -88,7 +97,7 @@ const main = () => {
|
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
options = { loose
|
|
100
|
+
options = parseOptions({ loose, includePrerelease, rtl })
|
|
92
101
|
|
|
93
102
|
versions = versions.map((v) => {
|
|
94
103
|
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
|
@@ -127,7 +136,7 @@ const success = () => {
|
|
|
127
136
|
}).map((v) => {
|
|
128
137
|
return semver.clean(v, options)
|
|
129
138
|
}).map((v) => {
|
|
130
|
-
return inc ? semver.inc(v, inc, options, identifier) : v
|
|
139
|
+
return inc ? semver.inc(v, inc, options, identifier, identifierBase) : v
|
|
131
140
|
}).forEach((v, i, _) => {
|
|
132
141
|
console.log(v)
|
|
133
142
|
})
|
|
@@ -172,6 +181,11 @@ Options:
|
|
|
172
181
|
--ltr
|
|
173
182
|
Coerce version strings left to right (default)
|
|
174
183
|
|
|
184
|
+
-n <base>
|
|
185
|
+
Base number to be used for the prerelease identifier.
|
|
186
|
+
Can be either 0 or 1, or false to omit the number altogether.
|
|
187
|
+
Defaults to 0.
|
|
188
|
+
|
|
175
189
|
Program exits successfully if any valid version satisfies
|
|
176
190
|
all supplied ranges, and prints all satisfying versions.
|
|
177
191
|
|
|
@@ -16,6 +16,7 @@ class Comparator {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
comp = comp.trim().split(/\s+/).join(' ')
|
|
19
20
|
debug('comparator', comp, options)
|
|
20
21
|
this.options = options
|
|
21
22
|
this.loose = !!options.loose
|
|
@@ -78,13 +79,6 @@ class Comparator {
|
|
|
78
79
|
throw new TypeError('a Comparator is required')
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
if (!options || typeof options !== 'object') {
|
|
82
|
-
options = {
|
|
83
|
-
loose: !!options,
|
|
84
|
-
includePrerelease: false,
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
82
|
if (this.operator === '') {
|
|
89
83
|
if (this.value === '') {
|
|
90
84
|
return true
|
|
@@ -97,39 +91,50 @@ class Comparator {
|
|
|
97
91
|
return new Range(this.value, options).test(comp.semver)
|
|
98
92
|
}
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
94
|
+
options = parseOptions(options)
|
|
95
|
+
|
|
96
|
+
// Special cases where nothing can possibly be lower
|
|
97
|
+
if (options.includePrerelease &&
|
|
98
|
+
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
if (!options.includePrerelease &&
|
|
102
|
+
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Same direction increasing (> or >=)
|
|
107
|
+
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
|
108
|
+
return true
|
|
109
|
+
}
|
|
110
|
+
// Same direction decreasing (< or <=)
|
|
111
|
+
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
|
112
|
+
return true
|
|
113
|
+
}
|
|
114
|
+
// same SemVer and both sides are inclusive (<= or >=)
|
|
115
|
+
if (
|
|
116
|
+
(this.semver.version === comp.semver.version) &&
|
|
117
|
+
this.operator.includes('=') && comp.operator.includes('=')) {
|
|
118
|
+
return true
|
|
119
|
+
}
|
|
120
|
+
// opposite directions less than
|
|
121
|
+
if (cmp(this.semver, '<', comp.semver, options) &&
|
|
122
|
+
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
|
123
|
+
return true
|
|
124
|
+
}
|
|
125
|
+
// opposite directions greater than
|
|
126
|
+
if (cmp(this.semver, '>', comp.semver, options) &&
|
|
127
|
+
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
|
128
|
+
return true
|
|
129
|
+
}
|
|
130
|
+
return false
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
module.exports = Comparator
|
|
130
135
|
|
|
131
136
|
const parseOptions = require('../internal/parse-options')
|
|
132
|
-
const { re, t } = require('../internal/re')
|
|
137
|
+
const { safeRe: re, t } = require('../internal/re')
|
|
133
138
|
const cmp = require('../functions/cmp')
|
|
134
139
|
const debug = require('../internal/debug')
|
|
135
140
|
const SemVer = require('./semver')
|
|
@@ -26,9 +26,16 @@ class Range {
|
|
|
26
26
|
this.loose = !!options.loose
|
|
27
27
|
this.includePrerelease = !!options.includePrerelease
|
|
28
28
|
|
|
29
|
-
// First
|
|
29
|
+
// First reduce all whitespace as much as possible so we do not have to rely
|
|
30
|
+
// on potentially slow regexes like \s*. This is then stored and used for
|
|
31
|
+
// future error messages as well.
|
|
30
32
|
this.raw = range
|
|
31
|
-
|
|
33
|
+
.trim()
|
|
34
|
+
.split(/\s+/)
|
|
35
|
+
.join(' ')
|
|
36
|
+
|
|
37
|
+
// First, split on ||
|
|
38
|
+
this.set = this.raw
|
|
32
39
|
.split('||')
|
|
33
40
|
// map the range to a 2d array of comparators
|
|
34
41
|
.map(r => this.parseRange(r.trim()))
|
|
@@ -38,7 +45,7 @@ class Range {
|
|
|
38
45
|
.filter(c => c.length)
|
|
39
46
|
|
|
40
47
|
if (!this.set.length) {
|
|
41
|
-
throw new TypeError(`Invalid SemVer Range: ${
|
|
48
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
// if we have any that are not the null set, throw out null sets.
|
|
@@ -64,9 +71,7 @@ class Range {
|
|
|
64
71
|
|
|
65
72
|
format () {
|
|
66
73
|
this.range = this.set
|
|
67
|
-
.map((comps) =>
|
|
68
|
-
return comps.join(' ').trim()
|
|
69
|
-
})
|
|
74
|
+
.map((comps) => comps.join(' ').trim())
|
|
70
75
|
.join('||')
|
|
71
76
|
.trim()
|
|
72
77
|
return this.range
|
|
@@ -77,12 +82,12 @@ class Range {
|
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
parseRange (range) {
|
|
80
|
-
range = range.trim()
|
|
81
|
-
|
|
82
85
|
// memoize range parsing for performance.
|
|
83
86
|
// this is a very hot path, and fully deterministic.
|
|
84
|
-
const memoOpts =
|
|
85
|
-
|
|
87
|
+
const memoOpts =
|
|
88
|
+
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
|
89
|
+
(this.options.loose && FLAG_LOOSE)
|
|
90
|
+
const memoKey = memoOpts + ':' + range
|
|
86
91
|
const cached = cache.get(memoKey)
|
|
87
92
|
if (cached) {
|
|
88
93
|
return cached
|
|
@@ -93,18 +98,18 @@ class Range {
|
|
|
93
98
|
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
|
94
99
|
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
|
|
95
100
|
debug('hyphen replace', range)
|
|
101
|
+
|
|
96
102
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
97
103
|
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
|
98
104
|
debug('comparator trim', range)
|
|
99
105
|
|
|
100
106
|
// `~ 1.2.3` => `~1.2.3`
|
|
101
107
|
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
|
108
|
+
debug('tilde trim', range)
|
|
102
109
|
|
|
103
110
|
// `^ 1.2.3` => `^1.2.3`
|
|
104
111
|
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
|
105
|
-
|
|
106
|
-
// normalize spaces
|
|
107
|
-
range = range.split(/\s+/).join(' ')
|
|
112
|
+
debug('caret trim', range)
|
|
108
113
|
|
|
109
114
|
// At this point, the range is completely trimmed and
|
|
110
115
|
// ready to be split into comparators.
|
|
@@ -190,6 +195,7 @@ class Range {
|
|
|
190
195
|
return false
|
|
191
196
|
}
|
|
192
197
|
}
|
|
198
|
+
|
|
193
199
|
module.exports = Range
|
|
194
200
|
|
|
195
201
|
const LRU = require('lru-cache')
|
|
@@ -200,12 +206,13 @@ const Comparator = require('./comparator')
|
|
|
200
206
|
const debug = require('../internal/debug')
|
|
201
207
|
const SemVer = require('./semver')
|
|
202
208
|
const {
|
|
203
|
-
re,
|
|
209
|
+
safeRe: re,
|
|
204
210
|
t,
|
|
205
211
|
comparatorTrimReplace,
|
|
206
212
|
tildeTrimReplace,
|
|
207
213
|
caretTrimReplace,
|
|
208
214
|
} = require('../internal/re')
|
|
215
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
|
|
209
216
|
|
|
210
217
|
const isNullSet = c => c.value === '<0.0.0-0'
|
|
211
218
|
const isAny = c => c.value === ''
|
|
@@ -253,10 +260,13 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
|
|
253
260
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
254
261
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
255
262
|
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
|
256
|
-
const replaceTildes = (comp, options) =>
|
|
257
|
-
comp
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
const replaceTildes = (comp, options) => {
|
|
264
|
+
return comp
|
|
265
|
+
.trim()
|
|
266
|
+
.split(/\s+/)
|
|
267
|
+
.map((c) => replaceTilde(c, options))
|
|
268
|
+
.join(' ')
|
|
269
|
+
}
|
|
260
270
|
|
|
261
271
|
const replaceTilde = (comp, options) => {
|
|
262
272
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
|
@@ -294,10 +304,13 @@ const replaceTilde = (comp, options) => {
|
|
|
294
304
|
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
295
305
|
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
|
296
306
|
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
|
297
|
-
const replaceCarets = (comp, options) =>
|
|
298
|
-
comp
|
|
299
|
-
|
|
300
|
-
|
|
307
|
+
const replaceCarets = (comp, options) => {
|
|
308
|
+
return comp
|
|
309
|
+
.trim()
|
|
310
|
+
.split(/\s+/)
|
|
311
|
+
.map((c) => replaceCaret(c, options))
|
|
312
|
+
.join(' ')
|
|
313
|
+
}
|
|
301
314
|
|
|
302
315
|
const replaceCaret = (comp, options) => {
|
|
303
316
|
debug('caret', comp, options)
|
|
@@ -354,9 +367,10 @@ const replaceCaret = (comp, options) => {
|
|
|
354
367
|
|
|
355
368
|
const replaceXRanges = (comp, options) => {
|
|
356
369
|
debug('replaceXRanges', comp, options)
|
|
357
|
-
return comp
|
|
358
|
-
|
|
359
|
-
|
|
370
|
+
return comp
|
|
371
|
+
.split(/\s+/)
|
|
372
|
+
.map((c) => replaceXRange(c, options))
|
|
373
|
+
.join(' ')
|
|
360
374
|
}
|
|
361
375
|
|
|
362
376
|
const replaceXRange = (comp, options) => {
|
|
@@ -439,12 +453,15 @@ const replaceXRange = (comp, options) => {
|
|
|
439
453
|
const replaceStars = (comp, options) => {
|
|
440
454
|
debug('replaceStars', comp, options)
|
|
441
455
|
// Looseness is ignored here. star is always as loose as it gets!
|
|
442
|
-
return comp
|
|
456
|
+
return comp
|
|
457
|
+
.trim()
|
|
458
|
+
.replace(re[t.STAR], '')
|
|
443
459
|
}
|
|
444
460
|
|
|
445
461
|
const replaceGTE0 = (comp, options) => {
|
|
446
462
|
debug('replaceGTE0', comp, options)
|
|
447
|
-
return comp
|
|
463
|
+
return comp
|
|
464
|
+
.trim()
|
|
448
465
|
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
|
449
466
|
}
|
|
450
467
|
|
|
@@ -482,7 +499,7 @@ const hyphenReplace = incPr => ($0,
|
|
|
482
499
|
to = `<=${to}`
|
|
483
500
|
}
|
|
484
501
|
|
|
485
|
-
return
|
|
502
|
+
return `${from} ${to}`.trim()
|
|
486
503
|
}
|
|
487
504
|
|
|
488
505
|
const testSet = (set, version, options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const debug = require('../internal/debug')
|
|
2
2
|
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
|
3
|
-
const { re, t } = require('../internal/re')
|
|
3
|
+
const { safeRe: re, t } = require('../internal/re')
|
|
4
4
|
|
|
5
5
|
const parseOptions = require('../internal/parse-options')
|
|
6
6
|
const { compareIdentifiers } = require('../internal/identifiers')
|
|
@@ -16,7 +16,7 @@ class SemVer {
|
|
|
16
16
|
version = version.version
|
|
17
17
|
}
|
|
18
18
|
} else if (typeof version !== 'string') {
|
|
19
|
-
throw new TypeError(`Invalid
|
|
19
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (version.length > MAX_LENGTH) {
|
|
@@ -175,36 +175,36 @@ class SemVer {
|
|
|
175
175
|
|
|
176
176
|
// preminor will bump the version up to the next minor release, and immediately
|
|
177
177
|
// down to pre-release. premajor and prepatch work the same way.
|
|
178
|
-
inc (release, identifier) {
|
|
178
|
+
inc (release, identifier, identifierBase) {
|
|
179
179
|
switch (release) {
|
|
180
180
|
case 'premajor':
|
|
181
181
|
this.prerelease.length = 0
|
|
182
182
|
this.patch = 0
|
|
183
183
|
this.minor = 0
|
|
184
184
|
this.major++
|
|
185
|
-
this.inc('pre', identifier)
|
|
185
|
+
this.inc('pre', identifier, identifierBase)
|
|
186
186
|
break
|
|
187
187
|
case 'preminor':
|
|
188
188
|
this.prerelease.length = 0
|
|
189
189
|
this.patch = 0
|
|
190
190
|
this.minor++
|
|
191
|
-
this.inc('pre', identifier)
|
|
191
|
+
this.inc('pre', identifier, identifierBase)
|
|
192
192
|
break
|
|
193
193
|
case 'prepatch':
|
|
194
194
|
// If this is already a prerelease, it will bump to the next version
|
|
195
195
|
// drop any prereleases that might already exist, since they are not
|
|
196
196
|
// relevant at this point.
|
|
197
197
|
this.prerelease.length = 0
|
|
198
|
-
this.inc('patch', identifier)
|
|
199
|
-
this.inc('pre', identifier)
|
|
198
|
+
this.inc('patch', identifier, identifierBase)
|
|
199
|
+
this.inc('pre', identifier, identifierBase)
|
|
200
200
|
break
|
|
201
201
|
// If the input is a non-prerelease version, this acts the same as
|
|
202
202
|
// prepatch.
|
|
203
203
|
case 'prerelease':
|
|
204
204
|
if (this.prerelease.length === 0) {
|
|
205
|
-
this.inc('patch', identifier)
|
|
205
|
+
this.inc('patch', identifier, identifierBase)
|
|
206
206
|
}
|
|
207
|
-
this.inc('pre', identifier)
|
|
207
|
+
this.inc('pre', identifier, identifierBase)
|
|
208
208
|
break
|
|
209
209
|
|
|
210
210
|
case 'major':
|
|
@@ -246,9 +246,15 @@ class SemVer {
|
|
|
246
246
|
break
|
|
247
247
|
// This probably shouldn't be used publicly.
|
|
248
248
|
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
249
|
-
case 'pre':
|
|
249
|
+
case 'pre': {
|
|
250
|
+
const base = Number(identifierBase) ? 1 : 0
|
|
251
|
+
|
|
252
|
+
if (!identifier && identifierBase === false) {
|
|
253
|
+
throw new Error('invalid increment argument: identifier is empty')
|
|
254
|
+
}
|
|
255
|
+
|
|
250
256
|
if (this.prerelease.length === 0) {
|
|
251
|
-
this.prerelease = [
|
|
257
|
+
this.prerelease = [base]
|
|
252
258
|
} else {
|
|
253
259
|
let i = this.prerelease.length
|
|
254
260
|
while (--i >= 0) {
|
|
@@ -259,27 +265,36 @@ class SemVer {
|
|
|
259
265
|
}
|
|
260
266
|
if (i === -1) {
|
|
261
267
|
// didn't increment anything
|
|
262
|
-
this.prerelease.
|
|
268
|
+
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
|
269
|
+
throw new Error('invalid increment argument: identifier already exists')
|
|
270
|
+
}
|
|
271
|
+
this.prerelease.push(base)
|
|
263
272
|
}
|
|
264
273
|
}
|
|
265
274
|
if (identifier) {
|
|
266
275
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
267
276
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
277
|
+
let prerelease = [identifier, base]
|
|
278
|
+
if (identifierBase === false) {
|
|
279
|
+
prerelease = [identifier]
|
|
280
|
+
}
|
|
268
281
|
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
269
282
|
if (isNaN(this.prerelease[1])) {
|
|
270
|
-
this.prerelease =
|
|
283
|
+
this.prerelease = prerelease
|
|
271
284
|
}
|
|
272
285
|
} else {
|
|
273
|
-
this.prerelease =
|
|
286
|
+
this.prerelease = prerelease
|
|
274
287
|
}
|
|
275
288
|
}
|
|
276
289
|
break
|
|
277
|
-
|
|
290
|
+
}
|
|
278
291
|
default:
|
|
279
292
|
throw new Error(`invalid increment argument: ${release}`)
|
|
280
293
|
}
|
|
281
|
-
this.format()
|
|
282
|
-
this.
|
|
294
|
+
this.raw = this.format()
|
|
295
|
+
if (this.build.length) {
|
|
296
|
+
this.raw += `+${this.build.join('.')}`
|
|
297
|
+
}
|
|
283
298
|
return this
|
|
284
299
|
}
|
|
285
300
|
}
|