@slicemachine/init 1.1.16-dev-alpha.6 → 1.1.16-dev-ct-slice-delete.3

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/build/index.js CHANGED
@@ -14,7 +14,7 @@ const ora = require('ora');
14
14
  const core = require('@slicemachine/core');
15
15
  const hapi = require('@hapi/hapi');
16
16
  const open = require('open');
17
- const t$5 = require('io-ts');
17
+ const t = require('io-ts');
18
18
  const cookie = require('@slicemachine/core/build/utils/cookie');
19
19
  const fs = require('fs');
20
20
  const NodeUtils = require('@slicemachine/core/build/node-utils');
@@ -60,7 +60,7 @@ const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
60
60
  const ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
61
61
  const hapi__namespace = /*#__PURE__*/_interopNamespace(hapi);
62
62
  const open__default = /*#__PURE__*/_interopDefaultLegacy(open);
63
- const t__namespace = /*#__PURE__*/_interopNamespace(t$5);
63
+ const t__namespace = /*#__PURE__*/_interopNamespace(t);
64
64
  const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
65
65
  const NodeUtils__namespace = /*#__PURE__*/_interopNamespace(NodeUtils);
66
66
  const inquirer__namespace = /*#__PURE__*/_interopNamespace(inquirer);
@@ -457,2162 +457,6 @@ async function lsfiles(dir) {
457
457
  });
458
458
  }
459
459
 
460
- const debug$3 = (
461
- typeof process === 'object' &&
462
- process.env &&
463
- process.env.NODE_DEBUG &&
464
- /\bsemver\b/i.test(process.env.NODE_DEBUG)
465
- ) ? (...args) => console.error('SEMVER', ...args)
466
- : () => {};
467
-
468
- var debug_1 = debug$3;
469
-
470
- // Note: this is the semver.org version of the spec that it implements
471
- // Not necessarily the package version of this code.
472
- const SEMVER_SPEC_VERSION = '2.0.0';
473
-
474
- const MAX_LENGTH$2 = 256;
475
- const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
476
- /* istanbul ignore next */ 9007199254740991;
477
-
478
- // Max safe segment length for coercion.
479
- const MAX_SAFE_COMPONENT_LENGTH = 16;
480
-
481
- var constants = {
482
- SEMVER_SPEC_VERSION,
483
- MAX_LENGTH: MAX_LENGTH$2,
484
- MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
485
- MAX_SAFE_COMPONENT_LENGTH,
486
- };
487
-
488
- var re$5 = {exports: {}};
489
-
490
- (function (module, exports) {
491
- const { MAX_SAFE_COMPONENT_LENGTH } = constants;
492
- const debug = debug_1;
493
- exports = module.exports = {};
494
-
495
- // The actual regexps go on exports.re
496
- const re = exports.re = [];
497
- const src = exports.src = [];
498
- const t = exports.t = {};
499
- let R = 0;
500
-
501
- const createToken = (name, value, isGlobal) => {
502
- const index = R++;
503
- debug(name, index, value);
504
- t[name] = index;
505
- src[index] = value;
506
- re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
507
- };
508
-
509
- // The following Regular Expressions can be used for tokenizing,
510
- // validating, and parsing SemVer version strings.
511
-
512
- // ## Numeric Identifier
513
- // A single `0`, or a non-zero digit followed by zero or more digits.
514
-
515
- createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
516
- createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
517
-
518
- // ## Non-numeric Identifier
519
- // Zero or more digits, followed by a letter or hyphen, and then zero or
520
- // more letters, digits, or hyphens.
521
-
522
- createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
523
-
524
- // ## Main Version
525
- // Three dot-separated numeric identifiers.
526
-
527
- createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
528
- `(${src[t.NUMERICIDENTIFIER]})\\.` +
529
- `(${src[t.NUMERICIDENTIFIER]})`);
530
-
531
- createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
532
- `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
533
- `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
534
-
535
- // ## Pre-release Version Identifier
536
- // A numeric identifier, or a non-numeric identifier.
537
-
538
- createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
539
- }|${src[t.NONNUMERICIDENTIFIER]})`);
540
-
541
- createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
542
- }|${src[t.NONNUMERICIDENTIFIER]})`);
543
-
544
- // ## Pre-release Version
545
- // Hyphen, followed by one or more dot-separated pre-release version
546
- // identifiers.
547
-
548
- createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
549
- }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
550
-
551
- createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
552
- }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
553
-
554
- // ## Build Metadata Identifier
555
- // Any combination of digits, letters, or hyphens.
556
-
557
- createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
558
-
559
- // ## Build Metadata
560
- // Plus sign, followed by one or more period-separated build metadata
561
- // identifiers.
562
-
563
- createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
564
- }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
565
-
566
- // ## Full Version String
567
- // A main version, followed optionally by a pre-release version and
568
- // build metadata.
569
-
570
- // Note that the only major, minor, patch, and pre-release sections of
571
- // the version string are capturing groups. The build metadata is not a
572
- // capturing group, because it should not ever be used in version
573
- // comparison.
574
-
575
- createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
576
- }${src[t.PRERELEASE]}?${
577
- src[t.BUILD]}?`);
578
-
579
- createToken('FULL', `^${src[t.FULLPLAIN]}$`);
580
-
581
- // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
582
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
583
- // common in the npm registry.
584
- createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
585
- }${src[t.PRERELEASELOOSE]}?${
586
- src[t.BUILD]}?`);
587
-
588
- createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
589
-
590
- createToken('GTLT', '((?:<|>)?=?)');
591
-
592
- // Something like "2.*" or "1.2.x".
593
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
594
- // Only the first item is strictly required.
595
- createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
596
- createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
597
-
598
- createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
599
- `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
600
- `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
601
- `(?:${src[t.PRERELEASE]})?${
602
- src[t.BUILD]}?` +
603
- `)?)?`);
604
-
605
- createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
606
- `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
607
- `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
608
- `(?:${src[t.PRERELEASELOOSE]})?${
609
- src[t.BUILD]}?` +
610
- `)?)?`);
611
-
612
- createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
613
- createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
614
-
615
- // Coercion.
616
- // Extract anything that could conceivably be a part of a valid semver
617
- createToken('COERCE', `${'(^|[^\\d])' +
618
- '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
619
- `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
620
- `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
621
- `(?:$|[^\\d])`);
622
- createToken('COERCERTL', src[t.COERCE], true);
623
-
624
- // Tilde ranges.
625
- // Meaning is "reasonably at or greater than"
626
- createToken('LONETILDE', '(?:~>?)');
627
-
628
- createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
629
- exports.tildeTrimReplace = '$1~';
630
-
631
- createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
632
- createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
633
-
634
- // Caret ranges.
635
- // Meaning is "at least and backwards compatible with"
636
- createToken('LONECARET', '(?:\\^)');
637
-
638
- createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
639
- exports.caretTrimReplace = '$1^';
640
-
641
- createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
642
- createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
643
-
644
- // A simple gt/lt/eq thing, or just "" to indicate "any version"
645
- createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
646
- createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
647
-
648
- // An expression to strip any whitespace between the gtlt and the thing
649
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
650
- createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
651
- }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
652
- exports.comparatorTrimReplace = '$1$2$3';
653
-
654
- // Something like `1.2.3 - 1.2.4`
655
- // Note that these all use the loose form, because they'll be
656
- // checked against either the strict or loose comparator form
657
- // later.
658
- createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
659
- `\\s+-\\s+` +
660
- `(${src[t.XRANGEPLAIN]})` +
661
- `\\s*$`);
662
-
663
- createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
664
- `\\s+-\\s+` +
665
- `(${src[t.XRANGEPLAINLOOSE]})` +
666
- `\\s*$`);
667
-
668
- // Star ranges basically just allow anything at all.
669
- createToken('STAR', '(<|>)?=?\\s*\\*');
670
- // >=0.0.0 is like a star
671
- createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
672
- createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
673
- }(re$5, re$5.exports));
674
-
675
- // parse out just the options we care about so we always get a consistent
676
- // obj with keys in a consistent order.
677
- const opts = ['includePrerelease', 'loose', 'rtl'];
678
- const parseOptions$4 = options =>
679
- !options ? {}
680
- : typeof options !== 'object' ? { loose: true }
681
- : opts.filter(k => options[k]).reduce((o, k) => {
682
- o[k] = true;
683
- return o
684
- }, {});
685
- var parseOptions_1 = parseOptions$4;
686
-
687
- const numeric = /^[0-9]+$/;
688
- const compareIdentifiers$1 = (a, b) => {
689
- const anum = numeric.test(a);
690
- const bnum = numeric.test(b);
691
-
692
- if (anum && bnum) {
693
- a = +a;
694
- b = +b;
695
- }
696
-
697
- return a === b ? 0
698
- : (anum && !bnum) ? -1
699
- : (bnum && !anum) ? 1
700
- : a < b ? -1
701
- : 1
702
- };
703
-
704
- const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
705
-
706
- var identifiers = {
707
- compareIdentifiers: compareIdentifiers$1,
708
- rcompareIdentifiers,
709
- };
710
-
711
- const debug$2 = debug_1;
712
- const { MAX_LENGTH: MAX_LENGTH$1, MAX_SAFE_INTEGER } = constants;
713
- const { re: re$4, t: t$4 } = re$5.exports;
714
-
715
- const parseOptions$3 = parseOptions_1;
716
- const { compareIdentifiers } = identifiers;
717
- class SemVer$5 {
718
- constructor (version, options) {
719
- options = parseOptions$3(options);
720
-
721
- if (version instanceof SemVer$5) {
722
- if (version.loose === !!options.loose &&
723
- version.includePrerelease === !!options.includePrerelease) {
724
- return version
725
- } else {
726
- version = version.version;
727
- }
728
- } else if (typeof version !== 'string') {
729
- throw new TypeError(`Invalid Version: ${version}`)
730
- }
731
-
732
- if (version.length > MAX_LENGTH$1) {
733
- throw new TypeError(
734
- `version is longer than ${MAX_LENGTH$1} characters`
735
- )
736
- }
737
-
738
- debug$2('SemVer', version, options);
739
- this.options = options;
740
- this.loose = !!options.loose;
741
- // this isn't actually relevant for versions, but keep it so that we
742
- // don't run into trouble passing this.options around.
743
- this.includePrerelease = !!options.includePrerelease;
744
-
745
- const m = version.trim().match(options.loose ? re$4[t$4.LOOSE] : re$4[t$4.FULL]);
746
-
747
- if (!m) {
748
- throw new TypeError(`Invalid Version: ${version}`)
749
- }
750
-
751
- this.raw = version;
752
-
753
- // these are actually numbers
754
- this.major = +m[1];
755
- this.minor = +m[2];
756
- this.patch = +m[3];
757
-
758
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
759
- throw new TypeError('Invalid major version')
760
- }
761
-
762
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
763
- throw new TypeError('Invalid minor version')
764
- }
765
-
766
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
767
- throw new TypeError('Invalid patch version')
768
- }
769
-
770
- // numberify any prerelease numeric ids
771
- if (!m[4]) {
772
- this.prerelease = [];
773
- } else {
774
- this.prerelease = m[4].split('.').map((id) => {
775
- if (/^[0-9]+$/.test(id)) {
776
- const num = +id;
777
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
778
- return num
779
- }
780
- }
781
- return id
782
- });
783
- }
784
-
785
- this.build = m[5] ? m[5].split('.') : [];
786
- this.format();
787
- }
788
-
789
- format () {
790
- this.version = `${this.major}.${this.minor}.${this.patch}`;
791
- if (this.prerelease.length) {
792
- this.version += `-${this.prerelease.join('.')}`;
793
- }
794
- return this.version
795
- }
796
-
797
- toString () {
798
- return this.version
799
- }
800
-
801
- compare (other) {
802
- debug$2('SemVer.compare', this.version, this.options, other);
803
- if (!(other instanceof SemVer$5)) {
804
- if (typeof other === 'string' && other === this.version) {
805
- return 0
806
- }
807
- other = new SemVer$5(other, this.options);
808
- }
809
-
810
- if (other.version === this.version) {
811
- return 0
812
- }
813
-
814
- return this.compareMain(other) || this.comparePre(other)
815
- }
816
-
817
- compareMain (other) {
818
- if (!(other instanceof SemVer$5)) {
819
- other = new SemVer$5(other, this.options);
820
- }
821
-
822
- return (
823
- compareIdentifiers(this.major, other.major) ||
824
- compareIdentifiers(this.minor, other.minor) ||
825
- compareIdentifiers(this.patch, other.patch)
826
- )
827
- }
828
-
829
- comparePre (other) {
830
- if (!(other instanceof SemVer$5)) {
831
- other = new SemVer$5(other, this.options);
832
- }
833
-
834
- // NOT having a prerelease is > having one
835
- if (this.prerelease.length && !other.prerelease.length) {
836
- return -1
837
- } else if (!this.prerelease.length && other.prerelease.length) {
838
- return 1
839
- } else if (!this.prerelease.length && !other.prerelease.length) {
840
- return 0
841
- }
842
-
843
- let i = 0;
844
- do {
845
- const a = this.prerelease[i];
846
- const b = other.prerelease[i];
847
- debug$2('prerelease compare', i, a, b);
848
- if (a === undefined && b === undefined) {
849
- return 0
850
- } else if (b === undefined) {
851
- return 1
852
- } else if (a === undefined) {
853
- return -1
854
- } else if (a === b) {
855
- continue
856
- } else {
857
- return compareIdentifiers(a, b)
858
- }
859
- } while (++i)
860
- }
861
-
862
- compareBuild (other) {
863
- if (!(other instanceof SemVer$5)) {
864
- other = new SemVer$5(other, this.options);
865
- }
866
-
867
- let i = 0;
868
- do {
869
- const a = this.build[i];
870
- const b = other.build[i];
871
- debug$2('prerelease compare', i, a, b);
872
- if (a === undefined && b === undefined) {
873
- return 0
874
- } else if (b === undefined) {
875
- return 1
876
- } else if (a === undefined) {
877
- return -1
878
- } else if (a === b) {
879
- continue
880
- } else {
881
- return compareIdentifiers(a, b)
882
- }
883
- } while (++i)
884
- }
885
-
886
- // preminor will bump the version up to the next minor release, and immediately
887
- // down to pre-release. premajor and prepatch work the same way.
888
- inc (release, identifier) {
889
- switch (release) {
890
- case 'premajor':
891
- this.prerelease.length = 0;
892
- this.patch = 0;
893
- this.minor = 0;
894
- this.major++;
895
- this.inc('pre', identifier);
896
- break
897
- case 'preminor':
898
- this.prerelease.length = 0;
899
- this.patch = 0;
900
- this.minor++;
901
- this.inc('pre', identifier);
902
- break
903
- case 'prepatch':
904
- // If this is already a prerelease, it will bump to the next version
905
- // drop any prereleases that might already exist, since they are not
906
- // relevant at this point.
907
- this.prerelease.length = 0;
908
- this.inc('patch', identifier);
909
- this.inc('pre', identifier);
910
- break
911
- // If the input is a non-prerelease version, this acts the same as
912
- // prepatch.
913
- case 'prerelease':
914
- if (this.prerelease.length === 0) {
915
- this.inc('patch', identifier);
916
- }
917
- this.inc('pre', identifier);
918
- break
919
-
920
- case 'major':
921
- // If this is a pre-major version, bump up to the same major version.
922
- // Otherwise increment major.
923
- // 1.0.0-5 bumps to 1.0.0
924
- // 1.1.0 bumps to 2.0.0
925
- if (
926
- this.minor !== 0 ||
927
- this.patch !== 0 ||
928
- this.prerelease.length === 0
929
- ) {
930
- this.major++;
931
- }
932
- this.minor = 0;
933
- this.patch = 0;
934
- this.prerelease = [];
935
- break
936
- case 'minor':
937
- // If this is a pre-minor version, bump up to the same minor version.
938
- // Otherwise increment minor.
939
- // 1.2.0-5 bumps to 1.2.0
940
- // 1.2.1 bumps to 1.3.0
941
- if (this.patch !== 0 || this.prerelease.length === 0) {
942
- this.minor++;
943
- }
944
- this.patch = 0;
945
- this.prerelease = [];
946
- break
947
- case 'patch':
948
- // If this is not a pre-release version, it will increment the patch.
949
- // If it is a pre-release it will bump up to the same patch version.
950
- // 1.2.0-5 patches to 1.2.0
951
- // 1.2.0 patches to 1.2.1
952
- if (this.prerelease.length === 0) {
953
- this.patch++;
954
- }
955
- this.prerelease = [];
956
- break
957
- // This probably shouldn't be used publicly.
958
- // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
959
- case 'pre':
960
- if (this.prerelease.length === 0) {
961
- this.prerelease = [0];
962
- } else {
963
- let i = this.prerelease.length;
964
- while (--i >= 0) {
965
- if (typeof this.prerelease[i] === 'number') {
966
- this.prerelease[i]++;
967
- i = -2;
968
- }
969
- }
970
- if (i === -1) {
971
- // didn't increment anything
972
- this.prerelease.push(0);
973
- }
974
- }
975
- if (identifier) {
976
- // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
977
- // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
978
- if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
979
- if (isNaN(this.prerelease[1])) {
980
- this.prerelease = [identifier, 0];
981
- }
982
- } else {
983
- this.prerelease = [identifier, 0];
984
- }
985
- }
986
- break
987
-
988
- default:
989
- throw new Error(`invalid increment argument: ${release}`)
990
- }
991
- this.format();
992
- this.raw = this.version;
993
- return this
994
- }
995
- }
996
-
997
- var semver = SemVer$5;
998
-
999
- const { MAX_LENGTH } = constants;
1000
- const { re: re$3, t: t$3 } = re$5.exports;
1001
- const SemVer$4 = semver;
1002
-
1003
- const parseOptions$2 = parseOptions_1;
1004
- const parse$1 = (version, options) => {
1005
- options = parseOptions$2(options);
1006
-
1007
- if (version instanceof SemVer$4) {
1008
- return version
1009
- }
1010
-
1011
- if (typeof version !== 'string') {
1012
- return null
1013
- }
1014
-
1015
- if (version.length > MAX_LENGTH) {
1016
- return null
1017
- }
1018
-
1019
- const r = options.loose ? re$3[t$3.LOOSE] : re$3[t$3.FULL];
1020
- if (!r.test(version)) {
1021
- return null
1022
- }
1023
-
1024
- try {
1025
- return new SemVer$4(version, options)
1026
- } catch (er) {
1027
- return null
1028
- }
1029
- };
1030
-
1031
- var parse_1 = parse$1;
1032
-
1033
- const SemVer$3 = semver;
1034
- const parse = parse_1;
1035
- const { re: re$2, t: t$2 } = re$5.exports;
1036
-
1037
- const coerce = (version, options) => {
1038
- if (version instanceof SemVer$3) {
1039
- return version
1040
- }
1041
-
1042
- if (typeof version === 'number') {
1043
- version = String(version);
1044
- }
1045
-
1046
- if (typeof version !== 'string') {
1047
- return null
1048
- }
1049
-
1050
- options = options || {};
1051
-
1052
- let match = null;
1053
- if (!options.rtl) {
1054
- match = version.match(re$2[t$2.COERCE]);
1055
- } else {
1056
- // Find the right-most coercible string that does not share
1057
- // a terminus with a more left-ward coercible string.
1058
- // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
1059
- //
1060
- // Walk through the string checking with a /g regexp
1061
- // Manually set the index so as to pick up overlapping matches.
1062
- // Stop when we get a match that ends at the string end, since no
1063
- // coercible string can be more right-ward without the same terminus.
1064
- let next;
1065
- while ((next = re$2[t$2.COERCERTL].exec(version)) &&
1066
- (!match || match.index + match[0].length !== version.length)
1067
- ) {
1068
- if (!match ||
1069
- next.index + next[0].length !== match.index + match[0].length) {
1070
- match = next;
1071
- }
1072
- re$2[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
1073
- }
1074
- // leave it in a clean state
1075
- re$2[t$2.COERCERTL].lastIndex = -1;
1076
- }
1077
-
1078
- if (match === null) {
1079
- return null
1080
- }
1081
-
1082
- return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
1083
- };
1084
- var coerce_1 = coerce;
1085
-
1086
- var iterator = function (Yallist) {
1087
- Yallist.prototype[Symbol.iterator] = function* () {
1088
- for (let walker = this.head; walker; walker = walker.next) {
1089
- yield walker.value;
1090
- }
1091
- };
1092
- };
1093
-
1094
- var yallist = Yallist$1;
1095
-
1096
- Yallist$1.Node = Node;
1097
- Yallist$1.create = Yallist$1;
1098
-
1099
- function Yallist$1 (list) {
1100
- var self = this;
1101
- if (!(self instanceof Yallist$1)) {
1102
- self = new Yallist$1();
1103
- }
1104
-
1105
- self.tail = null;
1106
- self.head = null;
1107
- self.length = 0;
1108
-
1109
- if (list && typeof list.forEach === 'function') {
1110
- list.forEach(function (item) {
1111
- self.push(item);
1112
- });
1113
- } else if (arguments.length > 0) {
1114
- for (var i = 0, l = arguments.length; i < l; i++) {
1115
- self.push(arguments[i]);
1116
- }
1117
- }
1118
-
1119
- return self
1120
- }
1121
-
1122
- Yallist$1.prototype.removeNode = function (node) {
1123
- if (node.list !== this) {
1124
- throw new Error('removing node which does not belong to this list')
1125
- }
1126
-
1127
- var next = node.next;
1128
- var prev = node.prev;
1129
-
1130
- if (next) {
1131
- next.prev = prev;
1132
- }
1133
-
1134
- if (prev) {
1135
- prev.next = next;
1136
- }
1137
-
1138
- if (node === this.head) {
1139
- this.head = next;
1140
- }
1141
- if (node === this.tail) {
1142
- this.tail = prev;
1143
- }
1144
-
1145
- node.list.length--;
1146
- node.next = null;
1147
- node.prev = null;
1148
- node.list = null;
1149
-
1150
- return next
1151
- };
1152
-
1153
- Yallist$1.prototype.unshiftNode = function (node) {
1154
- if (node === this.head) {
1155
- return
1156
- }
1157
-
1158
- if (node.list) {
1159
- node.list.removeNode(node);
1160
- }
1161
-
1162
- var head = this.head;
1163
- node.list = this;
1164
- node.next = head;
1165
- if (head) {
1166
- head.prev = node;
1167
- }
1168
-
1169
- this.head = node;
1170
- if (!this.tail) {
1171
- this.tail = node;
1172
- }
1173
- this.length++;
1174
- };
1175
-
1176
- Yallist$1.prototype.pushNode = function (node) {
1177
- if (node === this.tail) {
1178
- return
1179
- }
1180
-
1181
- if (node.list) {
1182
- node.list.removeNode(node);
1183
- }
1184
-
1185
- var tail = this.tail;
1186
- node.list = this;
1187
- node.prev = tail;
1188
- if (tail) {
1189
- tail.next = node;
1190
- }
1191
-
1192
- this.tail = node;
1193
- if (!this.head) {
1194
- this.head = node;
1195
- }
1196
- this.length++;
1197
- };
1198
-
1199
- Yallist$1.prototype.push = function () {
1200
- for (var i = 0, l = arguments.length; i < l; i++) {
1201
- push(this, arguments[i]);
1202
- }
1203
- return this.length
1204
- };
1205
-
1206
- Yallist$1.prototype.unshift = function () {
1207
- for (var i = 0, l = arguments.length; i < l; i++) {
1208
- unshift(this, arguments[i]);
1209
- }
1210
- return this.length
1211
- };
1212
-
1213
- Yallist$1.prototype.pop = function () {
1214
- if (!this.tail) {
1215
- return undefined
1216
- }
1217
-
1218
- var res = this.tail.value;
1219
- this.tail = this.tail.prev;
1220
- if (this.tail) {
1221
- this.tail.next = null;
1222
- } else {
1223
- this.head = null;
1224
- }
1225
- this.length--;
1226
- return res
1227
- };
1228
-
1229
- Yallist$1.prototype.shift = function () {
1230
- if (!this.head) {
1231
- return undefined
1232
- }
1233
-
1234
- var res = this.head.value;
1235
- this.head = this.head.next;
1236
- if (this.head) {
1237
- this.head.prev = null;
1238
- } else {
1239
- this.tail = null;
1240
- }
1241
- this.length--;
1242
- return res
1243
- };
1244
-
1245
- Yallist$1.prototype.forEach = function (fn, thisp) {
1246
- thisp = thisp || this;
1247
- for (var walker = this.head, i = 0; walker !== null; i++) {
1248
- fn.call(thisp, walker.value, i, this);
1249
- walker = walker.next;
1250
- }
1251
- };
1252
-
1253
- Yallist$1.prototype.forEachReverse = function (fn, thisp) {
1254
- thisp = thisp || this;
1255
- for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
1256
- fn.call(thisp, walker.value, i, this);
1257
- walker = walker.prev;
1258
- }
1259
- };
1260
-
1261
- Yallist$1.prototype.get = function (n) {
1262
- for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
1263
- // abort out of the list early if we hit a cycle
1264
- walker = walker.next;
1265
- }
1266
- if (i === n && walker !== null) {
1267
- return walker.value
1268
- }
1269
- };
1270
-
1271
- Yallist$1.prototype.getReverse = function (n) {
1272
- for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
1273
- // abort out of the list early if we hit a cycle
1274
- walker = walker.prev;
1275
- }
1276
- if (i === n && walker !== null) {
1277
- return walker.value
1278
- }
1279
- };
1280
-
1281
- Yallist$1.prototype.map = function (fn, thisp) {
1282
- thisp = thisp || this;
1283
- var res = new Yallist$1();
1284
- for (var walker = this.head; walker !== null;) {
1285
- res.push(fn.call(thisp, walker.value, this));
1286
- walker = walker.next;
1287
- }
1288
- return res
1289
- };
1290
-
1291
- Yallist$1.prototype.mapReverse = function (fn, thisp) {
1292
- thisp = thisp || this;
1293
- var res = new Yallist$1();
1294
- for (var walker = this.tail; walker !== null;) {
1295
- res.push(fn.call(thisp, walker.value, this));
1296
- walker = walker.prev;
1297
- }
1298
- return res
1299
- };
1300
-
1301
- Yallist$1.prototype.reduce = function (fn, initial) {
1302
- var acc;
1303
- var walker = this.head;
1304
- if (arguments.length > 1) {
1305
- acc = initial;
1306
- } else if (this.head) {
1307
- walker = this.head.next;
1308
- acc = this.head.value;
1309
- } else {
1310
- throw new TypeError('Reduce of empty list with no initial value')
1311
- }
1312
-
1313
- for (var i = 0; walker !== null; i++) {
1314
- acc = fn(acc, walker.value, i);
1315
- walker = walker.next;
1316
- }
1317
-
1318
- return acc
1319
- };
1320
-
1321
- Yallist$1.prototype.reduceReverse = function (fn, initial) {
1322
- var acc;
1323
- var walker = this.tail;
1324
- if (arguments.length > 1) {
1325
- acc = initial;
1326
- } else if (this.tail) {
1327
- walker = this.tail.prev;
1328
- acc = this.tail.value;
1329
- } else {
1330
- throw new TypeError('Reduce of empty list with no initial value')
1331
- }
1332
-
1333
- for (var i = this.length - 1; walker !== null; i--) {
1334
- acc = fn(acc, walker.value, i);
1335
- walker = walker.prev;
1336
- }
1337
-
1338
- return acc
1339
- };
1340
-
1341
- Yallist$1.prototype.toArray = function () {
1342
- var arr = new Array(this.length);
1343
- for (var i = 0, walker = this.head; walker !== null; i++) {
1344
- arr[i] = walker.value;
1345
- walker = walker.next;
1346
- }
1347
- return arr
1348
- };
1349
-
1350
- Yallist$1.prototype.toArrayReverse = function () {
1351
- var arr = new Array(this.length);
1352
- for (var i = 0, walker = this.tail; walker !== null; i++) {
1353
- arr[i] = walker.value;
1354
- walker = walker.prev;
1355
- }
1356
- return arr
1357
- };
1358
-
1359
- Yallist$1.prototype.slice = function (from, to) {
1360
- to = to || this.length;
1361
- if (to < 0) {
1362
- to += this.length;
1363
- }
1364
- from = from || 0;
1365
- if (from < 0) {
1366
- from += this.length;
1367
- }
1368
- var ret = new Yallist$1();
1369
- if (to < from || to < 0) {
1370
- return ret
1371
- }
1372
- if (from < 0) {
1373
- from = 0;
1374
- }
1375
- if (to > this.length) {
1376
- to = this.length;
1377
- }
1378
- for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
1379
- walker = walker.next;
1380
- }
1381
- for (; walker !== null && i < to; i++, walker = walker.next) {
1382
- ret.push(walker.value);
1383
- }
1384
- return ret
1385
- };
1386
-
1387
- Yallist$1.prototype.sliceReverse = function (from, to) {
1388
- to = to || this.length;
1389
- if (to < 0) {
1390
- to += this.length;
1391
- }
1392
- from = from || 0;
1393
- if (from < 0) {
1394
- from += this.length;
1395
- }
1396
- var ret = new Yallist$1();
1397
- if (to < from || to < 0) {
1398
- return ret
1399
- }
1400
- if (from < 0) {
1401
- from = 0;
1402
- }
1403
- if (to > this.length) {
1404
- to = this.length;
1405
- }
1406
- for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
1407
- walker = walker.prev;
1408
- }
1409
- for (; walker !== null && i > from; i--, walker = walker.prev) {
1410
- ret.push(walker.value);
1411
- }
1412
- return ret
1413
- };
1414
-
1415
- Yallist$1.prototype.splice = function (start, deleteCount, ...nodes) {
1416
- if (start > this.length) {
1417
- start = this.length - 1;
1418
- }
1419
- if (start < 0) {
1420
- start = this.length + start;
1421
- }
1422
-
1423
- for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
1424
- walker = walker.next;
1425
- }
1426
-
1427
- var ret = [];
1428
- for (var i = 0; walker && i < deleteCount; i++) {
1429
- ret.push(walker.value);
1430
- walker = this.removeNode(walker);
1431
- }
1432
- if (walker === null) {
1433
- walker = this.tail;
1434
- }
1435
-
1436
- if (walker !== this.head && walker !== this.tail) {
1437
- walker = walker.prev;
1438
- }
1439
-
1440
- for (var i = 0; i < nodes.length; i++) {
1441
- walker = insert(this, walker, nodes[i]);
1442
- }
1443
- return ret;
1444
- };
1445
-
1446
- Yallist$1.prototype.reverse = function () {
1447
- var head = this.head;
1448
- var tail = this.tail;
1449
- for (var walker = head; walker !== null; walker = walker.prev) {
1450
- var p = walker.prev;
1451
- walker.prev = walker.next;
1452
- walker.next = p;
1453
- }
1454
- this.head = tail;
1455
- this.tail = head;
1456
- return this
1457
- };
1458
-
1459
- function insert (self, node, value) {
1460
- var inserted = node === self.head ?
1461
- new Node(value, null, node, self) :
1462
- new Node(value, node, node.next, self);
1463
-
1464
- if (inserted.next === null) {
1465
- self.tail = inserted;
1466
- }
1467
- if (inserted.prev === null) {
1468
- self.head = inserted;
1469
- }
1470
-
1471
- self.length++;
1472
-
1473
- return inserted
1474
- }
1475
-
1476
- function push (self, item) {
1477
- self.tail = new Node(item, self.tail, null, self);
1478
- if (!self.head) {
1479
- self.head = self.tail;
1480
- }
1481
- self.length++;
1482
- }
1483
-
1484
- function unshift (self, item) {
1485
- self.head = new Node(item, null, self.head, self);
1486
- if (!self.tail) {
1487
- self.tail = self.head;
1488
- }
1489
- self.length++;
1490
- }
1491
-
1492
- function Node (value, prev, next, list) {
1493
- if (!(this instanceof Node)) {
1494
- return new Node(value, prev, next, list)
1495
- }
1496
-
1497
- this.list = list;
1498
- this.value = value;
1499
-
1500
- if (prev) {
1501
- prev.next = this;
1502
- this.prev = prev;
1503
- } else {
1504
- this.prev = null;
1505
- }
1506
-
1507
- if (next) {
1508
- next.prev = this;
1509
- this.next = next;
1510
- } else {
1511
- this.next = null;
1512
- }
1513
- }
1514
-
1515
- try {
1516
- // add if support for Symbol.iterator is present
1517
- iterator(Yallist$1);
1518
- } catch (er) {}
1519
-
1520
- // A linked list to keep track of recently-used-ness
1521
- const Yallist = yallist;
1522
-
1523
- const MAX = Symbol('max');
1524
- const LENGTH = Symbol('length');
1525
- const LENGTH_CALCULATOR = Symbol('lengthCalculator');
1526
- const ALLOW_STALE = Symbol('allowStale');
1527
- const MAX_AGE = Symbol('maxAge');
1528
- const DISPOSE = Symbol('dispose');
1529
- const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
1530
- const LRU_LIST = Symbol('lruList');
1531
- const CACHE = Symbol('cache');
1532
- const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
1533
-
1534
- const naiveLength = () => 1;
1535
-
1536
- // lruList is a yallist where the head is the youngest
1537
- // item, and the tail is the oldest. the list contains the Hit
1538
- // objects as the entries.
1539
- // Each Hit object has a reference to its Yallist.Node. This
1540
- // never changes.
1541
- //
1542
- // cache is a Map (or PseudoMap) that matches the keys to
1543
- // the Yallist.Node object.
1544
- class LRUCache {
1545
- constructor (options) {
1546
- if (typeof options === 'number')
1547
- options = { max: options };
1548
-
1549
- if (!options)
1550
- options = {};
1551
-
1552
- if (options.max && (typeof options.max !== 'number' || options.max < 0))
1553
- throw new TypeError('max must be a non-negative number')
1554
- // Kind of weird to have a default max of Infinity, but oh well.
1555
- this[MAX] = options.max || Infinity;
1556
-
1557
- const lc = options.length || naiveLength;
1558
- this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
1559
- this[ALLOW_STALE] = options.stale || false;
1560
- if (options.maxAge && typeof options.maxAge !== 'number')
1561
- throw new TypeError('maxAge must be a number')
1562
- this[MAX_AGE] = options.maxAge || 0;
1563
- this[DISPOSE] = options.dispose;
1564
- this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
1565
- this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
1566
- this.reset();
1567
- }
1568
-
1569
- // resize the cache when the max changes.
1570
- set max (mL) {
1571
- if (typeof mL !== 'number' || mL < 0)
1572
- throw new TypeError('max must be a non-negative number')
1573
-
1574
- this[MAX] = mL || Infinity;
1575
- trim(this);
1576
- }
1577
- get max () {
1578
- return this[MAX]
1579
- }
1580
-
1581
- set allowStale (allowStale) {
1582
- this[ALLOW_STALE] = !!allowStale;
1583
- }
1584
- get allowStale () {
1585
- return this[ALLOW_STALE]
1586
- }
1587
-
1588
- set maxAge (mA) {
1589
- if (typeof mA !== 'number')
1590
- throw new TypeError('maxAge must be a non-negative number')
1591
-
1592
- this[MAX_AGE] = mA;
1593
- trim(this);
1594
- }
1595
- get maxAge () {
1596
- return this[MAX_AGE]
1597
- }
1598
-
1599
- // resize the cache when the lengthCalculator changes.
1600
- set lengthCalculator (lC) {
1601
- if (typeof lC !== 'function')
1602
- lC = naiveLength;
1603
-
1604
- if (lC !== this[LENGTH_CALCULATOR]) {
1605
- this[LENGTH_CALCULATOR] = lC;
1606
- this[LENGTH] = 0;
1607
- this[LRU_LIST].forEach(hit => {
1608
- hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
1609
- this[LENGTH] += hit.length;
1610
- });
1611
- }
1612
- trim(this);
1613
- }
1614
- get lengthCalculator () { return this[LENGTH_CALCULATOR] }
1615
-
1616
- get length () { return this[LENGTH] }
1617
- get itemCount () { return this[LRU_LIST].length }
1618
-
1619
- rforEach (fn, thisp) {
1620
- thisp = thisp || this;
1621
- for (let walker = this[LRU_LIST].tail; walker !== null;) {
1622
- const prev = walker.prev;
1623
- forEachStep(this, fn, walker, thisp);
1624
- walker = prev;
1625
- }
1626
- }
1627
-
1628
- forEach (fn, thisp) {
1629
- thisp = thisp || this;
1630
- for (let walker = this[LRU_LIST].head; walker !== null;) {
1631
- const next = walker.next;
1632
- forEachStep(this, fn, walker, thisp);
1633
- walker = next;
1634
- }
1635
- }
1636
-
1637
- keys () {
1638
- return this[LRU_LIST].toArray().map(k => k.key)
1639
- }
1640
-
1641
- values () {
1642
- return this[LRU_LIST].toArray().map(k => k.value)
1643
- }
1644
-
1645
- reset () {
1646
- if (this[DISPOSE] &&
1647
- this[LRU_LIST] &&
1648
- this[LRU_LIST].length) {
1649
- this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
1650
- }
1651
-
1652
- this[CACHE] = new Map(); // hash of items by key
1653
- this[LRU_LIST] = new Yallist(); // list of items in order of use recency
1654
- this[LENGTH] = 0; // length of items in the list
1655
- }
1656
-
1657
- dump () {
1658
- return this[LRU_LIST].map(hit =>
1659
- isStale(this, hit) ? false : {
1660
- k: hit.key,
1661
- v: hit.value,
1662
- e: hit.now + (hit.maxAge || 0)
1663
- }).toArray().filter(h => h)
1664
- }
1665
-
1666
- dumpLru () {
1667
- return this[LRU_LIST]
1668
- }
1669
-
1670
- set (key, value, maxAge) {
1671
- maxAge = maxAge || this[MAX_AGE];
1672
-
1673
- if (maxAge && typeof maxAge !== 'number')
1674
- throw new TypeError('maxAge must be a number')
1675
-
1676
- const now = maxAge ? Date.now() : 0;
1677
- const len = this[LENGTH_CALCULATOR](value, key);
1678
-
1679
- if (this[CACHE].has(key)) {
1680
- if (len > this[MAX]) {
1681
- del(this, this[CACHE].get(key));
1682
- return false
1683
- }
1684
-
1685
- const node = this[CACHE].get(key);
1686
- const item = node.value;
1687
-
1688
- // dispose of the old one before overwriting
1689
- // split out into 2 ifs for better coverage tracking
1690
- if (this[DISPOSE]) {
1691
- if (!this[NO_DISPOSE_ON_SET])
1692
- this[DISPOSE](key, item.value);
1693
- }
1694
-
1695
- item.now = now;
1696
- item.maxAge = maxAge;
1697
- item.value = value;
1698
- this[LENGTH] += len - item.length;
1699
- item.length = len;
1700
- this.get(key);
1701
- trim(this);
1702
- return true
1703
- }
1704
-
1705
- const hit = new Entry(key, value, len, now, maxAge);
1706
-
1707
- // oversized objects fall out of cache automatically.
1708
- if (hit.length > this[MAX]) {
1709
- if (this[DISPOSE])
1710
- this[DISPOSE](key, value);
1711
-
1712
- return false
1713
- }
1714
-
1715
- this[LENGTH] += hit.length;
1716
- this[LRU_LIST].unshift(hit);
1717
- this[CACHE].set(key, this[LRU_LIST].head);
1718
- trim(this);
1719
- return true
1720
- }
1721
-
1722
- has (key) {
1723
- if (!this[CACHE].has(key)) return false
1724
- const hit = this[CACHE].get(key).value;
1725
- return !isStale(this, hit)
1726
- }
1727
-
1728
- get (key) {
1729
- return get(this, key, true)
1730
- }
1731
-
1732
- peek (key) {
1733
- return get(this, key, false)
1734
- }
1735
-
1736
- pop () {
1737
- const node = this[LRU_LIST].tail;
1738
- if (!node)
1739
- return null
1740
-
1741
- del(this, node);
1742
- return node.value
1743
- }
1744
-
1745
- del (key) {
1746
- del(this, this[CACHE].get(key));
1747
- }
1748
-
1749
- load (arr) {
1750
- // reset the cache
1751
- this.reset();
1752
-
1753
- const now = Date.now();
1754
- // A previous serialized cache has the most recent items first
1755
- for (let l = arr.length - 1; l >= 0; l--) {
1756
- const hit = arr[l];
1757
- const expiresAt = hit.e || 0;
1758
- if (expiresAt === 0)
1759
- // the item was created without expiration in a non aged cache
1760
- this.set(hit.k, hit.v);
1761
- else {
1762
- const maxAge = expiresAt - now;
1763
- // dont add already expired items
1764
- if (maxAge > 0) {
1765
- this.set(hit.k, hit.v, maxAge);
1766
- }
1767
- }
1768
- }
1769
- }
1770
-
1771
- prune () {
1772
- this[CACHE].forEach((value, key) => get(this, key, false));
1773
- }
1774
- }
1775
-
1776
- const get = (self, key, doUse) => {
1777
- const node = self[CACHE].get(key);
1778
- if (node) {
1779
- const hit = node.value;
1780
- if (isStale(self, hit)) {
1781
- del(self, node);
1782
- if (!self[ALLOW_STALE])
1783
- return undefined
1784
- } else {
1785
- if (doUse) {
1786
- if (self[UPDATE_AGE_ON_GET])
1787
- node.value.now = Date.now();
1788
- self[LRU_LIST].unshiftNode(node);
1789
- }
1790
- }
1791
- return hit.value
1792
- }
1793
- };
1794
-
1795
- const isStale = (self, hit) => {
1796
- if (!hit || (!hit.maxAge && !self[MAX_AGE]))
1797
- return false
1798
-
1799
- const diff = Date.now() - hit.now;
1800
- return hit.maxAge ? diff > hit.maxAge
1801
- : self[MAX_AGE] && (diff > self[MAX_AGE])
1802
- };
1803
-
1804
- const trim = self => {
1805
- if (self[LENGTH] > self[MAX]) {
1806
- for (let walker = self[LRU_LIST].tail;
1807
- self[LENGTH] > self[MAX] && walker !== null;) {
1808
- // We know that we're about to delete this one, and also
1809
- // what the next least recently used key will be, so just
1810
- // go ahead and set it now.
1811
- const prev = walker.prev;
1812
- del(self, walker);
1813
- walker = prev;
1814
- }
1815
- }
1816
- };
1817
-
1818
- const del = (self, node) => {
1819
- if (node) {
1820
- const hit = node.value;
1821
- if (self[DISPOSE])
1822
- self[DISPOSE](hit.key, hit.value);
1823
-
1824
- self[LENGTH] -= hit.length;
1825
- self[CACHE].delete(hit.key);
1826
- self[LRU_LIST].removeNode(node);
1827
- }
1828
- };
1829
-
1830
- class Entry {
1831
- constructor (key, value, length, now, maxAge) {
1832
- this.key = key;
1833
- this.value = value;
1834
- this.length = length;
1835
- this.now = now;
1836
- this.maxAge = maxAge || 0;
1837
- }
1838
- }
1839
-
1840
- const forEachStep = (self, fn, node, thisp) => {
1841
- let hit = node.value;
1842
- if (isStale(self, hit)) {
1843
- del(self, node);
1844
- if (!self[ALLOW_STALE])
1845
- hit = undefined;
1846
- }
1847
- if (hit)
1848
- fn.call(thisp, hit.value, hit.key, self);
1849
- };
1850
-
1851
- var lruCache = LRUCache;
1852
-
1853
- const SemVer$2 = semver;
1854
- const compare$6 = (a, b, loose) =>
1855
- new SemVer$2(a, loose).compare(new SemVer$2(b, loose));
1856
-
1857
- var compare_1 = compare$6;
1858
-
1859
- const compare$5 = compare_1;
1860
- const eq$1 = (a, b, loose) => compare$5(a, b, loose) === 0;
1861
- var eq_1 = eq$1;
1862
-
1863
- const compare$4 = compare_1;
1864
- const neq$1 = (a, b, loose) => compare$4(a, b, loose) !== 0;
1865
- var neq_1 = neq$1;
1866
-
1867
- const compare$3 = compare_1;
1868
- const gt$1 = (a, b, loose) => compare$3(a, b, loose) > 0;
1869
- var gt_1 = gt$1;
1870
-
1871
- const compare$2 = compare_1;
1872
- const gte$1 = (a, b, loose) => compare$2(a, b, loose) >= 0;
1873
- var gte_1 = gte$1;
1874
-
1875
- const compare$1 = compare_1;
1876
- const lt$1 = (a, b, loose) => compare$1(a, b, loose) < 0;
1877
- var lt_1 = lt$1;
1878
-
1879
- const compare = compare_1;
1880
- const lte$1 = (a, b, loose) => compare(a, b, loose) <= 0;
1881
- var lte_1 = lte$1;
1882
-
1883
- const eq = eq_1;
1884
- const neq = neq_1;
1885
- const gt = gt_1;
1886
- const gte = gte_1;
1887
- const lt = lt_1;
1888
- const lte = lte_1;
1889
-
1890
- const cmp$1 = (a, op, b, loose) => {
1891
- switch (op) {
1892
- case '===':
1893
- if (typeof a === 'object') {
1894
- a = a.version;
1895
- }
1896
- if (typeof b === 'object') {
1897
- b = b.version;
1898
- }
1899
- return a === b
1900
-
1901
- case '!==':
1902
- if (typeof a === 'object') {
1903
- a = a.version;
1904
- }
1905
- if (typeof b === 'object') {
1906
- b = b.version;
1907
- }
1908
- return a !== b
1909
-
1910
- case '':
1911
- case '=':
1912
- case '==':
1913
- return eq(a, b, loose)
1914
-
1915
- case '!=':
1916
- return neq(a, b, loose)
1917
-
1918
- case '>':
1919
- return gt(a, b, loose)
1920
-
1921
- case '>=':
1922
- return gte(a, b, loose)
1923
-
1924
- case '<':
1925
- return lt(a, b, loose)
1926
-
1927
- case '<=':
1928
- return lte(a, b, loose)
1929
-
1930
- default:
1931
- throw new TypeError(`Invalid operator: ${op}`)
1932
- }
1933
- };
1934
- var cmp_1 = cmp$1;
1935
-
1936
- const ANY = Symbol('SemVer ANY');
1937
- // hoisted class for cyclic dependency
1938
- class Comparator$1 {
1939
- static get ANY () {
1940
- return ANY
1941
- }
1942
-
1943
- constructor (comp, options) {
1944
- options = parseOptions$1(options);
1945
-
1946
- if (comp instanceof Comparator$1) {
1947
- if (comp.loose === !!options.loose) {
1948
- return comp
1949
- } else {
1950
- comp = comp.value;
1951
- }
1952
- }
1953
-
1954
- debug$1('comparator', comp, options);
1955
- this.options = options;
1956
- this.loose = !!options.loose;
1957
- this.parse(comp);
1958
-
1959
- if (this.semver === ANY) {
1960
- this.value = '';
1961
- } else {
1962
- this.value = this.operator + this.semver.version;
1963
- }
1964
-
1965
- debug$1('comp', this);
1966
- }
1967
-
1968
- parse (comp) {
1969
- const r = this.options.loose ? re$1[t$1.COMPARATORLOOSE] : re$1[t$1.COMPARATOR];
1970
- const m = comp.match(r);
1971
-
1972
- if (!m) {
1973
- throw new TypeError(`Invalid comparator: ${comp}`)
1974
- }
1975
-
1976
- this.operator = m[1] !== undefined ? m[1] : '';
1977
- if (this.operator === '=') {
1978
- this.operator = '';
1979
- }
1980
-
1981
- // if it literally is just '>' or '' then allow anything.
1982
- if (!m[2]) {
1983
- this.semver = ANY;
1984
- } else {
1985
- this.semver = new SemVer$1(m[2], this.options.loose);
1986
- }
1987
- }
1988
-
1989
- toString () {
1990
- return this.value
1991
- }
1992
-
1993
- test (version) {
1994
- debug$1('Comparator.test', version, this.options.loose);
1995
-
1996
- if (this.semver === ANY || version === ANY) {
1997
- return true
1998
- }
1999
-
2000
- if (typeof version === 'string') {
2001
- try {
2002
- version = new SemVer$1(version, this.options);
2003
- } catch (er) {
2004
- return false
2005
- }
2006
- }
2007
-
2008
- return cmp(version, this.operator, this.semver, this.options)
2009
- }
2010
-
2011
- intersects (comp, options) {
2012
- if (!(comp instanceof Comparator$1)) {
2013
- throw new TypeError('a Comparator is required')
2014
- }
2015
-
2016
- if (!options || typeof options !== 'object') {
2017
- options = {
2018
- loose: !!options,
2019
- includePrerelease: false,
2020
- };
2021
- }
2022
-
2023
- if (this.operator === '') {
2024
- if (this.value === '') {
2025
- return true
2026
- }
2027
- return new Range$2(comp.value, options).test(this.value)
2028
- } else if (comp.operator === '') {
2029
- if (comp.value === '') {
2030
- return true
2031
- }
2032
- return new Range$2(this.value, options).test(comp.semver)
2033
- }
2034
-
2035
- const sameDirectionIncreasing =
2036
- (this.operator === '>=' || this.operator === '>') &&
2037
- (comp.operator === '>=' || comp.operator === '>');
2038
- const sameDirectionDecreasing =
2039
- (this.operator === '<=' || this.operator === '<') &&
2040
- (comp.operator === '<=' || comp.operator === '<');
2041
- const sameSemVer = this.semver.version === comp.semver.version;
2042
- const differentDirectionsInclusive =
2043
- (this.operator === '>=' || this.operator === '<=') &&
2044
- (comp.operator === '>=' || comp.operator === '<=');
2045
- const oppositeDirectionsLessThan =
2046
- cmp(this.semver, '<', comp.semver, options) &&
2047
- (this.operator === '>=' || this.operator === '>') &&
2048
- (comp.operator === '<=' || comp.operator === '<');
2049
- const oppositeDirectionsGreaterThan =
2050
- cmp(this.semver, '>', comp.semver, options) &&
2051
- (this.operator === '<=' || this.operator === '<') &&
2052
- (comp.operator === '>=' || comp.operator === '>');
2053
-
2054
- return (
2055
- sameDirectionIncreasing ||
2056
- sameDirectionDecreasing ||
2057
- (sameSemVer && differentDirectionsInclusive) ||
2058
- oppositeDirectionsLessThan ||
2059
- oppositeDirectionsGreaterThan
2060
- )
2061
- }
2062
- }
2063
-
2064
- var comparator = Comparator$1;
2065
-
2066
- const parseOptions$1 = parseOptions_1;
2067
- const { re: re$1, t: t$1 } = re$5.exports;
2068
- const cmp = cmp_1;
2069
- const debug$1 = debug_1;
2070
- const SemVer$1 = semver;
2071
- const Range$2 = range;
2072
-
2073
- // hoisted class for cyclic dependency
2074
- class Range$1 {
2075
- constructor (range, options) {
2076
- options = parseOptions(options);
2077
-
2078
- if (range instanceof Range$1) {
2079
- if (
2080
- range.loose === !!options.loose &&
2081
- range.includePrerelease === !!options.includePrerelease
2082
- ) {
2083
- return range
2084
- } else {
2085
- return new Range$1(range.raw, options)
2086
- }
2087
- }
2088
-
2089
- if (range instanceof Comparator) {
2090
- // just put it in the set and return
2091
- this.raw = range.value;
2092
- this.set = [[range]];
2093
- this.format();
2094
- return this
2095
- }
2096
-
2097
- this.options = options;
2098
- this.loose = !!options.loose;
2099
- this.includePrerelease = !!options.includePrerelease;
2100
-
2101
- // First, split based on boolean or ||
2102
- this.raw = range;
2103
- this.set = range
2104
- .split('||')
2105
- // map the range to a 2d array of comparators
2106
- .map(r => this.parseRange(r.trim()))
2107
- // throw out any comparator lists that are empty
2108
- // this generally means that it was not a valid range, which is allowed
2109
- // in loose mode, but will still throw if the WHOLE range is invalid.
2110
- .filter(c => c.length);
2111
-
2112
- if (!this.set.length) {
2113
- throw new TypeError(`Invalid SemVer Range: ${range}`)
2114
- }
2115
-
2116
- // if we have any that are not the null set, throw out null sets.
2117
- if (this.set.length > 1) {
2118
- // keep the first one, in case they're all null sets
2119
- const first = this.set[0];
2120
- this.set = this.set.filter(c => !isNullSet(c[0]));
2121
- if (this.set.length === 0) {
2122
- this.set = [first];
2123
- } else if (this.set.length > 1) {
2124
- // if we have any that are *, then the range is just *
2125
- for (const c of this.set) {
2126
- if (c.length === 1 && isAny(c[0])) {
2127
- this.set = [c];
2128
- break
2129
- }
2130
- }
2131
- }
2132
- }
2133
-
2134
- this.format();
2135
- }
2136
-
2137
- format () {
2138
- this.range = this.set
2139
- .map((comps) => {
2140
- return comps.join(' ').trim()
2141
- })
2142
- .join('||')
2143
- .trim();
2144
- return this.range
2145
- }
2146
-
2147
- toString () {
2148
- return this.range
2149
- }
2150
-
2151
- parseRange (range) {
2152
- range = range.trim();
2153
-
2154
- // memoize range parsing for performance.
2155
- // this is a very hot path, and fully deterministic.
2156
- const memoOpts = Object.keys(this.options).join(',');
2157
- const memoKey = `parseRange:${memoOpts}:${range}`;
2158
- const cached = cache.get(memoKey);
2159
- if (cached) {
2160
- return cached
2161
- }
2162
-
2163
- const loose = this.options.loose;
2164
- // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
2165
- const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
2166
- range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
2167
- debug('hyphen replace', range);
2168
- // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
2169
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
2170
- debug('comparator trim', range);
2171
-
2172
- // `~ 1.2.3` => `~1.2.3`
2173
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
2174
-
2175
- // `^ 1.2.3` => `^1.2.3`
2176
- range = range.replace(re[t.CARETTRIM], caretTrimReplace);
2177
-
2178
- // normalize spaces
2179
- range = range.split(/\s+/).join(' ');
2180
-
2181
- // At this point, the range is completely trimmed and
2182
- // ready to be split into comparators.
2183
-
2184
- let rangeList = range
2185
- .split(' ')
2186
- .map(comp => parseComparator(comp, this.options))
2187
- .join(' ')
2188
- .split(/\s+/)
2189
- // >=0.0.0 is equivalent to *
2190
- .map(comp => replaceGTE0(comp, this.options));
2191
-
2192
- if (loose) {
2193
- // in loose mode, throw out any that are not valid comparators
2194
- rangeList = rangeList.filter(comp => {
2195
- debug('loose invalid filter', comp, this.options);
2196
- return !!comp.match(re[t.COMPARATORLOOSE])
2197
- });
2198
- }
2199
- debug('range list', rangeList);
2200
-
2201
- // if any comparators are the null set, then replace with JUST null set
2202
- // if more than one comparator, remove any * comparators
2203
- // also, don't include the same comparator more than once
2204
- const rangeMap = new Map();
2205
- const comparators = rangeList.map(comp => new Comparator(comp, this.options));
2206
- for (const comp of comparators) {
2207
- if (isNullSet(comp)) {
2208
- return [comp]
2209
- }
2210
- rangeMap.set(comp.value, comp);
2211
- }
2212
- if (rangeMap.size > 1 && rangeMap.has('')) {
2213
- rangeMap.delete('');
2214
- }
2215
-
2216
- const result = [...rangeMap.values()];
2217
- cache.set(memoKey, result);
2218
- return result
2219
- }
2220
-
2221
- intersects (range, options) {
2222
- if (!(range instanceof Range$1)) {
2223
- throw new TypeError('a Range is required')
2224
- }
2225
-
2226
- return this.set.some((thisComparators) => {
2227
- return (
2228
- isSatisfiable(thisComparators, options) &&
2229
- range.set.some((rangeComparators) => {
2230
- return (
2231
- isSatisfiable(rangeComparators, options) &&
2232
- thisComparators.every((thisComparator) => {
2233
- return rangeComparators.every((rangeComparator) => {
2234
- return thisComparator.intersects(rangeComparator, options)
2235
- })
2236
- })
2237
- )
2238
- })
2239
- )
2240
- })
2241
- }
2242
-
2243
- // if ANY of the sets match ALL of its comparators, then pass
2244
- test (version) {
2245
- if (!version) {
2246
- return false
2247
- }
2248
-
2249
- if (typeof version === 'string') {
2250
- try {
2251
- version = new SemVer(version, this.options);
2252
- } catch (er) {
2253
- return false
2254
- }
2255
- }
2256
-
2257
- for (let i = 0; i < this.set.length; i++) {
2258
- if (testSet(this.set[i], version, this.options)) {
2259
- return true
2260
- }
2261
- }
2262
- return false
2263
- }
2264
- }
2265
- var range = Range$1;
2266
-
2267
- const LRU = lruCache;
2268
- const cache = new LRU({ max: 1000 });
2269
-
2270
- const parseOptions = parseOptions_1;
2271
- const Comparator = comparator;
2272
- const debug = debug_1;
2273
- const SemVer = semver;
2274
- const {
2275
- re,
2276
- t,
2277
- comparatorTrimReplace,
2278
- tildeTrimReplace,
2279
- caretTrimReplace,
2280
- } = re$5.exports;
2281
-
2282
- const isNullSet = c => c.value === '<0.0.0-0';
2283
- const isAny = c => c.value === '';
2284
-
2285
- // take a set of comparators and determine whether there
2286
- // exists a version which can satisfy it
2287
- const isSatisfiable = (comparators, options) => {
2288
- let result = true;
2289
- const remainingComparators = comparators.slice();
2290
- let testComparator = remainingComparators.pop();
2291
-
2292
- while (result && remainingComparators.length) {
2293
- result = remainingComparators.every((otherComparator) => {
2294
- return testComparator.intersects(otherComparator, options)
2295
- });
2296
-
2297
- testComparator = remainingComparators.pop();
2298
- }
2299
-
2300
- return result
2301
- };
2302
-
2303
- // comprised of xranges, tildes, stars, and gtlt's at this point.
2304
- // already replaced the hyphen ranges
2305
- // turn into a set of JUST comparators.
2306
- const parseComparator = (comp, options) => {
2307
- debug('comp', comp, options);
2308
- comp = replaceCarets(comp, options);
2309
- debug('caret', comp);
2310
- comp = replaceTildes(comp, options);
2311
- debug('tildes', comp);
2312
- comp = replaceXRanges(comp, options);
2313
- debug('xrange', comp);
2314
- comp = replaceStars(comp, options);
2315
- debug('stars', comp);
2316
- return comp
2317
- };
2318
-
2319
- const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
2320
-
2321
- // ~, ~> --> * (any, kinda silly)
2322
- // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
2323
- // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
2324
- // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
2325
- // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
2326
- // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
2327
- // ~0.0.1 --> >=0.0.1 <0.1.0-0
2328
- const replaceTildes = (comp, options) =>
2329
- comp.trim().split(/\s+/).map((c) => {
2330
- return replaceTilde(c, options)
2331
- }).join(' ');
2332
-
2333
- const replaceTilde = (comp, options) => {
2334
- const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
2335
- return comp.replace(r, (_, M, m, p, pr) => {
2336
- debug('tilde', comp, _, M, m, p, pr);
2337
- let ret;
2338
-
2339
- if (isX(M)) {
2340
- ret = '';
2341
- } else if (isX(m)) {
2342
- ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
2343
- } else if (isX(p)) {
2344
- // ~1.2 == >=1.2.0 <1.3.0-0
2345
- ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
2346
- } else if (pr) {
2347
- debug('replaceTilde pr', pr);
2348
- ret = `>=${M}.${m}.${p}-${pr
2349
- } <${M}.${+m + 1}.0-0`;
2350
- } else {
2351
- // ~1.2.3 == >=1.2.3 <1.3.0-0
2352
- ret = `>=${M}.${m}.${p
2353
- } <${M}.${+m + 1}.0-0`;
2354
- }
2355
-
2356
- debug('tilde return', ret);
2357
- return ret
2358
- })
2359
- };
2360
-
2361
- // ^ --> * (any, kinda silly)
2362
- // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
2363
- // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
2364
- // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
2365
- // ^1.2.3 --> >=1.2.3 <2.0.0-0
2366
- // ^1.2.0 --> >=1.2.0 <2.0.0-0
2367
- // ^0.0.1 --> >=0.0.1 <0.0.2-0
2368
- // ^0.1.0 --> >=0.1.0 <0.2.0-0
2369
- const replaceCarets = (comp, options) =>
2370
- comp.trim().split(/\s+/).map((c) => {
2371
- return replaceCaret(c, options)
2372
- }).join(' ');
2373
-
2374
- const replaceCaret = (comp, options) => {
2375
- debug('caret', comp, options);
2376
- const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
2377
- const z = options.includePrerelease ? '-0' : '';
2378
- return comp.replace(r, (_, M, m, p, pr) => {
2379
- debug('caret', comp, _, M, m, p, pr);
2380
- let ret;
2381
-
2382
- if (isX(M)) {
2383
- ret = '';
2384
- } else if (isX(m)) {
2385
- ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
2386
- } else if (isX(p)) {
2387
- if (M === '0') {
2388
- ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
2389
- } else {
2390
- ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
2391
- }
2392
- } else if (pr) {
2393
- debug('replaceCaret pr', pr);
2394
- if (M === '0') {
2395
- if (m === '0') {
2396
- ret = `>=${M}.${m}.${p}-${pr
2397
- } <${M}.${m}.${+p + 1}-0`;
2398
- } else {
2399
- ret = `>=${M}.${m}.${p}-${pr
2400
- } <${M}.${+m + 1}.0-0`;
2401
- }
2402
- } else {
2403
- ret = `>=${M}.${m}.${p}-${pr
2404
- } <${+M + 1}.0.0-0`;
2405
- }
2406
- } else {
2407
- debug('no pr');
2408
- if (M === '0') {
2409
- if (m === '0') {
2410
- ret = `>=${M}.${m}.${p
2411
- }${z} <${M}.${m}.${+p + 1}-0`;
2412
- } else {
2413
- ret = `>=${M}.${m}.${p
2414
- }${z} <${M}.${+m + 1}.0-0`;
2415
- }
2416
- } else {
2417
- ret = `>=${M}.${m}.${p
2418
- } <${+M + 1}.0.0-0`;
2419
- }
2420
- }
2421
-
2422
- debug('caret return', ret);
2423
- return ret
2424
- })
2425
- };
2426
-
2427
- const replaceXRanges = (comp, options) => {
2428
- debug('replaceXRanges', comp, options);
2429
- return comp.split(/\s+/).map((c) => {
2430
- return replaceXRange(c, options)
2431
- }).join(' ')
2432
- };
2433
-
2434
- const replaceXRange = (comp, options) => {
2435
- comp = comp.trim();
2436
- const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
2437
- return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
2438
- debug('xRange', comp, ret, gtlt, M, m, p, pr);
2439
- const xM = isX(M);
2440
- const xm = xM || isX(m);
2441
- const xp = xm || isX(p);
2442
- const anyX = xp;
2443
-
2444
- if (gtlt === '=' && anyX) {
2445
- gtlt = '';
2446
- }
2447
-
2448
- // if we're including prereleases in the match, then we need
2449
- // to fix this to -0, the lowest possible prerelease value
2450
- pr = options.includePrerelease ? '-0' : '';
2451
-
2452
- if (xM) {
2453
- if (gtlt === '>' || gtlt === '<') {
2454
- // nothing is allowed
2455
- ret = '<0.0.0-0';
2456
- } else {
2457
- // nothing is forbidden
2458
- ret = '*';
2459
- }
2460
- } else if (gtlt && anyX) {
2461
- // we know patch is an x, because we have any x at all.
2462
- // replace X with 0
2463
- if (xm) {
2464
- m = 0;
2465
- }
2466
- p = 0;
2467
-
2468
- if (gtlt === '>') {
2469
- // >1 => >=2.0.0
2470
- // >1.2 => >=1.3.0
2471
- gtlt = '>=';
2472
- if (xm) {
2473
- M = +M + 1;
2474
- m = 0;
2475
- p = 0;
2476
- } else {
2477
- m = +m + 1;
2478
- p = 0;
2479
- }
2480
- } else if (gtlt === '<=') {
2481
- // <=0.7.x is actually <0.8.0, since any 0.7.x should
2482
- // pass. Similarly, <=7.x is actually <8.0.0, etc.
2483
- gtlt = '<';
2484
- if (xm) {
2485
- M = +M + 1;
2486
- } else {
2487
- m = +m + 1;
2488
- }
2489
- }
2490
-
2491
- if (gtlt === '<') {
2492
- pr = '-0';
2493
- }
2494
-
2495
- ret = `${gtlt + M}.${m}.${p}${pr}`;
2496
- } else if (xm) {
2497
- ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
2498
- } else if (xp) {
2499
- ret = `>=${M}.${m}.0${pr
2500
- } <${M}.${+m + 1}.0-0`;
2501
- }
2502
-
2503
- debug('xRange return', ret);
2504
-
2505
- return ret
2506
- })
2507
- };
2508
-
2509
- // Because * is AND-ed with everything else in the comparator,
2510
- // and '' means "any version", just remove the *s entirely.
2511
- const replaceStars = (comp, options) => {
2512
- debug('replaceStars', comp, options);
2513
- // Looseness is ignored here. star is always as loose as it gets!
2514
- return comp.trim().replace(re[t.STAR], '')
2515
- };
2516
-
2517
- const replaceGTE0 = (comp, options) => {
2518
- debug('replaceGTE0', comp, options);
2519
- return comp.trim()
2520
- .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
2521
- };
2522
-
2523
- // This function is passed to string.replace(re[t.HYPHENRANGE])
2524
- // M, m, patch, prerelease, build
2525
- // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
2526
- // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
2527
- // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
2528
- const hyphenReplace = incPr => ($0,
2529
- from, fM, fm, fp, fpr, fb,
2530
- to, tM, tm, tp, tpr, tb) => {
2531
- if (isX(fM)) {
2532
- from = '';
2533
- } else if (isX(fm)) {
2534
- from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
2535
- } else if (isX(fp)) {
2536
- from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
2537
- } else if (fpr) {
2538
- from = `>=${from}`;
2539
- } else {
2540
- from = `>=${from}${incPr ? '-0' : ''}`;
2541
- }
2542
-
2543
- if (isX(tM)) {
2544
- to = '';
2545
- } else if (isX(tm)) {
2546
- to = `<${+tM + 1}.0.0-0`;
2547
- } else if (isX(tp)) {
2548
- to = `<${tM}.${+tm + 1}.0-0`;
2549
- } else if (tpr) {
2550
- to = `<=${tM}.${tm}.${tp}-${tpr}`;
2551
- } else if (incPr) {
2552
- to = `<${tM}.${tm}.${+tp + 1}-0`;
2553
- } else {
2554
- to = `<=${to}`;
2555
- }
2556
-
2557
- return (`${from} ${to}`).trim()
2558
- };
2559
-
2560
- const testSet = (set, version, options) => {
2561
- for (let i = 0; i < set.length; i++) {
2562
- if (!set[i].test(version)) {
2563
- return false
2564
- }
2565
- }
2566
-
2567
- if (version.prerelease.length && !options.includePrerelease) {
2568
- // Find the set of versions that are allowed to have prereleases
2569
- // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
2570
- // That should allow `1.2.3-pr.2` to pass.
2571
- // However, `1.2.4-alpha.notready` should NOT be allowed,
2572
- // even though it's within the range set by the comparators.
2573
- for (let i = 0; i < set.length; i++) {
2574
- debug(set[i].semver);
2575
- if (set[i].semver === Comparator.ANY) {
2576
- continue
2577
- }
2578
-
2579
- if (set[i].semver.prerelease.length > 0) {
2580
- const allowed = set[i].semver;
2581
- if (allowed.major === version.major &&
2582
- allowed.minor === version.minor &&
2583
- allowed.patch === version.patch) {
2584
- return true
2585
- }
2586
- }
2587
- }
2588
-
2589
- // Version has a -pre, but it's not one of the ones we like.
2590
- return false
2591
- }
2592
-
2593
- return true
2594
- };
2595
-
2596
- const Range = range;
2597
- const satisfies = (version, range, options) => {
2598
- try {
2599
- range = new Range(range, options);
2600
- } catch (er) {
2601
- return false
2602
- }
2603
- return range.test(version)
2604
- };
2605
- var satisfies_1 = satisfies;
2606
-
2607
- function checkVersion(threshold, version) {
2608
- if (!version)
2609
- return false;
2610
- const parsedVersion = coerce_1(version);
2611
- if (parsedVersion === null)
2612
- return false;
2613
- return satisfies_1(parsedVersion, threshold);
2614
- }
2615
-
2616
460
  function findArgument(args, name) {
2617
461
  const flagIndex = args.indexOf(`--${name}`);
2618
462
  if (flagIndex === -1)
@@ -2644,7 +488,6 @@ const {
2644
488
  PRISMIC_CLIENT,
2645
489
  PRISMIC_DOM_PACKAGE_NAME,
2646
490
  PRISMIC_REACT_PACKAGE_NAME,
2647
- PRISMIC_NEXT,
2648
491
  SM_PACKAGE_NAME,
2649
492
  NUXT_PRISMIC,
2650
493
  PRISMIC_VUE,
@@ -2653,18 +496,12 @@ const {
2653
496
  PRISMIC_HELPERS,
2654
497
  PRISMIC_TYPES
2655
498
  } = core.CONSTS;
2656
- function nextDeps(version) {
2657
- if (checkVersion(">=13.0.0", version)) {
2658
- return PRISMIC_NEXT;
2659
- }
2660
- return "";
2661
- }
2662
- function depsForFramework(framework, version) {
499
+ function depsForFramework(framework) {
2663
500
  switch (framework) {
2664
501
  case core.Models.Frameworks.react:
2665
502
  return `${PRISMIC_REACT_PACKAGE_NAME} ${PRISMIC_CLIENT} ${PRISMIC_HELPERS}`;
2666
503
  case core.Models.Frameworks.next:
2667
- return `${PRISMIC_REACT_PACKAGE_NAME} ${nextDeps(version)} ${PRISMIC_CLIENT} ${SLICE_SIMULATOR_REACT} ${PRISMIC_HELPERS}`;
504
+ return `${PRISMIC_REACT_PACKAGE_NAME} ${PRISMIC_CLIENT} ${SLICE_SIMULATOR_REACT} ${PRISMIC_HELPERS}`;
2668
505
  case core.Models.Frameworks.svelte:
2669
506
  return `${PRISMIC_DOM_PACKAGE_NAME} ${PRISMIC_CLIENT}`;
2670
507
  case core.Models.Frameworks.nuxt:
@@ -2675,11 +512,11 @@ function depsForFramework(framework, version) {
2675
512
  return "";
2676
513
  }
2677
514
  }
2678
- async function addAndInstallDeps(framework, version, useYarn = false) {
515
+ async function addAndInstallDeps(framework, useYarn = false) {
2679
516
  const installDevDependencyCommand = useYarn ? "yarn add -D" : "npm install --save-dev";
2680
517
  const installDependencyCommand = useYarn ? "yarn add" : "npm install --save";
2681
518
  const { stderr } = await execCommand(`${installDevDependencyCommand} ${SM_PACKAGE_NAME} ${PRISMIC_TYPES}`);
2682
- const deps = depsForFramework(framework, version);
519
+ const deps = depsForFramework(framework);
2683
520
  if (deps)
2684
521
  await execCommand(`${installDependencyCommand} ${deps}`);
2685
522
  return stderr;
@@ -2689,11 +526,11 @@ async function installDeps(useYarn = false) {
2689
526
  const { stderr } = await execCommand(installCommand);
2690
527
  return stderr;
2691
528
  }
2692
- async function installRequiredDependencies(cwd, framework, skipDependencies, version) {
529
+ async function installRequiredDependencies(cwd, framework, skipDependencies) {
2693
530
  const yarnLock = NodeUtils__namespace.Files.exists(NodeUtils__namespace.YarnLockPath(cwd));
2694
531
  const spinner = spinner$1("Installing Slice Machine");
2695
532
  spinner.start();
2696
- const stderr = await (skipDependencies ? installDeps(yarnLock) : addAndInstallDeps(framework, version, yarnLock));
533
+ const stderr = await (skipDependencies ? installDeps(yarnLock) : addAndInstallDeps(framework, yarnLock));
2697
534
  const pathToPkg = path__default["default"].join(NodeUtils__namespace.PackagePaths(cwd).value(), SM_PACKAGE_NAME);
2698
535
  const isPackageInstalled = NodeUtils__namespace.Files.exists(pathToPkg);
2699
536
  if (isPackageInstalled || !stderr.length) {
@@ -2885,8 +722,7 @@ async function promptForFramework() {
2885
722
  ]).then((res) => {
2886
723
  return {
2887
724
  value: res.framework,
2888
- manuallyAdded: true,
2889
- version: void 0
725
+ manuallyAdded: true
2890
726
  };
2891
727
  });
2892
728
  }
@@ -2895,26 +731,25 @@ async function detectFramework(cwd) {
2895
731
  const spinner = spinner$1("Detecting framework to install correct dependencies");
2896
732
  spinner.start();
2897
733
  try {
2898
- const { framework, version } = NodeUtils__namespace.Framework.defineFrameworkWithVersion({
734
+ const maybeFramework = NodeUtils__namespace.Framework.defineFramework({
2899
735
  cwd,
2900
736
  supportedFrameworks: Object.values(core.Models.Frameworks)
2901
737
  });
2902
738
  spinner.stop();
2903
- if (!framework || framework === core.Models.Frameworks.vanillajs) {
739
+ if (!maybeFramework || maybeFramework === core.Models.Frameworks.vanillajs) {
2904
740
  writeError$1("Framework not detected");
2905
741
  return await promptForFramework();
2906
742
  }
2907
- const nameToPrint = NodeUtils__namespace.Framework.fancyName(framework);
2908
- if (!NodeUtils__namespace.Framework.isFrameworkSupported(framework)) {
743
+ const nameToPrint = NodeUtils__namespace.Framework.fancyName(maybeFramework);
744
+ if (!NodeUtils__namespace.Framework.isFrameworkSupported(maybeFramework)) {
2909
745
  writeError$1(`${nameToPrint} is currently not supported`);
2910
746
  console.log(failMessage);
2911
747
  process.exit(1);
2912
748
  }
2913
749
  writeCheck(`${nameToPrint} detected`);
2914
750
  return {
2915
- value: framework,
2916
- manuallyAdded: false,
2917
- version
751
+ value: maybeFramework,
752
+ manuallyAdded: false
2918
753
  };
2919
754
  } catch (error) {
2920
755
  spinner.fail("package.json not found");
@@ -3364,7 +1199,7 @@ async function init() {
3364
1199
  const sliceLibPath = lib ? await installLib(cwd, lib, branch) : void 0;
3365
1200
  const wasStarter = await sendStarterData(client$1, cwd, pushDocuments);
3366
1201
  await configureProject(client$1, cwd, repository, frameworkResult, sliceLibPath, isTrackingAvailable);
3367
- await installRequiredDependencies(cwd, frameworkResult.value, wasStarter, frameworkResult.version);
1202
+ await installRequiredDependencies(cwd, frameworkResult.value, wasStarter);
3368
1203
  setVersion(cwd);
3369
1204
  displayFinalMessage(cwd, wasStarter, repository, client$1.apisEndpoints.Wroom);
3370
1205
  }