react-doctor 0.4.2-dev.b4b79ad → 0.5.0-dev.cbb7975
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/LICENSE +1 -1
- package/README.md +4 -23
- package/dist/cli.js +3755 -1258
- package/dist/index.d.ts +57 -0
- package/dist/index.js +2018 -96
- package/dist/lsp.js +2075 -165
- package/dist/skills/react-doctor/SKILL.md +2 -2
- package/dist/skills/{doctor-explain/SKILL.md → react-doctor/references/explain.md} +6 -9
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="50a9af23-7f4c-50ee-ab12-d23a4915d902")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as fs$1 from "node:fs";
|
|
@@ -7,6 +7,7 @@ import fs from "node:fs";
|
|
|
7
7
|
import * as path$1 from "node:path";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { spawn, spawnSync } from "node:child_process";
|
|
10
|
+
import * as ts from "typescript";
|
|
10
11
|
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES } from "oxlint-plugin-react-doctor";
|
|
11
12
|
import * as Cause from "effect/Cause";
|
|
12
13
|
import * as Effect from "effect/Effect";
|
|
@@ -31,7 +32,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
|
31
32
|
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
32
33
|
import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
33
34
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
34
|
-
import * as ts from "typescript";
|
|
35
35
|
import { gzipSync } from "node:zlib";
|
|
36
36
|
import "effect/Exit";
|
|
37
37
|
//#region \0rolldown/runtime.js
|
|
@@ -179,7 +179,7 @@ var JsonReportV2 = class extends Schema.Class("JsonReportV2")({
|
|
|
179
179
|
Schema.Union([JsonReportV1, JsonReportV2]);
|
|
180
180
|
//#endregion
|
|
181
181
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
182
|
-
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
182
|
+
var require_constants$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
183
183
|
const WIN_SLASH = "\\\\/";
|
|
184
184
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
185
185
|
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
@@ -349,7 +349,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
349
349
|
//#endregion
|
|
350
350
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js
|
|
351
351
|
var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
352
|
-
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
352
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants$1();
|
|
353
353
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
354
354
|
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
355
355
|
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
@@ -398,7 +398,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
|
398
398
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js
|
|
399
399
|
var require_scan = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
400
400
|
const utils = require_utils();
|
|
401
|
-
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
401
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants$1();
|
|
402
402
|
const isPathSeparator = (code) => {
|
|
403
403
|
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
404
404
|
};
|
|
@@ -683,8 +683,8 @@ var require_scan = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
683
683
|
}));
|
|
684
684
|
//#endregion
|
|
685
685
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js
|
|
686
|
-
var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
687
|
-
const constants = require_constants();
|
|
686
|
+
var require_parse$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
687
|
+
const constants = require_constants$1();
|
|
688
688
|
const utils = require_utils();
|
|
689
689
|
/**
|
|
690
690
|
* Constants
|
|
@@ -1740,9 +1740,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
1740
1740
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js
|
|
1741
1741
|
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
1742
1742
|
const scan = require_scan();
|
|
1743
|
-
const parse = require_parse();
|
|
1743
|
+
const parse = require_parse$1();
|
|
1744
1744
|
const utils = require_utils();
|
|
1745
|
-
const constants = require_constants();
|
|
1745
|
+
const constants = require_constants$1();
|
|
1746
1746
|
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1747
1747
|
/**
|
|
1748
1748
|
* Creates a matcher function from one or more glob patterns. The
|
|
@@ -2037,8 +2037,8 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
|
|
|
2037
2037
|
module.exports = picomatch;
|
|
2038
2038
|
}));
|
|
2039
2039
|
//#endregion
|
|
2040
|
-
//#region
|
|
2041
|
-
var
|
|
2040
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js
|
|
2041
|
+
var require_picomatch = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2042
2042
|
const pico = require_picomatch$1();
|
|
2043
2043
|
const utils = require_utils();
|
|
2044
2044
|
function picomatch(glob, options, returnState = false) {
|
|
@@ -2050,7 +2050,1349 @@ var import_picomatch = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$
|
|
|
2050
2050
|
}
|
|
2051
2051
|
Object.assign(picomatch, pico);
|
|
2052
2052
|
module.exports = picomatch;
|
|
2053
|
-
}))
|
|
2053
|
+
}));
|
|
2054
|
+
//#endregion
|
|
2055
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
|
|
2056
|
+
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2057
|
+
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
2058
|
+
const MAX_LENGTH = 256;
|
|
2059
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
2060
|
+
module.exports = {
|
|
2061
|
+
MAX_LENGTH,
|
|
2062
|
+
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
2063
|
+
MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
|
|
2064
|
+
MAX_SAFE_INTEGER,
|
|
2065
|
+
RELEASE_TYPES: [
|
|
2066
|
+
"major",
|
|
2067
|
+
"premajor",
|
|
2068
|
+
"minor",
|
|
2069
|
+
"preminor",
|
|
2070
|
+
"patch",
|
|
2071
|
+
"prepatch",
|
|
2072
|
+
"prerelease"
|
|
2073
|
+
],
|
|
2074
|
+
SEMVER_SPEC_VERSION,
|
|
2075
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
2076
|
+
FLAG_LOOSE: 2
|
|
2077
|
+
};
|
|
2078
|
+
}));
|
|
2079
|
+
//#endregion
|
|
2080
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
|
|
2081
|
+
var require_debug = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2082
|
+
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
2083
|
+
}));
|
|
2084
|
+
//#endregion
|
|
2085
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js
|
|
2086
|
+
var require_re = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2087
|
+
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
2088
|
+
const debug = require_debug();
|
|
2089
|
+
exports = module.exports = {};
|
|
2090
|
+
const re = exports.re = [];
|
|
2091
|
+
const safeRe = exports.safeRe = [];
|
|
2092
|
+
const src = exports.src = [];
|
|
2093
|
+
const safeSrc = exports.safeSrc = [];
|
|
2094
|
+
const t = exports.t = {};
|
|
2095
|
+
let R = 0;
|
|
2096
|
+
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
2097
|
+
const safeRegexReplacements = [
|
|
2098
|
+
["\\s", 1],
|
|
2099
|
+
["\\d", MAX_LENGTH],
|
|
2100
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
2101
|
+
];
|
|
2102
|
+
const makeSafeRegex = (value) => {
|
|
2103
|
+
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
2104
|
+
return value;
|
|
2105
|
+
};
|
|
2106
|
+
const createToken = (name, value, isGlobal) => {
|
|
2107
|
+
const safe = makeSafeRegex(value);
|
|
2108
|
+
const index = R++;
|
|
2109
|
+
debug(name, index, value);
|
|
2110
|
+
t[name] = index;
|
|
2111
|
+
src[index] = value;
|
|
2112
|
+
safeSrc[index] = safe;
|
|
2113
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
2114
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
2115
|
+
};
|
|
2116
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
2117
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
2118
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
2119
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
2120
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
2121
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
2122
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
2123
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
2124
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
2125
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
2126
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
2127
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
2128
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
2129
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
2130
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
2131
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
2132
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
2133
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
2134
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
2135
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
2136
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
2137
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
2138
|
+
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
2139
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
2140
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
2141
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
2142
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
2143
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
2144
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
2145
|
+
exports.tildeTrimReplace = "$1~";
|
|
2146
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
2147
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
2148
|
+
createToken("LONECARET", "(?:\\^)");
|
|
2149
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
2150
|
+
exports.caretTrimReplace = "$1^";
|
|
2151
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
2152
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
2153
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
2154
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
2155
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
2156
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
2157
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
2158
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
2159
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
2160
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
2161
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
2162
|
+
}));
|
|
2163
|
+
//#endregion
|
|
2164
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js
|
|
2165
|
+
var require_parse_options = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2166
|
+
const looseOption = Object.freeze({ loose: true });
|
|
2167
|
+
const emptyOpts = Object.freeze({});
|
|
2168
|
+
const parseOptions = (options) => {
|
|
2169
|
+
if (!options) return emptyOpts;
|
|
2170
|
+
if (typeof options !== "object") return looseOption;
|
|
2171
|
+
return options;
|
|
2172
|
+
};
|
|
2173
|
+
module.exports = parseOptions;
|
|
2174
|
+
}));
|
|
2175
|
+
//#endregion
|
|
2176
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js
|
|
2177
|
+
var require_identifiers = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2178
|
+
const numeric = /^[0-9]+$/;
|
|
2179
|
+
const compareIdentifiers = (a, b) => {
|
|
2180
|
+
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
2181
|
+
const anum = numeric.test(a);
|
|
2182
|
+
const bnum = numeric.test(b);
|
|
2183
|
+
if (anum && bnum) {
|
|
2184
|
+
a = +a;
|
|
2185
|
+
b = +b;
|
|
2186
|
+
}
|
|
2187
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
2188
|
+
};
|
|
2189
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
2190
|
+
module.exports = {
|
|
2191
|
+
compareIdentifiers,
|
|
2192
|
+
rcompareIdentifiers
|
|
2193
|
+
};
|
|
2194
|
+
}));
|
|
2195
|
+
//#endregion
|
|
2196
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js
|
|
2197
|
+
var require_semver$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2198
|
+
const debug = require_debug();
|
|
2199
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
2200
|
+
const { safeRe: re, t } = require_re();
|
|
2201
|
+
const parseOptions = require_parse_options();
|
|
2202
|
+
const { compareIdentifiers } = require_identifiers();
|
|
2203
|
+
module.exports = class SemVer {
|
|
2204
|
+
constructor(version, options) {
|
|
2205
|
+
options = parseOptions(options);
|
|
2206
|
+
if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
2207
|
+
else version = version.version;
|
|
2208
|
+
else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
2209
|
+
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
2210
|
+
debug("SemVer", version, options);
|
|
2211
|
+
this.options = options;
|
|
2212
|
+
this.loose = !!options.loose;
|
|
2213
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
2214
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
2215
|
+
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
2216
|
+
this.raw = version;
|
|
2217
|
+
this.major = +m[1];
|
|
2218
|
+
this.minor = +m[2];
|
|
2219
|
+
this.patch = +m[3];
|
|
2220
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
2221
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
2222
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
2223
|
+
if (!m[4]) this.prerelease = [];
|
|
2224
|
+
else this.prerelease = m[4].split(".").map((id) => {
|
|
2225
|
+
if (/^[0-9]+$/.test(id)) {
|
|
2226
|
+
const num = +id;
|
|
2227
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
2228
|
+
}
|
|
2229
|
+
return id;
|
|
2230
|
+
});
|
|
2231
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
2232
|
+
this.format();
|
|
2233
|
+
}
|
|
2234
|
+
format() {
|
|
2235
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
2236
|
+
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
2237
|
+
return this.version;
|
|
2238
|
+
}
|
|
2239
|
+
toString() {
|
|
2240
|
+
return this.version;
|
|
2241
|
+
}
|
|
2242
|
+
compare(other) {
|
|
2243
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
2244
|
+
if (!(other instanceof SemVer)) {
|
|
2245
|
+
if (typeof other === "string" && other === this.version) return 0;
|
|
2246
|
+
other = new SemVer(other, this.options);
|
|
2247
|
+
}
|
|
2248
|
+
if (other.version === this.version) return 0;
|
|
2249
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
2250
|
+
}
|
|
2251
|
+
compareMain(other) {
|
|
2252
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
2253
|
+
if (this.major < other.major) return -1;
|
|
2254
|
+
if (this.major > other.major) return 1;
|
|
2255
|
+
if (this.minor < other.minor) return -1;
|
|
2256
|
+
if (this.minor > other.minor) return 1;
|
|
2257
|
+
if (this.patch < other.patch) return -1;
|
|
2258
|
+
if (this.patch > other.patch) return 1;
|
|
2259
|
+
return 0;
|
|
2260
|
+
}
|
|
2261
|
+
comparePre(other) {
|
|
2262
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
2263
|
+
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
2264
|
+
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
2265
|
+
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
2266
|
+
let i = 0;
|
|
2267
|
+
do {
|
|
2268
|
+
const a = this.prerelease[i];
|
|
2269
|
+
const b = other.prerelease[i];
|
|
2270
|
+
debug("prerelease compare", i, a, b);
|
|
2271
|
+
if (a === void 0 && b === void 0) return 0;
|
|
2272
|
+
else if (b === void 0) return 1;
|
|
2273
|
+
else if (a === void 0) return -1;
|
|
2274
|
+
else if (a === b) continue;
|
|
2275
|
+
else return compareIdentifiers(a, b);
|
|
2276
|
+
} while (++i);
|
|
2277
|
+
}
|
|
2278
|
+
compareBuild(other) {
|
|
2279
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
2280
|
+
let i = 0;
|
|
2281
|
+
do {
|
|
2282
|
+
const a = this.build[i];
|
|
2283
|
+
const b = other.build[i];
|
|
2284
|
+
debug("build compare", i, a, b);
|
|
2285
|
+
if (a === void 0 && b === void 0) return 0;
|
|
2286
|
+
else if (b === void 0) return 1;
|
|
2287
|
+
else if (a === void 0) return -1;
|
|
2288
|
+
else if (a === b) continue;
|
|
2289
|
+
else return compareIdentifiers(a, b);
|
|
2290
|
+
} while (++i);
|
|
2291
|
+
}
|
|
2292
|
+
inc(release, identifier, identifierBase) {
|
|
2293
|
+
if (release.startsWith("pre")) {
|
|
2294
|
+
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
2295
|
+
if (identifier) {
|
|
2296
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
2297
|
+
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
switch (release) {
|
|
2301
|
+
case "premajor":
|
|
2302
|
+
this.prerelease.length = 0;
|
|
2303
|
+
this.patch = 0;
|
|
2304
|
+
this.minor = 0;
|
|
2305
|
+
this.major++;
|
|
2306
|
+
this.inc("pre", identifier, identifierBase);
|
|
2307
|
+
break;
|
|
2308
|
+
case "preminor":
|
|
2309
|
+
this.prerelease.length = 0;
|
|
2310
|
+
this.patch = 0;
|
|
2311
|
+
this.minor++;
|
|
2312
|
+
this.inc("pre", identifier, identifierBase);
|
|
2313
|
+
break;
|
|
2314
|
+
case "prepatch":
|
|
2315
|
+
this.prerelease.length = 0;
|
|
2316
|
+
this.inc("patch", identifier, identifierBase);
|
|
2317
|
+
this.inc("pre", identifier, identifierBase);
|
|
2318
|
+
break;
|
|
2319
|
+
case "prerelease":
|
|
2320
|
+
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
2321
|
+
this.inc("pre", identifier, identifierBase);
|
|
2322
|
+
break;
|
|
2323
|
+
case "release":
|
|
2324
|
+
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
2325
|
+
this.prerelease.length = 0;
|
|
2326
|
+
break;
|
|
2327
|
+
case "major":
|
|
2328
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
2329
|
+
this.minor = 0;
|
|
2330
|
+
this.patch = 0;
|
|
2331
|
+
this.prerelease = [];
|
|
2332
|
+
break;
|
|
2333
|
+
case "minor":
|
|
2334
|
+
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
2335
|
+
this.patch = 0;
|
|
2336
|
+
this.prerelease = [];
|
|
2337
|
+
break;
|
|
2338
|
+
case "patch":
|
|
2339
|
+
if (this.prerelease.length === 0) this.patch++;
|
|
2340
|
+
this.prerelease = [];
|
|
2341
|
+
break;
|
|
2342
|
+
case "pre": {
|
|
2343
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
2344
|
+
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
2345
|
+
else {
|
|
2346
|
+
let i = this.prerelease.length;
|
|
2347
|
+
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
2348
|
+
this.prerelease[i]++;
|
|
2349
|
+
i = -2;
|
|
2350
|
+
}
|
|
2351
|
+
if (i === -1) {
|
|
2352
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
2353
|
+
this.prerelease.push(base);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
if (identifier) {
|
|
2357
|
+
let prerelease = [identifier, base];
|
|
2358
|
+
if (identifierBase === false) prerelease = [identifier];
|
|
2359
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
2360
|
+
if (isNaN(this.prerelease[1])) this.prerelease = prerelease;
|
|
2361
|
+
} else this.prerelease = prerelease;
|
|
2362
|
+
}
|
|
2363
|
+
break;
|
|
2364
|
+
}
|
|
2365
|
+
default: throw new Error(`invalid increment argument: ${release}`);
|
|
2366
|
+
}
|
|
2367
|
+
this.raw = this.format();
|
|
2368
|
+
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
2369
|
+
return this;
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
}));
|
|
2373
|
+
//#endregion
|
|
2374
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js
|
|
2375
|
+
var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2376
|
+
const SemVer = require_semver$1();
|
|
2377
|
+
const parse = (version, options, throwErrors = false) => {
|
|
2378
|
+
if (version instanceof SemVer) return version;
|
|
2379
|
+
try {
|
|
2380
|
+
return new SemVer(version, options);
|
|
2381
|
+
} catch (er) {
|
|
2382
|
+
if (!throwErrors) return null;
|
|
2383
|
+
throw er;
|
|
2384
|
+
}
|
|
2385
|
+
};
|
|
2386
|
+
module.exports = parse;
|
|
2387
|
+
}));
|
|
2388
|
+
//#endregion
|
|
2389
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js
|
|
2390
|
+
var require_valid$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2391
|
+
const parse = require_parse();
|
|
2392
|
+
const valid = (version, options) => {
|
|
2393
|
+
const v = parse(version, options);
|
|
2394
|
+
return v ? v.version : null;
|
|
2395
|
+
};
|
|
2396
|
+
module.exports = valid;
|
|
2397
|
+
}));
|
|
2398
|
+
//#endregion
|
|
2399
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js
|
|
2400
|
+
var require_clean = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2401
|
+
const parse = require_parse();
|
|
2402
|
+
const clean = (version, options) => {
|
|
2403
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
2404
|
+
return s ? s.version : null;
|
|
2405
|
+
};
|
|
2406
|
+
module.exports = clean;
|
|
2407
|
+
}));
|
|
2408
|
+
//#endregion
|
|
2409
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js
|
|
2410
|
+
var require_inc = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2411
|
+
const SemVer = require_semver$1();
|
|
2412
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
2413
|
+
if (typeof options === "string") {
|
|
2414
|
+
identifierBase = identifier;
|
|
2415
|
+
identifier = options;
|
|
2416
|
+
options = void 0;
|
|
2417
|
+
}
|
|
2418
|
+
try {
|
|
2419
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
2420
|
+
} catch (er) {
|
|
2421
|
+
return null;
|
|
2422
|
+
}
|
|
2423
|
+
};
|
|
2424
|
+
module.exports = inc;
|
|
2425
|
+
}));
|
|
2426
|
+
//#endregion
|
|
2427
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js
|
|
2428
|
+
var require_diff = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2429
|
+
const parse = require_parse();
|
|
2430
|
+
const diff = (version1, version2) => {
|
|
2431
|
+
const v1 = parse(version1, null, true);
|
|
2432
|
+
const v2 = parse(version2, null, true);
|
|
2433
|
+
const comparison = v1.compare(v2);
|
|
2434
|
+
if (comparison === 0) return null;
|
|
2435
|
+
const v1Higher = comparison > 0;
|
|
2436
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
2437
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
2438
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
2439
|
+
if (!!lowVersion.prerelease.length && !highHasPre) {
|
|
2440
|
+
if (!lowVersion.patch && !lowVersion.minor) return "major";
|
|
2441
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
2442
|
+
if (lowVersion.minor && !lowVersion.patch) return "minor";
|
|
2443
|
+
return "patch";
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
const prefix = highHasPre ? "pre" : "";
|
|
2447
|
+
if (v1.major !== v2.major) return prefix + "major";
|
|
2448
|
+
if (v1.minor !== v2.minor) return prefix + "minor";
|
|
2449
|
+
if (v1.patch !== v2.patch) return prefix + "patch";
|
|
2450
|
+
return "prerelease";
|
|
2451
|
+
};
|
|
2452
|
+
module.exports = diff;
|
|
2453
|
+
}));
|
|
2454
|
+
//#endregion
|
|
2455
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js
|
|
2456
|
+
var require_major = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2457
|
+
const SemVer = require_semver$1();
|
|
2458
|
+
const major = (a, loose) => new SemVer(a, loose).major;
|
|
2459
|
+
module.exports = major;
|
|
2460
|
+
}));
|
|
2461
|
+
//#endregion
|
|
2462
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js
|
|
2463
|
+
var require_minor = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2464
|
+
const SemVer = require_semver$1();
|
|
2465
|
+
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
2466
|
+
module.exports = minor;
|
|
2467
|
+
}));
|
|
2468
|
+
//#endregion
|
|
2469
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js
|
|
2470
|
+
var require_patch = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2471
|
+
const SemVer = require_semver$1();
|
|
2472
|
+
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
2473
|
+
module.exports = patch;
|
|
2474
|
+
}));
|
|
2475
|
+
//#endregion
|
|
2476
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js
|
|
2477
|
+
var require_prerelease = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2478
|
+
const parse = require_parse();
|
|
2479
|
+
const prerelease = (version, options) => {
|
|
2480
|
+
const parsed = parse(version, options);
|
|
2481
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
2482
|
+
};
|
|
2483
|
+
module.exports = prerelease;
|
|
2484
|
+
}));
|
|
2485
|
+
//#endregion
|
|
2486
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js
|
|
2487
|
+
var require_compare = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2488
|
+
const SemVer = require_semver$1();
|
|
2489
|
+
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
2490
|
+
module.exports = compare;
|
|
2491
|
+
}));
|
|
2492
|
+
//#endregion
|
|
2493
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js
|
|
2494
|
+
var require_rcompare = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2495
|
+
const compare = require_compare();
|
|
2496
|
+
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
2497
|
+
module.exports = rcompare;
|
|
2498
|
+
}));
|
|
2499
|
+
//#endregion
|
|
2500
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js
|
|
2501
|
+
var require_compare_loose = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2502
|
+
const compare = require_compare();
|
|
2503
|
+
const compareLoose = (a, b) => compare(a, b, true);
|
|
2504
|
+
module.exports = compareLoose;
|
|
2505
|
+
}));
|
|
2506
|
+
//#endregion
|
|
2507
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js
|
|
2508
|
+
var require_compare_build = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2509
|
+
const SemVer = require_semver$1();
|
|
2510
|
+
const compareBuild = (a, b, loose) => {
|
|
2511
|
+
const versionA = new SemVer(a, loose);
|
|
2512
|
+
const versionB = new SemVer(b, loose);
|
|
2513
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
2514
|
+
};
|
|
2515
|
+
module.exports = compareBuild;
|
|
2516
|
+
}));
|
|
2517
|
+
//#endregion
|
|
2518
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js
|
|
2519
|
+
var require_sort = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2520
|
+
const compareBuild = require_compare_build();
|
|
2521
|
+
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
2522
|
+
module.exports = sort;
|
|
2523
|
+
}));
|
|
2524
|
+
//#endregion
|
|
2525
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js
|
|
2526
|
+
var require_rsort = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2527
|
+
const compareBuild = require_compare_build();
|
|
2528
|
+
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
2529
|
+
module.exports = rsort;
|
|
2530
|
+
}));
|
|
2531
|
+
//#endregion
|
|
2532
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js
|
|
2533
|
+
var require_gt = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2534
|
+
const compare = require_compare();
|
|
2535
|
+
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
2536
|
+
module.exports = gt;
|
|
2537
|
+
}));
|
|
2538
|
+
//#endregion
|
|
2539
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js
|
|
2540
|
+
var require_lt = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2541
|
+
const compare = require_compare();
|
|
2542
|
+
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
2543
|
+
module.exports = lt;
|
|
2544
|
+
}));
|
|
2545
|
+
//#endregion
|
|
2546
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js
|
|
2547
|
+
var require_eq = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2548
|
+
const compare = require_compare();
|
|
2549
|
+
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
2550
|
+
module.exports = eq;
|
|
2551
|
+
}));
|
|
2552
|
+
//#endregion
|
|
2553
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js
|
|
2554
|
+
var require_neq = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2555
|
+
const compare = require_compare();
|
|
2556
|
+
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
2557
|
+
module.exports = neq;
|
|
2558
|
+
}));
|
|
2559
|
+
//#endregion
|
|
2560
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js
|
|
2561
|
+
var require_gte = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2562
|
+
const compare = require_compare();
|
|
2563
|
+
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
2564
|
+
module.exports = gte;
|
|
2565
|
+
}));
|
|
2566
|
+
//#endregion
|
|
2567
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js
|
|
2568
|
+
var require_lte = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2569
|
+
const compare = require_compare();
|
|
2570
|
+
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
2571
|
+
module.exports = lte;
|
|
2572
|
+
}));
|
|
2573
|
+
//#endregion
|
|
2574
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js
|
|
2575
|
+
var require_cmp = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2576
|
+
const eq = require_eq();
|
|
2577
|
+
const neq = require_neq();
|
|
2578
|
+
const gt = require_gt();
|
|
2579
|
+
const gte = require_gte();
|
|
2580
|
+
const lt = require_lt();
|
|
2581
|
+
const lte = require_lte();
|
|
2582
|
+
const cmp = (a, op, b, loose) => {
|
|
2583
|
+
switch (op) {
|
|
2584
|
+
case "===":
|
|
2585
|
+
if (typeof a === "object") a = a.version;
|
|
2586
|
+
if (typeof b === "object") b = b.version;
|
|
2587
|
+
return a === b;
|
|
2588
|
+
case "!==":
|
|
2589
|
+
if (typeof a === "object") a = a.version;
|
|
2590
|
+
if (typeof b === "object") b = b.version;
|
|
2591
|
+
return a !== b;
|
|
2592
|
+
case "":
|
|
2593
|
+
case "=":
|
|
2594
|
+
case "==": return eq(a, b, loose);
|
|
2595
|
+
case "!=": return neq(a, b, loose);
|
|
2596
|
+
case ">": return gt(a, b, loose);
|
|
2597
|
+
case ">=": return gte(a, b, loose);
|
|
2598
|
+
case "<": return lt(a, b, loose);
|
|
2599
|
+
case "<=": return lte(a, b, loose);
|
|
2600
|
+
default: throw new TypeError(`Invalid operator: ${op}`);
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
module.exports = cmp;
|
|
2604
|
+
}));
|
|
2605
|
+
//#endregion
|
|
2606
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js
|
|
2607
|
+
var require_coerce = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2608
|
+
const SemVer = require_semver$1();
|
|
2609
|
+
const parse = require_parse();
|
|
2610
|
+
const { safeRe: re, t } = require_re();
|
|
2611
|
+
const coerce = (version, options) => {
|
|
2612
|
+
if (version instanceof SemVer) return version;
|
|
2613
|
+
if (typeof version === "number") version = String(version);
|
|
2614
|
+
if (typeof version !== "string") return null;
|
|
2615
|
+
options = options || {};
|
|
2616
|
+
let match = null;
|
|
2617
|
+
if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
2618
|
+
else {
|
|
2619
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
2620
|
+
let next;
|
|
2621
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
2622
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
|
|
2623
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
2624
|
+
}
|
|
2625
|
+
coerceRtlRegex.lastIndex = -1;
|
|
2626
|
+
}
|
|
2627
|
+
if (match === null) return null;
|
|
2628
|
+
const major = match[2];
|
|
2629
|
+
return parse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
|
|
2630
|
+
};
|
|
2631
|
+
module.exports = coerce;
|
|
2632
|
+
}));
|
|
2633
|
+
//#endregion
|
|
2634
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js
|
|
2635
|
+
var require_lrucache = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2636
|
+
var LRUCache = class {
|
|
2637
|
+
constructor() {
|
|
2638
|
+
this.max = 1e3;
|
|
2639
|
+
this.map = /* @__PURE__ */ new Map();
|
|
2640
|
+
}
|
|
2641
|
+
get(key) {
|
|
2642
|
+
const value = this.map.get(key);
|
|
2643
|
+
if (value === void 0) return;
|
|
2644
|
+
else {
|
|
2645
|
+
this.map.delete(key);
|
|
2646
|
+
this.map.set(key, value);
|
|
2647
|
+
return value;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
delete(key) {
|
|
2651
|
+
return this.map.delete(key);
|
|
2652
|
+
}
|
|
2653
|
+
set(key, value) {
|
|
2654
|
+
if (!this.delete(key) && value !== void 0) {
|
|
2655
|
+
if (this.map.size >= this.max) {
|
|
2656
|
+
const firstKey = this.map.keys().next().value;
|
|
2657
|
+
this.delete(firstKey);
|
|
2658
|
+
}
|
|
2659
|
+
this.map.set(key, value);
|
|
2660
|
+
}
|
|
2661
|
+
return this;
|
|
2662
|
+
}
|
|
2663
|
+
};
|
|
2664
|
+
module.exports = LRUCache;
|
|
2665
|
+
}));
|
|
2666
|
+
//#endregion
|
|
2667
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js
|
|
2668
|
+
var require_range = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2669
|
+
const SPACE_CHARACTERS = /\s+/g;
|
|
2670
|
+
module.exports = class Range {
|
|
2671
|
+
constructor(range, options) {
|
|
2672
|
+
options = parseOptions(options);
|
|
2673
|
+
if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
|
|
2674
|
+
else return new Range(range.raw, options);
|
|
2675
|
+
if (range instanceof Comparator) {
|
|
2676
|
+
this.raw = range.value;
|
|
2677
|
+
this.set = [[range]];
|
|
2678
|
+
this.formatted = void 0;
|
|
2679
|
+
return this;
|
|
2680
|
+
}
|
|
2681
|
+
this.options = options;
|
|
2682
|
+
this.loose = !!options.loose;
|
|
2683
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
2684
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
2685
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
2686
|
+
if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
2687
|
+
if (this.set.length > 1) {
|
|
2688
|
+
const first = this.set[0];
|
|
2689
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
2690
|
+
if (this.set.length === 0) this.set = [first];
|
|
2691
|
+
else if (this.set.length > 1) {
|
|
2692
|
+
for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
|
|
2693
|
+
this.set = [c];
|
|
2694
|
+
break;
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
this.formatted = void 0;
|
|
2699
|
+
}
|
|
2700
|
+
get range() {
|
|
2701
|
+
if (this.formatted === void 0) {
|
|
2702
|
+
this.formatted = "";
|
|
2703
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
2704
|
+
if (i > 0) this.formatted += "||";
|
|
2705
|
+
const comps = this.set[i];
|
|
2706
|
+
for (let k = 0; k < comps.length; k++) {
|
|
2707
|
+
if (k > 0) this.formatted += " ";
|
|
2708
|
+
this.formatted += comps[k].toString().trim();
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return this.formatted;
|
|
2713
|
+
}
|
|
2714
|
+
format() {
|
|
2715
|
+
return this.range;
|
|
2716
|
+
}
|
|
2717
|
+
toString() {
|
|
2718
|
+
return this.range;
|
|
2719
|
+
}
|
|
2720
|
+
parseRange(range) {
|
|
2721
|
+
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
2722
|
+
const cached = cache.get(memoKey);
|
|
2723
|
+
if (cached) return cached;
|
|
2724
|
+
const loose = this.options.loose;
|
|
2725
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
2726
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
2727
|
+
debug("hyphen replace", range);
|
|
2728
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
2729
|
+
debug("comparator trim", range);
|
|
2730
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
2731
|
+
debug("tilde trim", range);
|
|
2732
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
2733
|
+
debug("caret trim", range);
|
|
2734
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
2735
|
+
if (loose) rangeList = rangeList.filter((comp) => {
|
|
2736
|
+
debug("loose invalid filter", comp, this.options);
|
|
2737
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
2738
|
+
});
|
|
2739
|
+
debug("range list", rangeList);
|
|
2740
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
2741
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
2742
|
+
for (const comp of comparators) {
|
|
2743
|
+
if (isNullSet(comp)) return [comp];
|
|
2744
|
+
rangeMap.set(comp.value, comp);
|
|
2745
|
+
}
|
|
2746
|
+
if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
|
|
2747
|
+
const result = [...rangeMap.values()];
|
|
2748
|
+
cache.set(memoKey, result);
|
|
2749
|
+
return result;
|
|
2750
|
+
}
|
|
2751
|
+
intersects(range, options) {
|
|
2752
|
+
if (!(range instanceof Range)) throw new TypeError("a Range is required");
|
|
2753
|
+
return this.set.some((thisComparators) => {
|
|
2754
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
2755
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
2756
|
+
return rangeComparators.every((rangeComparator) => {
|
|
2757
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
2758
|
+
});
|
|
2759
|
+
});
|
|
2760
|
+
});
|
|
2761
|
+
});
|
|
2762
|
+
}
|
|
2763
|
+
test(version) {
|
|
2764
|
+
if (!version) return false;
|
|
2765
|
+
if (typeof version === "string") try {
|
|
2766
|
+
version = new SemVer(version, this.options);
|
|
2767
|
+
} catch (er) {
|
|
2768
|
+
return false;
|
|
2769
|
+
}
|
|
2770
|
+
for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
|
|
2771
|
+
return false;
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
const cache = new (require_lrucache())();
|
|
2775
|
+
const parseOptions = require_parse_options();
|
|
2776
|
+
const Comparator = require_comparator();
|
|
2777
|
+
const debug = require_debug();
|
|
2778
|
+
const SemVer = require_semver$1();
|
|
2779
|
+
const { safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
2780
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
2781
|
+
const isNullSet = (c) => c.value === "<0.0.0-0";
|
|
2782
|
+
const isAny = (c) => c.value === "";
|
|
2783
|
+
const isSatisfiable = (comparators, options) => {
|
|
2784
|
+
let result = true;
|
|
2785
|
+
const remainingComparators = comparators.slice();
|
|
2786
|
+
let testComparator = remainingComparators.pop();
|
|
2787
|
+
while (result && remainingComparators.length) {
|
|
2788
|
+
result = remainingComparators.every((otherComparator) => {
|
|
2789
|
+
return testComparator.intersects(otherComparator, options);
|
|
2790
|
+
});
|
|
2791
|
+
testComparator = remainingComparators.pop();
|
|
2792
|
+
}
|
|
2793
|
+
return result;
|
|
2794
|
+
};
|
|
2795
|
+
const parseComparator = (comp, options) => {
|
|
2796
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
2797
|
+
debug("comp", comp, options);
|
|
2798
|
+
comp = replaceCarets(comp, options);
|
|
2799
|
+
debug("caret", comp);
|
|
2800
|
+
comp = replaceTildes(comp, options);
|
|
2801
|
+
debug("tildes", comp);
|
|
2802
|
+
comp = replaceXRanges(comp, options);
|
|
2803
|
+
debug("xrange", comp);
|
|
2804
|
+
comp = replaceStars(comp, options);
|
|
2805
|
+
debug("stars", comp);
|
|
2806
|
+
return comp;
|
|
2807
|
+
};
|
|
2808
|
+
const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
2809
|
+
const replaceTildes = (comp, options) => {
|
|
2810
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
2811
|
+
};
|
|
2812
|
+
const replaceTilde = (comp, options) => {
|
|
2813
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
2814
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
2815
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
2816
|
+
let ret;
|
|
2817
|
+
if (isX(M)) ret = "";
|
|
2818
|
+
else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
2819
|
+
else if (isX(p)) ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
2820
|
+
else if (pr) {
|
|
2821
|
+
debug("replaceTilde pr", pr);
|
|
2822
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
2823
|
+
} else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
2824
|
+
debug("tilde return", ret);
|
|
2825
|
+
return ret;
|
|
2826
|
+
});
|
|
2827
|
+
};
|
|
2828
|
+
const replaceCarets = (comp, options) => {
|
|
2829
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
2830
|
+
};
|
|
2831
|
+
const replaceCaret = (comp, options) => {
|
|
2832
|
+
debug("caret", comp, options);
|
|
2833
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
2834
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
2835
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
2836
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
2837
|
+
let ret;
|
|
2838
|
+
if (isX(M)) ret = "";
|
|
2839
|
+
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
2840
|
+
else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
2841
|
+
else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
2842
|
+
else if (pr) {
|
|
2843
|
+
debug("replaceCaret pr", pr);
|
|
2844
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
2845
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
2846
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
2847
|
+
} else {
|
|
2848
|
+
debug("no pr");
|
|
2849
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
|
|
2850
|
+
else ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
|
|
2851
|
+
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
2852
|
+
}
|
|
2853
|
+
debug("caret return", ret);
|
|
2854
|
+
return ret;
|
|
2855
|
+
});
|
|
2856
|
+
};
|
|
2857
|
+
const replaceXRanges = (comp, options) => {
|
|
2858
|
+
debug("replaceXRanges", comp, options);
|
|
2859
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
2860
|
+
};
|
|
2861
|
+
const replaceXRange = (comp, options) => {
|
|
2862
|
+
comp = comp.trim();
|
|
2863
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
2864
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
2865
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
2866
|
+
const xM = isX(M);
|
|
2867
|
+
const xm = xM || isX(m);
|
|
2868
|
+
const xp = xm || isX(p);
|
|
2869
|
+
const anyX = xp;
|
|
2870
|
+
if (gtlt === "=" && anyX) gtlt = "";
|
|
2871
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
2872
|
+
if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
|
|
2873
|
+
else ret = "*";
|
|
2874
|
+
else if (gtlt && anyX) {
|
|
2875
|
+
if (xm) m = 0;
|
|
2876
|
+
p = 0;
|
|
2877
|
+
if (gtlt === ">") {
|
|
2878
|
+
gtlt = ">=";
|
|
2879
|
+
if (xm) {
|
|
2880
|
+
M = +M + 1;
|
|
2881
|
+
m = 0;
|
|
2882
|
+
p = 0;
|
|
2883
|
+
} else {
|
|
2884
|
+
m = +m + 1;
|
|
2885
|
+
p = 0;
|
|
2886
|
+
}
|
|
2887
|
+
} else if (gtlt === "<=") {
|
|
2888
|
+
gtlt = "<";
|
|
2889
|
+
if (xm) M = +M + 1;
|
|
2890
|
+
else m = +m + 1;
|
|
2891
|
+
}
|
|
2892
|
+
if (gtlt === "<") pr = "-0";
|
|
2893
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
2894
|
+
} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
2895
|
+
else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
2896
|
+
debug("xRange return", ret);
|
|
2897
|
+
return ret;
|
|
2898
|
+
});
|
|
2899
|
+
};
|
|
2900
|
+
const replaceStars = (comp, options) => {
|
|
2901
|
+
debug("replaceStars", comp, options);
|
|
2902
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
2903
|
+
};
|
|
2904
|
+
const replaceGTE0 = (comp, options) => {
|
|
2905
|
+
debug("replaceGTE0", comp, options);
|
|
2906
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
2907
|
+
};
|
|
2908
|
+
const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
2909
|
+
if (isX(fM)) from = "";
|
|
2910
|
+
else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
2911
|
+
else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
2912
|
+
else if (fpr) from = `>=${from}`;
|
|
2913
|
+
else from = `>=${from}${incPr ? "-0" : ""}`;
|
|
2914
|
+
if (isX(tM)) to = "";
|
|
2915
|
+
else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
|
|
2916
|
+
else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
|
|
2917
|
+
else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
2918
|
+
else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
2919
|
+
else to = `<=${to}`;
|
|
2920
|
+
return `${from} ${to}`.trim();
|
|
2921
|
+
};
|
|
2922
|
+
const testSet = (set, version, options) => {
|
|
2923
|
+
for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
|
|
2924
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
2925
|
+
for (let i = 0; i < set.length; i++) {
|
|
2926
|
+
debug(set[i].semver);
|
|
2927
|
+
if (set[i].semver === Comparator.ANY) continue;
|
|
2928
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
2929
|
+
const allowed = set[i].semver;
|
|
2930
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
return false;
|
|
2934
|
+
}
|
|
2935
|
+
return true;
|
|
2936
|
+
};
|
|
2937
|
+
}));
|
|
2938
|
+
//#endregion
|
|
2939
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js
|
|
2940
|
+
var require_comparator = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2941
|
+
const ANY = Symbol("SemVer ANY");
|
|
2942
|
+
module.exports = class Comparator {
|
|
2943
|
+
static get ANY() {
|
|
2944
|
+
return ANY;
|
|
2945
|
+
}
|
|
2946
|
+
constructor(comp, options) {
|
|
2947
|
+
options = parseOptions(options);
|
|
2948
|
+
if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
|
|
2949
|
+
else comp = comp.value;
|
|
2950
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
2951
|
+
debug("comparator", comp, options);
|
|
2952
|
+
this.options = options;
|
|
2953
|
+
this.loose = !!options.loose;
|
|
2954
|
+
this.parse(comp);
|
|
2955
|
+
if (this.semver === ANY) this.value = "";
|
|
2956
|
+
else this.value = this.operator + this.semver.version;
|
|
2957
|
+
debug("comp", this);
|
|
2958
|
+
}
|
|
2959
|
+
parse(comp) {
|
|
2960
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
2961
|
+
const m = comp.match(r);
|
|
2962
|
+
if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
|
|
2963
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
2964
|
+
if (this.operator === "=") this.operator = "";
|
|
2965
|
+
if (!m[2]) this.semver = ANY;
|
|
2966
|
+
else this.semver = new SemVer(m[2], this.options.loose);
|
|
2967
|
+
}
|
|
2968
|
+
toString() {
|
|
2969
|
+
return this.value;
|
|
2970
|
+
}
|
|
2971
|
+
test(version) {
|
|
2972
|
+
debug("Comparator.test", version, this.options.loose);
|
|
2973
|
+
if (this.semver === ANY || version === ANY) return true;
|
|
2974
|
+
if (typeof version === "string") try {
|
|
2975
|
+
version = new SemVer(version, this.options);
|
|
2976
|
+
} catch (er) {
|
|
2977
|
+
return false;
|
|
2978
|
+
}
|
|
2979
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
2980
|
+
}
|
|
2981
|
+
intersects(comp, options) {
|
|
2982
|
+
if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
|
|
2983
|
+
if (this.operator === "") {
|
|
2984
|
+
if (this.value === "") return true;
|
|
2985
|
+
return new Range(comp.value, options).test(this.value);
|
|
2986
|
+
} else if (comp.operator === "") {
|
|
2987
|
+
if (comp.value === "") return true;
|
|
2988
|
+
return new Range(this.value, options).test(comp.semver);
|
|
2989
|
+
}
|
|
2990
|
+
options = parseOptions(options);
|
|
2991
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
|
|
2992
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
|
|
2993
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
|
|
2994
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
|
|
2995
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
|
|
2996
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
|
|
2997
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
|
|
2998
|
+
return false;
|
|
2999
|
+
}
|
|
3000
|
+
};
|
|
3001
|
+
const parseOptions = require_parse_options();
|
|
3002
|
+
const { safeRe: re, t } = require_re();
|
|
3003
|
+
const cmp = require_cmp();
|
|
3004
|
+
const debug = require_debug();
|
|
3005
|
+
const SemVer = require_semver$1();
|
|
3006
|
+
const Range = require_range();
|
|
3007
|
+
}));
|
|
3008
|
+
//#endregion
|
|
3009
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js
|
|
3010
|
+
var require_satisfies = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3011
|
+
const Range = require_range();
|
|
3012
|
+
const satisfies = (version, range, options) => {
|
|
3013
|
+
try {
|
|
3014
|
+
range = new Range(range, options);
|
|
3015
|
+
} catch (er) {
|
|
3016
|
+
return false;
|
|
3017
|
+
}
|
|
3018
|
+
return range.test(version);
|
|
3019
|
+
};
|
|
3020
|
+
module.exports = satisfies;
|
|
3021
|
+
}));
|
|
3022
|
+
//#endregion
|
|
3023
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js
|
|
3024
|
+
var require_to_comparators = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3025
|
+
const Range = require_range();
|
|
3026
|
+
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
3027
|
+
module.exports = toComparators;
|
|
3028
|
+
}));
|
|
3029
|
+
//#endregion
|
|
3030
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js
|
|
3031
|
+
var require_max_satisfying = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3032
|
+
const SemVer = require_semver$1();
|
|
3033
|
+
const Range = require_range();
|
|
3034
|
+
const maxSatisfying = (versions, range, options) => {
|
|
3035
|
+
let max = null;
|
|
3036
|
+
let maxSV = null;
|
|
3037
|
+
let rangeObj = null;
|
|
3038
|
+
try {
|
|
3039
|
+
rangeObj = new Range(range, options);
|
|
3040
|
+
} catch (er) {
|
|
3041
|
+
return null;
|
|
3042
|
+
}
|
|
3043
|
+
versions.forEach((v) => {
|
|
3044
|
+
if (rangeObj.test(v)) {
|
|
3045
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
3046
|
+
max = v;
|
|
3047
|
+
maxSV = new SemVer(max, options);
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
});
|
|
3051
|
+
return max;
|
|
3052
|
+
};
|
|
3053
|
+
module.exports = maxSatisfying;
|
|
3054
|
+
}));
|
|
3055
|
+
//#endregion
|
|
3056
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js
|
|
3057
|
+
var require_min_satisfying = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3058
|
+
const SemVer = require_semver$1();
|
|
3059
|
+
const Range = require_range();
|
|
3060
|
+
const minSatisfying = (versions, range, options) => {
|
|
3061
|
+
let min = null;
|
|
3062
|
+
let minSV = null;
|
|
3063
|
+
let rangeObj = null;
|
|
3064
|
+
try {
|
|
3065
|
+
rangeObj = new Range(range, options);
|
|
3066
|
+
} catch (er) {
|
|
3067
|
+
return null;
|
|
3068
|
+
}
|
|
3069
|
+
versions.forEach((v) => {
|
|
3070
|
+
if (rangeObj.test(v)) {
|
|
3071
|
+
if (!min || minSV.compare(v) === 1) {
|
|
3072
|
+
min = v;
|
|
3073
|
+
minSV = new SemVer(min, options);
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
});
|
|
3077
|
+
return min;
|
|
3078
|
+
};
|
|
3079
|
+
module.exports = minSatisfying;
|
|
3080
|
+
}));
|
|
3081
|
+
//#endregion
|
|
3082
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js
|
|
3083
|
+
var require_min_version = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3084
|
+
const SemVer = require_semver$1();
|
|
3085
|
+
const Range = require_range();
|
|
3086
|
+
const gt = require_gt();
|
|
3087
|
+
const minVersion = (range, loose) => {
|
|
3088
|
+
range = new Range(range, loose);
|
|
3089
|
+
let minver = new SemVer("0.0.0");
|
|
3090
|
+
if (range.test(minver)) return minver;
|
|
3091
|
+
minver = new SemVer("0.0.0-0");
|
|
3092
|
+
if (range.test(minver)) return minver;
|
|
3093
|
+
minver = null;
|
|
3094
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
3095
|
+
const comparators = range.set[i];
|
|
3096
|
+
let setMin = null;
|
|
3097
|
+
comparators.forEach((comparator) => {
|
|
3098
|
+
const compver = new SemVer(comparator.semver.version);
|
|
3099
|
+
switch (comparator.operator) {
|
|
3100
|
+
case ">":
|
|
3101
|
+
if (compver.prerelease.length === 0) compver.patch++;
|
|
3102
|
+
else compver.prerelease.push(0);
|
|
3103
|
+
compver.raw = compver.format();
|
|
3104
|
+
case "":
|
|
3105
|
+
case ">=":
|
|
3106
|
+
if (!setMin || gt(compver, setMin)) setMin = compver;
|
|
3107
|
+
break;
|
|
3108
|
+
case "<":
|
|
3109
|
+
case "<=": break;
|
|
3110
|
+
/* istanbul ignore next */
|
|
3111
|
+
default: throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
3112
|
+
}
|
|
3113
|
+
});
|
|
3114
|
+
if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
|
|
3115
|
+
}
|
|
3116
|
+
if (minver && range.test(minver)) return minver;
|
|
3117
|
+
return null;
|
|
3118
|
+
};
|
|
3119
|
+
module.exports = minVersion;
|
|
3120
|
+
}));
|
|
3121
|
+
//#endregion
|
|
3122
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js
|
|
3123
|
+
var require_valid = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3124
|
+
const Range = require_range();
|
|
3125
|
+
const validRange = (range, options) => {
|
|
3126
|
+
try {
|
|
3127
|
+
return new Range(range, options).range || "*";
|
|
3128
|
+
} catch (er) {
|
|
3129
|
+
return null;
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
module.exports = validRange;
|
|
3133
|
+
}));
|
|
3134
|
+
//#endregion
|
|
3135
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js
|
|
3136
|
+
var require_outside = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3137
|
+
const SemVer = require_semver$1();
|
|
3138
|
+
const Comparator = require_comparator();
|
|
3139
|
+
const { ANY } = Comparator;
|
|
3140
|
+
const Range = require_range();
|
|
3141
|
+
const satisfies = require_satisfies();
|
|
3142
|
+
const gt = require_gt();
|
|
3143
|
+
const lt = require_lt();
|
|
3144
|
+
const lte = require_lte();
|
|
3145
|
+
const gte = require_gte();
|
|
3146
|
+
const outside = (version, range, hilo, options) => {
|
|
3147
|
+
version = new SemVer(version, options);
|
|
3148
|
+
range = new Range(range, options);
|
|
3149
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
3150
|
+
switch (hilo) {
|
|
3151
|
+
case ">":
|
|
3152
|
+
gtfn = gt;
|
|
3153
|
+
ltefn = lte;
|
|
3154
|
+
ltfn = lt;
|
|
3155
|
+
comp = ">";
|
|
3156
|
+
ecomp = ">=";
|
|
3157
|
+
break;
|
|
3158
|
+
case "<":
|
|
3159
|
+
gtfn = lt;
|
|
3160
|
+
ltefn = gte;
|
|
3161
|
+
ltfn = gt;
|
|
3162
|
+
comp = "<";
|
|
3163
|
+
ecomp = "<=";
|
|
3164
|
+
break;
|
|
3165
|
+
default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
|
|
3166
|
+
}
|
|
3167
|
+
if (satisfies(version, range, options)) return false;
|
|
3168
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
3169
|
+
const comparators = range.set[i];
|
|
3170
|
+
let high = null;
|
|
3171
|
+
let low = null;
|
|
3172
|
+
comparators.forEach((comparator) => {
|
|
3173
|
+
if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
|
|
3174
|
+
high = high || comparator;
|
|
3175
|
+
low = low || comparator;
|
|
3176
|
+
if (gtfn(comparator.semver, high.semver, options)) high = comparator;
|
|
3177
|
+
else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
|
|
3178
|
+
});
|
|
3179
|
+
if (high.operator === comp || high.operator === ecomp) return false;
|
|
3180
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
|
|
3181
|
+
else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
|
|
3182
|
+
}
|
|
3183
|
+
return true;
|
|
3184
|
+
};
|
|
3185
|
+
module.exports = outside;
|
|
3186
|
+
}));
|
|
3187
|
+
//#endregion
|
|
3188
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js
|
|
3189
|
+
var require_gtr = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3190
|
+
const outside = require_outside();
|
|
3191
|
+
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
3192
|
+
module.exports = gtr;
|
|
3193
|
+
}));
|
|
3194
|
+
//#endregion
|
|
3195
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js
|
|
3196
|
+
var require_ltr = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3197
|
+
const outside = require_outside();
|
|
3198
|
+
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
3199
|
+
module.exports = ltr;
|
|
3200
|
+
}));
|
|
3201
|
+
//#endregion
|
|
3202
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js
|
|
3203
|
+
var require_intersects = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3204
|
+
const Range = require_range();
|
|
3205
|
+
const intersects = (r1, r2, options) => {
|
|
3206
|
+
r1 = new Range(r1, options);
|
|
3207
|
+
r2 = new Range(r2, options);
|
|
3208
|
+
return r1.intersects(r2, options);
|
|
3209
|
+
};
|
|
3210
|
+
module.exports = intersects;
|
|
3211
|
+
}));
|
|
3212
|
+
//#endregion
|
|
3213
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js
|
|
3214
|
+
var require_simplify = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3215
|
+
const satisfies = require_satisfies();
|
|
3216
|
+
const compare = require_compare();
|
|
3217
|
+
module.exports = (versions, range, options) => {
|
|
3218
|
+
const set = [];
|
|
3219
|
+
let first = null;
|
|
3220
|
+
let prev = null;
|
|
3221
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
3222
|
+
for (const version of v) if (satisfies(version, range, options)) {
|
|
3223
|
+
prev = version;
|
|
3224
|
+
if (!first) first = version;
|
|
3225
|
+
} else {
|
|
3226
|
+
if (prev) set.push([first, prev]);
|
|
3227
|
+
prev = null;
|
|
3228
|
+
first = null;
|
|
3229
|
+
}
|
|
3230
|
+
if (first) set.push([first, null]);
|
|
3231
|
+
const ranges = [];
|
|
3232
|
+
for (const [min, max] of set) if (min === max) ranges.push(min);
|
|
3233
|
+
else if (!max && min === v[0]) ranges.push("*");
|
|
3234
|
+
else if (!max) ranges.push(`>=${min}`);
|
|
3235
|
+
else if (min === v[0]) ranges.push(`<=${max}`);
|
|
3236
|
+
else ranges.push(`${min} - ${max}`);
|
|
3237
|
+
const simplified = ranges.join(" || ");
|
|
3238
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
3239
|
+
return simplified.length < original.length ? simplified : range;
|
|
3240
|
+
};
|
|
3241
|
+
}));
|
|
3242
|
+
//#endregion
|
|
3243
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js
|
|
3244
|
+
var require_subset = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3245
|
+
const Range = require_range();
|
|
3246
|
+
const Comparator = require_comparator();
|
|
3247
|
+
const { ANY } = Comparator;
|
|
3248
|
+
const satisfies = require_satisfies();
|
|
3249
|
+
const compare = require_compare();
|
|
3250
|
+
const subset = (sub, dom, options = {}) => {
|
|
3251
|
+
if (sub === dom) return true;
|
|
3252
|
+
sub = new Range(sub, options);
|
|
3253
|
+
dom = new Range(dom, options);
|
|
3254
|
+
let sawNonNull = false;
|
|
3255
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
3256
|
+
for (const simpleDom of dom.set) {
|
|
3257
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
3258
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
3259
|
+
if (isSub) continue OUTER;
|
|
3260
|
+
}
|
|
3261
|
+
if (sawNonNull) return false;
|
|
3262
|
+
}
|
|
3263
|
+
return true;
|
|
3264
|
+
};
|
|
3265
|
+
const minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
3266
|
+
const minimumVersion = [new Comparator(">=0.0.0")];
|
|
3267
|
+
const simpleSubset = (sub, dom, options) => {
|
|
3268
|
+
if (sub === dom) return true;
|
|
3269
|
+
if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
|
|
3270
|
+
else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
|
|
3271
|
+
else sub = minimumVersion;
|
|
3272
|
+
if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
|
|
3273
|
+
else dom = minimumVersion;
|
|
3274
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
3275
|
+
let gt, lt;
|
|
3276
|
+
for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
|
|
3277
|
+
else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
|
|
3278
|
+
else eqSet.add(c.semver);
|
|
3279
|
+
if (eqSet.size > 1) return null;
|
|
3280
|
+
let gtltComp;
|
|
3281
|
+
if (gt && lt) {
|
|
3282
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
3283
|
+
if (gtltComp > 0) return null;
|
|
3284
|
+
else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
|
|
3285
|
+
}
|
|
3286
|
+
for (const eq of eqSet) {
|
|
3287
|
+
if (gt && !satisfies(eq, String(gt), options)) return null;
|
|
3288
|
+
if (lt && !satisfies(eq, String(lt), options)) return null;
|
|
3289
|
+
for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
|
|
3290
|
+
return true;
|
|
3291
|
+
}
|
|
3292
|
+
let higher, lower;
|
|
3293
|
+
let hasDomLT, hasDomGT;
|
|
3294
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
3295
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
3296
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
|
|
3297
|
+
for (const c of dom) {
|
|
3298
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
3299
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
3300
|
+
if (gt) {
|
|
3301
|
+
if (needDomGTPre) {
|
|
3302
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
|
|
3303
|
+
}
|
|
3304
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
3305
|
+
higher = higherGT(gt, c, options);
|
|
3306
|
+
if (higher === c && higher !== gt) return false;
|
|
3307
|
+
} else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) return false;
|
|
3308
|
+
}
|
|
3309
|
+
if (lt) {
|
|
3310
|
+
if (needDomLTPre) {
|
|
3311
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
|
|
3312
|
+
}
|
|
3313
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
3314
|
+
lower = lowerLT(lt, c, options);
|
|
3315
|
+
if (lower === c && lower !== lt) return false;
|
|
3316
|
+
} else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) return false;
|
|
3317
|
+
}
|
|
3318
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
|
|
3319
|
+
}
|
|
3320
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
|
|
3321
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
|
|
3322
|
+
if (needDomGTPre || needDomLTPre) return false;
|
|
3323
|
+
return true;
|
|
3324
|
+
};
|
|
3325
|
+
const higherGT = (a, b, options) => {
|
|
3326
|
+
if (!a) return b;
|
|
3327
|
+
const comp = compare(a.semver, b.semver, options);
|
|
3328
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
3329
|
+
};
|
|
3330
|
+
const lowerLT = (a, b, options) => {
|
|
3331
|
+
if (!a) return b;
|
|
3332
|
+
const comp = compare(a.semver, b.semver, options);
|
|
3333
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
3334
|
+
};
|
|
3335
|
+
module.exports = subset;
|
|
3336
|
+
}));
|
|
3337
|
+
//#endregion
|
|
3338
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js
|
|
3339
|
+
var require_semver = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3340
|
+
const internalRe = require_re();
|
|
3341
|
+
const constants = require_constants();
|
|
3342
|
+
const SemVer = require_semver$1();
|
|
3343
|
+
const identifiers = require_identifiers();
|
|
3344
|
+
module.exports = {
|
|
3345
|
+
parse: require_parse(),
|
|
3346
|
+
valid: require_valid$1(),
|
|
3347
|
+
clean: require_clean(),
|
|
3348
|
+
inc: require_inc(),
|
|
3349
|
+
diff: require_diff(),
|
|
3350
|
+
major: require_major(),
|
|
3351
|
+
minor: require_minor(),
|
|
3352
|
+
patch: require_patch(),
|
|
3353
|
+
prerelease: require_prerelease(),
|
|
3354
|
+
compare: require_compare(),
|
|
3355
|
+
rcompare: require_rcompare(),
|
|
3356
|
+
compareLoose: require_compare_loose(),
|
|
3357
|
+
compareBuild: require_compare_build(),
|
|
3358
|
+
sort: require_sort(),
|
|
3359
|
+
rsort: require_rsort(),
|
|
3360
|
+
gt: require_gt(),
|
|
3361
|
+
lt: require_lt(),
|
|
3362
|
+
eq: require_eq(),
|
|
3363
|
+
neq: require_neq(),
|
|
3364
|
+
gte: require_gte(),
|
|
3365
|
+
lte: require_lte(),
|
|
3366
|
+
cmp: require_cmp(),
|
|
3367
|
+
coerce: require_coerce(),
|
|
3368
|
+
Comparator: require_comparator(),
|
|
3369
|
+
Range: require_range(),
|
|
3370
|
+
satisfies: require_satisfies(),
|
|
3371
|
+
toComparators: require_to_comparators(),
|
|
3372
|
+
maxSatisfying: require_max_satisfying(),
|
|
3373
|
+
minSatisfying: require_min_satisfying(),
|
|
3374
|
+
minVersion: require_min_version(),
|
|
3375
|
+
validRange: require_valid(),
|
|
3376
|
+
outside: require_outside(),
|
|
3377
|
+
gtr: require_gtr(),
|
|
3378
|
+
ltr: require_ltr(),
|
|
3379
|
+
intersects: require_intersects(),
|
|
3380
|
+
simplifyRange: require_simplify(),
|
|
3381
|
+
subset: require_subset(),
|
|
3382
|
+
SemVer,
|
|
3383
|
+
re: internalRe.re,
|
|
3384
|
+
src: internalRe.src,
|
|
3385
|
+
tokens: internalRe.t,
|
|
3386
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
3387
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
3388
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
3389
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
3390
|
+
};
|
|
3391
|
+
}));
|
|
3392
|
+
//#endregion
|
|
3393
|
+
//#region ../core/dist/index.js
|
|
3394
|
+
var import_picomatch = /* @__PURE__ */ __toESM$1(require_picomatch(), 1);
|
|
3395
|
+
var import_semver = /* @__PURE__ */ __toESM$1(require_semver(), 1);
|
|
2054
3396
|
var __create = Object.create;
|
|
2055
3397
|
var __defProp = Object.defineProperty;
|
|
2056
3398
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -2125,8 +3467,8 @@ const isFile = (filePath) => {
|
|
|
2125
3467
|
return false;
|
|
2126
3468
|
}
|
|
2127
3469
|
};
|
|
2128
|
-
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx
|
|
2129
|
-
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.js$/i;
|
|
3470
|
+
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
3471
|
+
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
2130
3472
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
2131
3473
|
const GIT_LS_FILES_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
2132
3474
|
const IGNORED_DIRECTORIES = new Set([
|
|
@@ -3041,6 +4383,185 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
|
|
|
3041
4383
|
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
3042
4384
|
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
3043
4385
|
};
|
|
4386
|
+
const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
|
|
4387
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
4388
|
+
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
4389
|
+
const FETCH_TIMEOUT_MS = 1e4;
|
|
4390
|
+
const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
|
|
4391
|
+
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
4392
|
+
const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
|
|
4393
|
+
const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
4394
|
+
const ES_TARGET_YEAR_BY_NAME = {
|
|
4395
|
+
es3: 1999,
|
|
4396
|
+
es5: 2009,
|
|
4397
|
+
es6: 2015,
|
|
4398
|
+
es2015: 2015,
|
|
4399
|
+
es2016: 2016,
|
|
4400
|
+
es2017: 2017,
|
|
4401
|
+
es2018: 2018,
|
|
4402
|
+
es2019: 2019,
|
|
4403
|
+
es2020: 2020,
|
|
4404
|
+
es2021: 2021,
|
|
4405
|
+
es2022: 2022,
|
|
4406
|
+
es2023: 2023,
|
|
4407
|
+
es2024: 2024,
|
|
4408
|
+
es2025: 2025,
|
|
4409
|
+
esnext: 9999
|
|
4410
|
+
};
|
|
4411
|
+
/**
|
|
4412
|
+
* Project-config files that `StagedFiles.materialize` copies into
|
|
4413
|
+
* the temp directory alongside staged sources so oxlint resolves
|
|
4414
|
+
* `tsconfig` / `package.json` / lint configs the same way it would
|
|
4415
|
+
* in the working tree. Hoisted out of the staged-files helper so
|
|
4416
|
+
* the constant lives next to the rest of the IO budget knobs.
|
|
4417
|
+
*/
|
|
4418
|
+
const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
4419
|
+
"tsconfig.json",
|
|
4420
|
+
"tsconfig.base.json",
|
|
4421
|
+
"package.json",
|
|
4422
|
+
"doctor.config.ts",
|
|
4423
|
+
"doctor.config.mts",
|
|
4424
|
+
"doctor.config.cts",
|
|
4425
|
+
"doctor.config.js",
|
|
4426
|
+
"doctor.config.mjs",
|
|
4427
|
+
"doctor.config.cjs",
|
|
4428
|
+
"doctor.config.json",
|
|
4429
|
+
"doctor.config.jsonc",
|
|
4430
|
+
"oxlint.json",
|
|
4431
|
+
".oxlintrc.json"
|
|
4432
|
+
];
|
|
4433
|
+
const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
|
|
4434
|
+
const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
|
|
4435
|
+
const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
|
|
4436
|
+
const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
|
|
4437
|
+
const REACT_SERVER_DOM_PACKAGES = [
|
|
4438
|
+
"react-server-dom-webpack",
|
|
4439
|
+
"react-server-dom-parcel",
|
|
4440
|
+
"react-server-dom-turbopack"
|
|
4441
|
+
];
|
|
4442
|
+
const REACT_BLOG_RSC_ADVISORY_URL = "https://react.dev/blog/2025/12/03/critical-security-vulnerability-in-react-server-components";
|
|
4443
|
+
const VERCEL_NEXTJS_SECURITY_RELEASE_URL = "https://vercel.com/changelog/next-js-may-2026-security-release";
|
|
4444
|
+
const DIAGNOSTIC_CATEGORY_BUCKETS = [
|
|
4445
|
+
"Security",
|
|
4446
|
+
"Bugs",
|
|
4447
|
+
"Performance",
|
|
4448
|
+
"Accessibility",
|
|
4449
|
+
"Maintainability"
|
|
4450
|
+
];
|
|
4451
|
+
const APP_ONLY_RULE_KEYS = new Set([
|
|
4452
|
+
"react-hooks-js/static-components",
|
|
4453
|
+
"react-doctor/no-render-prop-children",
|
|
4454
|
+
"react-doctor/prefer-explicit-variants"
|
|
4455
|
+
]);
|
|
4456
|
+
const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
|
|
4457
|
+
const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
|
|
4458
|
+
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
4459
|
+
const CONFIG_CACHE_TTL_MS = 300 * 1e3;
|
|
4460
|
+
const SOCKET_FREE_PURL_API_BASE = "https://firewall-api.socket.dev/purl";
|
|
4461
|
+
const SOCKET_PACKAGE_PAGE_BASE = "https://socket.dev/npm/package";
|
|
4462
|
+
const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
4463
|
+
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
4464
|
+
const SUPPLY_CHAIN_RULE = "low-supply-chain-score";
|
|
4465
|
+
const SUPPLY_CHAIN_CATEGORY = "Security";
|
|
4466
|
+
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
4467
|
+
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
4468
|
+
const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || path$1.isAbsolute(extendsValue);
|
|
4469
|
+
const ensureJsonExtension = (filePath) => path$1.extname(filePath) === "" ? `${filePath}.json` : filePath;
|
|
4470
|
+
const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
4471
|
+
const requireFromConfig = createRequire(path$1.join(fromConfigDirectory, "tsconfig.json"));
|
|
4472
|
+
const candidates = [
|
|
4473
|
+
extendsValue,
|
|
4474
|
+
ensureJsonExtension(extendsValue),
|
|
4475
|
+
`${extendsValue.replace(/\/$/, "")}/tsconfig.json`
|
|
4476
|
+
];
|
|
4477
|
+
for (const candidate of candidates) try {
|
|
4478
|
+
return requireFromConfig.resolve(candidate);
|
|
4479
|
+
} catch {
|
|
4480
|
+
continue;
|
|
4481
|
+
}
|
|
4482
|
+
return null;
|
|
4483
|
+
};
|
|
4484
|
+
const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
4485
|
+
if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(path$1.resolve(fromConfigDirectory, extendsValue));
|
|
4486
|
+
return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
|
|
4487
|
+
};
|
|
4488
|
+
const normalizeCompilerOptions = (compilerOptions) => {
|
|
4489
|
+
if (!isPlainObject(compilerOptions)) return { hasExplicitLib: false };
|
|
4490
|
+
const target = typeof compilerOptions.target === "string" ? compilerOptions.target : void 0;
|
|
4491
|
+
const hasExplicitLib = Object.hasOwn(compilerOptions, "lib");
|
|
4492
|
+
return {
|
|
4493
|
+
target,
|
|
4494
|
+
lib: Array.isArray(compilerOptions.lib) ? compilerOptions.lib.filter((entry) => typeof entry === "string") : void 0,
|
|
4495
|
+
hasExplicitLib
|
|
4496
|
+
};
|
|
4497
|
+
};
|
|
4498
|
+
const readTsConfig = (filePath) => {
|
|
4499
|
+
let content;
|
|
4500
|
+
try {
|
|
4501
|
+
content = fs$1.readFileSync(filePath, "utf-8");
|
|
4502
|
+
} catch {
|
|
4503
|
+
return null;
|
|
4504
|
+
}
|
|
4505
|
+
const parsed = ts.parseConfigFileTextToJson(filePath, content);
|
|
4506
|
+
if (!isPlainObject(parsed.config)) return null;
|
|
4507
|
+
return {
|
|
4508
|
+
extends: typeof parsed.config.extends === "string" ? parsed.config.extends : void 0,
|
|
4509
|
+
compilerOptions: normalizeCompilerOptions(parsed.config.compilerOptions)
|
|
4510
|
+
};
|
|
4511
|
+
};
|
|
4512
|
+
const mergeCompilerOptions = (inherited, current) => {
|
|
4513
|
+
const target = current.target ?? inherited?.target;
|
|
4514
|
+
const hasExplicitLib = current.hasExplicitLib || Boolean(inherited?.hasExplicitLib);
|
|
4515
|
+
return {
|
|
4516
|
+
target,
|
|
4517
|
+
lib: current.hasExplicitLib ? current.lib : inherited?.lib,
|
|
4518
|
+
hasExplicitLib
|
|
4519
|
+
};
|
|
4520
|
+
};
|
|
4521
|
+
const readResolvedCompilerOptions = (tsConfigPath, extendsDepth, visitedPaths) => {
|
|
4522
|
+
const realPath = fs$1.realpathSync.native(tsConfigPath);
|
|
4523
|
+
if (visitedPaths.has(realPath)) return null;
|
|
4524
|
+
const tsConfig = readTsConfig(realPath);
|
|
4525
|
+
if (!tsConfig) return null;
|
|
4526
|
+
const nextVisitedPaths = new Set(visitedPaths);
|
|
4527
|
+
nextVisitedPaths.add(realPath);
|
|
4528
|
+
if (tsConfig.extends && extendsDepth < 8) {
|
|
4529
|
+
const parentPath = resolveExtendsPath(tsConfig.extends, path$1.dirname(realPath));
|
|
4530
|
+
if (parentPath && isFile(parentPath)) return mergeCompilerOptions(readResolvedCompilerOptions(parentPath, extendsDepth + 1, nextVisitedPaths), tsConfig.compilerOptions);
|
|
4531
|
+
}
|
|
4532
|
+
return tsConfig.compilerOptions;
|
|
4533
|
+
};
|
|
4534
|
+
const targetYearIsPreES2023 = (target) => {
|
|
4535
|
+
const year = ES_TARGET_YEAR_BY_NAME[target.toLowerCase()];
|
|
4536
|
+
return year !== void 0 && year < 2023;
|
|
4537
|
+
};
|
|
4538
|
+
const libEntryIncludesES2023Array = (entry) => {
|
|
4539
|
+
const normalizedEntry = entry.toLowerCase();
|
|
4540
|
+
if (normalizedEntry === "esnext" || normalizedEntry === "esnext.array") return true;
|
|
4541
|
+
const esYearMatch = /^es(\d{4})(?:\.(.+))?$/.exec(normalizedEntry);
|
|
4542
|
+
if (!esYearMatch) return false;
|
|
4543
|
+
if (Number(esYearMatch[1]) < 2023) return false;
|
|
4544
|
+
const component = esYearMatch[2];
|
|
4545
|
+
return component === void 0 || component === "array";
|
|
4546
|
+
};
|
|
4547
|
+
const libIncludesES2023 = (lib) => lib.some(libEntryIncludesES2023Array);
|
|
4548
|
+
const compilerOptionsArePreES2023 = (compilerOptions) => {
|
|
4549
|
+
if (compilerOptions.hasExplicitLib) return !libIncludesES2023(compilerOptions.lib ?? []);
|
|
4550
|
+
if (compilerOptions.target) return targetYearIsPreES2023(compilerOptions.target);
|
|
4551
|
+
return false;
|
|
4552
|
+
};
|
|
4553
|
+
const compilerOptionsDeclareTargetOrLib = (compilerOptions) => compilerOptions.hasExplicitLib || compilerOptions.target !== void 0;
|
|
4554
|
+
const detectPreES2023FromConfig = (tsConfigPath) => {
|
|
4555
|
+
const compilerOptions = readResolvedCompilerOptions(tsConfigPath, 0, /* @__PURE__ */ new Set());
|
|
4556
|
+
if (!compilerOptions) return false;
|
|
4557
|
+
if (!compilerOptionsDeclareTargetOrLib(compilerOptions)) return false;
|
|
4558
|
+
return compilerOptionsArePreES2023(compilerOptions);
|
|
4559
|
+
};
|
|
4560
|
+
const detectPreES2023Target = (directory) => {
|
|
4561
|
+
const tsConfigPath = path$1.join(directory, TSCONFIG_FILENAME);
|
|
4562
|
+
if (isFile(tsConfigPath)) return detectPreES2023FromConfig(tsConfigPath);
|
|
4563
|
+
return false;
|
|
4564
|
+
};
|
|
3044
4565
|
const REACT_DEPENDENCY_NAMES = new Set([
|
|
3045
4566
|
"react",
|
|
3046
4567
|
"react-native",
|
|
@@ -3155,11 +4676,63 @@ const cachedProjectInfos = /* @__PURE__ */ new Map();
|
|
|
3155
4676
|
const clearProjectCache = () => {
|
|
3156
4677
|
cachedProjectInfos.clear();
|
|
3157
4678
|
};
|
|
4679
|
+
/**
|
|
4680
|
+
* Build a `ProjectInfo` for a directory that has no `package.json` of
|
|
4681
|
+
* its own — a monorepo subfolder like `repo/packages`, or any loose tree
|
|
4682
|
+
* of TypeScript/JavaScript files. Dependency + framework detection is
|
|
4683
|
+
* inherited from the enclosing workspace root when there is one, so
|
|
4684
|
+
* scanning a subdirectory of a React monorepo still gets the React
|
|
4685
|
+
* capabilities; a standalone non-React directory simply scans with the
|
|
4686
|
+
* framework-agnostic rules. Throws only when the directory has nothing
|
|
4687
|
+
* to scan (no enclosing project and no source files of its own).
|
|
4688
|
+
*/
|
|
4689
|
+
const discoverProjectWithoutPackageJson = (directory) => {
|
|
4690
|
+
const sourceFileCount = countSourceFiles(directory);
|
|
4691
|
+
const hasOwnTsConfig = fs$1.existsSync(path$1.join(directory, "tsconfig.json"));
|
|
4692
|
+
const monorepoRoot = findMonorepoRoot(directory);
|
|
4693
|
+
const enclosingProject = monorepoRoot !== null && isFile(path$1.join(monorepoRoot, "package.json")) ? discoverProject(monorepoRoot) : null;
|
|
4694
|
+
if (enclosingProject !== null) return {
|
|
4695
|
+
...enclosingProject,
|
|
4696
|
+
rootDirectory: directory,
|
|
4697
|
+
projectName: path$1.basename(directory),
|
|
4698
|
+
hasTypeScript: hasOwnTsConfig || enclosingProject.hasTypeScript,
|
|
4699
|
+
sourceFileCount
|
|
4700
|
+
};
|
|
4701
|
+
if (sourceFileCount === 0) throw new PackageJsonNotFoundError(directory);
|
|
4702
|
+
return {
|
|
4703
|
+
rootDirectory: directory,
|
|
4704
|
+
projectName: path$1.basename(directory),
|
|
4705
|
+
reactVersion: null,
|
|
4706
|
+
reactMajorVersion: null,
|
|
4707
|
+
tailwindVersion: null,
|
|
4708
|
+
zodVersion: null,
|
|
4709
|
+
zodMajorVersion: null,
|
|
4710
|
+
framework: "unknown",
|
|
4711
|
+
hasTypeScript: hasOwnTsConfig,
|
|
4712
|
+
hasReactCompiler: false,
|
|
4713
|
+
hasTanStackQuery: false,
|
|
4714
|
+
preactVersion: null,
|
|
4715
|
+
preactMajorVersion: null,
|
|
4716
|
+
hasReactNativeWorkspace: false,
|
|
4717
|
+
nextjsVersion: null,
|
|
4718
|
+
nextjsMajorVersion: null,
|
|
4719
|
+
expoVersion: null,
|
|
4720
|
+
shopifyFlashListVersion: null,
|
|
4721
|
+
shopifyFlashListMajorVersion: null,
|
|
4722
|
+
hasReanimated: false,
|
|
4723
|
+
isPreES2023Target: hasOwnTsConfig && detectPreES2023Target(directory),
|
|
4724
|
+
sourceFileCount
|
|
4725
|
+
};
|
|
4726
|
+
};
|
|
3158
4727
|
const discoverProject = (directory) => {
|
|
3159
4728
|
const cached = cachedProjectInfos.get(directory);
|
|
3160
4729
|
if (cached !== void 0) return cached;
|
|
3161
4730
|
const packageJsonPath = path$1.join(directory, "package.json");
|
|
3162
|
-
if (!isFile(packageJsonPath))
|
|
4731
|
+
if (!isFile(packageJsonPath)) {
|
|
4732
|
+
const synthesized = discoverProjectWithoutPackageJson(directory);
|
|
4733
|
+
cachedProjectInfos.set(directory, synthesized);
|
|
4734
|
+
return synthesized;
|
|
4735
|
+
}
|
|
3163
4736
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3164
4737
|
let { reactVersion, tailwindVersion, zodVersion, framework } = extractDependencyInfo(packageJson);
|
|
3165
4738
|
const reactDeclaration = getDependencyDeclaration({
|
|
@@ -3245,6 +4818,7 @@ const discoverProject = (directory) => {
|
|
|
3245
4818
|
version: findNextjsVersion(directory, packageJson)
|
|
3246
4819
|
}) : null;
|
|
3247
4820
|
const preactVersion = getPreactVersion(packageJson);
|
|
4821
|
+
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
3248
4822
|
const projectInfo = {
|
|
3249
4823
|
rootDirectory: directory,
|
|
3250
4824
|
projectName,
|
|
@@ -3266,12 +4840,22 @@ const discoverProject = (directory) => {
|
|
|
3266
4840
|
shopifyFlashListVersion,
|
|
3267
4841
|
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
3268
4842
|
hasReanimated,
|
|
4843
|
+
isPreES2023Target,
|
|
3269
4844
|
sourceFileCount
|
|
3270
4845
|
};
|
|
3271
4846
|
cachedProjectInfos.set(directory, projectInfo);
|
|
3272
4847
|
return projectInfo;
|
|
3273
4848
|
};
|
|
3274
|
-
|
|
4849
|
+
/**
|
|
4850
|
+
* A project is worth scanning when it has React/Preact (the framework-
|
|
4851
|
+
* specific rules apply) OR it simply has source files to lint. The
|
|
4852
|
+
* second arm is what lets a plain TypeScript/JavaScript codebase — no
|
|
4853
|
+
* React dependency at all — run the framework-agnostic rules
|
|
4854
|
+
* (security, architecture, zod, bundle-size, …) instead of hard-failing
|
|
4855
|
+
* with "No React dependency". Only a directory with neither React nor a
|
|
4856
|
+
* single source file has nothing to analyze.
|
|
4857
|
+
*/
|
|
4858
|
+
const isAnalyzableProject = (project) => project.reactVersion !== null || project.preactVersion !== null || project.sourceFileCount > 0;
|
|
3275
4859
|
const MAJOR_MINOR_PATTERN = /(\d{1,4})\.(\d{1,4})/;
|
|
3276
4860
|
const MAJOR_ONLY_PATTERN = /(\d{1,4})/;
|
|
3277
4861
|
const UPPER_BOUND_COMPARATOR_PATTERN = /<=?\s{0,8}\d{1,4}(?:\.\d{1,4}){0,2}(?:-[^\s,|]+)?/g;
|
|
@@ -3335,56 +4919,6 @@ const isTailwindAtLeast = (detected, required) => {
|
|
|
3335
4919
|
if (detected.major !== required.major) return detected.major > required.major;
|
|
3336
4920
|
return detected.minor >= required.minor;
|
|
3337
4921
|
};
|
|
3338
|
-
const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
|
|
3339
|
-
const MILLISECONDS_PER_SECOND = 1e3;
|
|
3340
|
-
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
3341
|
-
const FETCH_TIMEOUT_MS = 1e4;
|
|
3342
|
-
const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
|
|
3343
|
-
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
3344
|
-
const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
|
|
3345
|
-
const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
3346
|
-
/**
|
|
3347
|
-
* Project-config files that `StagedFiles.materialize` copies into
|
|
3348
|
-
* the temp directory alongside staged sources so oxlint resolves
|
|
3349
|
-
* `tsconfig` / `package.json` / lint configs the same way it would
|
|
3350
|
-
* in the working tree. Hoisted out of the staged-files helper so
|
|
3351
|
-
* the constant lives next to the rest of the IO budget knobs.
|
|
3352
|
-
*/
|
|
3353
|
-
const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
3354
|
-
"tsconfig.json",
|
|
3355
|
-
"tsconfig.base.json",
|
|
3356
|
-
"package.json",
|
|
3357
|
-
"doctor.config.ts",
|
|
3358
|
-
"doctor.config.mts",
|
|
3359
|
-
"doctor.config.cts",
|
|
3360
|
-
"doctor.config.js",
|
|
3361
|
-
"doctor.config.mjs",
|
|
3362
|
-
"doctor.config.cjs",
|
|
3363
|
-
"doctor.config.json",
|
|
3364
|
-
"doctor.config.jsonc",
|
|
3365
|
-
"oxlint.json",
|
|
3366
|
-
".oxlintrc.json"
|
|
3367
|
-
];
|
|
3368
|
-
const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
|
|
3369
|
-
const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
|
|
3370
|
-
const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
|
|
3371
|
-
const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
|
|
3372
|
-
const DIAGNOSTIC_CATEGORY_BUCKETS = [
|
|
3373
|
-
"Security",
|
|
3374
|
-
"Bugs",
|
|
3375
|
-
"Performance",
|
|
3376
|
-
"Accessibility",
|
|
3377
|
-
"Maintainability"
|
|
3378
|
-
];
|
|
3379
|
-
const APP_ONLY_RULE_KEYS = new Set([
|
|
3380
|
-
"react-hooks-js/static-components",
|
|
3381
|
-
"react-doctor/no-render-prop-children",
|
|
3382
|
-
"react-doctor/prefer-explicit-variants"
|
|
3383
|
-
]);
|
|
3384
|
-
const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
|
|
3385
|
-
const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
|
|
3386
|
-
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
3387
|
-
const CONFIG_CACHE_TTL_MS = 300 * 1e3;
|
|
3388
4922
|
var InvalidGlobPatternError = class extends Error {
|
|
3389
4923
|
pattern;
|
|
3390
4924
|
reason;
|
|
@@ -3695,7 +5229,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
3695
5229
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
3696
5230
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
3697
5231
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
3698
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
3699
5232
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
3700
5233
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
3701
5234
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -4867,51 +6400,51 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
4867
6400
|
{
|
|
4868
6401
|
packageName: "expo-modules-autolinking",
|
|
4869
6402
|
rule: "expo-no-redundant-dependency",
|
|
4870
|
-
message: "\"expo-modules-autolinking\" should not be a direct dependency
|
|
6403
|
+
message: "\"expo-modules-autolinking\" should not be a direct dependency. Expo pins the compatible version through the SDK, and a direct entry can drift to a version that breaks prebuild, Metro, or native builds",
|
|
4871
6404
|
help: "Remove `expo-modules-autolinking` from your package.json"
|
|
4872
6405
|
},
|
|
4873
6406
|
{
|
|
4874
6407
|
packageName: "expo-dev-launcher",
|
|
4875
6408
|
rule: "expo-no-redundant-dependency",
|
|
4876
|
-
message: "\"expo-dev-launcher\" should not be a direct dependency
|
|
6409
|
+
message: "\"expo-dev-launcher\" should not be a direct dependency. `expo-dev-client` pins the compatible launcher, and a direct entry can drift to a version that breaks native builds",
|
|
4877
6410
|
help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
|
|
4878
6411
|
},
|
|
4879
6412
|
{
|
|
4880
6413
|
packageName: "expo-dev-menu",
|
|
4881
6414
|
rule: "expo-no-redundant-dependency",
|
|
4882
|
-
message: "\"expo-dev-menu\" should not be a direct dependency
|
|
6415
|
+
message: "\"expo-dev-menu\" should not be a direct dependency. `expo-dev-client` pins the compatible dev menu, and a direct entry can drift to a version that breaks native builds",
|
|
4883
6416
|
help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
|
|
4884
6417
|
},
|
|
4885
6418
|
{
|
|
4886
6419
|
packageName: "expo-modules-core",
|
|
4887
6420
|
rule: "expo-no-redundant-dependency",
|
|
4888
|
-
message: "\"expo-modules-core\" should not be a direct dependency
|
|
6421
|
+
message: "\"expo-modules-core\" should not be a direct dependency. Expo pins the compatible native core, and a direct entry can drift to a version that breaks prebuild or native builds",
|
|
4889
6422
|
help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
|
|
4890
6423
|
},
|
|
4891
6424
|
{
|
|
4892
6425
|
packageName: "@expo/metro-config",
|
|
4893
6426
|
rule: "expo-no-redundant-dependency",
|
|
4894
|
-
message: "\"@expo/metro-config\" should not be a direct dependency
|
|
6427
|
+
message: "\"@expo/metro-config\" should not be a direct dependency. Expo pins the compatible Metro config, and a direct entry can drift to a version that breaks bundling",
|
|
4895
6428
|
help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
|
|
4896
6429
|
},
|
|
4897
6430
|
{
|
|
4898
6431
|
packageName: "@types/react-native",
|
|
4899
6432
|
rule: "expo-no-redundant-dependency",
|
|
4900
|
-
message: "\"@types/react-native\" should not be installed
|
|
6433
|
+
message: "\"@types/react-native\" should not be installed. React Native ships its own types since SDK 48, so the extra package can introduce duplicate or stale type definitions",
|
|
4901
6434
|
help: "Remove `@types/react-native` from your package.json",
|
|
4902
6435
|
minSdkMajor: 48
|
|
4903
6436
|
},
|
|
4904
6437
|
{
|
|
4905
6438
|
packageName: "@expo/config-plugins",
|
|
4906
6439
|
rule: "expo-no-redundant-dependency",
|
|
4907
|
-
message: "\"@expo/config-plugins\" should not be a direct dependency
|
|
6440
|
+
message: "\"@expo/config-plugins\" should not be a direct dependency. Expo pins the compatible config-plugin API, and a direct entry can drift to a version that breaks prebuild",
|
|
4908
6441
|
help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
|
|
4909
6442
|
minSdkMajor: 48
|
|
4910
6443
|
},
|
|
4911
6444
|
{
|
|
4912
6445
|
packageName: "@expo/prebuild-config",
|
|
4913
6446
|
rule: "expo-no-redundant-dependency",
|
|
4914
|
-
message: "\"@expo/prebuild-config\" should not be a direct dependency
|
|
6447
|
+
message: "\"@expo/prebuild-config\" should not be a direct dependency. Expo pins the compatible prebuild config, and a direct entry can drift to a version that breaks prebuild",
|
|
4915
6448
|
help: "Remove `@expo/prebuild-config` from your package.json",
|
|
4916
6449
|
minSdkMajor: 53
|
|
4917
6450
|
},
|
|
@@ -4925,28 +6458,28 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
4925
6458
|
{
|
|
4926
6459
|
packageName: "expo-app-loading",
|
|
4927
6460
|
rule: "expo-no-redundant-dependency",
|
|
4928
|
-
message: "\"expo-app-loading\" was removed in SDK 49",
|
|
6461
|
+
message: "\"expo-app-loading\" was removed in SDK 49, so keeping it can leave imports unresolved after upgrading Expo",
|
|
4929
6462
|
help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
|
|
4930
6463
|
minSdkMajor: 49
|
|
4931
6464
|
},
|
|
4932
6465
|
{
|
|
4933
6466
|
packageName: "expo-firebase-analytics",
|
|
4934
6467
|
rule: "expo-no-redundant-dependency",
|
|
4935
|
-
message: "\"expo-firebase-analytics\" was removed in SDK 48",
|
|
6468
|
+
message: "\"expo-firebase-analytics\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
4936
6469
|
help: FIREBASE_HELP,
|
|
4937
6470
|
minSdkMajor: 48
|
|
4938
6471
|
},
|
|
4939
6472
|
{
|
|
4940
6473
|
packageName: "expo-firebase-recaptcha",
|
|
4941
6474
|
rule: "expo-no-redundant-dependency",
|
|
4942
|
-
message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
|
|
6475
|
+
message: "\"expo-firebase-recaptcha\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
4943
6476
|
help: FIREBASE_HELP,
|
|
4944
6477
|
minSdkMajor: 48
|
|
4945
6478
|
},
|
|
4946
6479
|
{
|
|
4947
6480
|
packageName: "expo-firebase-core",
|
|
4948
6481
|
rule: "expo-no-redundant-dependency",
|
|
4949
|
-
message: "\"expo-firebase-core\" was removed in SDK 48",
|
|
6482
|
+
message: "\"expo-firebase-core\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
4950
6483
|
help: FIREBASE_HELP,
|
|
4951
6484
|
minSdkMajor: 48
|
|
4952
6485
|
}
|
|
@@ -4987,7 +6520,7 @@ const checkExpoGitignore = (context) => {
|
|
|
4987
6520
|
}));
|
|
4988
6521
|
if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
|
|
4989
6522
|
rule: "expo-gitignore",
|
|
4990
|
-
message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored
|
|
6523
|
+
message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored, so required native code can be missing from CI or teammate checkouts.",
|
|
4991
6524
|
help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
|
|
4992
6525
|
}));
|
|
4993
6526
|
return diagnostics;
|
|
@@ -5049,17 +6582,16 @@ const checkExpoPackageJsonConflicts = (context) => {
|
|
|
5049
6582
|
const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
|
|
5050
6583
|
if (conflictingScriptNames.length > 0) {
|
|
5051
6584
|
const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
|
|
5052
|
-
const shadowsExpoCli = conflictingScriptNames.includes("expo");
|
|
5053
6585
|
diagnostics.push(buildExpoDiagnostic({
|
|
5054
6586
|
rule: "expo-package-json-conflict",
|
|
5055
|
-
message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that
|
|
6587
|
+
message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that shadows" : "as scripts that shadow"} Expo/React Native binaries in node_modules/.bin, so tooling can run the local script instead of the expected CLI and fail builds.`,
|
|
5056
6588
|
help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
|
|
5057
6589
|
}));
|
|
5058
6590
|
}
|
|
5059
6591
|
const packageName = packageJson.name;
|
|
5060
6592
|
if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
|
|
5061
6593
|
rule: "expo-package-json-conflict",
|
|
5062
|
-
message: `package.json "name" is "${packageName}", which collides with a dependency of the same name
|
|
6594
|
+
message: `package.json "name" is "${packageName}", which collides with a dependency of the same name, so package self-resolution can shadow the dependency and break imports that expect the installed package.`,
|
|
5063
6595
|
help: "Rename your package so it no longer matches one of its dependencies"
|
|
5064
6596
|
}));
|
|
5065
6597
|
return diagnostics;
|
|
@@ -5130,7 +6662,7 @@ const checkExpoRouterReactNavigation = (context) => {
|
|
|
5130
6662
|
if (reactNavigationNames.length === 0) return [];
|
|
5131
6663
|
return [buildExpoDiagnostic({
|
|
5132
6664
|
rule: "expo-router-no-react-navigation",
|
|
5133
|
-
message: `As of SDK 56, expo-router is no longer compatible with react-navigation,
|
|
6665
|
+
message: `As of SDK 56, expo-router is no longer compatible with directly installed @react-navigation packages, so keeping ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} can break routing or linking behavior after the SDK upgrade.`,
|
|
5134
6666
|
help: "Remove these `@react-navigation/*` packages and replace direct imports with their expo-router equivalents. See https://docs.expo.dev/router/migrate/sdk-55-to-56/"
|
|
5135
6667
|
})];
|
|
5136
6668
|
};
|
|
@@ -5353,6 +6885,168 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
5353
6885
|
if (!isReactNativeProject(project)) return [];
|
|
5354
6886
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
5355
6887
|
};
|
|
6888
|
+
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
6889
|
+
const DEPENDENCY_SECTIONS = [
|
|
6890
|
+
"dependencies",
|
|
6891
|
+
"devDependencies",
|
|
6892
|
+
"peerDependencies",
|
|
6893
|
+
"optionalDependencies"
|
|
6894
|
+
];
|
|
6895
|
+
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
6896
|
+
"19.0": {
|
|
6897
|
+
rceFixedVersion: "19.0.1",
|
|
6898
|
+
latestSafeVersion: "19.0.6"
|
|
6899
|
+
},
|
|
6900
|
+
"19.1": {
|
|
6901
|
+
rceFixedVersion: "19.1.2",
|
|
6902
|
+
latestSafeVersion: "19.1.7"
|
|
6903
|
+
},
|
|
6904
|
+
"19.2": {
|
|
6905
|
+
rceFixedVersion: "19.2.1",
|
|
6906
|
+
latestSafeVersion: "19.2.6"
|
|
6907
|
+
}
|
|
6908
|
+
};
|
|
6909
|
+
const NEXTJS_OLDEST_AFFECTED_MAJOR = 13;
|
|
6910
|
+
const NEXTJS_RCE_FIXED_BY_MINOR = {
|
|
6911
|
+
"15.0": "15.0.5",
|
|
6912
|
+
"15.1": "15.1.9",
|
|
6913
|
+
"15.2": "15.2.6",
|
|
6914
|
+
"15.3": "15.3.6",
|
|
6915
|
+
"15.4": "15.4.8",
|
|
6916
|
+
"15.5": "15.5.7",
|
|
6917
|
+
"16.0": "16.0.7"
|
|
6918
|
+
};
|
|
6919
|
+
const NEXTJS_LATEST_SAFE_BY_MAJOR = {
|
|
6920
|
+
15: "15.5.18",
|
|
6921
|
+
16: "16.2.6"
|
|
6922
|
+
};
|
|
6923
|
+
const NEXTJS_SUPPORTED_UPGRADE_TARGETS = "15.5.18 or 16.2.6";
|
|
6924
|
+
const buildAdvisoryDiagnostic = (input) => ({
|
|
6925
|
+
filePath: "package.json",
|
|
6926
|
+
plugin: "react-doctor",
|
|
6927
|
+
rule: RULE_KEY,
|
|
6928
|
+
severity: input.severity,
|
|
6929
|
+
message: input.message,
|
|
6930
|
+
help: input.help,
|
|
6931
|
+
line: 0,
|
|
6932
|
+
column: 0,
|
|
6933
|
+
category: "Security"
|
|
6934
|
+
});
|
|
6935
|
+
const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
6936
|
+
const patterns = getWorkspacePatterns(workspaceRoot, readPackageJson(path$1.join(workspaceRoot, "package.json")));
|
|
6937
|
+
const directories = /* @__PURE__ */ new Set();
|
|
6938
|
+
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
6939
|
+
return [...directories];
|
|
6940
|
+
};
|
|
6941
|
+
const readDeclaredSpec = (packageJson, packageName) => {
|
|
6942
|
+
for (const section of DEPENDENCY_SECTIONS) {
|
|
6943
|
+
const spec = packageJson[section]?.[packageName];
|
|
6944
|
+
if (typeof spec === "string") return spec;
|
|
6945
|
+
}
|
|
6946
|
+
return null;
|
|
6947
|
+
};
|
|
6948
|
+
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
6949
|
+
const manifestPath = path$1.join(directory, "node_modules", packageName, "package.json");
|
|
6950
|
+
if (isFile(manifestPath)) {
|
|
6951
|
+
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
6952
|
+
if (installedVersion !== null) return installedVersion;
|
|
6953
|
+
}
|
|
6954
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(path$1.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
6955
|
+
for (const spec of candidateSpecs) {
|
|
6956
|
+
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
6957
|
+
if (pinnedVersion !== null) return pinnedVersion;
|
|
6958
|
+
}
|
|
6959
|
+
return null;
|
|
6960
|
+
};
|
|
6961
|
+
const checkReactServerDomAdvisory = (packageName, version) => {
|
|
6962
|
+
const advisory = REACT_RSC_ADVISORIES_BY_MINOR[`${import_semver.major(version)}.${import_semver.minor(version)}`];
|
|
6963
|
+
if (advisory === void 0) return [];
|
|
6964
|
+
const installedDisplay = `${packageName}@${version}`;
|
|
6965
|
+
const lineDisplay = `${import_semver.major(version)}.${import_semver.minor(version)}`;
|
|
6966
|
+
if (import_semver.lt(version, advisory.rceFixedVersion)) return [buildAdvisoryDiagnostic({
|
|
6967
|
+
severity: "error",
|
|
6968
|
+
message: `${installedDisplay} has the critical React Server Components remote code execution vulnerability (CVE-2025-55182, CVSS 10.0) — an unauthenticated attacker can run arbitrary code on your server by sending a crafted payload to any Server Function endpoint`,
|
|
6969
|
+
help: `Upgrade React's Server Components runtime to ${advisory.latestSafeVersion} — a patch-level bump within ${lineDisplay} with no breaking changes. Run \`npm install ${packageName}@${advisory.latestSafeVersion}\` and pin \`react\`/\`react-dom\` to ${advisory.latestSafeVersion} too. See ${REACT_BLOG_RSC_ADVISORY_URL}`
|
|
6970
|
+
})];
|
|
6971
|
+
if (import_semver.lt(version, advisory.latestSafeVersion)) return [buildAdvisoryDiagnostic({
|
|
6972
|
+
severity: "warning",
|
|
6973
|
+
message: `${installedDisplay} is affected by a high-severity React Server Components denial-of-service vulnerability (CVE-2026-23870) patched in ${advisory.latestSafeVersion}`,
|
|
6974
|
+
help: `Upgrade to ${advisory.latestSafeVersion} — a patch-level bump within ${lineDisplay}. Run \`npm install ${packageName}@${advisory.latestSafeVersion}\` and align \`react\`/\`react-dom\`. See ${VERCEL_NEXTJS_SECURITY_RELEASE_URL}`
|
|
6975
|
+
})];
|
|
6976
|
+
return [];
|
|
6977
|
+
};
|
|
6978
|
+
const checkNextjsAdvisory = (version) => {
|
|
6979
|
+
const major = import_semver.major(version);
|
|
6980
|
+
if (major < NEXTJS_OLDEST_AFFECTED_MAJOR) return [];
|
|
6981
|
+
const installedDisplay = `next@${version}`;
|
|
6982
|
+
const latestSafeVersion = NEXTJS_LATEST_SAFE_BY_MAJOR[major];
|
|
6983
|
+
if (latestSafeVersion === void 0) {
|
|
6984
|
+
if (major >= 15) return [];
|
|
6985
|
+
return [buildAdvisoryDiagnostic({
|
|
6986
|
+
severity: "warning",
|
|
6987
|
+
message: `${installedDisplay} is on an unsupported Next.js release line affected by the React Server Components security advisories — there is no patched ${major}.x release`,
|
|
6988
|
+
help: `Upgrade to a patched Next.js release (${NEXTJS_SUPPORTED_UPGRADE_TARGETS}). Next.js bundles its own React Server Components runtime, so upgrading Next.js is what ships the fix. See ${VERCEL_NEXTJS_SECURITY_RELEASE_URL}`
|
|
6989
|
+
})];
|
|
6990
|
+
}
|
|
6991
|
+
const rceFixedVersion = NEXTJS_RCE_FIXED_BY_MINOR[`${major}.${import_semver.minor(version)}`];
|
|
6992
|
+
if (rceFixedVersion !== void 0 && import_semver.lt(version, rceFixedVersion)) return [buildAdvisoryDiagnostic({
|
|
6993
|
+
severity: "error",
|
|
6994
|
+
message: `${installedDisplay} bundles the React Server Components runtime affected by the critical remote code execution vulnerability (CVE-2025-55182, CVSS 10.0) — an unauthenticated attacker can run arbitrary code on your server by sending a crafted payload to any Server Function or Server Action endpoint`,
|
|
6995
|
+
help: `Upgrade Next.js to ${latestSafeVersion} (or newer). Next.js bundles its own React Server Components runtime, so bumping Next.js — not \`react\` — ships the fix. Run \`npm install next@${latestSafeVersion}\`. See ${VERCEL_NEXTJS_SECURITY_RELEASE_URL}`
|
|
6996
|
+
})];
|
|
6997
|
+
if (import_semver.lt(version, latestSafeVersion)) return [buildAdvisoryDiagnostic({
|
|
6998
|
+
severity: "warning",
|
|
6999
|
+
message: `${installedDisplay} bundles a React Server Components runtime affected by a high-severity denial-of-service vulnerability (CVE-2026-23870) patched in Next.js ${latestSafeVersion}`,
|
|
7000
|
+
help: `Upgrade Next.js to ${latestSafeVersion} (or newer). Next.js bundles its own React Server Components runtime, so bumping Next.js ships the fix. Run \`npm install next@${latestSafeVersion}\`. See ${VERCEL_NEXTJS_SECURITY_RELEASE_URL}`
|
|
7001
|
+
})];
|
|
7002
|
+
return [];
|
|
7003
|
+
};
|
|
7004
|
+
/**
|
|
7005
|
+
* Flags a project running React Server Components on a version with a known
|
|
7006
|
+
* security advisory — primarily the critical unauthenticated RCE
|
|
7007
|
+
* (CVE-2025-55182), plus the later high-severity DoS (CVE-2026-23870).
|
|
7008
|
+
*
|
|
7009
|
+
* Every candidate directory — the scan root and each workspace package — is
|
|
7010
|
+
* probed independently, so heterogeneous monorepo installs are all seen (a
|
|
7011
|
+
* vulnerable `next` in one workspace isn't masked by an inert one elsewhere).
|
|
7012
|
+
* Next.js vendors its own RSC runtime, so an affected `next` install in a
|
|
7013
|
+
* directory is reported by its `next` version (the fix is a Next.js bump) and
|
|
7014
|
+
* suppresses the standalone `react-server-dom-*` check for that directory only;
|
|
7015
|
+
* every other framework or bundler — Vite, Parcel, React Router, Waku,
|
|
7016
|
+
* RedwoodSDK — is reported by its `react-server-dom-*` version. Dispatch keys
|
|
7017
|
+
* on resolved installs rather than the root framework classification, so a
|
|
7018
|
+
* monorepo whose root is Vite but whose workspace runs Next.js is still
|
|
7019
|
+
* covered. Pure client-side React apps (no RSC packages, no Next.js) are not
|
|
7020
|
+
* affected and stay quiet.
|
|
7021
|
+
*/
|
|
7022
|
+
const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
|
|
7023
|
+
const workspaceRoot = findMonorepoRoot(scanDirectory) ?? project.rootDirectory;
|
|
7024
|
+
const candidateDirectories = [...new Set([
|
|
7025
|
+
scanDirectory,
|
|
7026
|
+
project.rootDirectory,
|
|
7027
|
+
workspaceRoot,
|
|
7028
|
+
...enumerateWorkspaceDirectories(workspaceRoot)
|
|
7029
|
+
])];
|
|
7030
|
+
const diagnostics = [];
|
|
7031
|
+
const seenMessages = /* @__PURE__ */ new Set();
|
|
7032
|
+
const pushUnique = (candidates) => {
|
|
7033
|
+
for (const candidate of candidates) {
|
|
7034
|
+
if (seenMessages.has(candidate.message)) continue;
|
|
7035
|
+
seenMessages.add(candidate.message);
|
|
7036
|
+
diagnostics.push(candidate);
|
|
7037
|
+
}
|
|
7038
|
+
};
|
|
7039
|
+
for (const directory of candidateDirectories) {
|
|
7040
|
+
const nextVersion = resolveVersionInDirectory(directory, "next", directory === scanDirectory ? project.nextjsVersion : null);
|
|
7041
|
+
if (nextVersion !== null) pushUnique(checkNextjsAdvisory(nextVersion));
|
|
7042
|
+
if (nextVersion !== null && import_semver.major(nextVersion) >= NEXTJS_OLDEST_AFFECTED_MAJOR) continue;
|
|
7043
|
+
for (const packageName of REACT_SERVER_DOM_PACKAGES) {
|
|
7044
|
+
const version = resolveVersionInDirectory(directory, packageName, null);
|
|
7045
|
+
if (version !== null) pushUnique(checkReactServerDomAdvisory(packageName, version));
|
|
7046
|
+
}
|
|
7047
|
+
}
|
|
7048
|
+
return diagnostics;
|
|
7049
|
+
};
|
|
5356
7050
|
const REDUCED_MOTION_GREP_PATTERN = "prefers-reduced-motion|useReducedMotion|MotionConfig|reducedMotion";
|
|
5357
7051
|
const REDUCED_MOTION_FILE_GLOBS = [
|
|
5358
7052
|
"*.ts",
|
|
@@ -5483,7 +7177,9 @@ const highlighter = {
|
|
|
5483
7177
|
gray: import_picocolors.default.gray,
|
|
5484
7178
|
bold: import_picocolors.default.bold
|
|
5485
7179
|
};
|
|
5486
|
-
const
|
|
7180
|
+
const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
|
|
7181
|
+
const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
|
|
7182
|
+
const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
|
|
5487
7183
|
const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
|
|
5488
7184
|
const FALSY_VALUES = new Set([
|
|
5489
7185
|
"false",
|
|
@@ -5912,7 +7608,7 @@ const checkDeadCode = async (options) => {
|
|
|
5912
7608
|
plugin: DEAD_CODE_PLUGIN,
|
|
5913
7609
|
rule: "unused-file",
|
|
5914
7610
|
severity: "warning",
|
|
5915
|
-
message: "Unused file
|
|
7611
|
+
message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
|
|
5916
7612
|
help: "Delete the file if it is truly unreachable, or import it from an entry point.",
|
|
5917
7613
|
line: 0,
|
|
5918
7614
|
column: 0,
|
|
@@ -5925,7 +7621,7 @@ const checkDeadCode = async (options) => {
|
|
|
5925
7621
|
plugin: DEAD_CODE_PLUGIN,
|
|
5926
7622
|
rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
|
|
5927
7623
|
severity: "warning",
|
|
5928
|
-
message: `Unused ${label}: \`${unusedExport.name}
|
|
7624
|
+
message: `Unused ${label}: \`${unusedExport.name}\` is exported but no module imports it, so it expands the public surface and can mislead callers about supported API.`,
|
|
5929
7625
|
help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
|
|
5930
7626
|
line: unusedExport.line,
|
|
5931
7627
|
column: unusedExport.column,
|
|
@@ -5940,7 +7636,7 @@ const checkDeadCode = async (options) => {
|
|
|
5940
7636
|
rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
|
|
5941
7637
|
severity: "warning",
|
|
5942
7638
|
message: `Unused ${label}: \`${unusedDependency.name}\``,
|
|
5943
|
-
help:
|
|
7639
|
+
help: `An unused ${label} adds install time and supply-chain surface without being used; remove it from package.json if it is genuinely unused.`,
|
|
5944
7640
|
line: 0,
|
|
5945
7641
|
column: 0,
|
|
5946
7642
|
category: DEAD_CODE_CATEGORY
|
|
@@ -5953,7 +7649,7 @@ const checkDeadCode = async (options) => {
|
|
|
5953
7649
|
plugin: DEAD_CODE_PLUGIN,
|
|
5954
7650
|
rule: "circular-dependency",
|
|
5955
7651
|
severity: "warning",
|
|
5956
|
-
message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}
|
|
7652
|
+
message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}. Modules in the cycle can observe partially initialized exports, causing order-dependent bugs.`,
|
|
5957
7653
|
help: "Break the cycle by extracting the shared code into a third module that both files import.",
|
|
5958
7654
|
line: 0,
|
|
5959
7655
|
column: 0,
|
|
@@ -6036,11 +7732,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
|
|
|
6036
7732
|
return filePaths;
|
|
6037
7733
|
};
|
|
6038
7734
|
const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
|
|
6039
|
-
const resolveLintIncludePaths = (rootDirectory, userConfig) => {
|
|
7735
|
+
const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
|
|
6040
7736
|
if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
|
|
6041
7737
|
const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
|
|
6042
7738
|
return listSourceFiles(rootDirectory).filter((filePath) => {
|
|
6043
|
-
if (!
|
|
7739
|
+
if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
|
|
6044
7740
|
return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
|
|
6045
7741
|
});
|
|
6046
7742
|
};
|
|
@@ -6743,6 +8439,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
6743
8439
|
const buildCapabilities = (project) => {
|
|
6744
8440
|
const capabilities = /* @__PURE__ */ new Set();
|
|
6745
8441
|
capabilities.add(project.framework);
|
|
8442
|
+
if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
|
|
6746
8443
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
6747
8444
|
if (project.expoVersion !== null) capabilities.add("expo");
|
|
6748
8445
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
@@ -6768,6 +8465,7 @@ const buildCapabilities = (project) => {
|
|
|
6768
8465
|
capabilities.add("zod");
|
|
6769
8466
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
6770
8467
|
}
|
|
8468
|
+
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
6771
8469
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
6772
8470
|
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
6773
8471
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
@@ -6786,6 +8484,7 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
|
|
|
6786
8484
|
if (requires) {
|
|
6787
8485
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
6788
8486
|
}
|
|
8487
|
+
if (tags?.includes("react-jsx-only") && !capabilities.has("react")) return false;
|
|
6789
8488
|
if (disabledBy) {
|
|
6790
8489
|
for (const capability of disabledBy) if (capabilities.has(capability)) return false;
|
|
6791
8490
|
}
|
|
@@ -8298,6 +9997,214 @@ var Score = class Score extends Context.Service()("react-doctor/Score") {
|
|
|
8298
9997
|
}) }));
|
|
8299
9998
|
static layerOf = (result) => Layer.succeed(Score, Score.of({ compute: () => Effect.succeed(result) }));
|
|
8300
9999
|
};
|
|
10000
|
+
const SocketScoreSchema = Schema.Struct({
|
|
10001
|
+
overall: Schema.Number,
|
|
10002
|
+
license: Schema.Number,
|
|
10003
|
+
maintenance: Schema.Number,
|
|
10004
|
+
quality: Schema.Number,
|
|
10005
|
+
supplyChain: Schema.Number,
|
|
10006
|
+
vulnerability: Schema.Number
|
|
10007
|
+
});
|
|
10008
|
+
const SocketArtifactSchema = Schema.Struct({ score: Schema.optional(SocketScoreSchema) });
|
|
10009
|
+
const decodeArtifact = Schema.decodeUnknownOption(SocketArtifactSchema);
|
|
10010
|
+
const SCORE_AXES = [
|
|
10011
|
+
{
|
|
10012
|
+
key: "supplyChain",
|
|
10013
|
+
label: "supply chain"
|
|
10014
|
+
},
|
|
10015
|
+
{
|
|
10016
|
+
key: "vulnerability",
|
|
10017
|
+
label: "vulnerability"
|
|
10018
|
+
},
|
|
10019
|
+
{
|
|
10020
|
+
key: "maintenance",
|
|
10021
|
+
label: "maintenance"
|
|
10022
|
+
},
|
|
10023
|
+
{
|
|
10024
|
+
key: "quality",
|
|
10025
|
+
label: "quality"
|
|
10026
|
+
},
|
|
10027
|
+
{
|
|
10028
|
+
key: "license",
|
|
10029
|
+
label: "license"
|
|
10030
|
+
}
|
|
10031
|
+
];
|
|
10032
|
+
const clampScore = (value) => {
|
|
10033
|
+
if (!Number.isFinite(value)) return 50;
|
|
10034
|
+
return Math.min(Math.max(value, 0), 100);
|
|
10035
|
+
};
|
|
10036
|
+
const toHundred = (normalizedScore) => Math.round(clampScore(normalizedScore * 100));
|
|
10037
|
+
const resolveOptions = (config) => {
|
|
10038
|
+
const supplyChain = config?.supplyChain ?? {};
|
|
10039
|
+
return {
|
|
10040
|
+
minScore: typeof supplyChain.minScore === "number" ? clampScore(supplyChain.minScore) : 50,
|
|
10041
|
+
severity: supplyChain.severity === "warning" ? "warning" : "error",
|
|
10042
|
+
includeDevDependencies: supplyChain.includeDevDependencies !== false
|
|
10043
|
+
};
|
|
10044
|
+
};
|
|
10045
|
+
const resolveConcreteVersion = (spec) => {
|
|
10046
|
+
const trimmed = spec.trim();
|
|
10047
|
+
if (trimmed.length === 0) return null;
|
|
10048
|
+
if (trimmed.includes(":")) return null;
|
|
10049
|
+
const match = trimmed.match(/\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/);
|
|
10050
|
+
return match ? match[0] : null;
|
|
10051
|
+
};
|
|
10052
|
+
const locateDependencyKey = (packageJsonText, section, name) => {
|
|
10053
|
+
const needle = `"${name}"`;
|
|
10054
|
+
const sectionHeader = new RegExp(`"${section}"\\s*:\\s*\\{`);
|
|
10055
|
+
const lines = packageJsonText.split(/\r?\n/);
|
|
10056
|
+
let depth = 0;
|
|
10057
|
+
let insideSection = false;
|
|
10058
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
|
|
10059
|
+
const lineText = lines[lineIndex];
|
|
10060
|
+
if (!insideSection) {
|
|
10061
|
+
if (sectionHeader.test(lineText)) {
|
|
10062
|
+
insideSection = true;
|
|
10063
|
+
depth = 1;
|
|
10064
|
+
}
|
|
10065
|
+
continue;
|
|
10066
|
+
}
|
|
10067
|
+
const columnIndex = lineText.indexOf(needle);
|
|
10068
|
+
if (columnIndex >= 0 && /^\s*:/.test(lineText.slice(columnIndex + needle.length))) return {
|
|
10069
|
+
line: lineIndex + 1,
|
|
10070
|
+
column: columnIndex + 1
|
|
10071
|
+
};
|
|
10072
|
+
for (const character of lineText) if (character === "{") depth += 1;
|
|
10073
|
+
else if (character === "}") depth -= 1;
|
|
10074
|
+
if (depth <= 0) return null;
|
|
10075
|
+
}
|
|
10076
|
+
return null;
|
|
10077
|
+
};
|
|
10078
|
+
const collectDependenciesToScore = (packageJson, packageJsonText, includeDevDependencies) => {
|
|
10079
|
+
const sectionByName = /* @__PURE__ */ new Map();
|
|
10080
|
+
for (const name of Object.keys(packageJson.dependencies ?? {})) sectionByName.set(name, "dependencies");
|
|
10081
|
+
if (includeDevDependencies) {
|
|
10082
|
+
for (const name of Object.keys(packageJson.devDependencies ?? {})) if (!sectionByName.has(name)) sectionByName.set(name, "devDependencies");
|
|
10083
|
+
}
|
|
10084
|
+
const dependencies = [];
|
|
10085
|
+
for (const [name, section] of sectionByName) {
|
|
10086
|
+
if (SUPPLY_CHAIN_IGNORED_PACKAGES.has(name)) continue;
|
|
10087
|
+
const spec = (packageJson[section] ?? {})[name] ?? "";
|
|
10088
|
+
const version = resolveConcreteVersion(spec);
|
|
10089
|
+
if (version === null) continue;
|
|
10090
|
+
const location = locateDependencyKey(packageJsonText, section, name);
|
|
10091
|
+
dependencies.push({
|
|
10092
|
+
name,
|
|
10093
|
+
version,
|
|
10094
|
+
spec,
|
|
10095
|
+
line: location?.line ?? 0,
|
|
10096
|
+
column: location?.column ?? 0
|
|
10097
|
+
});
|
|
10098
|
+
}
|
|
10099
|
+
return dependencies;
|
|
10100
|
+
};
|
|
10101
|
+
const readPackageJsonText = (packageJsonPath) => {
|
|
10102
|
+
try {
|
|
10103
|
+
return fs$1.readFileSync(packageJsonPath, "utf-8");
|
|
10104
|
+
} catch {
|
|
10105
|
+
return "";
|
|
10106
|
+
}
|
|
10107
|
+
};
|
|
10108
|
+
const toPurl = (dependency) => `pkg:npm/${dependency.name}@${dependency.version}`;
|
|
10109
|
+
const parseScoreFromBody = (body) => {
|
|
10110
|
+
for (const line of body.split("\n")) {
|
|
10111
|
+
if (line.trim().length === 0) continue;
|
|
10112
|
+
let parsed;
|
|
10113
|
+
try {
|
|
10114
|
+
parsed = JSON.parse(line);
|
|
10115
|
+
} catch {
|
|
10116
|
+
continue;
|
|
10117
|
+
}
|
|
10118
|
+
const artifact = Option.getOrNull(decodeArtifact(parsed));
|
|
10119
|
+
if (artifact?.score) return artifact.score;
|
|
10120
|
+
}
|
|
10121
|
+
return null;
|
|
10122
|
+
};
|
|
10123
|
+
const fetchSocketScore = (dependency) => Effect.tryPromise(async (signal) => {
|
|
10124
|
+
const requestUrl = `${SOCKET_FREE_PURL_API_BASE}/${encodeURIComponent(toPurl(dependency))}`;
|
|
10125
|
+
const response = await fetch(requestUrl, {
|
|
10126
|
+
headers: { "User-Agent": SOCKET_FREE_USER_AGENT },
|
|
10127
|
+
signal
|
|
10128
|
+
});
|
|
10129
|
+
if (!response.ok) return null;
|
|
10130
|
+
return parseScoreFromBody(await response.text());
|
|
10131
|
+
}).pipe(Effect.timeout(FETCH_TIMEOUT_MS), Effect.orElseSucceed(() => null), Effect.tap((score) => {
|
|
10132
|
+
const scoreAttributes = {};
|
|
10133
|
+
if (score !== null) {
|
|
10134
|
+
scoreAttributes["socket.score.overall"] = toHundred(score.overall);
|
|
10135
|
+
for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(score[axis.key]);
|
|
10136
|
+
}
|
|
10137
|
+
return Effect.annotateCurrentSpan({
|
|
10138
|
+
"socket.scored": score !== null,
|
|
10139
|
+
...scoreAttributes
|
|
10140
|
+
});
|
|
10141
|
+
}), Effect.withSpan("SupplyChain.fetchScore", { attributes: {
|
|
10142
|
+
"socket.package": dependency.name,
|
|
10143
|
+
"socket.version": dependency.version,
|
|
10144
|
+
"socket.purl": toPurl(dependency)
|
|
10145
|
+
} }));
|
|
10146
|
+
const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
|
|
10147
|
+
const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
10148
|
+
const overall = toHundred(score.overall);
|
|
10149
|
+
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
10150
|
+
return {
|
|
10151
|
+
filePath: "package.json",
|
|
10152
|
+
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
10153
|
+
rule: SUPPLY_CHAIN_RULE,
|
|
10154
|
+
severity: options.severity,
|
|
10155
|
+
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket supply-chain score of ${overall}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
|
|
10156
|
+
help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
|
|
10157
|
+
url: packagePageUrl,
|
|
10158
|
+
line: dependency.line,
|
|
10159
|
+
column: dependency.column,
|
|
10160
|
+
category: SUPPLY_CHAIN_CATEGORY
|
|
10161
|
+
};
|
|
10162
|
+
};
|
|
10163
|
+
/**
|
|
10164
|
+
* Scores every direct dependency in the project's `package.json` against
|
|
10165
|
+
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
10166
|
+
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
10167
|
+
* Socket `overall` score is below the configured `minScore`.
|
|
10168
|
+
*
|
|
10169
|
+
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
10170
|
+
* total/fail-open: each per-package lookup already recovers to `null`
|
|
10171
|
+
* (skip) on timeout or network/parse failure, so a flaky Socket API never
|
|
10172
|
+
* sinks the scan. Diagnostics default to `"error"` severity, so a low score
|
|
10173
|
+
* fails the run at the standard `blocking` gate.
|
|
10174
|
+
*/
|
|
10175
|
+
const checkSupplyChain = (input) => Effect.gen(function* () {
|
|
10176
|
+
const options = resolveOptions(input.userConfig);
|
|
10177
|
+
const packageJsonPath = path$1.join(input.rootDirectory, "package.json");
|
|
10178
|
+
const dependencies = collectDependenciesToScore(readPackageJson(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
|
|
10179
|
+
if (dependencies.length === 0) return [];
|
|
10180
|
+
const scores = yield* Effect.forEach(dependencies, fetchSocketScore, { concurrency: 8 });
|
|
10181
|
+
const diagnostics = [];
|
|
10182
|
+
for (let index = 0; index < dependencies.length; index += 1) {
|
|
10183
|
+
const score = scores[index];
|
|
10184
|
+
if (!score) continue;
|
|
10185
|
+
if (toHundred(score.overall) >= options.minScore) continue;
|
|
10186
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, options));
|
|
10187
|
+
}
|
|
10188
|
+
return diagnostics;
|
|
10189
|
+
});
|
|
10190
|
+
/**
|
|
10191
|
+
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
10192
|
+
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
10193
|
+
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
10194
|
+
* Socket score falls below the configured `supplyChain.minScore`.
|
|
10195
|
+
*
|
|
10196
|
+
* Runs by default (one network request per dependency); the orchestrator
|
|
10197
|
+
* provides `layerOf([])` only when the user opts out via
|
|
10198
|
+
* `supplyChain.enabled: false`, and always skips it in `--diff` / `--staged`
|
|
10199
|
+
* mode (dependency health is a whole-project property).
|
|
10200
|
+
* The underlying `checkSupplyChain` Effect is total/fail-open — per-package
|
|
10201
|
+
* timeouts and network failures recover to "skip" — so the stream never
|
|
10202
|
+
* fails, mirroring `DeadCode`'s stream shape so the two compose the same way.
|
|
10203
|
+
*/
|
|
10204
|
+
var SupplyChain = class SupplyChain extends Context.Service()("react-doctor/SupplyChain") {
|
|
10205
|
+
static layerNode = Layer.succeed(SupplyChain, SupplyChain.of({ run: (input) => Stream.unwrap(checkSupplyChain(input).pipe(Effect.map((diagnostics) => Stream.fromIterable(diagnostics)), Effect.withSpan("SupplyChain.run"))) }));
|
|
10206
|
+
static layerOf = (diagnostics) => Layer.succeed(SupplyChain, SupplyChain.of({ run: () => Stream.fromIterable(diagnostics) }));
|
|
10207
|
+
};
|
|
8301
10208
|
const getObjectProperty = (value, propertyName) => {
|
|
8302
10209
|
if (typeof value !== "object" || value === null) return void 0;
|
|
8303
10210
|
return Reflect.get(value, propertyName);
|
|
@@ -8375,6 +10282,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8375
10282
|
const reporterService = yield* Reporter;
|
|
8376
10283
|
const scoreService = yield* Score;
|
|
8377
10284
|
const deadCodeService = yield* DeadCode;
|
|
10285
|
+
const supplyChainService = yield* SupplyChain;
|
|
8378
10286
|
const gitService = yield* Git;
|
|
8379
10287
|
const progressService = yield* Progress;
|
|
8380
10288
|
const partialFailuresRef = yield* LintPartialFailures;
|
|
@@ -8392,7 +10300,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8392
10300
|
directory: scanDirectory,
|
|
8393
10301
|
repo
|
|
8394
10302
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
8395
|
-
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 :
|
|
10303
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
|
|
8396
10304
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
8397
10305
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
8398
10306
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -8410,10 +10318,15 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8410
10318
|
const environmentDiagnostics = isDiffMode ? [] : [
|
|
8411
10319
|
...checkReducedMotion(scanDirectory),
|
|
8412
10320
|
...checkPnpmHardening(scanDirectory),
|
|
10321
|
+
...checkReactServerComponentsAdvisory(scanDirectory, project),
|
|
8413
10322
|
...checkExpoProject(scanDirectory, project),
|
|
8414
10323
|
...checkReactNativeProject(scanDirectory, project)
|
|
8415
10324
|
];
|
|
8416
10325
|
const envCollected = yield* Stream.runCollect(applyPerElementPipeline(Stream.fromIterable(environmentDiagnostics)));
|
|
10326
|
+
const supplyChainCollected = !isDiffMode || (input.supplyChainManifestChanged ?? false) ? yield* Stream.runCollect(applyPerElementPipeline(supplyChainService.run({
|
|
10327
|
+
rootDirectory: scanDirectory,
|
|
10328
|
+
userConfig: resolvedConfig.config
|
|
10329
|
+
}))) : [];
|
|
8417
10330
|
const lintFailure = yield* Ref.make({
|
|
8418
10331
|
didFail: false,
|
|
8419
10332
|
reason: null,
|
|
@@ -8478,6 +10391,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8478
10391
|
yield* reporterService.finalize;
|
|
8479
10392
|
const finalDiagnostics = [
|
|
8480
10393
|
...envCollected,
|
|
10394
|
+
...supplyChainCollected,
|
|
8481
10395
|
...lintCollected,
|
|
8482
10396
|
...deadCodeCollected
|
|
8483
10397
|
];
|
|
@@ -8924,7 +10838,14 @@ const clearAutoSuppressionCaches = () => {};
|
|
|
8924
10838
|
const defineConfig = (config) => config;
|
|
8925
10839
|
//#endregion
|
|
8926
10840
|
//#region ../api/dist/index.js
|
|
8927
|
-
const buildDiagnoseLayer = (
|
|
10841
|
+
const buildDiagnoseLayer = (config, configOverride) => {
|
|
10842
|
+
const configLayer = configOverride === void 0 ? Config.layerNode : Config.layerOf({
|
|
10843
|
+
config,
|
|
10844
|
+
resolvedDirectory: configOverride.resolvedDirectory,
|
|
10845
|
+
configSourceDirectory: null
|
|
10846
|
+
});
|
|
10847
|
+
return Layer.mergeAll(Project.layerNode, configLayer, DeadCode.layerNode, Files.layerNode, Git.layerNode, Linter.layerOxlint, LintPartialFailures.layerLive, Progress.layerNoop, Reporter.layerNoop, Score.layerHttp, config?.supplyChain?.enabled !== false ? SupplyChain.layerNode : SupplyChain.layerOf([]));
|
|
10848
|
+
};
|
|
8928
10849
|
const buildInspectProgram = (scanTarget, options, configOverride) => {
|
|
8929
10850
|
const effectiveConfig = configOverride ?? scanTarget.userConfig;
|
|
8930
10851
|
const includePaths = options.includePaths ?? [];
|
|
@@ -8955,8 +10876,9 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
|
|
|
8955
10876
|
};
|
|
8956
10877
|
const diagnose = async (directory, options = {}) => {
|
|
8957
10878
|
const startTime = globalThis.performance.now();
|
|
8958
|
-
const
|
|
8959
|
-
|
|
10879
|
+
const scanTarget = await resolveScanTarget(directory);
|
|
10880
|
+
const program = buildInspectProgram(scanTarget, options);
|
|
10881
|
+
return outputToDiagnoseResult(await Effect.runPromise(restoreLegacyThrow(program.pipe(Effect.provide(buildDiagnoseLayer(scanTarget.userConfig)), Effect.provide(layerOtlp)))), globalThis.performance.now() - startTime);
|
|
8960
10882
|
};
|
|
8961
10883
|
//#endregion
|
|
8962
10884
|
//#region src/index.ts
|
|
@@ -8990,4 +10912,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8990
10912
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8991
10913
|
|
|
8992
10914
|
//# sourceMappingURL=index.js.map
|
|
8993
|
-
//# debugId=
|
|
10915
|
+
//# debugId=50a9af23-7f4c-50ee-ab12-d23a4915d902
|