package-json-scripts-portability 0.0.1 → 0.0.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.
Files changed (115) hide show
  1. package/README.md +59 -20
  2. package/dist/analyze-script.d.mts +34 -0
  3. package/dist/analyze-script.mjs +53 -0
  4. package/dist/command-checker.mjs +527 -0
  5. package/dist/command-usage.mjs +413 -0
  6. package/dist/commands.mjs +639 -0
  7. package/dist/context.mjs +25 -0
  8. package/dist/fixes.d.mts +9 -0
  9. package/dist/fixes.mjs +354 -0
  10. package/dist/index.d.mts +6 -118
  11. package/dist/index.mjs +4 -3787
  12. package/dist/line-break-checker.mjs +104 -0
  13. package/dist/messages.mjs +38 -0
  14. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-difference.mjs +11 -0
  15. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-includes.mjs +8 -0
  16. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs +13 -0
  17. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-is-subset.mjs +16 -0
  18. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/arrayify.mjs +7 -0
  19. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index-with.mjs +33 -0
  20. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index.mjs +10 -0
  21. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/iterable/sliding-window.mjs +30 -0
  22. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert-computed.mjs +42 -0
  23. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert.mjs +40 -0
  24. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/math/clamp.mjs +7 -0
  25. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/path/to-forward-slashes.mjs +8 -0
  26. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/predicate/is-array.mjs +39 -0
  27. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/semver/is-semver-in-range.mjs +5 -0
  28. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/semver/parse-semver.mjs +26 -0
  29. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/set/set-has.mjs +8 -0
  30. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after-last.mjs +24 -0
  31. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after.mjs +24 -0
  32. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-before.mjs +24 -0
  33. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/truncate.mjs +46 -0
  34. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/ts/all-union-members.mjs +45 -0
  35. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/types/maybe-readonly-array.d.mts +17 -0
  36. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/value/is-equal.mjs +37 -0
  37. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/@antfu/utils/dist/index.mjs +5 -0
  38. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/globalThis.mjs +5 -0
  39. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/isUnsafeProperty.mjs +18 -0
  40. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/setOwnValue.mjs +23 -0
  41. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/toPropertyKey.mjs +16 -0
  42. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceBy.mjs +40 -0
  43. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceWith.mjs +37 -0
  44. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/intersectionWith.mjs +43 -0
  45. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/isSubsetWith.mjs +36 -0
  46. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/bigint/clamp.mjs +15 -0
  47. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/baseToString.mjs +26 -0
  48. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getSymbols.mjs +5 -0
  49. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getTag.mjs +13 -0
  50. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/hasOwn.mjs +13 -0
  51. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/isDeepKey.mjs +39 -0
  52. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/isIndex.mjs +10 -0
  53. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/regexMultiByte.mjs +10 -0
  54. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/tags.mjs +28 -0
  55. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/toKey.mjs +15 -0
  56. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedIndex.mjs +36 -0
  57. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedIndexBy.mjs +54 -0
  58. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedLastIndex.mjs +34 -0
  59. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedLastIndexBy.mjs +21 -0
  60. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/function/identity.mjs +5 -0
  61. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeep.mjs +52 -0
  62. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeepWith.mjs +179 -0
  63. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/get.mjs +67 -0
  64. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/has.mjs +53 -0
  65. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/property.mjs +26 -0
  66. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isArguments.mjs +26 -0
  67. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isBuffer.mjs +24 -0
  68. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatch.mjs +34 -0
  69. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatchWith.mjs +163 -0
  70. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNaN.mjs +18 -0
  71. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNil.mjs +24 -0
  72. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNumber.mjs +24 -0
  73. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObject.mjs +28 -0
  74. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObjectLike.mjs +28 -0
  75. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isSymbol.mjs +19 -0
  76. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isTypedArray.mjs +21 -0
  77. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/matches.mjs +36 -0
  78. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/matchesProperty.mjs +47 -0
  79. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/string/truncate.mjs +78 -0
  80. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/eq.mjs +18 -0
  81. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/iteratee.mjs +46 -0
  82. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/toPath.mjs +75 -0
  83. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/toString.mjs +23 -0
  84. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/identity.mjs +24 -0
  85. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/noop.mjs +12 -0
  86. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/math/clamp.mjs +23 -0
  87. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isBuffer.mjs +24 -0
  88. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqual.mjs +21 -0
  89. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqualWith.mjs +150 -0
  90. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isNil.mjs +24 -0
  91. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isNull.mjs +25 -0
  92. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPlainObject.mjs +50 -0
  93. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPrimitive.mjs +26 -0
  94. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isSymbol.mjs +28 -0
  95. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isTypedArray.mjs +20 -0
  96. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isUndefined.mjs +25 -0
  97. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/binarySearchCutoffIndex-Bu-OMJ0Z.mjs +26 -0
  98. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/isArray.mjs +18 -0
  99. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/sortedIndexWith.mjs +7 -0
  100. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/array-includes.mjs +5 -0
  101. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/set-has.mjs +5 -0
  102. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/comparison-CmVirWIW.mjs +108 -0
  103. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/range-C5wjdo9a.mjs +164 -0
  104. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/set-BGFWKKE8.mjs +38 -0
  105. package/dist/platforms.d.mts +8 -0
  106. package/dist/platforms.mjs +26 -0
  107. package/dist/redirection-checker.mjs +169 -0
  108. package/dist/reporter.d.mts +32 -0
  109. package/dist/reporter.mjs +143 -0
  110. package/dist/runners.d.mts +21 -0
  111. package/dist/runners.mjs +199 -0
  112. package/dist/script-analyzer.mjs +853 -0
  113. package/dist/word-checker.mjs +573 -0
  114. package/dist/words.mjs +70 -0
  115. package/package.json +36 -30
@@ -0,0 +1,164 @@
1
+ import { A as LOOSE_PLAIN, C as BUILD, D as GREATER_LESS_THAN, F as safeRegex, N as XRANGE_PLAIN, O as LONE_CARET, P as XRANGE_PLAIN_LOOSE, S as tryParse, k as LONE_TILDE } from "./comparison-CmVirWIW.mjs";
2
+ import { r as testComparatorSet, s as parseComparator } from "./set-BGFWKKE8.mjs";
3
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/range-C5wjdo9a.mjs
4
+ const BUILD_STRIP = new RegExp(BUILD, "g");
5
+ const BUILD_SAFE = safeRegex(BUILD);
6
+ const STRICT_HYPHEN = safeRegex(String.raw`^\s*(${XRANGE_PLAIN})\s+-\s+(${XRANGE_PLAIN})\s*$`);
7
+ const LOOSE_HYPHEN = safeRegex(String.raw`^\s*(${XRANGE_PLAIN_LOOSE})\s+-\s+(${XRANGE_PLAIN_LOOSE})\s*$`);
8
+ const COMPARATOR_TRIM = safeRegex(String.raw`(\s*)${GREATER_LESS_THAN}\s*(${LOOSE_PLAIN}|${XRANGE_PLAIN})`, "g");
9
+ const TILDE_TRIM = safeRegex(String.raw`(\s*)${LONE_TILDE}\s+`, "g");
10
+ const CARET_TRIM = safeRegex(String.raw`(\s*)${LONE_CARET}\s+`, "g");
11
+ const STRICT_TILDE = safeRegex(`^${LONE_TILDE}${XRANGE_PLAIN}$`);
12
+ const LOOSE_TILDE = safeRegex(`^${LONE_TILDE}${XRANGE_PLAIN_LOOSE}$`);
13
+ const STRICT_CARET = safeRegex(`^${LONE_CARET}${XRANGE_PLAIN}$`);
14
+ const LOOSE_CARET = safeRegex(`^${LONE_CARET}${XRANGE_PLAIN_LOOSE}$`);
15
+ const STRICT_XRANGE = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*${XRANGE_PLAIN}$`);
16
+ const LOOSE_XRANGE = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*${XRANGE_PLAIN_LOOSE}$`);
17
+ const STAR = safeRegex(String.raw`(<|>)?=?\s*\*`);
18
+ const GTE_ZERO = /^\s*>=\s*0\.0\.0\s*$/;
19
+ const GTE_ZERO_PRERELEASE = /^\s*>=\s*0\.0\.0-0\s*$/;
20
+ const LOOSE_COMPARATOR = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${LOOSE_PLAIN})$|^$`);
21
+ function isWildcard(value) {
22
+ return !value || String(value).toLowerCase() === "x" || String(value) === "*";
23
+ }
24
+ function hasInvalidWildcardOrder(major, minor, patch) {
25
+ return isWildcard(major) && !isWildcard(minor) || isWildcard(minor) && Boolean(patch) && !isWildcard(patch);
26
+ }
27
+ function replaceTilde(comparator, options) {
28
+ const expression = options.loose ? LOOSE_TILDE : STRICT_TILDE;
29
+ const lowerPrerelease = options.includePrerelease ? "-0" : "";
30
+ return comparator.replace(expression, (_match, major, minor, patch, prerelease) => {
31
+ if (isWildcard(major)) return "";
32
+ if (isWildcard(minor)) return `>=${major}.0.0${lowerPrerelease} <${Number(major) + 1}.0.0-0`;
33
+ if (isWildcard(patch)) return `>=${major}.${minor}.0${lowerPrerelease} <${major}.${Number(minor) + 1}.0-0`;
34
+ return prerelease ? `>=${major}.${minor}.${patch}-${prerelease} <${major}.${Number(minor) + 1}.0-0` : `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
35
+ });
36
+ }
37
+ function replaceTildes(comparator, options) {
38
+ return comparator.trim().split(/\s+/).map((part) => replaceTilde(part, options)).join(" ");
39
+ }
40
+ function replaceCaret(comparator, options) {
41
+ const expression = options.loose ? LOOSE_CARET : STRICT_CARET;
42
+ const lowerPrerelease = options.includePrerelease ? "-0" : "";
43
+ return comparator.replace(expression, (_match, major, minor, patch, prerelease) => {
44
+ if (isWildcard(major)) return "";
45
+ if (isWildcard(minor)) return `>=${major}.0.0${lowerPrerelease} <${Number(major) + 1}.0.0-0`;
46
+ if (isWildcard(patch)) return major === "0" ? `>=${major}.${minor}.0${lowerPrerelease} <${major}.${Number(minor) + 1}.0-0` : `>=${major}.${minor}.0${lowerPrerelease} <${Number(major) + 1}.0.0-0`;
47
+ if (prerelease) return major === "0" ? minor === "0" ? `>=${major}.${minor}.${patch}-${prerelease} <${major}.${minor}.${Number(patch) + 1}-0` : `>=${major}.${minor}.${patch}-${prerelease} <${major}.${Number(minor) + 1}.0-0` : `>=${major}.${minor}.${patch}-${prerelease} <${Number(major) + 1}.0.0-0`;
48
+ return major === "0" ? minor === "0" ? `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0` : `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0` : `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
49
+ });
50
+ }
51
+ function replaceCarets(comparator, options) {
52
+ return comparator.trim().split(/\s+/).map((part) => replaceCaret(part, options)).join(" ");
53
+ }
54
+ function replaceXRange(comparator, options) {
55
+ const expression = options.loose ? LOOSE_XRANGE : STRICT_XRANGE;
56
+ return comparator.trim().replace(expression, (match, rawOperator, rawMajor, rawMinor, rawPatch) => {
57
+ let operator = rawOperator;
58
+ let major = rawMajor;
59
+ let minor = rawMinor;
60
+ let patch = rawPatch;
61
+ if (hasInvalidWildcardOrder(String(major), minor === void 0 ? void 0 : String(minor), patch === void 0 ? void 0 : String(patch))) return comparator;
62
+ const wildcardMajor = isWildcard(major);
63
+ const wildcardMinor = wildcardMajor || isWildcard(minor);
64
+ const wildcardPatch = wildcardMinor || isWildcard(patch);
65
+ if (operator === "=" && wildcardPatch) operator = "";
66
+ if (wildcardMajor) return operator === ">" || operator === "<" ? "<0.0.0-0" : "*";
67
+ let prerelease = options.includePrerelease ? "-0" : "";
68
+ if (operator && wildcardPatch) {
69
+ if (wildcardMinor) minor = 0;
70
+ patch = 0;
71
+ if (operator === ">") {
72
+ operator = ">=";
73
+ if (wildcardMinor) {
74
+ major = Number(major) + 1;
75
+ minor = 0;
76
+ } else minor = Number(minor) + 1;
77
+ } else if (operator === "<=") {
78
+ operator = "<";
79
+ if (wildcardMinor) major = Number(major) + 1;
80
+ else minor = Number(minor) + 1;
81
+ }
82
+ if (operator === "<") prerelease = "-0";
83
+ return `${operator}${major}.${minor}.${patch}${prerelease}`;
84
+ }
85
+ if (wildcardMinor) return `>=${major}.0.0${prerelease} <${Number(major) + 1}.0.0-0`;
86
+ if (wildcardPatch) return `>=${major}.${minor}.0${prerelease} <${major}.${Number(minor) + 1}.0-0`;
87
+ return match;
88
+ });
89
+ }
90
+ function replaceXRanges(comparator, options) {
91
+ return comparator.split(/\s+/).map((part) => replaceXRange(part, options)).join(" ");
92
+ }
93
+ function replaceHyphenRange(range, options) {
94
+ const expression = options.loose ? LOOSE_HYPHEN : STRICT_HYPHEN;
95
+ return range.replace(expression, (_match, rawFrom, fromMajor, fromMinor, fromPatch, fromPrerelease, _fromBuild, rawTo, toMajor, toMinor, toPatch, toPrerelease) => {
96
+ let from = rawFrom;
97
+ let to = rawTo;
98
+ if (isWildcard(fromMajor)) from = "";
99
+ else if (isWildcard(fromMinor)) from = `>=${fromMajor}.0.0${options.includePrerelease ? "-0" : ""}`;
100
+ else if (isWildcard(fromPatch)) from = `>=${fromMajor}.${fromMinor}.0${options.includePrerelease ? "-0" : ""}`;
101
+ else if (fromPrerelease) from = `>=${from}`;
102
+ else from = `>=${from}${options.includePrerelease ? "-0" : ""}`;
103
+ if (isWildcard(toMajor)) to = "";
104
+ else if (isWildcard(toMinor)) to = `<${Number(toMajor) + 1}.0.0-0`;
105
+ else if (isWildcard(toPatch)) to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
106
+ else if (toPrerelease) to = `<=${toMajor}.${toMinor}.${toPatch}-${toPrerelease}`;
107
+ else if (options.includePrerelease) to = `<${toMajor}.${toMinor}.${Number(toPatch) + 1}-0`;
108
+ else to = `<=${to}`;
109
+ return `${from} ${to}`.trim();
110
+ });
111
+ }
112
+ function expandComparator(comparator, options) {
113
+ return replaceXRanges(replaceTildes(replaceCarets(comparator.replace(BUILD_SAFE, ""), options), options), options).trim().replace(STAR, "");
114
+ }
115
+ function parseSimpleRange(input, options) {
116
+ let parts = replaceHyphenRange(input.replace(BUILD_STRIP, ""), options).replace(COMPARATOR_TRIM, "$1$2$3").replace(TILDE_TRIM, "$1~").replace(CARET_TRIM, "$1^").split(" ").map((part) => expandComparator(part, options)).join(" ").split(/\s+/).map((part) => part.trim().replace(options.includePrerelease ? GTE_ZERO_PRERELEASE : GTE_ZERO, ""));
117
+ if (options.loose) parts = parts.filter((part) => LOOSE_COMPARATOR.test(part));
118
+ const unique = /* @__PURE__ */ new Map();
119
+ for (const comparator of parts.map((part) => parseComparator(part, options))) {
120
+ if (comparator.value === "<0.0.0-0") return [comparator];
121
+ unique.set(comparator.value, comparator);
122
+ }
123
+ if (unique.size > 1) unique.delete("");
124
+ return [...unique.values()];
125
+ }
126
+ function parseRange(range, options = {}) {
127
+ if (typeof range !== "string") return range;
128
+ const parsedOptions = { ...options };
129
+ const normalizedRange = range.trim().replaceAll(/\s+/g, " ");
130
+ let sets = normalizedRange.split("||").map((part) => parseSimpleRange(part.trim(), parsedOptions)).filter((set) => set.length);
131
+ if (!sets.length) throw new TypeError(`Range contains no valid comparator sets: ${normalizedRange}`);
132
+ if (sets.length > 1) {
133
+ const first = sets[0];
134
+ sets = sets.filter((set) => set[0]?.value !== "<0.0.0-0");
135
+ if (!sets.length) sets = [first];
136
+ else if (sets.length > 1) {
137
+ const any = sets.find((set) => set.length === 1 && set[0]?.value === "");
138
+ if (any) sets = [any];
139
+ }
140
+ }
141
+ return {
142
+ options: parsedOptions,
143
+ sets
144
+ };
145
+ }
146
+ function tryParseRange(range, options = {}) {
147
+ try {
148
+ return parseRange(range, options);
149
+ } catch {
150
+ return null;
151
+ }
152
+ }
153
+ function testParsedRange(range, version) {
154
+ return range.sets.some((set) => testComparatorSet(set, version, range.options));
155
+ }
156
+ function testRangeVersion(range, version) {
157
+ const parsed = tryParse(version, range.options);
158
+ return parsed ? testParsedRange(range, parsed) : false;
159
+ }
160
+ function satisfies(version, range, options = {}) {
161
+ const parsed = tryParseRange(range, options);
162
+ return parsed ? testRangeVersion(parsed, version) : false;
163
+ }
164
+ export { satisfies as f, tryParseRange as h, parseRange as m };
@@ -0,0 +1,38 @@
1
+ import { A as LOOSE_PLAIN, D as GREATER_LESS_THAN, E as FULL_PLAIN, F as safeRegex, a as compareParsed, x as parse, y as formatComparableVersion } from "./comparison-CmVirWIW.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/set-BGFWKKE8.mjs
3
+ const STRICT_COMPARATOR = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${FULL_PLAIN})$|^$`);
4
+ const LOOSE_COMPARATOR = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${LOOSE_PLAIN})$|^$`);
5
+ function parseComparator(comparator, options = {}) {
6
+ if (typeof comparator !== "string") return comparator;
7
+ const normalized = comparator.trim().replaceAll(/\s+/g, " ");
8
+ const match = normalized.match(options.loose ? LOOSE_COMPARATOR : STRICT_COMPARATOR);
9
+ if (!match) throw new TypeError(`Invalid comparator: ${normalized}`);
10
+ const operator = match[1] === "=" ? "" : match[1] || "";
11
+ const version = match[2] ? parse(match[2], options) : null;
12
+ return {
13
+ operator,
14
+ options,
15
+ value: version ? `${operator}${formatComparableVersion(version)}` : "",
16
+ version
17
+ };
18
+ }
19
+ function testParsedComparator(comparator, version) {
20
+ if (!comparator.version) return true;
21
+ const comparison = compareParsed(version, comparator.version);
22
+ switch (comparator.operator) {
23
+ case "": return comparison === 0;
24
+ case ">": return comparison > 0;
25
+ case ">=": return comparison >= 0;
26
+ case "<": return comparison < 0;
27
+ case "<=": return comparison <= 0;
28
+ }
29
+ }
30
+ function comparatorAllowsPrerelease(comparator, version) {
31
+ const allowed = comparator.version;
32
+ return allowed !== null && !!allowed.prerelease?.length && allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch;
33
+ }
34
+ function testComparatorSet(set, version, options) {
35
+ if (set.some((comparator) => !testParsedComparator(comparator, version))) return false;
36
+ return !version.prerelease?.length || !!options.includePrerelease || set.some((comparator) => comparatorAllowsPrerelease(comparator, version));
37
+ }
38
+ export { testParsedComparator as a, testComparatorSet as r, parseComparator as s, comparatorAllowsPrerelease as t };
@@ -0,0 +1,8 @@
1
+ export type Platform = 'darwin' | 'linux' | 'win32';
2
+ export declare const PLATFORMS: readonly Platform[];
3
+ /**
4
+ * Formats platforms as a list for people, e.g. "macOS, Linux, and Windows".
5
+ * @param platforms The platforms to format
6
+ * @returns The formatted list
7
+ */
8
+ export declare const formatPlatforms: (platforms: readonly Platform[]) => string;
@@ -0,0 +1,26 @@
1
+ import { listFormat } from "./messages.mjs";
2
+ import { arrayIntersection } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs";
3
+ // src/platforms.ts
4
+ const PLATFORMS = [
5
+ "darwin",
6
+ "linux",
7
+ "win32"
8
+ ];
9
+ const POSIX_PLATFORMS = ["darwin", "linux"];
10
+ const MACOS_PLATFORMS = ["darwin"];
11
+ const LINUX_PLATFORMS = ["linux"];
12
+ const WINDOWS_PLATFORMS = ["win32"];
13
+ const NOT_LINUX_OR_WINDOWS = ["linux", "win32"];
14
+ const NOT_MACOS_OR_WINDOWS = ["darwin", "win32"];
15
+ const PLATFORM_NAMES = {
16
+ darwin: "macOS",
17
+ linux: "Linux",
18
+ win32: "Windows"
19
+ };
20
+ /**
21
+ * Formats platforms as a list for people, e.g. "macOS, Linux, and Windows".
22
+ * @param platforms The platforms to format
23
+ * @returns The formatted list
24
+ */
25
+ const formatPlatforms = (platforms) => listFormat.format(arrayIntersection(PLATFORMS, platforms).map((platform) => PLATFORM_NAMES[platform]));
26
+ export { LINUX_PLATFORMS, MACOS_PLATFORMS, NOT_LINUX_OR_WINDOWS, NOT_MACOS_OR_WINDOWS, PLATFORMS, POSIX_PLATFORMS, WINDOWS_PLATFORMS, formatPlatforms };
@@ -0,0 +1,169 @@
1
+ import { bashLabel, originalText } from "./context.mjs";
2
+ import { removal, replacement } from "./fixes.mjs";
3
+ import { BASH_4_SUGGESTION, NODE_SCRIPT_SUGGESTION, describeReplacement, truncate } from "./messages.mjs";
4
+ import { POSIX_PLATFORMS } from "./platforms.mjs";
5
+ import { mapGetOrInsert } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert.mjs";
6
+ import { setHas } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/set/set-has.mjs";
7
+ import { sortedArrayInsertionIndex } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index.mjs";
8
+ import { POSIX_PATH, WHITESPACE, staticValue } from "./words.mjs";
9
+ // src/redirection-checker.ts
10
+ /** The target of a redirection that duplicates or closes a file descriptor, e.g. `1` or `-` */
11
+ const DESCRIPTOR = /^(?:\d+|-)$/;
12
+ /** The target of a redirection that moves a file descriptor, e.g. `3-` */
13
+ const MOVED_DESCRIPTOR = /^\d+-$/;
14
+ /** Device names, which cmd.exe treats as the device in any directory */
15
+ const WINDOWS_DEVICES = /* @__PURE__ */ new Set([
16
+ "aux",
17
+ "con",
18
+ "nul",
19
+ "prn"
20
+ ]);
21
+ /** Redirection operators that write the standard output to a file, e.g. `>` */
22
+ const OUTPUT_OPERATORS = /* @__PURE__ */ new Set([
23
+ "&>",
24
+ "&>>",
25
+ ">",
26
+ ">&",
27
+ ">>",
28
+ ">|"
29
+ ]);
30
+ /** Checks whether a redirection is of the standard output, e.g. `>` or `1>`, but not `2>` */
31
+ const isOfStandardOutput = ({ descriptor }) => descriptor == null || descriptor.type === "FileDescriptor" && descriptor.value === 1;
32
+ /** Checks whether a redirection is of the standard output or error, e.g. `2>`, but not `3>` */
33
+ const isOfStandardStream = (redirection) => isOfStandardOutput(redirection) || redirection.descriptor?.type === "FileDescriptor" && redirection.descriptor.value === 2;
34
+ /**
35
+ * Checks whether a redirection writes the standard output to a file, e.g. `> out.log`, but not
36
+ * `>&2`, `2> err.log` or `> /dev/null`.
37
+ * @param redirection The redirection
38
+ * @returns Whether it does
39
+ */
40
+ const doesRedirectOutput = (redirection) => {
41
+ if (redirection.type !== "Redirect" || !OUTPUT_OPERATORS.has(redirection.operator)) return false;
42
+ const { operator, target } = redirection;
43
+ const value = target && staticValue(target);
44
+ return isOfStandardOutput(redirection) && !(operator === ">&" && value != null && DESCRIPTOR.test(value)) && !POSIX_PATH.test(value || "") && !setHas(WINDOWS_DEVICES, value?.toLowerCase());
45
+ };
46
+ /** Checks redirections, e.g. for Bash-specific operators and device files */
47
+ var RedirectionChecker = class {
48
+ /** End offsets of here-documents in ascending order, by the source that they're in */
49
+ hereDocumentEnds = /* @__PURE__ */ new Map();
50
+ #reporter;
51
+ #words;
52
+ constructor(reporter, words) {
53
+ this.#reporter = reporter;
54
+ this.#words = words;
55
+ }
56
+ /**
57
+ * Reports a double-quoted string that `echo` writes to a file or a pipe.
58
+ * @param node The `echo` command, whose output doesn't go to the terminal
59
+ * @param context Where the command is
60
+ */
61
+ checkQuotedEcho(node, context) {
62
+ const quoted = node.args.find((argument) => argument.type === "Word" && argument.parts?.some((part) => part.type === "DoubleQuoted"));
63
+ if (quoted) this.#reporter.reportSyntax(context, quoted, "posix", true, "inconsistentBehavior", {
64
+ reason: "cmd.exe's `echo` writes the quotes too",
65
+ suggestion: NODE_SCRIPT_SUGGESTION,
66
+ syntax: "Writing a double-quoted string with `echo`"
67
+ });
68
+ }
69
+ /**
70
+ * Checks a redirection and its target.
71
+ * @param redirection Redirection to check, e.g. `> out.log`
72
+ * @param context Where the redirection is
73
+ * @param isWholeCommand Whether the redirection is the whole command, e.g. `>log` in `tsc | >log`
74
+ */
75
+ checkRedirection(redirection, context, isWholeCommand = false) {
76
+ const text = originalText(context, redirection);
77
+ switch (redirection.type) {
78
+ case "HereDoc": {
79
+ this.#reporter.reportSyntax(context, redirection, "posix", false, "unsupportedSyntax", {
80
+ suggestion: NODE_SCRIPT_SUGGESTION,
81
+ syntax: `The here-document \`${redirection.operator}\``
82
+ });
83
+ const end = redirection.closing?.end ?? redirection.body.end;
84
+ const ends = mapGetOrInsert(this.hereDocumentEnds, context.source, []);
85
+ ends.splice(sortedArrayInsertionIndex(ends, end, { rightmost: true }), 0, end);
86
+ return;
87
+ }
88
+ case "HereString":
89
+ this.#reporter.reportSyntax(context, redirection, "bash", true, "unsupportedSyntax", {
90
+ suggestion: "Pipe the value into the command instead.",
91
+ syntax: "The Bash-specific here-string `<<<`"
92
+ });
93
+ break;
94
+ case "Redirect": {
95
+ const { descriptor, operator } = redirection;
96
+ if (descriptor?.type === "FileDescriptorVariable") this.#reporter.reportSyntax(context, descriptor, "bash4", false, "unsupportedSyntax", {
97
+ suggestion: BASH_4_SUGGESTION,
98
+ syntax: `The Bash 4 file descriptor variable \`{${descriptor.name}}\``
99
+ });
100
+ const separator = redirection.pos > 0 && !WHITESPACE.test(context.source.charAt(redirection.pos - 1)) ? " " : "";
101
+ const bothOutputsFix = (target, fixedOperator) => ({
102
+ description: describeReplacement(text, `${fixedOperator} ${originalText(context, target)} 2>&1`),
103
+ edits: [{
104
+ end: target.pos,
105
+ pos: redirection.pos,
106
+ text: `${separator}${fixedOperator} `
107
+ }, {
108
+ end: redirection.end,
109
+ pos: redirection.end,
110
+ text: " 2>&1"
111
+ }]
112
+ });
113
+ if (operator === "&>" || operator === "&>>") {
114
+ const kind = operator === "&>" ? "bash" : "bash4";
115
+ this.#reporter.reportSyntax(context, redirection, kind, false, "unsupportedSyntax", {
116
+ suggestion: `Use \`${operator.slice(1)} file 2>&1\` instead.`,
117
+ syntax: `The ${bashLabel(kind)} \`${operator}\` redirection`
118
+ }, redirection.target && bothOutputsFix(redirection.target, operator.slice(1)));
119
+ } else if (operator === ">|" || operator === "<>") {
120
+ const position = context.source.indexOf(operator, descriptor?.end || redirection.pos);
121
+ this.#reporter.reportSyntax(context, redirection, "posix", false, "unsupportedSyntax", {
122
+ suggestion: operator === ">|" ? "Use `>` instead." : NODE_SCRIPT_SUGGESTION,
123
+ syntax: `The \`${operator}\` redirection`
124
+ }, operator === ">|" ? replacement({
125
+ end: position + operator.length,
126
+ pos: position
127
+ }, operator, ">") : void 0);
128
+ }
129
+ if (redirection.target && (operator === ">&" || operator === "<&")) {
130
+ const target = staticValue(redirection.target);
131
+ if (target != null && DESCRIPTOR.test(target)) return;
132
+ if (target != null && MOVED_DESCRIPTOR.test(target)) {
133
+ const descriptorNumber = target.slice(0, -1);
134
+ this.#reporter.reportSyntax(context, redirection, "bash", false, "unsupportedSyntax", {
135
+ suggestion: `Use \`${truncate(text.slice(0, -1))} ${descriptorNumber}>&-\` instead.`,
136
+ syntax: `The Bash-specific \`${truncate(text)}\` file descriptor move`
137
+ });
138
+ return;
139
+ }
140
+ if (operator === ">&" && target != null) this.#reporter.reportSyntax(context, redirection, "bash", false, "unsupportedSyntax", {
141
+ suggestion: `Use \`> ${truncate(target)} 2>&1\` instead.`,
142
+ syntax: "The Bash-specific `>&` redirection to a file"
143
+ }, descriptor ? void 0 : bothOutputsFix(redirection.target, ">"));
144
+ }
145
+ break;
146
+ }
147
+ }
148
+ if (!redirection.target) return;
149
+ const target = staticValue(redirection.target);
150
+ const isHereString = redirection.type === "HereString";
151
+ if (target != null && !isHereString && WINDOWS_DEVICES.has(target.toLowerCase())) this.#reporter.report(context, redirection.target, "inconsistentBehavior", {
152
+ reason: `POSIX shells create a file named \`${target}\` instead`,
153
+ suggestion: "Remove the redirection or use a Node.js script instead.",
154
+ syntax: `The redirection to \`${target}\``
155
+ }, POSIX_PLATFORMS);
156
+ this.#words.checkWord(redirection.target, context, {
157
+ redirectTarget: true,
158
+ skipGlobs: isHereString,
159
+ text: isHereString
160
+ });
161
+ if (target == null || isHereString || target === "/dev/null" && context.portable) return;
162
+ const doesDiscardOutput = !isWholeCommand && (redirection.operator === ">" || redirection.operator === ">>") && isOfStandardStream(redirection) && target === "/dev/null" && !(context.outputRedirected && isOfStandardOutput(redirection));
163
+ this.#words.checkPosixPath(redirection.target, target, context, doesDiscardOutput ? {
164
+ description: `Remove \`${truncate(text)}\`.`,
165
+ edits: [removal(context.source, redirection.pos, redirection.end)]
166
+ } : void 0);
167
+ }
168
+ };
169
+ export { RedirectionChecker, doesRedirectOutput };
@@ -0,0 +1,32 @@
1
+ import { Platform } from "./platforms.mjs";
2
+ import { Runner } from "./runners.mjs";
3
+ export type ScriptIssueMessageId = 'inconsistentBehavior' | 'unsupportedCommand' | 'unsupportedSyntax' | 'unsupportedUsage';
4
+ export interface ScriptEdit {
5
+ /** End offset (exclusive) of the replaced text in the script */
6
+ end: number;
7
+ /** Start offset of the replaced text in the script */
8
+ pos: number;
9
+ /** The replacement */
10
+ text: string;
11
+ }
12
+ export interface ScriptFix {
13
+ /** Describes the fix for people, e.g. "Prefix the command with `cross-env`." */
14
+ description: string;
15
+ /** Replacements that don't overlap */
16
+ edits: ScriptEdit[];
17
+ }
18
+ export interface ScriptIssue {
19
+ /** Message data, apart from `platforms` */
20
+ data: Record<string, string>;
21
+ /** End offset (exclusive) of the issue in the script */
22
+ end: number;
23
+ /** A fix for the issue, if it has an obvious one */
24
+ fix?: ScriptFix;
25
+ messageId: ScriptIssueMessageId;
26
+ /** Platforms on which the script doesn't work as intended */
27
+ platforms: Platform[];
28
+ /** Start offset of the issue in the script */
29
+ pos: number;
30
+ /** Runners with which the script has the issue */
31
+ runners: Runner[];
32
+ }
@@ -0,0 +1,143 @@
1
+ import { rangeInScript } from "./context.mjs";
2
+ import { MACOS_PLATFORMS, NOT_LINUX_OR_WINDOWS, PLATFORMS, WINDOWS_PLATFORMS } from "./platforms.mjs";
3
+ import { arrayIntersection } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs";
4
+ import { clamp } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/math/clamp.mjs";
5
+ // src/reporter.ts
6
+ /**
7
+ * Gets what identifies an issue, apart from the platforms and the runners that it's found for.
8
+ * @param issue The issue
9
+ * @returns A string that is the same for the same issues
10
+ */
11
+ const issueKey = (issue) => JSON.stringify([
12
+ issue.messageId,
13
+ issue.pos,
14
+ issue.end,
15
+ issue.data
16
+ ]);
17
+ /** Platforms on which each kind of syntax doesn't work, by the shell that runs it */
18
+ const SYNTAX_PLATFORMS = {
19
+ bash: {
20
+ bash: [],
21
+ native: NOT_LINUX_OR_WINDOWS,
22
+ sh: NOT_LINUX_OR_WINDOWS
23
+ },
24
+ bash4: {
25
+ bash: MACOS_PLATFORMS,
26
+ native: PLATFORMS,
27
+ sh: PLATFORMS
28
+ },
29
+ bashNonPosix: {
30
+ bash: [],
31
+ native: PLATFORMS,
32
+ sh: PLATFORMS
33
+ },
34
+ posix: {
35
+ bash: [],
36
+ native: WINDOWS_PLATFORMS,
37
+ sh: []
38
+ }
39
+ };
40
+ var Reporter = class {
41
+ /** Reported issues, including duplicates */
42
+ issues = [];
43
+ /**
44
+ * Issues that make a command fail, e.g. `rm` on Windows, unlike ones in its arguments, with the
45
+ * platforms where it fails, if only on some of the issue's platforms
46
+ */
47
+ #failures = /* @__PURE__ */ new WeakMap();
48
+ /** Length of the analyzed script */
49
+ #length;
50
+ constructor(length) {
51
+ this.#length = length;
52
+ }
53
+ /** The issues without duplicates by their keys, each on the platforms of all of its duplicates */
54
+ get uniqueIssues() {
55
+ const unique = /* @__PURE__ */ new Map();
56
+ this.issues.forEach((issue) => {
57
+ const key = issueKey(issue);
58
+ const existing = unique.get(key);
59
+ unique.set(key, existing ? {
60
+ ...existing,
61
+ platforms: arrayIntersection(PLATFORMS, [...existing.platforms, ...issue.platforms])
62
+ } : issue);
63
+ });
64
+ return unique;
65
+ }
66
+ isFailure(issue) {
67
+ return this.#failures.has(issue);
68
+ }
69
+ /**
70
+ * Gets where an issue makes its command fail.
71
+ * @param issue The issue
72
+ * @returns The platforms, which are none if it doesn't make the command fail
73
+ */
74
+ failingPlatforms(issue) {
75
+ if (!this.#failures.has(issue)) return [];
76
+ const platforms = this.#failures.get(issue);
77
+ return platforms ? issue.platforms.filter((platform) => platforms.includes(platform)) : issue.platforms;
78
+ }
79
+ /**
80
+ * Marks the issues reported since an index as ones that make a command fail, unless they are
81
+ * marked already.
82
+ * @param start Index of the first issue to mark
83
+ * @param platforms Where they make the command fail, if only on some of their platforms, e.g.
84
+ * where the issue is that it's not known what the command is meant for
85
+ */
86
+ markFailures(start, platforms) {
87
+ this.issues.slice(start).forEach((issue) => {
88
+ if (!this.#failures.has(issue)) this.#failures.set(issue, platforms);
89
+ });
90
+ }
91
+ /**
92
+ * Removes platforms from the issues reported since an index, and drops the issues that are left
93
+ * without platforms.
94
+ * @param start Index of the first issue to update
95
+ * @param platformsOf Gets the platforms to remove from an issue
96
+ */
97
+ removePlatforms(start, platformsOf) {
98
+ this.issues.splice(start).forEach((issue) => {
99
+ const removed = platformsOf(issue);
100
+ if (removed) issue.platforms = issue.platforms.filter((platform) => !removed.has(platform));
101
+ if (issue.platforms.length > 0) this.issues.push(issue);
102
+ });
103
+ }
104
+ /**
105
+ * Maps a fix's positions to the analyzed script.
106
+ * @param context Where the fix is
107
+ * @param fix The fix, with positions relative to the context's source
108
+ * @returns The mapped fix, or `undefined` if it can't be applied in the context
109
+ */
110
+ #mapFix(context, fix) {
111
+ if (!fix || context.fixedRange) return;
112
+ const edits = fix.edits.map(({ end, pos, text }) => ({
113
+ end: context.offset + end,
114
+ pos: context.offset + pos,
115
+ text
116
+ }));
117
+ return !fix.description.includes("￿") && edits.every(({ end, pos, text }) => pos >= 0 && pos <= end && end <= this.#length && !text.includes("￿") && context.fixExclusions.every((exclusion) => !exclusion.test(text))) ? {
118
+ description: fix.description,
119
+ edits
120
+ } : void 0;
121
+ }
122
+ report(context, node, messageId, data, platforms, fix) {
123
+ const remaining = platforms.filter((platform) => !context.covered.has(platform));
124
+ if (remaining.length > 0) {
125
+ const range = rangeInScript(context, node);
126
+ const pos = clamp(range.pos, 0, this.#length);
127
+ this.issues.push({
128
+ data,
129
+ end: clamp(range.end, pos, this.#length),
130
+ fix: this.#mapFix(context, fix),
131
+ messageId,
132
+ platforms: remaining,
133
+ pos
134
+ });
135
+ }
136
+ return remaining;
137
+ }
138
+ reportSyntax(context, node, kind, isPortableSupported, messageId, data, fix) {
139
+ const platforms = context.portable ? isPortableSupported ? [] : PLATFORMS : SYNTAX_PLATFORMS[kind][context.shell];
140
+ return this.report(context, node, messageId, data, platforms, fix);
141
+ }
142
+ };
143
+ export { Reporter };
@@ -0,0 +1,21 @@
1
+ /** What can run the scripts: a package manager, or `node` for `node --run` */
2
+ export type Runner = 'aube' | 'node' | 'npm' | 'pnpm' | 'pnpm-10' | 'upm' | 'yarn' | 'yarn-classic';
3
+ export declare const RUNNERS: readonly Runner[];
4
+ /** Scripts that any package manager may run by default */
5
+ export declare const RUNNER_AGNOSTIC_SCRIPTS: ReadonlySet<string>;
6
+ /**
7
+ * Gets the runner for a package manager, e.g. the one in the `packageManager` or
8
+ * `devEngines.packageManager` field of `package.json`.
9
+ * @param name Name of the package manager, e.g. `yarn`
10
+ * @param version Its version or version range, which tells Yarn v1 from Yarn v2+, and pnpm v10
11
+ * from later versions, e.g. `1.22.22`
12
+ * @returns The runner, or `undefined` if it's an unknown package manager or Yarn of an unknown
13
+ * version
14
+ */
15
+ export declare const getRunner: (name: string, version?: string) => Runner | undefined;
16
+ /**
17
+ * Formats runners as a list for people, e.g. "pnpm and Yarn v1".
18
+ * @param runners The runners to format
19
+ * @returns The formatted list
20
+ */
21
+ export declare const formatRunners: (runners: readonly Runner[]) => string;