@shopify/cli-hydrogen 0.6.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.
@@ -0,0 +1,2213 @@
1
+ import { l as lruCache, C as Command, H as HelpfulError, s as source } from '../../Command-05a807a5.js';
2
+ import 'path';
3
+ import 'prettier';
4
+ import { c as cliHydrogenPackageJson } from '../../package-224e3f45.js';
5
+ import '@oclif/core';
6
+ import 'fs';
7
+ import 'constants';
8
+ import 'stream';
9
+ import 'util';
10
+ import 'assert';
11
+ import 'os';
12
+ import 'events';
13
+ import 'tty';
14
+ import 'readline';
15
+ import 'buffer';
16
+ import 'child_process';
17
+ import 'string_decoder';
18
+ import 'crypto';
19
+ import '@shopify/cli-kit';
20
+ import 'module';
21
+ import 'vm';
22
+ import 'url';
23
+ import 'v8';
24
+
25
+ var re$5 = {exports: {}};
26
+
27
+ // Note: this is the semver.org version of the spec that it implements
28
+ // Not necessarily the package version of this code.
29
+ const SEMVER_SPEC_VERSION = '2.0.0';
30
+
31
+ const MAX_LENGTH$2 = 256;
32
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
33
+ /* istanbul ignore next */ 9007199254740991;
34
+
35
+ // Max safe segment length for coercion.
36
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
37
+
38
+ var constants = {
39
+ SEMVER_SPEC_VERSION,
40
+ MAX_LENGTH: MAX_LENGTH$2,
41
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
42
+ MAX_SAFE_COMPONENT_LENGTH
43
+ };
44
+
45
+ const debug$3 = (
46
+ typeof process === 'object' &&
47
+ process.env &&
48
+ process.env.NODE_DEBUG &&
49
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
50
+ ) ? (...args) => console.error('SEMVER', ...args)
51
+ : () => {};
52
+
53
+ var debug_1 = debug$3;
54
+
55
+ (function (module, exports) {
56
+ const { MAX_SAFE_COMPONENT_LENGTH } = constants;
57
+ const debug = debug_1;
58
+ exports = module.exports = {};
59
+
60
+ // The actual regexps go on exports.re
61
+ const re = exports.re = [];
62
+ const src = exports.src = [];
63
+ const t = exports.t = {};
64
+ let R = 0;
65
+
66
+ const createToken = (name, value, isGlobal) => {
67
+ const index = R++;
68
+ debug(index, value);
69
+ t[name] = index;
70
+ src[index] = value;
71
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
72
+ };
73
+
74
+ // The following Regular Expressions can be used for tokenizing,
75
+ // validating, and parsing SemVer version strings.
76
+
77
+ // ## Numeric Identifier
78
+ // A single `0`, or a non-zero digit followed by zero or more digits.
79
+
80
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
81
+ createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
82
+
83
+ // ## Non-numeric Identifier
84
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
85
+ // more letters, digits, or hyphens.
86
+
87
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
88
+
89
+ // ## Main Version
90
+ // Three dot-separated numeric identifiers.
91
+
92
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
93
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
94
+ `(${src[t.NUMERICIDENTIFIER]})`);
95
+
96
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
97
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
98
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
99
+
100
+ // ## Pre-release Version Identifier
101
+ // A numeric identifier, or a non-numeric identifier.
102
+
103
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
104
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
105
+
106
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
107
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
108
+
109
+ // ## Pre-release Version
110
+ // Hyphen, followed by one or more dot-separated pre-release version
111
+ // identifiers.
112
+
113
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
114
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
115
+
116
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
117
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
118
+
119
+ // ## Build Metadata Identifier
120
+ // Any combination of digits, letters, or hyphens.
121
+
122
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
123
+
124
+ // ## Build Metadata
125
+ // Plus sign, followed by one or more period-separated build metadata
126
+ // identifiers.
127
+
128
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
129
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
130
+
131
+ // ## Full Version String
132
+ // A main version, followed optionally by a pre-release version and
133
+ // build metadata.
134
+
135
+ // Note that the only major, minor, patch, and pre-release sections of
136
+ // the version string are capturing groups. The build metadata is not a
137
+ // capturing group, because it should not ever be used in version
138
+ // comparison.
139
+
140
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
141
+ }${src[t.PRERELEASE]}?${
142
+ src[t.BUILD]}?`);
143
+
144
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
145
+
146
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
147
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
148
+ // common in the npm registry.
149
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
150
+ }${src[t.PRERELEASELOOSE]}?${
151
+ src[t.BUILD]}?`);
152
+
153
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
154
+
155
+ createToken('GTLT', '((?:<|>)?=?)');
156
+
157
+ // Something like "2.*" or "1.2.x".
158
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
159
+ // Only the first item is strictly required.
160
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
161
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
162
+
163
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
164
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
165
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
166
+ `(?:${src[t.PRERELEASE]})?${
167
+ src[t.BUILD]}?` +
168
+ `)?)?`);
169
+
170
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
171
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
172
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
173
+ `(?:${src[t.PRERELEASELOOSE]})?${
174
+ src[t.BUILD]}?` +
175
+ `)?)?`);
176
+
177
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
178
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
179
+
180
+ // Coercion.
181
+ // Extract anything that could conceivably be a part of a valid semver
182
+ createToken('COERCE', `${'(^|[^\\d])' +
183
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
184
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
185
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
186
+ `(?:$|[^\\d])`);
187
+ createToken('COERCERTL', src[t.COERCE], true);
188
+
189
+ // Tilde ranges.
190
+ // Meaning is "reasonably at or greater than"
191
+ createToken('LONETILDE', '(?:~>?)');
192
+
193
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
194
+ exports.tildeTrimReplace = '$1~';
195
+
196
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
197
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
198
+
199
+ // Caret ranges.
200
+ // Meaning is "at least and backwards compatible with"
201
+ createToken('LONECARET', '(?:\\^)');
202
+
203
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
204
+ exports.caretTrimReplace = '$1^';
205
+
206
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
207
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
208
+
209
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
210
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
211
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
212
+
213
+ // An expression to strip any whitespace between the gtlt and the thing
214
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
215
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
216
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
217
+ exports.comparatorTrimReplace = '$1$2$3';
218
+
219
+ // Something like `1.2.3 - 1.2.4`
220
+ // Note that these all use the loose form, because they'll be
221
+ // checked against either the strict or loose comparator form
222
+ // later.
223
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
224
+ `\\s+-\\s+` +
225
+ `(${src[t.XRANGEPLAIN]})` +
226
+ `\\s*$`);
227
+
228
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
229
+ `\\s+-\\s+` +
230
+ `(${src[t.XRANGEPLAINLOOSE]})` +
231
+ `\\s*$`);
232
+
233
+ // Star ranges basically just allow anything at all.
234
+ createToken('STAR', '(<|>)?=?\\s*\\*');
235
+ // >=0.0.0 is like a star
236
+ createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
237
+ createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
238
+ }(re$5, re$5.exports));
239
+
240
+ // parse out just the options we care about so we always get a consistent
241
+ // obj with keys in a consistent order.
242
+ const opts = ['includePrerelease', 'loose', 'rtl'];
243
+ const parseOptions$4 = options =>
244
+ !options ? {}
245
+ : typeof options !== 'object' ? { loose: true }
246
+ : opts.filter(k => options[k]).reduce((options, k) => {
247
+ options[k] = true;
248
+ return options
249
+ }, {});
250
+ var parseOptions_1 = parseOptions$4;
251
+
252
+ const numeric = /^[0-9]+$/;
253
+ const compareIdentifiers$1 = (a, b) => {
254
+ const anum = numeric.test(a);
255
+ const bnum = numeric.test(b);
256
+
257
+ if (anum && bnum) {
258
+ a = +a;
259
+ b = +b;
260
+ }
261
+
262
+ return a === b ? 0
263
+ : (anum && !bnum) ? -1
264
+ : (bnum && !anum) ? 1
265
+ : a < b ? -1
266
+ : 1
267
+ };
268
+
269
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
270
+
271
+ var identifiers = {
272
+ compareIdentifiers: compareIdentifiers$1,
273
+ rcompareIdentifiers
274
+ };
275
+
276
+ const debug$2 = debug_1;
277
+ const { MAX_LENGTH: MAX_LENGTH$1, MAX_SAFE_INTEGER } = constants;
278
+ const { re: re$4, t: t$4 } = re$5.exports;
279
+
280
+ const parseOptions$3 = parseOptions_1;
281
+ const { compareIdentifiers } = identifiers;
282
+ class SemVer$e {
283
+ constructor (version, options) {
284
+ options = parseOptions$3(options);
285
+
286
+ if (version instanceof SemVer$e) {
287
+ if (version.loose === !!options.loose &&
288
+ version.includePrerelease === !!options.includePrerelease) {
289
+ return version
290
+ } else {
291
+ version = version.version;
292
+ }
293
+ } else if (typeof version !== 'string') {
294
+ throw new TypeError(`Invalid Version: ${version}`)
295
+ }
296
+
297
+ if (version.length > MAX_LENGTH$1) {
298
+ throw new TypeError(
299
+ `version is longer than ${MAX_LENGTH$1} characters`
300
+ )
301
+ }
302
+
303
+ debug$2('SemVer', version, options);
304
+ this.options = options;
305
+ this.loose = !!options.loose;
306
+ // this isn't actually relevant for versions, but keep it so that we
307
+ // don't run into trouble passing this.options around.
308
+ this.includePrerelease = !!options.includePrerelease;
309
+
310
+ const m = version.trim().match(options.loose ? re$4[t$4.LOOSE] : re$4[t$4.FULL]);
311
+
312
+ if (!m) {
313
+ throw new TypeError(`Invalid Version: ${version}`)
314
+ }
315
+
316
+ this.raw = version;
317
+
318
+ // these are actually numbers
319
+ this.major = +m[1];
320
+ this.minor = +m[2];
321
+ this.patch = +m[3];
322
+
323
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
324
+ throw new TypeError('Invalid major version')
325
+ }
326
+
327
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
328
+ throw new TypeError('Invalid minor version')
329
+ }
330
+
331
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
332
+ throw new TypeError('Invalid patch version')
333
+ }
334
+
335
+ // numberify any prerelease numeric ids
336
+ if (!m[4]) {
337
+ this.prerelease = [];
338
+ } else {
339
+ this.prerelease = m[4].split('.').map((id) => {
340
+ if (/^[0-9]+$/.test(id)) {
341
+ const num = +id;
342
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
343
+ return num
344
+ }
345
+ }
346
+ return id
347
+ });
348
+ }
349
+
350
+ this.build = m[5] ? m[5].split('.') : [];
351
+ this.format();
352
+ }
353
+
354
+ format () {
355
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
356
+ if (this.prerelease.length) {
357
+ this.version += `-${this.prerelease.join('.')}`;
358
+ }
359
+ return this.version
360
+ }
361
+
362
+ toString () {
363
+ return this.version
364
+ }
365
+
366
+ compare (other) {
367
+ debug$2('SemVer.compare', this.version, this.options, other);
368
+ if (!(other instanceof SemVer$e)) {
369
+ if (typeof other === 'string' && other === this.version) {
370
+ return 0
371
+ }
372
+ other = new SemVer$e(other, this.options);
373
+ }
374
+
375
+ if (other.version === this.version) {
376
+ return 0
377
+ }
378
+
379
+ return this.compareMain(other) || this.comparePre(other)
380
+ }
381
+
382
+ compareMain (other) {
383
+ if (!(other instanceof SemVer$e)) {
384
+ other = new SemVer$e(other, this.options);
385
+ }
386
+
387
+ return (
388
+ compareIdentifiers(this.major, other.major) ||
389
+ compareIdentifiers(this.minor, other.minor) ||
390
+ compareIdentifiers(this.patch, other.patch)
391
+ )
392
+ }
393
+
394
+ comparePre (other) {
395
+ if (!(other instanceof SemVer$e)) {
396
+ other = new SemVer$e(other, this.options);
397
+ }
398
+
399
+ // NOT having a prerelease is > having one
400
+ if (this.prerelease.length && !other.prerelease.length) {
401
+ return -1
402
+ } else if (!this.prerelease.length && other.prerelease.length) {
403
+ return 1
404
+ } else if (!this.prerelease.length && !other.prerelease.length) {
405
+ return 0
406
+ }
407
+
408
+ let i = 0;
409
+ do {
410
+ const a = this.prerelease[i];
411
+ const b = other.prerelease[i];
412
+ debug$2('prerelease compare', i, a, b);
413
+ if (a === undefined && b === undefined) {
414
+ return 0
415
+ } else if (b === undefined) {
416
+ return 1
417
+ } else if (a === undefined) {
418
+ return -1
419
+ } else if (a === b) {
420
+ continue
421
+ } else {
422
+ return compareIdentifiers(a, b)
423
+ }
424
+ } while (++i)
425
+ }
426
+
427
+ compareBuild (other) {
428
+ if (!(other instanceof SemVer$e)) {
429
+ other = new SemVer$e(other, this.options);
430
+ }
431
+
432
+ let i = 0;
433
+ do {
434
+ const a = this.build[i];
435
+ const b = other.build[i];
436
+ debug$2('prerelease compare', i, a, b);
437
+ if (a === undefined && b === undefined) {
438
+ return 0
439
+ } else if (b === undefined) {
440
+ return 1
441
+ } else if (a === undefined) {
442
+ return -1
443
+ } else if (a === b) {
444
+ continue
445
+ } else {
446
+ return compareIdentifiers(a, b)
447
+ }
448
+ } while (++i)
449
+ }
450
+
451
+ // preminor will bump the version up to the next minor release, and immediately
452
+ // down to pre-release. premajor and prepatch work the same way.
453
+ inc (release, identifier) {
454
+ switch (release) {
455
+ case 'premajor':
456
+ this.prerelease.length = 0;
457
+ this.patch = 0;
458
+ this.minor = 0;
459
+ this.major++;
460
+ this.inc('pre', identifier);
461
+ break
462
+ case 'preminor':
463
+ this.prerelease.length = 0;
464
+ this.patch = 0;
465
+ this.minor++;
466
+ this.inc('pre', identifier);
467
+ break
468
+ case 'prepatch':
469
+ // If this is already a prerelease, it will bump to the next version
470
+ // drop any prereleases that might already exist, since they are not
471
+ // relevant at this point.
472
+ this.prerelease.length = 0;
473
+ this.inc('patch', identifier);
474
+ this.inc('pre', identifier);
475
+ break
476
+ // If the input is a non-prerelease version, this acts the same as
477
+ // prepatch.
478
+ case 'prerelease':
479
+ if (this.prerelease.length === 0) {
480
+ this.inc('patch', identifier);
481
+ }
482
+ this.inc('pre', identifier);
483
+ break
484
+
485
+ case 'major':
486
+ // If this is a pre-major version, bump up to the same major version.
487
+ // Otherwise increment major.
488
+ // 1.0.0-5 bumps to 1.0.0
489
+ // 1.1.0 bumps to 2.0.0
490
+ if (
491
+ this.minor !== 0 ||
492
+ this.patch !== 0 ||
493
+ this.prerelease.length === 0
494
+ ) {
495
+ this.major++;
496
+ }
497
+ this.minor = 0;
498
+ this.patch = 0;
499
+ this.prerelease = [];
500
+ break
501
+ case 'minor':
502
+ // If this is a pre-minor version, bump up to the same minor version.
503
+ // Otherwise increment minor.
504
+ // 1.2.0-5 bumps to 1.2.0
505
+ // 1.2.1 bumps to 1.3.0
506
+ if (this.patch !== 0 || this.prerelease.length === 0) {
507
+ this.minor++;
508
+ }
509
+ this.patch = 0;
510
+ this.prerelease = [];
511
+ break
512
+ case 'patch':
513
+ // If this is not a pre-release version, it will increment the patch.
514
+ // If it is a pre-release it will bump up to the same patch version.
515
+ // 1.2.0-5 patches to 1.2.0
516
+ // 1.2.0 patches to 1.2.1
517
+ if (this.prerelease.length === 0) {
518
+ this.patch++;
519
+ }
520
+ this.prerelease = [];
521
+ break
522
+ // This probably shouldn't be used publicly.
523
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
524
+ case 'pre':
525
+ if (this.prerelease.length === 0) {
526
+ this.prerelease = [0];
527
+ } else {
528
+ let i = this.prerelease.length;
529
+ while (--i >= 0) {
530
+ if (typeof this.prerelease[i] === 'number') {
531
+ this.prerelease[i]++;
532
+ i = -2;
533
+ }
534
+ }
535
+ if (i === -1) {
536
+ // didn't increment anything
537
+ this.prerelease.push(0);
538
+ }
539
+ }
540
+ if (identifier) {
541
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
542
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
543
+ if (this.prerelease[0] === identifier) {
544
+ if (isNaN(this.prerelease[1])) {
545
+ this.prerelease = [identifier, 0];
546
+ }
547
+ } else {
548
+ this.prerelease = [identifier, 0];
549
+ }
550
+ }
551
+ break
552
+
553
+ default:
554
+ throw new Error(`invalid increment argument: ${release}`)
555
+ }
556
+ this.format();
557
+ this.raw = this.version;
558
+ return this
559
+ }
560
+ }
561
+
562
+ var semver$1 = SemVer$e;
563
+
564
+ const {MAX_LENGTH} = constants;
565
+ const { re: re$3, t: t$3 } = re$5.exports;
566
+ const SemVer$d = semver$1;
567
+
568
+ const parseOptions$2 = parseOptions_1;
569
+ const parse$5 = (version, options) => {
570
+ options = parseOptions$2(options);
571
+
572
+ if (version instanceof SemVer$d) {
573
+ return version
574
+ }
575
+
576
+ if (typeof version !== 'string') {
577
+ return null
578
+ }
579
+
580
+ if (version.length > MAX_LENGTH) {
581
+ return null
582
+ }
583
+
584
+ const r = options.loose ? re$3[t$3.LOOSE] : re$3[t$3.FULL];
585
+ if (!r.test(version)) {
586
+ return null
587
+ }
588
+
589
+ try {
590
+ return new SemVer$d(version, options)
591
+ } catch (er) {
592
+ return null
593
+ }
594
+ };
595
+
596
+ var parse_1 = parse$5;
597
+
598
+ const parse$4 = parse_1;
599
+ const valid$1 = (version, options) => {
600
+ const v = parse$4(version, options);
601
+ return v ? v.version : null
602
+ };
603
+ var valid_1 = valid$1;
604
+
605
+ const parse$3 = parse_1;
606
+ const clean = (version, options) => {
607
+ const s = parse$3(version.trim().replace(/^[=v]+/, ''), options);
608
+ return s ? s.version : null
609
+ };
610
+ var clean_1 = clean;
611
+
612
+ const SemVer$c = semver$1;
613
+
614
+ const inc = (version, release, options, identifier) => {
615
+ if (typeof (options) === 'string') {
616
+ identifier = options;
617
+ options = undefined;
618
+ }
619
+
620
+ try {
621
+ return new SemVer$c(version, options).inc(release, identifier).version
622
+ } catch (er) {
623
+ return null
624
+ }
625
+ };
626
+ var inc_1 = inc;
627
+
628
+ const SemVer$b = semver$1;
629
+ const compare$a = (a, b, loose) =>
630
+ new SemVer$b(a, loose).compare(new SemVer$b(b, loose));
631
+
632
+ var compare_1 = compare$a;
633
+
634
+ const compare$9 = compare_1;
635
+ const eq$2 = (a, b, loose) => compare$9(a, b, loose) === 0;
636
+ var eq_1 = eq$2;
637
+
638
+ const parse$2 = parse_1;
639
+ const eq$1 = eq_1;
640
+
641
+ const diff = (version1, version2) => {
642
+ if (eq$1(version1, version2)) {
643
+ return null
644
+ } else {
645
+ const v1 = parse$2(version1);
646
+ const v2 = parse$2(version2);
647
+ const hasPre = v1.prerelease.length || v2.prerelease.length;
648
+ const prefix = hasPre ? 'pre' : '';
649
+ const defaultResult = hasPre ? 'prerelease' : '';
650
+ for (const key in v1) {
651
+ if (key === 'major' || key === 'minor' || key === 'patch') {
652
+ if (v1[key] !== v2[key]) {
653
+ return prefix + key
654
+ }
655
+ }
656
+ }
657
+ return defaultResult // may be undefined
658
+ }
659
+ };
660
+ var diff_1 = diff;
661
+
662
+ const SemVer$a = semver$1;
663
+ const major = (a, loose) => new SemVer$a(a, loose).major;
664
+ var major_1 = major;
665
+
666
+ const SemVer$9 = semver$1;
667
+ const minor = (a, loose) => new SemVer$9(a, loose).minor;
668
+ var minor_1 = minor;
669
+
670
+ const SemVer$8 = semver$1;
671
+ const patch = (a, loose) => new SemVer$8(a, loose).patch;
672
+ var patch_1 = patch;
673
+
674
+ const parse$1 = parse_1;
675
+ const prerelease = (version, options) => {
676
+ const parsed = parse$1(version, options);
677
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
678
+ };
679
+ var prerelease_1 = prerelease;
680
+
681
+ const compare$8 = compare_1;
682
+ const rcompare = (a, b, loose) => compare$8(b, a, loose);
683
+ var rcompare_1 = rcompare;
684
+
685
+ const compare$7 = compare_1;
686
+ const compareLoose = (a, b) => compare$7(a, b, true);
687
+ var compareLoose_1 = compareLoose;
688
+
689
+ const SemVer$7 = semver$1;
690
+ const compareBuild$2 = (a, b, loose) => {
691
+ const versionA = new SemVer$7(a, loose);
692
+ const versionB = new SemVer$7(b, loose);
693
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
694
+ };
695
+ var compareBuild_1 = compareBuild$2;
696
+
697
+ const compareBuild$1 = compareBuild_1;
698
+ const sort = (list, loose) => list.sort((a, b) => compareBuild$1(a, b, loose));
699
+ var sort_1 = sort;
700
+
701
+ const compareBuild = compareBuild_1;
702
+ const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
703
+ var rsort_1 = rsort;
704
+
705
+ const compare$6 = compare_1;
706
+ const gt$3 = (a, b, loose) => compare$6(a, b, loose) > 0;
707
+ var gt_1 = gt$3;
708
+
709
+ const compare$5 = compare_1;
710
+ const lt$2 = (a, b, loose) => compare$5(a, b, loose) < 0;
711
+ var lt_1 = lt$2;
712
+
713
+ const compare$4 = compare_1;
714
+ const neq$1 = (a, b, loose) => compare$4(a, b, loose) !== 0;
715
+ var neq_1 = neq$1;
716
+
717
+ const compare$3 = compare_1;
718
+ const gte$2 = (a, b, loose) => compare$3(a, b, loose) >= 0;
719
+ var gte_1 = gte$2;
720
+
721
+ const compare$2 = compare_1;
722
+ const lte$2 = (a, b, loose) => compare$2(a, b, loose) <= 0;
723
+ var lte_1 = lte$2;
724
+
725
+ const eq = eq_1;
726
+ const neq = neq_1;
727
+ const gt$2 = gt_1;
728
+ const gte$1 = gte_1;
729
+ const lt$1 = lt_1;
730
+ const lte$1 = lte_1;
731
+
732
+ const cmp$1 = (a, op, b, loose) => {
733
+ switch (op) {
734
+ case '===':
735
+ if (typeof a === 'object')
736
+ a = a.version;
737
+ if (typeof b === 'object')
738
+ b = b.version;
739
+ return a === b
740
+
741
+ case '!==':
742
+ if (typeof a === 'object')
743
+ a = a.version;
744
+ if (typeof b === 'object')
745
+ b = b.version;
746
+ return a !== b
747
+
748
+ case '':
749
+ case '=':
750
+ case '==':
751
+ return eq(a, b, loose)
752
+
753
+ case '!=':
754
+ return neq(a, b, loose)
755
+
756
+ case '>':
757
+ return gt$2(a, b, loose)
758
+
759
+ case '>=':
760
+ return gte$1(a, b, loose)
761
+
762
+ case '<':
763
+ return lt$1(a, b, loose)
764
+
765
+ case '<=':
766
+ return lte$1(a, b, loose)
767
+
768
+ default:
769
+ throw new TypeError(`Invalid operator: ${op}`)
770
+ }
771
+ };
772
+ var cmp_1 = cmp$1;
773
+
774
+ const SemVer$6 = semver$1;
775
+ const parse = parse_1;
776
+ const {re: re$2, t: t$2} = re$5.exports;
777
+
778
+ const coerce = (version, options) => {
779
+ if (version instanceof SemVer$6) {
780
+ return version
781
+ }
782
+
783
+ if (typeof version === 'number') {
784
+ version = String(version);
785
+ }
786
+
787
+ if (typeof version !== 'string') {
788
+ return null
789
+ }
790
+
791
+ options = options || {};
792
+
793
+ let match = null;
794
+ if (!options.rtl) {
795
+ match = version.match(re$2[t$2.COERCE]);
796
+ } else {
797
+ // Find the right-most coercible string that does not share
798
+ // a terminus with a more left-ward coercible string.
799
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
800
+ //
801
+ // Walk through the string checking with a /g regexp
802
+ // Manually set the index so as to pick up overlapping matches.
803
+ // Stop when we get a match that ends at the string end, since no
804
+ // coercible string can be more right-ward without the same terminus.
805
+ let next;
806
+ while ((next = re$2[t$2.COERCERTL].exec(version)) &&
807
+ (!match || match.index + match[0].length !== version.length)
808
+ ) {
809
+ if (!match ||
810
+ next.index + next[0].length !== match.index + match[0].length) {
811
+ match = next;
812
+ }
813
+ re$2[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
814
+ }
815
+ // leave it in a clean state
816
+ re$2[t$2.COERCERTL].lastIndex = -1;
817
+ }
818
+
819
+ if (match === null)
820
+ return null
821
+
822
+ return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
823
+ };
824
+ var coerce_1 = coerce;
825
+
826
+ // hoisted class for cyclic dependency
827
+ class Range$a {
828
+ constructor (range, options) {
829
+ options = parseOptions$1(options);
830
+
831
+ if (range instanceof Range$a) {
832
+ if (
833
+ range.loose === !!options.loose &&
834
+ range.includePrerelease === !!options.includePrerelease
835
+ ) {
836
+ return range
837
+ } else {
838
+ return new Range$a(range.raw, options)
839
+ }
840
+ }
841
+
842
+ if (range instanceof Comparator$3) {
843
+ // just put it in the set and return
844
+ this.raw = range.value;
845
+ this.set = [[range]];
846
+ this.format();
847
+ return this
848
+ }
849
+
850
+ this.options = options;
851
+ this.loose = !!options.loose;
852
+ this.includePrerelease = !!options.includePrerelease;
853
+
854
+ // First, split based on boolean or ||
855
+ this.raw = range;
856
+ this.set = range
857
+ .split(/\s*\|\|\s*/)
858
+ // map the range to a 2d array of comparators
859
+ .map(range => this.parseRange(range.trim()))
860
+ // throw out any comparator lists that are empty
861
+ // this generally means that it was not a valid range, which is allowed
862
+ // in loose mode, but will still throw if the WHOLE range is invalid.
863
+ .filter(c => c.length);
864
+
865
+ if (!this.set.length) {
866
+ throw new TypeError(`Invalid SemVer Range: ${range}`)
867
+ }
868
+
869
+ // if we have any that are not the null set, throw out null sets.
870
+ if (this.set.length > 1) {
871
+ // keep the first one, in case they're all null sets
872
+ const first = this.set[0];
873
+ this.set = this.set.filter(c => !isNullSet(c[0]));
874
+ if (this.set.length === 0)
875
+ this.set = [first];
876
+ else if (this.set.length > 1) {
877
+ // if we have any that are *, then the range is just *
878
+ for (const c of this.set) {
879
+ if (c.length === 1 && isAny(c[0])) {
880
+ this.set = [c];
881
+ break
882
+ }
883
+ }
884
+ }
885
+ }
886
+
887
+ this.format();
888
+ }
889
+
890
+ format () {
891
+ this.range = this.set
892
+ .map((comps) => {
893
+ return comps.join(' ').trim()
894
+ })
895
+ .join('||')
896
+ .trim();
897
+ return this.range
898
+ }
899
+
900
+ toString () {
901
+ return this.range
902
+ }
903
+
904
+ parseRange (range) {
905
+ range = range.trim();
906
+
907
+ // memoize range parsing for performance.
908
+ // this is a very hot path, and fully deterministic.
909
+ const memoOpts = Object.keys(this.options).join(',');
910
+ const memoKey = `parseRange:${memoOpts}:${range}`;
911
+ const cached = cache.get(memoKey);
912
+ if (cached)
913
+ return cached
914
+
915
+ const loose = this.options.loose;
916
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
917
+ const hr = loose ? re$1[t$1.HYPHENRANGELOOSE] : re$1[t$1.HYPHENRANGE];
918
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
919
+ debug$1('hyphen replace', range);
920
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
921
+ range = range.replace(re$1[t$1.COMPARATORTRIM], comparatorTrimReplace);
922
+ debug$1('comparator trim', range, re$1[t$1.COMPARATORTRIM]);
923
+
924
+ // `~ 1.2.3` => `~1.2.3`
925
+ range = range.replace(re$1[t$1.TILDETRIM], tildeTrimReplace);
926
+
927
+ // `^ 1.2.3` => `^1.2.3`
928
+ range = range.replace(re$1[t$1.CARETTRIM], caretTrimReplace);
929
+
930
+ // normalize spaces
931
+ range = range.split(/\s+/).join(' ');
932
+
933
+ // At this point, the range is completely trimmed and
934
+ // ready to be split into comparators.
935
+
936
+ const compRe = loose ? re$1[t$1.COMPARATORLOOSE] : re$1[t$1.COMPARATOR];
937
+ const rangeList = range
938
+ .split(' ')
939
+ .map(comp => parseComparator(comp, this.options))
940
+ .join(' ')
941
+ .split(/\s+/)
942
+ // >=0.0.0 is equivalent to *
943
+ .map(comp => replaceGTE0(comp, this.options))
944
+ // in loose mode, throw out any that are not valid comparators
945
+ .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
946
+ .map(comp => new Comparator$3(comp, this.options));
947
+
948
+ // if any comparators are the null set, then replace with JUST null set
949
+ // if more than one comparator, remove any * comparators
950
+ // also, don't include the same comparator more than once
951
+ rangeList.length;
952
+ const rangeMap = new Map();
953
+ for (const comp of rangeList) {
954
+ if (isNullSet(comp))
955
+ return [comp]
956
+ rangeMap.set(comp.value, comp);
957
+ }
958
+ if (rangeMap.size > 1 && rangeMap.has(''))
959
+ rangeMap.delete('');
960
+
961
+ const result = [...rangeMap.values()];
962
+ cache.set(memoKey, result);
963
+ return result
964
+ }
965
+
966
+ intersects (range, options) {
967
+ if (!(range instanceof Range$a)) {
968
+ throw new TypeError('a Range is required')
969
+ }
970
+
971
+ return this.set.some((thisComparators) => {
972
+ return (
973
+ isSatisfiable(thisComparators, options) &&
974
+ range.set.some((rangeComparators) => {
975
+ return (
976
+ isSatisfiable(rangeComparators, options) &&
977
+ thisComparators.every((thisComparator) => {
978
+ return rangeComparators.every((rangeComparator) => {
979
+ return thisComparator.intersects(rangeComparator, options)
980
+ })
981
+ })
982
+ )
983
+ })
984
+ )
985
+ })
986
+ }
987
+
988
+ // if ANY of the sets match ALL of its comparators, then pass
989
+ test (version) {
990
+ if (!version) {
991
+ return false
992
+ }
993
+
994
+ if (typeof version === 'string') {
995
+ try {
996
+ version = new SemVer$5(version, this.options);
997
+ } catch (er) {
998
+ return false
999
+ }
1000
+ }
1001
+
1002
+ for (let i = 0; i < this.set.length; i++) {
1003
+ if (testSet(this.set[i], version, this.options)) {
1004
+ return true
1005
+ }
1006
+ }
1007
+ return false
1008
+ }
1009
+ }
1010
+ var range = Range$a;
1011
+
1012
+ const LRU = lruCache;
1013
+ const cache = new LRU({ max: 1000 });
1014
+
1015
+ const parseOptions$1 = parseOptions_1;
1016
+ const Comparator$3 = comparator;
1017
+ const debug$1 = debug_1;
1018
+ const SemVer$5 = semver$1;
1019
+ const {
1020
+ re: re$1,
1021
+ t: t$1,
1022
+ comparatorTrimReplace,
1023
+ tildeTrimReplace,
1024
+ caretTrimReplace
1025
+ } = re$5.exports;
1026
+
1027
+ const isNullSet = c => c.value === '<0.0.0-0';
1028
+ const isAny = c => c.value === '';
1029
+
1030
+ // take a set of comparators and determine whether there
1031
+ // exists a version which can satisfy it
1032
+ const isSatisfiable = (comparators, options) => {
1033
+ let result = true;
1034
+ const remainingComparators = comparators.slice();
1035
+ let testComparator = remainingComparators.pop();
1036
+
1037
+ while (result && remainingComparators.length) {
1038
+ result = remainingComparators.every((otherComparator) => {
1039
+ return testComparator.intersects(otherComparator, options)
1040
+ });
1041
+
1042
+ testComparator = remainingComparators.pop();
1043
+ }
1044
+
1045
+ return result
1046
+ };
1047
+
1048
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
1049
+ // already replaced the hyphen ranges
1050
+ // turn into a set of JUST comparators.
1051
+ const parseComparator = (comp, options) => {
1052
+ debug$1('comp', comp, options);
1053
+ comp = replaceCarets(comp, options);
1054
+ debug$1('caret', comp);
1055
+ comp = replaceTildes(comp, options);
1056
+ debug$1('tildes', comp);
1057
+ comp = replaceXRanges(comp, options);
1058
+ debug$1('xrange', comp);
1059
+ comp = replaceStars(comp, options);
1060
+ debug$1('stars', comp);
1061
+ return comp
1062
+ };
1063
+
1064
+ const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
1065
+
1066
+ // ~, ~> --> * (any, kinda silly)
1067
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
1068
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
1069
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
1070
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
1071
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
1072
+ const replaceTildes = (comp, options) =>
1073
+ comp.trim().split(/\s+/).map((comp) => {
1074
+ return replaceTilde(comp, options)
1075
+ }).join(' ');
1076
+
1077
+ const replaceTilde = (comp, options) => {
1078
+ const r = options.loose ? re$1[t$1.TILDELOOSE] : re$1[t$1.TILDE];
1079
+ return comp.replace(r, (_, M, m, p, pr) => {
1080
+ debug$1('tilde', comp, _, M, m, p, pr);
1081
+ let ret;
1082
+
1083
+ if (isX(M)) {
1084
+ ret = '';
1085
+ } else if (isX(m)) {
1086
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1087
+ } else if (isX(p)) {
1088
+ // ~1.2 == >=1.2.0 <1.3.0-0
1089
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1090
+ } else if (pr) {
1091
+ debug$1('replaceTilde pr', pr);
1092
+ ret = `>=${M}.${m}.${p}-${pr
1093
+ } <${M}.${+m + 1}.0-0`;
1094
+ } else {
1095
+ // ~1.2.3 == >=1.2.3 <1.3.0-0
1096
+ ret = `>=${M}.${m}.${p
1097
+ } <${M}.${+m + 1}.0-0`;
1098
+ }
1099
+
1100
+ debug$1('tilde return', ret);
1101
+ return ret
1102
+ })
1103
+ };
1104
+
1105
+ // ^ --> * (any, kinda silly)
1106
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
1107
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
1108
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
1109
+ // ^1.2.3 --> >=1.2.3 <2.0.0-0
1110
+ // ^1.2.0 --> >=1.2.0 <2.0.0-0
1111
+ const replaceCarets = (comp, options) =>
1112
+ comp.trim().split(/\s+/).map((comp) => {
1113
+ return replaceCaret(comp, options)
1114
+ }).join(' ');
1115
+
1116
+ const replaceCaret = (comp, options) => {
1117
+ debug$1('caret', comp, options);
1118
+ const r = options.loose ? re$1[t$1.CARETLOOSE] : re$1[t$1.CARET];
1119
+ const z = options.includePrerelease ? '-0' : '';
1120
+ return comp.replace(r, (_, M, m, p, pr) => {
1121
+ debug$1('caret', comp, _, M, m, p, pr);
1122
+ let ret;
1123
+
1124
+ if (isX(M)) {
1125
+ ret = '';
1126
+ } else if (isX(m)) {
1127
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1128
+ } else if (isX(p)) {
1129
+ if (M === '0') {
1130
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1131
+ } else {
1132
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1133
+ }
1134
+ } else if (pr) {
1135
+ debug$1('replaceCaret pr', pr);
1136
+ if (M === '0') {
1137
+ if (m === '0') {
1138
+ ret = `>=${M}.${m}.${p}-${pr
1139
+ } <${M}.${m}.${+p + 1}-0`;
1140
+ } else {
1141
+ ret = `>=${M}.${m}.${p}-${pr
1142
+ } <${M}.${+m + 1}.0-0`;
1143
+ }
1144
+ } else {
1145
+ ret = `>=${M}.${m}.${p}-${pr
1146
+ } <${+M + 1}.0.0-0`;
1147
+ }
1148
+ } else {
1149
+ debug$1('no pr');
1150
+ if (M === '0') {
1151
+ if (m === '0') {
1152
+ ret = `>=${M}.${m}.${p
1153
+ }${z} <${M}.${m}.${+p + 1}-0`;
1154
+ } else {
1155
+ ret = `>=${M}.${m}.${p
1156
+ }${z} <${M}.${+m + 1}.0-0`;
1157
+ }
1158
+ } else {
1159
+ ret = `>=${M}.${m}.${p
1160
+ } <${+M + 1}.0.0-0`;
1161
+ }
1162
+ }
1163
+
1164
+ debug$1('caret return', ret);
1165
+ return ret
1166
+ })
1167
+ };
1168
+
1169
+ const replaceXRanges = (comp, options) => {
1170
+ debug$1('replaceXRanges', comp, options);
1171
+ return comp.split(/\s+/).map((comp) => {
1172
+ return replaceXRange(comp, options)
1173
+ }).join(' ')
1174
+ };
1175
+
1176
+ const replaceXRange = (comp, options) => {
1177
+ comp = comp.trim();
1178
+ const r = options.loose ? re$1[t$1.XRANGELOOSE] : re$1[t$1.XRANGE];
1179
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1180
+ debug$1('xRange', comp, ret, gtlt, M, m, p, pr);
1181
+ const xM = isX(M);
1182
+ const xm = xM || isX(m);
1183
+ const xp = xm || isX(p);
1184
+ const anyX = xp;
1185
+
1186
+ if (gtlt === '=' && anyX) {
1187
+ gtlt = '';
1188
+ }
1189
+
1190
+ // if we're including prereleases in the match, then we need
1191
+ // to fix this to -0, the lowest possible prerelease value
1192
+ pr = options.includePrerelease ? '-0' : '';
1193
+
1194
+ if (xM) {
1195
+ if (gtlt === '>' || gtlt === '<') {
1196
+ // nothing is allowed
1197
+ ret = '<0.0.0-0';
1198
+ } else {
1199
+ // nothing is forbidden
1200
+ ret = '*';
1201
+ }
1202
+ } else if (gtlt && anyX) {
1203
+ // we know patch is an x, because we have any x at all.
1204
+ // replace X with 0
1205
+ if (xm) {
1206
+ m = 0;
1207
+ }
1208
+ p = 0;
1209
+
1210
+ if (gtlt === '>') {
1211
+ // >1 => >=2.0.0
1212
+ // >1.2 => >=1.3.0
1213
+ gtlt = '>=';
1214
+ if (xm) {
1215
+ M = +M + 1;
1216
+ m = 0;
1217
+ p = 0;
1218
+ } else {
1219
+ m = +m + 1;
1220
+ p = 0;
1221
+ }
1222
+ } else if (gtlt === '<=') {
1223
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
1224
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
1225
+ gtlt = '<';
1226
+ if (xm) {
1227
+ M = +M + 1;
1228
+ } else {
1229
+ m = +m + 1;
1230
+ }
1231
+ }
1232
+
1233
+ if (gtlt === '<')
1234
+ pr = '-0';
1235
+
1236
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1237
+ } else if (xm) {
1238
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1239
+ } else if (xp) {
1240
+ ret = `>=${M}.${m}.0${pr
1241
+ } <${M}.${+m + 1}.0-0`;
1242
+ }
1243
+
1244
+ debug$1('xRange return', ret);
1245
+
1246
+ return ret
1247
+ })
1248
+ };
1249
+
1250
+ // Because * is AND-ed with everything else in the comparator,
1251
+ // and '' means "any version", just remove the *s entirely.
1252
+ const replaceStars = (comp, options) => {
1253
+ debug$1('replaceStars', comp, options);
1254
+ // Looseness is ignored here. star is always as loose as it gets!
1255
+ return comp.trim().replace(re$1[t$1.STAR], '')
1256
+ };
1257
+
1258
+ const replaceGTE0 = (comp, options) => {
1259
+ debug$1('replaceGTE0', comp, options);
1260
+ return comp.trim()
1261
+ .replace(re$1[options.includePrerelease ? t$1.GTE0PRE : t$1.GTE0], '')
1262
+ };
1263
+
1264
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
1265
+ // M, m, patch, prerelease, build
1266
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1267
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
1268
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
1269
+ const hyphenReplace = incPr => ($0,
1270
+ from, fM, fm, fp, fpr, fb,
1271
+ to, tM, tm, tp, tpr, tb) => {
1272
+ if (isX(fM)) {
1273
+ from = '';
1274
+ } else if (isX(fm)) {
1275
+ from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
1276
+ } else if (isX(fp)) {
1277
+ from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
1278
+ } else if (fpr) {
1279
+ from = `>=${from}`;
1280
+ } else {
1281
+ from = `>=${from}${incPr ? '-0' : ''}`;
1282
+ }
1283
+
1284
+ if (isX(tM)) {
1285
+ to = '';
1286
+ } else if (isX(tm)) {
1287
+ to = `<${+tM + 1}.0.0-0`;
1288
+ } else if (isX(tp)) {
1289
+ to = `<${tM}.${+tm + 1}.0-0`;
1290
+ } else if (tpr) {
1291
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1292
+ } else if (incPr) {
1293
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1294
+ } else {
1295
+ to = `<=${to}`;
1296
+ }
1297
+
1298
+ return (`${from} ${to}`).trim()
1299
+ };
1300
+
1301
+ const testSet = (set, version, options) => {
1302
+ for (let i = 0; i < set.length; i++) {
1303
+ if (!set[i].test(version)) {
1304
+ return false
1305
+ }
1306
+ }
1307
+
1308
+ if (version.prerelease.length && !options.includePrerelease) {
1309
+ // Find the set of versions that are allowed to have prereleases
1310
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1311
+ // That should allow `1.2.3-pr.2` to pass.
1312
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
1313
+ // even though it's within the range set by the comparators.
1314
+ for (let i = 0; i < set.length; i++) {
1315
+ debug$1(set[i].semver);
1316
+ if (set[i].semver === Comparator$3.ANY) {
1317
+ continue
1318
+ }
1319
+
1320
+ if (set[i].semver.prerelease.length > 0) {
1321
+ const allowed = set[i].semver;
1322
+ if (allowed.major === version.major &&
1323
+ allowed.minor === version.minor &&
1324
+ allowed.patch === version.patch) {
1325
+ return true
1326
+ }
1327
+ }
1328
+ }
1329
+
1330
+ // Version has a -pre, but it's not one of the ones we like.
1331
+ return false
1332
+ }
1333
+
1334
+ return true
1335
+ };
1336
+
1337
+ const ANY$2 = Symbol('SemVer ANY');
1338
+ // hoisted class for cyclic dependency
1339
+ class Comparator$2 {
1340
+ static get ANY () {
1341
+ return ANY$2
1342
+ }
1343
+ constructor (comp, options) {
1344
+ options = parseOptions(options);
1345
+
1346
+ if (comp instanceof Comparator$2) {
1347
+ if (comp.loose === !!options.loose) {
1348
+ return comp
1349
+ } else {
1350
+ comp = comp.value;
1351
+ }
1352
+ }
1353
+
1354
+ debug('comparator', comp, options);
1355
+ this.options = options;
1356
+ this.loose = !!options.loose;
1357
+ this.parse(comp);
1358
+
1359
+ if (this.semver === ANY$2) {
1360
+ this.value = '';
1361
+ } else {
1362
+ this.value = this.operator + this.semver.version;
1363
+ }
1364
+
1365
+ debug('comp', this);
1366
+ }
1367
+
1368
+ parse (comp) {
1369
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1370
+ const m = comp.match(r);
1371
+
1372
+ if (!m) {
1373
+ throw new TypeError(`Invalid comparator: ${comp}`)
1374
+ }
1375
+
1376
+ this.operator = m[1] !== undefined ? m[1] : '';
1377
+ if (this.operator === '=') {
1378
+ this.operator = '';
1379
+ }
1380
+
1381
+ // if it literally is just '>' or '' then allow anything.
1382
+ if (!m[2]) {
1383
+ this.semver = ANY$2;
1384
+ } else {
1385
+ this.semver = new SemVer$4(m[2], this.options.loose);
1386
+ }
1387
+ }
1388
+
1389
+ toString () {
1390
+ return this.value
1391
+ }
1392
+
1393
+ test (version) {
1394
+ debug('Comparator.test', version, this.options.loose);
1395
+
1396
+ if (this.semver === ANY$2 || version === ANY$2) {
1397
+ return true
1398
+ }
1399
+
1400
+ if (typeof version === 'string') {
1401
+ try {
1402
+ version = new SemVer$4(version, this.options);
1403
+ } catch (er) {
1404
+ return false
1405
+ }
1406
+ }
1407
+
1408
+ return cmp(version, this.operator, this.semver, this.options)
1409
+ }
1410
+
1411
+ intersects (comp, options) {
1412
+ if (!(comp instanceof Comparator$2)) {
1413
+ throw new TypeError('a Comparator is required')
1414
+ }
1415
+
1416
+ if (!options || typeof options !== 'object') {
1417
+ options = {
1418
+ loose: !!options,
1419
+ includePrerelease: false
1420
+ };
1421
+ }
1422
+
1423
+ if (this.operator === '') {
1424
+ if (this.value === '') {
1425
+ return true
1426
+ }
1427
+ return new Range$9(comp.value, options).test(this.value)
1428
+ } else if (comp.operator === '') {
1429
+ if (comp.value === '') {
1430
+ return true
1431
+ }
1432
+ return new Range$9(this.value, options).test(comp.semver)
1433
+ }
1434
+
1435
+ const sameDirectionIncreasing =
1436
+ (this.operator === '>=' || this.operator === '>') &&
1437
+ (comp.operator === '>=' || comp.operator === '>');
1438
+ const sameDirectionDecreasing =
1439
+ (this.operator === '<=' || this.operator === '<') &&
1440
+ (comp.operator === '<=' || comp.operator === '<');
1441
+ const sameSemVer = this.semver.version === comp.semver.version;
1442
+ const differentDirectionsInclusive =
1443
+ (this.operator === '>=' || this.operator === '<=') &&
1444
+ (comp.operator === '>=' || comp.operator === '<=');
1445
+ const oppositeDirectionsLessThan =
1446
+ cmp(this.semver, '<', comp.semver, options) &&
1447
+ (this.operator === '>=' || this.operator === '>') &&
1448
+ (comp.operator === '<=' || comp.operator === '<');
1449
+ const oppositeDirectionsGreaterThan =
1450
+ cmp(this.semver, '>', comp.semver, options) &&
1451
+ (this.operator === '<=' || this.operator === '<') &&
1452
+ (comp.operator === '>=' || comp.operator === '>');
1453
+
1454
+ return (
1455
+ sameDirectionIncreasing ||
1456
+ sameDirectionDecreasing ||
1457
+ (sameSemVer && differentDirectionsInclusive) ||
1458
+ oppositeDirectionsLessThan ||
1459
+ oppositeDirectionsGreaterThan
1460
+ )
1461
+ }
1462
+ }
1463
+
1464
+ var comparator = Comparator$2;
1465
+
1466
+ const parseOptions = parseOptions_1;
1467
+ const {re, t} = re$5.exports;
1468
+ const cmp = cmp_1;
1469
+ const debug = debug_1;
1470
+ const SemVer$4 = semver$1;
1471
+ const Range$9 = range;
1472
+
1473
+ const Range$8 = range;
1474
+ const satisfies$3 = (version, range, options) => {
1475
+ try {
1476
+ range = new Range$8(range, options);
1477
+ } catch (er) {
1478
+ return false
1479
+ }
1480
+ return range.test(version)
1481
+ };
1482
+ var satisfies_1 = satisfies$3;
1483
+
1484
+ const Range$7 = range;
1485
+
1486
+ // Mostly just for testing and legacy API reasons
1487
+ const toComparators = (range, options) =>
1488
+ new Range$7(range, options).set
1489
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
1490
+
1491
+ var toComparators_1 = toComparators;
1492
+
1493
+ const SemVer$3 = semver$1;
1494
+ const Range$6 = range;
1495
+
1496
+ const maxSatisfying = (versions, range, options) => {
1497
+ let max = null;
1498
+ let maxSV = null;
1499
+ let rangeObj = null;
1500
+ try {
1501
+ rangeObj = new Range$6(range, options);
1502
+ } catch (er) {
1503
+ return null
1504
+ }
1505
+ versions.forEach((v) => {
1506
+ if (rangeObj.test(v)) {
1507
+ // satisfies(v, range, options)
1508
+ if (!max || maxSV.compare(v) === -1) {
1509
+ // compare(max, v, true)
1510
+ max = v;
1511
+ maxSV = new SemVer$3(max, options);
1512
+ }
1513
+ }
1514
+ });
1515
+ return max
1516
+ };
1517
+ var maxSatisfying_1 = maxSatisfying;
1518
+
1519
+ const SemVer$2 = semver$1;
1520
+ const Range$5 = range;
1521
+ const minSatisfying = (versions, range, options) => {
1522
+ let min = null;
1523
+ let minSV = null;
1524
+ let rangeObj = null;
1525
+ try {
1526
+ rangeObj = new Range$5(range, options);
1527
+ } catch (er) {
1528
+ return null
1529
+ }
1530
+ versions.forEach((v) => {
1531
+ if (rangeObj.test(v)) {
1532
+ // satisfies(v, range, options)
1533
+ if (!min || minSV.compare(v) === 1) {
1534
+ // compare(min, v, true)
1535
+ min = v;
1536
+ minSV = new SemVer$2(min, options);
1537
+ }
1538
+ }
1539
+ });
1540
+ return min
1541
+ };
1542
+ var minSatisfying_1 = minSatisfying;
1543
+
1544
+ const SemVer$1 = semver$1;
1545
+ const Range$4 = range;
1546
+ const gt$1 = gt_1;
1547
+
1548
+ const minVersion = (range, loose) => {
1549
+ range = new Range$4(range, loose);
1550
+
1551
+ let minver = new SemVer$1('0.0.0');
1552
+ if (range.test(minver)) {
1553
+ return minver
1554
+ }
1555
+
1556
+ minver = new SemVer$1('0.0.0-0');
1557
+ if (range.test(minver)) {
1558
+ return minver
1559
+ }
1560
+
1561
+ minver = null;
1562
+ for (let i = 0; i < range.set.length; ++i) {
1563
+ const comparators = range.set[i];
1564
+
1565
+ let setMin = null;
1566
+ comparators.forEach((comparator) => {
1567
+ // Clone to avoid manipulating the comparator's semver object.
1568
+ const compver = new SemVer$1(comparator.semver.version);
1569
+ switch (comparator.operator) {
1570
+ case '>':
1571
+ if (compver.prerelease.length === 0) {
1572
+ compver.patch++;
1573
+ } else {
1574
+ compver.prerelease.push(0);
1575
+ }
1576
+ compver.raw = compver.format();
1577
+ /* fallthrough */
1578
+ case '':
1579
+ case '>=':
1580
+ if (!setMin || gt$1(compver, setMin)) {
1581
+ setMin = compver;
1582
+ }
1583
+ break
1584
+ case '<':
1585
+ case '<=':
1586
+ /* Ignore maximum versions */
1587
+ break
1588
+ /* istanbul ignore next */
1589
+ default:
1590
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
1591
+ }
1592
+ });
1593
+ if (setMin && (!minver || gt$1(minver, setMin)))
1594
+ minver = setMin;
1595
+ }
1596
+
1597
+ if (minver && range.test(minver)) {
1598
+ return minver
1599
+ }
1600
+
1601
+ return null
1602
+ };
1603
+ var minVersion_1 = minVersion;
1604
+
1605
+ const Range$3 = range;
1606
+ const validRange = (range, options) => {
1607
+ try {
1608
+ // Return '*' instead of '' so that truthiness works.
1609
+ // This will throw if it's invalid anyway
1610
+ return new Range$3(range, options).range || '*'
1611
+ } catch (er) {
1612
+ return null
1613
+ }
1614
+ };
1615
+ var valid = validRange;
1616
+
1617
+ const SemVer = semver$1;
1618
+ const Comparator$1 = comparator;
1619
+ const {ANY: ANY$1} = Comparator$1;
1620
+ const Range$2 = range;
1621
+ const satisfies$2 = satisfies_1;
1622
+ const gt = gt_1;
1623
+ const lt = lt_1;
1624
+ const lte = lte_1;
1625
+ const gte = gte_1;
1626
+
1627
+ const outside$2 = (version, range, hilo, options) => {
1628
+ version = new SemVer(version, options);
1629
+ range = new Range$2(range, options);
1630
+
1631
+ let gtfn, ltefn, ltfn, comp, ecomp;
1632
+ switch (hilo) {
1633
+ case '>':
1634
+ gtfn = gt;
1635
+ ltefn = lte;
1636
+ ltfn = lt;
1637
+ comp = '>';
1638
+ ecomp = '>=';
1639
+ break
1640
+ case '<':
1641
+ gtfn = lt;
1642
+ ltefn = gte;
1643
+ ltfn = gt;
1644
+ comp = '<';
1645
+ ecomp = '<=';
1646
+ break
1647
+ default:
1648
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
1649
+ }
1650
+
1651
+ // If it satisfies the range it is not outside
1652
+ if (satisfies$2(version, range, options)) {
1653
+ return false
1654
+ }
1655
+
1656
+ // From now on, variable terms are as if we're in "gtr" mode.
1657
+ // but note that everything is flipped for the "ltr" function.
1658
+
1659
+ for (let i = 0; i < range.set.length; ++i) {
1660
+ const comparators = range.set[i];
1661
+
1662
+ let high = null;
1663
+ let low = null;
1664
+
1665
+ comparators.forEach((comparator) => {
1666
+ if (comparator.semver === ANY$1) {
1667
+ comparator = new Comparator$1('>=0.0.0');
1668
+ }
1669
+ high = high || comparator;
1670
+ low = low || comparator;
1671
+ if (gtfn(comparator.semver, high.semver, options)) {
1672
+ high = comparator;
1673
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1674
+ low = comparator;
1675
+ }
1676
+ });
1677
+
1678
+ // If the edge version comparator has a operator then our version
1679
+ // isn't outside it
1680
+ if (high.operator === comp || high.operator === ecomp) {
1681
+ return false
1682
+ }
1683
+
1684
+ // If the lowest version comparator has an operator and our version
1685
+ // is less than it then it isn't higher than the range
1686
+ if ((!low.operator || low.operator === comp) &&
1687
+ ltefn(version, low.semver)) {
1688
+ return false
1689
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1690
+ return false
1691
+ }
1692
+ }
1693
+ return true
1694
+ };
1695
+
1696
+ var outside_1 = outside$2;
1697
+
1698
+ // Determine if version is greater than all the versions possible in the range.
1699
+ const outside$1 = outside_1;
1700
+ const gtr = (version, range, options) => outside$1(version, range, '>', options);
1701
+ var gtr_1 = gtr;
1702
+
1703
+ const outside = outside_1;
1704
+ // Determine if version is less than all the versions possible in the range
1705
+ const ltr = (version, range, options) => outside(version, range, '<', options);
1706
+ var ltr_1 = ltr;
1707
+
1708
+ const Range$1 = range;
1709
+ const intersects = (r1, r2, options) => {
1710
+ r1 = new Range$1(r1, options);
1711
+ r2 = new Range$1(r2, options);
1712
+ return r1.intersects(r2)
1713
+ };
1714
+ var intersects_1 = intersects;
1715
+
1716
+ // given a set of versions and a range, create a "simplified" range
1717
+ // that includes the same versions that the original range does
1718
+ // If the original range is shorter than the simplified one, return that.
1719
+ const satisfies$1 = satisfies_1;
1720
+ const compare$1 = compare_1;
1721
+ var simplify = (versions, range, options) => {
1722
+ const set = [];
1723
+ let min = null;
1724
+ let prev = null;
1725
+ const v = versions.sort((a, b) => compare$1(a, b, options));
1726
+ for (const version of v) {
1727
+ const included = satisfies$1(version, range, options);
1728
+ if (included) {
1729
+ prev = version;
1730
+ if (!min)
1731
+ min = version;
1732
+ } else {
1733
+ if (prev) {
1734
+ set.push([min, prev]);
1735
+ }
1736
+ prev = null;
1737
+ min = null;
1738
+ }
1739
+ }
1740
+ if (min)
1741
+ set.push([min, null]);
1742
+
1743
+ const ranges = [];
1744
+ for (const [min, max] of set) {
1745
+ if (min === max)
1746
+ ranges.push(min);
1747
+ else if (!max && min === v[0])
1748
+ ranges.push('*');
1749
+ else if (!max)
1750
+ ranges.push(`>=${min}`);
1751
+ else if (min === v[0])
1752
+ ranges.push(`<=${max}`);
1753
+ else
1754
+ ranges.push(`${min} - ${max}`);
1755
+ }
1756
+ const simplified = ranges.join(' || ');
1757
+ const original = typeof range.raw === 'string' ? range.raw : String(range);
1758
+ return simplified.length < original.length ? simplified : range
1759
+ };
1760
+
1761
+ const Range = range;
1762
+ const Comparator = comparator;
1763
+ const { ANY } = Comparator;
1764
+ const satisfies = satisfies_1;
1765
+ const compare = compare_1;
1766
+
1767
+ // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
1768
+ // - Every simple range `r1, r2, ...` is a null set, OR
1769
+ // - Every simple range `r1, r2, ...` which is not a null set is a subset of
1770
+ // some `R1, R2, ...`
1771
+ //
1772
+ // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
1773
+ // - If c is only the ANY comparator
1774
+ // - If C is only the ANY comparator, return true
1775
+ // - Else if in prerelease mode, return false
1776
+ // - else replace c with `[>=0.0.0]`
1777
+ // - If C is only the ANY comparator
1778
+ // - if in prerelease mode, return true
1779
+ // - else replace C with `[>=0.0.0]`
1780
+ // - Let EQ be the set of = comparators in c
1781
+ // - If EQ is more than one, return true (null set)
1782
+ // - Let GT be the highest > or >= comparator in c
1783
+ // - Let LT be the lowest < or <= comparator in c
1784
+ // - If GT and LT, and GT.semver > LT.semver, return true (null set)
1785
+ // - If any C is a = range, and GT or LT are set, return false
1786
+ // - If EQ
1787
+ // - If GT, and EQ does not satisfy GT, return true (null set)
1788
+ // - If LT, and EQ does not satisfy LT, return true (null set)
1789
+ // - If EQ satisfies every C, return true
1790
+ // - Else return false
1791
+ // - If GT
1792
+ // - If GT.semver is lower than any > or >= comp in C, return false
1793
+ // - If GT is >=, and GT.semver does not satisfy every C, return false
1794
+ // - If GT.semver has a prerelease, and not in prerelease mode
1795
+ // - If no C has a prerelease and the GT.semver tuple, return false
1796
+ // - If LT
1797
+ // - If LT.semver is greater than any < or <= comp in C, return false
1798
+ // - If LT is <=, and LT.semver does not satisfy every C, return false
1799
+ // - If GT.semver has a prerelease, and not in prerelease mode
1800
+ // - If no C has a prerelease and the LT.semver tuple, return false
1801
+ // - Else return true
1802
+
1803
+ const subset = (sub, dom, options = {}) => {
1804
+ if (sub === dom)
1805
+ return true
1806
+
1807
+ sub = new Range(sub, options);
1808
+ dom = new Range(dom, options);
1809
+ let sawNonNull = false;
1810
+
1811
+ OUTER: for (const simpleSub of sub.set) {
1812
+ for (const simpleDom of dom.set) {
1813
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1814
+ sawNonNull = sawNonNull || isSub !== null;
1815
+ if (isSub)
1816
+ continue OUTER
1817
+ }
1818
+ // the null set is a subset of everything, but null simple ranges in
1819
+ // a complex range should be ignored. so if we saw a non-null range,
1820
+ // then we know this isn't a subset, but if EVERY simple range was null,
1821
+ // then it is a subset.
1822
+ if (sawNonNull)
1823
+ return false
1824
+ }
1825
+ return true
1826
+ };
1827
+
1828
+ const simpleSubset = (sub, dom, options) => {
1829
+ if (sub === dom)
1830
+ return true
1831
+
1832
+ if (sub.length === 1 && sub[0].semver === ANY) {
1833
+ if (dom.length === 1 && dom[0].semver === ANY)
1834
+ return true
1835
+ else if (options.includePrerelease)
1836
+ sub = [ new Comparator('>=0.0.0-0') ];
1837
+ else
1838
+ sub = [ new Comparator('>=0.0.0') ];
1839
+ }
1840
+
1841
+ if (dom.length === 1 && dom[0].semver === ANY) {
1842
+ if (options.includePrerelease)
1843
+ return true
1844
+ else
1845
+ dom = [ new Comparator('>=0.0.0') ];
1846
+ }
1847
+
1848
+ const eqSet = new Set();
1849
+ let gt, lt;
1850
+ for (const c of sub) {
1851
+ if (c.operator === '>' || c.operator === '>=')
1852
+ gt = higherGT(gt, c, options);
1853
+ else if (c.operator === '<' || c.operator === '<=')
1854
+ lt = lowerLT(lt, c, options);
1855
+ else
1856
+ eqSet.add(c.semver);
1857
+ }
1858
+
1859
+ if (eqSet.size > 1)
1860
+ return null
1861
+
1862
+ let gtltComp;
1863
+ if (gt && lt) {
1864
+ gtltComp = compare(gt.semver, lt.semver, options);
1865
+ if (gtltComp > 0)
1866
+ return null
1867
+ else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<='))
1868
+ return null
1869
+ }
1870
+
1871
+ // will iterate one or zero times
1872
+ for (const eq of eqSet) {
1873
+ if (gt && !satisfies(eq, String(gt), options))
1874
+ return null
1875
+
1876
+ if (lt && !satisfies(eq, String(lt), options))
1877
+ return null
1878
+
1879
+ for (const c of dom) {
1880
+ if (!satisfies(eq, String(c), options))
1881
+ return false
1882
+ }
1883
+
1884
+ return true
1885
+ }
1886
+
1887
+ let higher, lower;
1888
+ let hasDomLT, hasDomGT;
1889
+ // if the subset has a prerelease, we need a comparator in the superset
1890
+ // with the same tuple and a prerelease, or it's not a subset
1891
+ let needDomLTPre = lt &&
1892
+ !options.includePrerelease &&
1893
+ lt.semver.prerelease.length ? lt.semver : false;
1894
+ let needDomGTPre = gt &&
1895
+ !options.includePrerelease &&
1896
+ gt.semver.prerelease.length ? gt.semver : false;
1897
+ // exception: <1.2.3-0 is the same as <1.2.3
1898
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
1899
+ lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
1900
+ needDomLTPre = false;
1901
+ }
1902
+
1903
+ for (const c of dom) {
1904
+ hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
1905
+ hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
1906
+ if (gt) {
1907
+ if (needDomGTPre) {
1908
+ if (c.semver.prerelease && c.semver.prerelease.length &&
1909
+ c.semver.major === needDomGTPre.major &&
1910
+ c.semver.minor === needDomGTPre.minor &&
1911
+ c.semver.patch === needDomGTPre.patch) {
1912
+ needDomGTPre = false;
1913
+ }
1914
+ }
1915
+ if (c.operator === '>' || c.operator === '>=') {
1916
+ higher = higherGT(gt, c, options);
1917
+ if (higher === c && higher !== gt)
1918
+ return false
1919
+ } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options))
1920
+ return false
1921
+ }
1922
+ if (lt) {
1923
+ if (needDomLTPre) {
1924
+ if (c.semver.prerelease && c.semver.prerelease.length &&
1925
+ c.semver.major === needDomLTPre.major &&
1926
+ c.semver.minor === needDomLTPre.minor &&
1927
+ c.semver.patch === needDomLTPre.patch) {
1928
+ needDomLTPre = false;
1929
+ }
1930
+ }
1931
+ if (c.operator === '<' || c.operator === '<=') {
1932
+ lower = lowerLT(lt, c, options);
1933
+ if (lower === c && lower !== lt)
1934
+ return false
1935
+ } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options))
1936
+ return false
1937
+ }
1938
+ if (!c.operator && (lt || gt) && gtltComp !== 0)
1939
+ return false
1940
+ }
1941
+
1942
+ // if there was a < or >, and nothing in the dom, then must be false
1943
+ // UNLESS it was limited by another range in the other direction.
1944
+ // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
1945
+ if (gt && hasDomLT && !lt && gtltComp !== 0)
1946
+ return false
1947
+
1948
+ if (lt && hasDomGT && !gt && gtltComp !== 0)
1949
+ return false
1950
+
1951
+ // we needed a prerelease range in a specific tuple, but didn't get one
1952
+ // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
1953
+ // because it includes prereleases in the 1.2.3 tuple
1954
+ if (needDomGTPre || needDomLTPre)
1955
+ return false
1956
+
1957
+ return true
1958
+ };
1959
+
1960
+ // >=1.2.3 is lower than >1.2.3
1961
+ const higherGT = (a, b, options) => {
1962
+ if (!a)
1963
+ return b
1964
+ const comp = compare(a.semver, b.semver, options);
1965
+ return comp > 0 ? a
1966
+ : comp < 0 ? b
1967
+ : b.operator === '>' && a.operator === '>=' ? b
1968
+ : a
1969
+ };
1970
+
1971
+ // <=1.2.3 is higher than <1.2.3
1972
+ const lowerLT = (a, b, options) => {
1973
+ if (!a)
1974
+ return b
1975
+ const comp = compare(a.semver, b.semver, options);
1976
+ return comp < 0 ? a
1977
+ : comp > 0 ? b
1978
+ : b.operator === '<' && a.operator === '<=' ? b
1979
+ : a
1980
+ };
1981
+
1982
+ var subset_1 = subset;
1983
+
1984
+ // just pre-load all the stuff that index.js lazily exports
1985
+ const internalRe = re$5.exports;
1986
+ var semver = {
1987
+ re: internalRe.re,
1988
+ src: internalRe.src,
1989
+ tokens: internalRe.t,
1990
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
1991
+ SemVer: semver$1,
1992
+ compareIdentifiers: identifiers.compareIdentifiers,
1993
+ rcompareIdentifiers: identifiers.rcompareIdentifiers,
1994
+ parse: parse_1,
1995
+ valid: valid_1,
1996
+ clean: clean_1,
1997
+ inc: inc_1,
1998
+ diff: diff_1,
1999
+ major: major_1,
2000
+ minor: minor_1,
2001
+ patch: patch_1,
2002
+ prerelease: prerelease_1,
2003
+ compare: compare_1,
2004
+ rcompare: rcompare_1,
2005
+ compareLoose: compareLoose_1,
2006
+ compareBuild: compareBuild_1,
2007
+ sort: sort_1,
2008
+ rsort: rsort_1,
2009
+ gt: gt_1,
2010
+ lt: lt_1,
2011
+ eq: eq_1,
2012
+ neq: neq_1,
2013
+ gte: gte_1,
2014
+ lte: lte_1,
2015
+ cmp: cmp_1,
2016
+ coerce: coerce_1,
2017
+ Comparator: comparator,
2018
+ Range: range,
2019
+ satisfies: satisfies_1,
2020
+ toComparators: toComparators_1,
2021
+ maxSatisfying: maxSatisfying_1,
2022
+ minSatisfying: minSatisfying_1,
2023
+ minVersion: minVersion_1,
2024
+ validRange: valid,
2025
+ outside: outside_1,
2026
+ gtr: gtr_1,
2027
+ ltr: ltr_1,
2028
+ intersects: intersects_1,
2029
+ simplifyRange: simplify,
2030
+ subset: subset_1,
2031
+ };
2032
+
2033
+ async function addHydrogen() {
2034
+ this.package.install("@shopify/hydrogen");
2035
+ }
2036
+
2037
+ const HYDROGEN_MIN_VERSION = cliHydrogenPackageJson.version;
2038
+ async function checkHydrogenVersion() {
2039
+ const h2Version = await this.package.hasDependency("@shopify/hydrogen");
2040
+ const normalizedVersion = h2Version ? semver.coerce(h2Version)?.version : `@shopify/hydrogen not installed`;
2041
+ const latestHydrogen = typeof h2Version === "string" && typeof normalizedVersion === "string" && semver.gte(normalizedVersion, HYDROGEN_MIN_VERSION);
2042
+ const success = h2Version === "latest" || latestHydrogen;
2043
+ const description = `Has latest hydrogen version (latest: ${HYDROGEN_MIN_VERSION} / found ${normalizedVersion})`;
2044
+ return [
2045
+ {
2046
+ id: "hydrogen-latest",
2047
+ type: "Dependencies",
2048
+ description,
2049
+ success,
2050
+ fix: addHydrogen
2051
+ }
2052
+ ];
2053
+ }
2054
+
2055
+ const NODE_MIN_VERSION = ">=12.0.0";
2056
+ async function checkNodeVersion() {
2057
+ const nodeVersion = await this.package.nodeVersion();
2058
+ const normalizedVersion = semver.coerce(nodeVersion)?.version;
2059
+ return [
2060
+ {
2061
+ id: "node-version",
2062
+ type: "Dependencies",
2063
+ description: "Has min node version",
2064
+ success: !nodeVersion || normalizedVersion !== void 0 && semver.satisfies(normalizedVersion, NODE_MIN_VERSION),
2065
+ link: "https://shopify.dev/custom-storefronts/hydrogen/support"
2066
+ }
2067
+ ];
2068
+ }
2069
+
2070
+ async function addEslint() {
2071
+ const { fs } = this;
2072
+ await fs.write(".eslintrc.js", (await import('../../eslintrc-js-6f6a13b8.js')).default());
2073
+ this.package.install("eslint", { dev: true, version: "^7.31.0" });
2074
+ this.package.install("eslint-plugin-hydrogen", {
2075
+ dev: true,
2076
+ version: "^0.6.2"
2077
+ });
2078
+ }
2079
+
2080
+ async function checkEslintConfig() {
2081
+ const eslintConfig = await this.workspace.loadConfig("eslint");
2082
+ const hasEslintConfig = Boolean(eslintConfig);
2083
+ const hasHydrogenConfig = hasEslintConfig && Boolean(eslintConfig.config.extends?.filter((extended) => extended.includes("plugin:hydrogen")).length);
2084
+ const hasHydrogenEslintPackage = Boolean(await this.package.hasDependency("eslint-plugin-hydrogen"));
2085
+ return [
2086
+ {
2087
+ id: "eslint-config",
2088
+ type: "Setup",
2089
+ description: "Has eslint config",
2090
+ success: hasEslintConfig,
2091
+ link: "https://shopify.dev/custom-storefronts/hydrogen/lint",
2092
+ fix: addEslint
2093
+ },
2094
+ {
2095
+ id: "eslint-config-hydrogen",
2096
+ type: "Setup",
2097
+ description: "Has hydrogen eslint config",
2098
+ success: hasHydrogenConfig && hasHydrogenEslintPackage,
2099
+ link: "https://shopify.dev/custom-storefronts/hydrogen/lint",
2100
+ fix: addEslint
2101
+ }
2102
+ ];
2103
+ }
2104
+
2105
+ class Check extends Command {
2106
+ async run() {
2107
+ this.interface.say("Running checks...");
2108
+ let results;
2109
+ try {
2110
+ results = [
2111
+ ...await checkNodeVersion.call(this),
2112
+ ...await checkHydrogenVersion.call(this),
2113
+ ...await checkEslintConfig.call(this)
2114
+ ];
2115
+ } catch (error) {
2116
+ throw new HelpfulError({ title: "Error running checks" });
2117
+ }
2118
+ displayCheckResults.call(this, results);
2119
+ const failedChecks = results.filter(({ success }) => !success);
2120
+ if (failedChecks.length) {
2121
+ this.interface.say(`${source.red.bold(`\u2022 ${failedChecks.length} errors `)}${source.dim(`found in ${results.length} checks`)}`);
2122
+ } else {
2123
+ this.interface.say(`${source.green.bold(`\u2022 No errors `)}${source.dim(`found in ${results.length} checks`)}`);
2124
+ }
2125
+ await fixChecks.call(this, results);
2126
+ console.log();
2127
+ }
2128
+ }
2129
+ Check.description = "Check a hydrogen app for common problems.";
2130
+ Check.examples = [`$ shopify hydrogen check`];
2131
+ Check.flags = {
2132
+ ...Command.flags
2133
+ };
2134
+ Check.args = [];
2135
+ function displayCheckResults(allCheckResults) {
2136
+ const indent = " ";
2137
+ const checksBySection = allCheckResults.reduce((acc, { type, ...rest }) => {
2138
+ if (!acc[type]) {
2139
+ acc[type] = [];
2140
+ }
2141
+ acc[type].push({ type, ...rest });
2142
+ return acc;
2143
+ }, {});
2144
+ [...Object.entries(checksBySection)].forEach(([section, sectionResults]) => {
2145
+ const allChecksStatusEmoji = statusEmoji(sectionResults.every(({ success }) => success));
2146
+ console.log();
2147
+ this.interface.say(`${allChecksStatusEmoji} ${source.cyan.bold.underline(section)}`);
2148
+ console.log();
2149
+ sectionResults.forEach(({ description, link, success, fix, id }) => {
2150
+ const docsLink = link ? source.dim(`${indent}${link}
2151
+ `) : "";
2152
+ const idText = id ? source.dim(id) : "";
2153
+ const fixedText = success ? "" : statusFixable(fix);
2154
+ const lines = [
2155
+ [statusEmoji(success), description, idText, fixedText].join(" "),
2156
+ docsLink
2157
+ ];
2158
+ this.interface.say(lines.join("\n"));
2159
+ });
2160
+ });
2161
+ console.log();
2162
+ }
2163
+ async function fixChecks(results) {
2164
+ let changedFiles = /* @__PURE__ */ new Map();
2165
+ const allFixableResults = results.filter(({ fix, success }) => !success && fix !== void 0 && typeof fix === "function");
2166
+ if (allFixableResults.length === 0) {
2167
+ this.interface.say(`No fixable checks`);
2168
+ return;
2169
+ }
2170
+ console.log();
2171
+ console.log();
2172
+ await this.interface.say(`${allFixableResults.length} failed checks might be automatically fixable.`);
2173
+ console.log();
2174
+ const wantsFix = await this.interface.ask(`Do you want to apply automatic fixes to ${allFixableResults.length} failed checks?`, { boolean: true, name: "fix", default: false });
2175
+ if (!wantsFix) {
2176
+ return;
2177
+ }
2178
+ for await (const { description, files } of runFixers(allFixableResults, {
2179
+ fs: this.fs,
2180
+ package: this.package,
2181
+ interface: this.interface
2182
+ })) {
2183
+ this.interface.say([statusEmoji(true), description, source.green("fixed")].join(" "));
2184
+ changedFiles = new Map([...changedFiles, ...files]);
2185
+ }
2186
+ const cleanUpPromises = Array.from(changedFiles).map(async ([path, content]) => {
2187
+ const action = await this.fs.hasFile(path) ? source.red(`{red overwrote`) : source.green(`{green wrote}`);
2188
+ await this.fs.write(path, content);
2189
+ this.interface.say(`${action}${stripPath(path)}`);
2190
+ });
2191
+ await Promise.all(cleanUpPromises);
2192
+ }
2193
+ async function* runFixers(allFixableResults, context) {
2194
+ for (const { fix, description } of allFixableResults) {
2195
+ try {
2196
+ await fix(context);
2197
+ } finally {
2198
+ yield { description, files: [] };
2199
+ }
2200
+ }
2201
+ }
2202
+ function statusEmoji(success) {
2203
+ return success ? "\u2713" : `\u2715`;
2204
+ }
2205
+ function statusFixable(fix) {
2206
+ return typeof fix === "function" ? source.cyan(` (fixable) `) : " ";
2207
+ }
2208
+ function stripPath(path) {
2209
+ return path.replace(`${process.cwd()}`, "");
2210
+ }
2211
+
2212
+ export { Check as default };
2213
+ //# sourceMappingURL=check.js.map