react-doctor 0.4.2 → 0.5.0-dev.77a70ab
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/lsp.js
CHANGED
|
@@ -6,6 +6,7 @@ import * as path$1 from "node:path";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import { spawn, spawnSync } from "node:child_process";
|
|
9
|
+
import * as ts from "typescript";
|
|
9
10
|
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";
|
|
10
11
|
import * as Cause from "effect/Cause";
|
|
11
12
|
import * as Effect from "effect/Effect";
|
|
@@ -29,7 +30,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
|
29
30
|
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
30
31
|
import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
31
32
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
32
|
-
import * as ts from "typescript";
|
|
33
33
|
import { gzipSync } from "node:zlib";
|
|
34
34
|
import crypto from "node:crypto";
|
|
35
35
|
import * as Exit from "effect/Exit";
|
|
@@ -190,7 +190,7 @@ var JsonReportV2 = class extends Schema.Class("JsonReportV2")({
|
|
|
190
190
|
Schema.Union([JsonReportV1, JsonReportV2]);
|
|
191
191
|
//#endregion
|
|
192
192
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
193
|
-
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
193
|
+
var require_constants$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
194
194
|
const WIN_SLASH = "\\\\/";
|
|
195
195
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
196
196
|
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
@@ -360,7 +360,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
360
360
|
//#endregion
|
|
361
361
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js
|
|
362
362
|
var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
363
|
-
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
363
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants$1();
|
|
364
364
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
365
365
|
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
366
366
|
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
@@ -409,7 +409,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
|
409
409
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js
|
|
410
410
|
var require_scan = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
411
411
|
const utils = require_utils();
|
|
412
|
-
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();
|
|
412
|
+
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();
|
|
413
413
|
const isPathSeparator = (code) => {
|
|
414
414
|
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
415
415
|
};
|
|
@@ -694,8 +694,8 @@ var require_scan = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
694
694
|
}));
|
|
695
695
|
//#endregion
|
|
696
696
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js
|
|
697
|
-
var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
698
|
-
const constants = require_constants();
|
|
697
|
+
var require_parse$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
698
|
+
const constants = require_constants$1();
|
|
699
699
|
const utils = require_utils();
|
|
700
700
|
/**
|
|
701
701
|
* Constants
|
|
@@ -1751,9 +1751,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
1751
1751
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js
|
|
1752
1752
|
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
1753
1753
|
const scan = require_scan();
|
|
1754
|
-
const parse = require_parse();
|
|
1754
|
+
const parse = require_parse$1();
|
|
1755
1755
|
const utils = require_utils();
|
|
1756
|
-
const constants = require_constants();
|
|
1756
|
+
const constants = require_constants$1();
|
|
1757
1757
|
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1758
1758
|
/**
|
|
1759
1759
|
* Creates a matcher function from one or more glob patterns. The
|
|
@@ -2048,8 +2048,8 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
|
|
|
2048
2048
|
module.exports = picomatch;
|
|
2049
2049
|
}));
|
|
2050
2050
|
//#endregion
|
|
2051
|
-
//#region
|
|
2052
|
-
var
|
|
2051
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js
|
|
2052
|
+
var require_picomatch = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2053
2053
|
const pico = require_picomatch$1();
|
|
2054
2054
|
const utils = require_utils();
|
|
2055
2055
|
function picomatch(glob, options, returnState = false) {
|
|
@@ -2061,7 +2061,1349 @@ var import_picomatch = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$
|
|
|
2061
2061
|
}
|
|
2062
2062
|
Object.assign(picomatch, pico);
|
|
2063
2063
|
module.exports = picomatch;
|
|
2064
|
-
}))
|
|
2064
|
+
}));
|
|
2065
|
+
//#endregion
|
|
2066
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
|
|
2067
|
+
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2068
|
+
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
2069
|
+
const MAX_LENGTH = 256;
|
|
2070
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
2071
|
+
module.exports = {
|
|
2072
|
+
MAX_LENGTH,
|
|
2073
|
+
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
2074
|
+
MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
|
|
2075
|
+
MAX_SAFE_INTEGER,
|
|
2076
|
+
RELEASE_TYPES: [
|
|
2077
|
+
"major",
|
|
2078
|
+
"premajor",
|
|
2079
|
+
"minor",
|
|
2080
|
+
"preminor",
|
|
2081
|
+
"patch",
|
|
2082
|
+
"prepatch",
|
|
2083
|
+
"prerelease"
|
|
2084
|
+
],
|
|
2085
|
+
SEMVER_SPEC_VERSION,
|
|
2086
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
2087
|
+
FLAG_LOOSE: 2
|
|
2088
|
+
};
|
|
2089
|
+
}));
|
|
2090
|
+
//#endregion
|
|
2091
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
|
|
2092
|
+
var require_debug = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2093
|
+
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
2094
|
+
}));
|
|
2095
|
+
//#endregion
|
|
2096
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js
|
|
2097
|
+
var require_re = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2098
|
+
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
2099
|
+
const debug = require_debug();
|
|
2100
|
+
exports = module.exports = {};
|
|
2101
|
+
const re = exports.re = [];
|
|
2102
|
+
const safeRe = exports.safeRe = [];
|
|
2103
|
+
const src = exports.src = [];
|
|
2104
|
+
const safeSrc = exports.safeSrc = [];
|
|
2105
|
+
const t = exports.t = {};
|
|
2106
|
+
let R = 0;
|
|
2107
|
+
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
2108
|
+
const safeRegexReplacements = [
|
|
2109
|
+
["\\s", 1],
|
|
2110
|
+
["\\d", MAX_LENGTH],
|
|
2111
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
2112
|
+
];
|
|
2113
|
+
const makeSafeRegex = (value) => {
|
|
2114
|
+
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
2115
|
+
return value;
|
|
2116
|
+
};
|
|
2117
|
+
const createToken = (name, value, isGlobal) => {
|
|
2118
|
+
const safe = makeSafeRegex(value);
|
|
2119
|
+
const index = R++;
|
|
2120
|
+
debug(name, index, value);
|
|
2121
|
+
t[name] = index;
|
|
2122
|
+
src[index] = value;
|
|
2123
|
+
safeSrc[index] = safe;
|
|
2124
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
2125
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
2126
|
+
};
|
|
2127
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
2128
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
2129
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
2130
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
2131
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
2132
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
2133
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
2134
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
2135
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
2136
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
2137
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
2138
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
2139
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
2140
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
2141
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
2142
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
2143
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
2144
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
2145
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
2146
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
2147
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
2148
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
2149
|
+
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
2150
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
2151
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
2152
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
2153
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
2154
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
2155
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
2156
|
+
exports.tildeTrimReplace = "$1~";
|
|
2157
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
2158
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
2159
|
+
createToken("LONECARET", "(?:\\^)");
|
|
2160
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
2161
|
+
exports.caretTrimReplace = "$1^";
|
|
2162
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
2163
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
2164
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
2165
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
2166
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
2167
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
2168
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
2169
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
2170
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
2171
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
2172
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
2173
|
+
}));
|
|
2174
|
+
//#endregion
|
|
2175
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js
|
|
2176
|
+
var require_parse_options = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2177
|
+
const looseOption = Object.freeze({ loose: true });
|
|
2178
|
+
const emptyOpts = Object.freeze({});
|
|
2179
|
+
const parseOptions = (options) => {
|
|
2180
|
+
if (!options) return emptyOpts;
|
|
2181
|
+
if (typeof options !== "object") return looseOption;
|
|
2182
|
+
return options;
|
|
2183
|
+
};
|
|
2184
|
+
module.exports = parseOptions;
|
|
2185
|
+
}));
|
|
2186
|
+
//#endregion
|
|
2187
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js
|
|
2188
|
+
var require_identifiers = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2189
|
+
const numeric = /^[0-9]+$/;
|
|
2190
|
+
const compareIdentifiers = (a, b) => {
|
|
2191
|
+
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
2192
|
+
const anum = numeric.test(a);
|
|
2193
|
+
const bnum = numeric.test(b);
|
|
2194
|
+
if (anum && bnum) {
|
|
2195
|
+
a = +a;
|
|
2196
|
+
b = +b;
|
|
2197
|
+
}
|
|
2198
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
2199
|
+
};
|
|
2200
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
2201
|
+
module.exports = {
|
|
2202
|
+
compareIdentifiers,
|
|
2203
|
+
rcompareIdentifiers
|
|
2204
|
+
};
|
|
2205
|
+
}));
|
|
2206
|
+
//#endregion
|
|
2207
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js
|
|
2208
|
+
var require_semver$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2209
|
+
const debug = require_debug();
|
|
2210
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
2211
|
+
const { safeRe: re, t } = require_re();
|
|
2212
|
+
const parseOptions = require_parse_options();
|
|
2213
|
+
const { compareIdentifiers } = require_identifiers();
|
|
2214
|
+
module.exports = class SemVer {
|
|
2215
|
+
constructor(version, options) {
|
|
2216
|
+
options = parseOptions(options);
|
|
2217
|
+
if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
2218
|
+
else version = version.version;
|
|
2219
|
+
else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
2220
|
+
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
2221
|
+
debug("SemVer", version, options);
|
|
2222
|
+
this.options = options;
|
|
2223
|
+
this.loose = !!options.loose;
|
|
2224
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
2225
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
2226
|
+
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
2227
|
+
this.raw = version;
|
|
2228
|
+
this.major = +m[1];
|
|
2229
|
+
this.minor = +m[2];
|
|
2230
|
+
this.patch = +m[3];
|
|
2231
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
2232
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
2233
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
2234
|
+
if (!m[4]) this.prerelease = [];
|
|
2235
|
+
else this.prerelease = m[4].split(".").map((id) => {
|
|
2236
|
+
if (/^[0-9]+$/.test(id)) {
|
|
2237
|
+
const num = +id;
|
|
2238
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
2239
|
+
}
|
|
2240
|
+
return id;
|
|
2241
|
+
});
|
|
2242
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
2243
|
+
this.format();
|
|
2244
|
+
}
|
|
2245
|
+
format() {
|
|
2246
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
2247
|
+
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
2248
|
+
return this.version;
|
|
2249
|
+
}
|
|
2250
|
+
toString() {
|
|
2251
|
+
return this.version;
|
|
2252
|
+
}
|
|
2253
|
+
compare(other) {
|
|
2254
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
2255
|
+
if (!(other instanceof SemVer)) {
|
|
2256
|
+
if (typeof other === "string" && other === this.version) return 0;
|
|
2257
|
+
other = new SemVer(other, this.options);
|
|
2258
|
+
}
|
|
2259
|
+
if (other.version === this.version) return 0;
|
|
2260
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
2261
|
+
}
|
|
2262
|
+
compareMain(other) {
|
|
2263
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
2264
|
+
if (this.major < other.major) return -1;
|
|
2265
|
+
if (this.major > other.major) return 1;
|
|
2266
|
+
if (this.minor < other.minor) return -1;
|
|
2267
|
+
if (this.minor > other.minor) return 1;
|
|
2268
|
+
if (this.patch < other.patch) return -1;
|
|
2269
|
+
if (this.patch > other.patch) return 1;
|
|
2270
|
+
return 0;
|
|
2271
|
+
}
|
|
2272
|
+
comparePre(other) {
|
|
2273
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
2274
|
+
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
2275
|
+
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
2276
|
+
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
2277
|
+
let i = 0;
|
|
2278
|
+
do {
|
|
2279
|
+
const a = this.prerelease[i];
|
|
2280
|
+
const b = other.prerelease[i];
|
|
2281
|
+
debug("prerelease compare", i, a, b);
|
|
2282
|
+
if (a === void 0 && b === void 0) return 0;
|
|
2283
|
+
else if (b === void 0) return 1;
|
|
2284
|
+
else if (a === void 0) return -1;
|
|
2285
|
+
else if (a === b) continue;
|
|
2286
|
+
else return compareIdentifiers(a, b);
|
|
2287
|
+
} while (++i);
|
|
2288
|
+
}
|
|
2289
|
+
compareBuild(other) {
|
|
2290
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
2291
|
+
let i = 0;
|
|
2292
|
+
do {
|
|
2293
|
+
const a = this.build[i];
|
|
2294
|
+
const b = other.build[i];
|
|
2295
|
+
debug("build compare", i, a, b);
|
|
2296
|
+
if (a === void 0 && b === void 0) return 0;
|
|
2297
|
+
else if (b === void 0) return 1;
|
|
2298
|
+
else if (a === void 0) return -1;
|
|
2299
|
+
else if (a === b) continue;
|
|
2300
|
+
else return compareIdentifiers(a, b);
|
|
2301
|
+
} while (++i);
|
|
2302
|
+
}
|
|
2303
|
+
inc(release, identifier, identifierBase) {
|
|
2304
|
+
if (release.startsWith("pre")) {
|
|
2305
|
+
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
2306
|
+
if (identifier) {
|
|
2307
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
2308
|
+
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
switch (release) {
|
|
2312
|
+
case "premajor":
|
|
2313
|
+
this.prerelease.length = 0;
|
|
2314
|
+
this.patch = 0;
|
|
2315
|
+
this.minor = 0;
|
|
2316
|
+
this.major++;
|
|
2317
|
+
this.inc("pre", identifier, identifierBase);
|
|
2318
|
+
break;
|
|
2319
|
+
case "preminor":
|
|
2320
|
+
this.prerelease.length = 0;
|
|
2321
|
+
this.patch = 0;
|
|
2322
|
+
this.minor++;
|
|
2323
|
+
this.inc("pre", identifier, identifierBase);
|
|
2324
|
+
break;
|
|
2325
|
+
case "prepatch":
|
|
2326
|
+
this.prerelease.length = 0;
|
|
2327
|
+
this.inc("patch", identifier, identifierBase);
|
|
2328
|
+
this.inc("pre", identifier, identifierBase);
|
|
2329
|
+
break;
|
|
2330
|
+
case "prerelease":
|
|
2331
|
+
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
2332
|
+
this.inc("pre", identifier, identifierBase);
|
|
2333
|
+
break;
|
|
2334
|
+
case "release":
|
|
2335
|
+
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
2336
|
+
this.prerelease.length = 0;
|
|
2337
|
+
break;
|
|
2338
|
+
case "major":
|
|
2339
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
2340
|
+
this.minor = 0;
|
|
2341
|
+
this.patch = 0;
|
|
2342
|
+
this.prerelease = [];
|
|
2343
|
+
break;
|
|
2344
|
+
case "minor":
|
|
2345
|
+
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
2346
|
+
this.patch = 0;
|
|
2347
|
+
this.prerelease = [];
|
|
2348
|
+
break;
|
|
2349
|
+
case "patch":
|
|
2350
|
+
if (this.prerelease.length === 0) this.patch++;
|
|
2351
|
+
this.prerelease = [];
|
|
2352
|
+
break;
|
|
2353
|
+
case "pre": {
|
|
2354
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
2355
|
+
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
2356
|
+
else {
|
|
2357
|
+
let i = this.prerelease.length;
|
|
2358
|
+
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
2359
|
+
this.prerelease[i]++;
|
|
2360
|
+
i = -2;
|
|
2361
|
+
}
|
|
2362
|
+
if (i === -1) {
|
|
2363
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
2364
|
+
this.prerelease.push(base);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
if (identifier) {
|
|
2368
|
+
let prerelease = [identifier, base];
|
|
2369
|
+
if (identifierBase === false) prerelease = [identifier];
|
|
2370
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
2371
|
+
if (isNaN(this.prerelease[1])) this.prerelease = prerelease;
|
|
2372
|
+
} else this.prerelease = prerelease;
|
|
2373
|
+
}
|
|
2374
|
+
break;
|
|
2375
|
+
}
|
|
2376
|
+
default: throw new Error(`invalid increment argument: ${release}`);
|
|
2377
|
+
}
|
|
2378
|
+
this.raw = this.format();
|
|
2379
|
+
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
2380
|
+
return this;
|
|
2381
|
+
}
|
|
2382
|
+
};
|
|
2383
|
+
}));
|
|
2384
|
+
//#endregion
|
|
2385
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js
|
|
2386
|
+
var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2387
|
+
const SemVer = require_semver$1();
|
|
2388
|
+
const parse = (version, options, throwErrors = false) => {
|
|
2389
|
+
if (version instanceof SemVer) return version;
|
|
2390
|
+
try {
|
|
2391
|
+
return new SemVer(version, options);
|
|
2392
|
+
} catch (er) {
|
|
2393
|
+
if (!throwErrors) return null;
|
|
2394
|
+
throw er;
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
module.exports = parse;
|
|
2398
|
+
}));
|
|
2399
|
+
//#endregion
|
|
2400
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js
|
|
2401
|
+
var require_valid$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2402
|
+
const parse = require_parse();
|
|
2403
|
+
const valid = (version, options) => {
|
|
2404
|
+
const v = parse(version, options);
|
|
2405
|
+
return v ? v.version : null;
|
|
2406
|
+
};
|
|
2407
|
+
module.exports = valid;
|
|
2408
|
+
}));
|
|
2409
|
+
//#endregion
|
|
2410
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js
|
|
2411
|
+
var require_clean = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2412
|
+
const parse = require_parse();
|
|
2413
|
+
const clean = (version, options) => {
|
|
2414
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
2415
|
+
return s ? s.version : null;
|
|
2416
|
+
};
|
|
2417
|
+
module.exports = clean;
|
|
2418
|
+
}));
|
|
2419
|
+
//#endregion
|
|
2420
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js
|
|
2421
|
+
var require_inc = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2422
|
+
const SemVer = require_semver$1();
|
|
2423
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
2424
|
+
if (typeof options === "string") {
|
|
2425
|
+
identifierBase = identifier;
|
|
2426
|
+
identifier = options;
|
|
2427
|
+
options = void 0;
|
|
2428
|
+
}
|
|
2429
|
+
try {
|
|
2430
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
2431
|
+
} catch (er) {
|
|
2432
|
+
return null;
|
|
2433
|
+
}
|
|
2434
|
+
};
|
|
2435
|
+
module.exports = inc;
|
|
2436
|
+
}));
|
|
2437
|
+
//#endregion
|
|
2438
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js
|
|
2439
|
+
var require_diff = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2440
|
+
const parse = require_parse();
|
|
2441
|
+
const diff = (version1, version2) => {
|
|
2442
|
+
const v1 = parse(version1, null, true);
|
|
2443
|
+
const v2 = parse(version2, null, true);
|
|
2444
|
+
const comparison = v1.compare(v2);
|
|
2445
|
+
if (comparison === 0) return null;
|
|
2446
|
+
const v1Higher = comparison > 0;
|
|
2447
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
2448
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
2449
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
2450
|
+
if (!!lowVersion.prerelease.length && !highHasPre) {
|
|
2451
|
+
if (!lowVersion.patch && !lowVersion.minor) return "major";
|
|
2452
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
2453
|
+
if (lowVersion.minor && !lowVersion.patch) return "minor";
|
|
2454
|
+
return "patch";
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
const prefix = highHasPre ? "pre" : "";
|
|
2458
|
+
if (v1.major !== v2.major) return prefix + "major";
|
|
2459
|
+
if (v1.minor !== v2.minor) return prefix + "minor";
|
|
2460
|
+
if (v1.patch !== v2.patch) return prefix + "patch";
|
|
2461
|
+
return "prerelease";
|
|
2462
|
+
};
|
|
2463
|
+
module.exports = diff;
|
|
2464
|
+
}));
|
|
2465
|
+
//#endregion
|
|
2466
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js
|
|
2467
|
+
var require_major = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2468
|
+
const SemVer = require_semver$1();
|
|
2469
|
+
const major = (a, loose) => new SemVer(a, loose).major;
|
|
2470
|
+
module.exports = major;
|
|
2471
|
+
}));
|
|
2472
|
+
//#endregion
|
|
2473
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js
|
|
2474
|
+
var require_minor = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2475
|
+
const SemVer = require_semver$1();
|
|
2476
|
+
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
2477
|
+
module.exports = minor;
|
|
2478
|
+
}));
|
|
2479
|
+
//#endregion
|
|
2480
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js
|
|
2481
|
+
var require_patch = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2482
|
+
const SemVer = require_semver$1();
|
|
2483
|
+
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
2484
|
+
module.exports = patch;
|
|
2485
|
+
}));
|
|
2486
|
+
//#endregion
|
|
2487
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js
|
|
2488
|
+
var require_prerelease = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2489
|
+
const parse = require_parse();
|
|
2490
|
+
const prerelease = (version, options) => {
|
|
2491
|
+
const parsed = parse(version, options);
|
|
2492
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
2493
|
+
};
|
|
2494
|
+
module.exports = prerelease;
|
|
2495
|
+
}));
|
|
2496
|
+
//#endregion
|
|
2497
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js
|
|
2498
|
+
var require_compare = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2499
|
+
const SemVer = require_semver$1();
|
|
2500
|
+
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
2501
|
+
module.exports = compare;
|
|
2502
|
+
}));
|
|
2503
|
+
//#endregion
|
|
2504
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js
|
|
2505
|
+
var require_rcompare = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2506
|
+
const compare = require_compare();
|
|
2507
|
+
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
2508
|
+
module.exports = rcompare;
|
|
2509
|
+
}));
|
|
2510
|
+
//#endregion
|
|
2511
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js
|
|
2512
|
+
var require_compare_loose = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2513
|
+
const compare = require_compare();
|
|
2514
|
+
const compareLoose = (a, b) => compare(a, b, true);
|
|
2515
|
+
module.exports = compareLoose;
|
|
2516
|
+
}));
|
|
2517
|
+
//#endregion
|
|
2518
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js
|
|
2519
|
+
var require_compare_build = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2520
|
+
const SemVer = require_semver$1();
|
|
2521
|
+
const compareBuild = (a, b, loose) => {
|
|
2522
|
+
const versionA = new SemVer(a, loose);
|
|
2523
|
+
const versionB = new SemVer(b, loose);
|
|
2524
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
2525
|
+
};
|
|
2526
|
+
module.exports = compareBuild;
|
|
2527
|
+
}));
|
|
2528
|
+
//#endregion
|
|
2529
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js
|
|
2530
|
+
var require_sort = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2531
|
+
const compareBuild = require_compare_build();
|
|
2532
|
+
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
2533
|
+
module.exports = sort;
|
|
2534
|
+
}));
|
|
2535
|
+
//#endregion
|
|
2536
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js
|
|
2537
|
+
var require_rsort = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2538
|
+
const compareBuild = require_compare_build();
|
|
2539
|
+
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
2540
|
+
module.exports = rsort;
|
|
2541
|
+
}));
|
|
2542
|
+
//#endregion
|
|
2543
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js
|
|
2544
|
+
var require_gt = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2545
|
+
const compare = require_compare();
|
|
2546
|
+
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
2547
|
+
module.exports = gt;
|
|
2548
|
+
}));
|
|
2549
|
+
//#endregion
|
|
2550
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js
|
|
2551
|
+
var require_lt = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2552
|
+
const compare = require_compare();
|
|
2553
|
+
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
2554
|
+
module.exports = lt;
|
|
2555
|
+
}));
|
|
2556
|
+
//#endregion
|
|
2557
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js
|
|
2558
|
+
var require_eq = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2559
|
+
const compare = require_compare();
|
|
2560
|
+
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
2561
|
+
module.exports = eq;
|
|
2562
|
+
}));
|
|
2563
|
+
//#endregion
|
|
2564
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js
|
|
2565
|
+
var require_neq = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2566
|
+
const compare = require_compare();
|
|
2567
|
+
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
2568
|
+
module.exports = neq;
|
|
2569
|
+
}));
|
|
2570
|
+
//#endregion
|
|
2571
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js
|
|
2572
|
+
var require_gte = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2573
|
+
const compare = require_compare();
|
|
2574
|
+
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
2575
|
+
module.exports = gte;
|
|
2576
|
+
}));
|
|
2577
|
+
//#endregion
|
|
2578
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js
|
|
2579
|
+
var require_lte = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2580
|
+
const compare = require_compare();
|
|
2581
|
+
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
2582
|
+
module.exports = lte;
|
|
2583
|
+
}));
|
|
2584
|
+
//#endregion
|
|
2585
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js
|
|
2586
|
+
var require_cmp = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2587
|
+
const eq = require_eq();
|
|
2588
|
+
const neq = require_neq();
|
|
2589
|
+
const gt = require_gt();
|
|
2590
|
+
const gte = require_gte();
|
|
2591
|
+
const lt = require_lt();
|
|
2592
|
+
const lte = require_lte();
|
|
2593
|
+
const cmp = (a, op, b, loose) => {
|
|
2594
|
+
switch (op) {
|
|
2595
|
+
case "===":
|
|
2596
|
+
if (typeof a === "object") a = a.version;
|
|
2597
|
+
if (typeof b === "object") b = b.version;
|
|
2598
|
+
return a === b;
|
|
2599
|
+
case "!==":
|
|
2600
|
+
if (typeof a === "object") a = a.version;
|
|
2601
|
+
if (typeof b === "object") b = b.version;
|
|
2602
|
+
return a !== b;
|
|
2603
|
+
case "":
|
|
2604
|
+
case "=":
|
|
2605
|
+
case "==": return eq(a, b, loose);
|
|
2606
|
+
case "!=": return neq(a, b, loose);
|
|
2607
|
+
case ">": return gt(a, b, loose);
|
|
2608
|
+
case ">=": return gte(a, b, loose);
|
|
2609
|
+
case "<": return lt(a, b, loose);
|
|
2610
|
+
case "<=": return lte(a, b, loose);
|
|
2611
|
+
default: throw new TypeError(`Invalid operator: ${op}`);
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
module.exports = cmp;
|
|
2615
|
+
}));
|
|
2616
|
+
//#endregion
|
|
2617
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js
|
|
2618
|
+
var require_coerce = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2619
|
+
const SemVer = require_semver$1();
|
|
2620
|
+
const parse = require_parse();
|
|
2621
|
+
const { safeRe: re, t } = require_re();
|
|
2622
|
+
const coerce = (version, options) => {
|
|
2623
|
+
if (version instanceof SemVer) return version;
|
|
2624
|
+
if (typeof version === "number") version = String(version);
|
|
2625
|
+
if (typeof version !== "string") return null;
|
|
2626
|
+
options = options || {};
|
|
2627
|
+
let match = null;
|
|
2628
|
+
if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
2629
|
+
else {
|
|
2630
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
2631
|
+
let next;
|
|
2632
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
2633
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
|
|
2634
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
2635
|
+
}
|
|
2636
|
+
coerceRtlRegex.lastIndex = -1;
|
|
2637
|
+
}
|
|
2638
|
+
if (match === null) return null;
|
|
2639
|
+
const major = match[2];
|
|
2640
|
+
return parse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
|
|
2641
|
+
};
|
|
2642
|
+
module.exports = coerce;
|
|
2643
|
+
}));
|
|
2644
|
+
//#endregion
|
|
2645
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js
|
|
2646
|
+
var require_lrucache = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2647
|
+
var LRUCache = class {
|
|
2648
|
+
constructor() {
|
|
2649
|
+
this.max = 1e3;
|
|
2650
|
+
this.map = /* @__PURE__ */ new Map();
|
|
2651
|
+
}
|
|
2652
|
+
get(key) {
|
|
2653
|
+
const value = this.map.get(key);
|
|
2654
|
+
if (value === void 0) return;
|
|
2655
|
+
else {
|
|
2656
|
+
this.map.delete(key);
|
|
2657
|
+
this.map.set(key, value);
|
|
2658
|
+
return value;
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
delete(key) {
|
|
2662
|
+
return this.map.delete(key);
|
|
2663
|
+
}
|
|
2664
|
+
set(key, value) {
|
|
2665
|
+
if (!this.delete(key) && value !== void 0) {
|
|
2666
|
+
if (this.map.size >= this.max) {
|
|
2667
|
+
const firstKey = this.map.keys().next().value;
|
|
2668
|
+
this.delete(firstKey);
|
|
2669
|
+
}
|
|
2670
|
+
this.map.set(key, value);
|
|
2671
|
+
}
|
|
2672
|
+
return this;
|
|
2673
|
+
}
|
|
2674
|
+
};
|
|
2675
|
+
module.exports = LRUCache;
|
|
2676
|
+
}));
|
|
2677
|
+
//#endregion
|
|
2678
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js
|
|
2679
|
+
var require_range = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2680
|
+
const SPACE_CHARACTERS = /\s+/g;
|
|
2681
|
+
module.exports = class Range {
|
|
2682
|
+
constructor(range, options) {
|
|
2683
|
+
options = parseOptions(options);
|
|
2684
|
+
if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
|
|
2685
|
+
else return new Range(range.raw, options);
|
|
2686
|
+
if (range instanceof Comparator) {
|
|
2687
|
+
this.raw = range.value;
|
|
2688
|
+
this.set = [[range]];
|
|
2689
|
+
this.formatted = void 0;
|
|
2690
|
+
return this;
|
|
2691
|
+
}
|
|
2692
|
+
this.options = options;
|
|
2693
|
+
this.loose = !!options.loose;
|
|
2694
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
2695
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
2696
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
2697
|
+
if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
2698
|
+
if (this.set.length > 1) {
|
|
2699
|
+
const first = this.set[0];
|
|
2700
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
2701
|
+
if (this.set.length === 0) this.set = [first];
|
|
2702
|
+
else if (this.set.length > 1) {
|
|
2703
|
+
for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
|
|
2704
|
+
this.set = [c];
|
|
2705
|
+
break;
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
this.formatted = void 0;
|
|
2710
|
+
}
|
|
2711
|
+
get range() {
|
|
2712
|
+
if (this.formatted === void 0) {
|
|
2713
|
+
this.formatted = "";
|
|
2714
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
2715
|
+
if (i > 0) this.formatted += "||";
|
|
2716
|
+
const comps = this.set[i];
|
|
2717
|
+
for (let k = 0; k < comps.length; k++) {
|
|
2718
|
+
if (k > 0) this.formatted += " ";
|
|
2719
|
+
this.formatted += comps[k].toString().trim();
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
return this.formatted;
|
|
2724
|
+
}
|
|
2725
|
+
format() {
|
|
2726
|
+
return this.range;
|
|
2727
|
+
}
|
|
2728
|
+
toString() {
|
|
2729
|
+
return this.range;
|
|
2730
|
+
}
|
|
2731
|
+
parseRange(range) {
|
|
2732
|
+
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
2733
|
+
const cached = cache.get(memoKey);
|
|
2734
|
+
if (cached) return cached;
|
|
2735
|
+
const loose = this.options.loose;
|
|
2736
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
2737
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
2738
|
+
debug("hyphen replace", range);
|
|
2739
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
2740
|
+
debug("comparator trim", range);
|
|
2741
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
2742
|
+
debug("tilde trim", range);
|
|
2743
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
2744
|
+
debug("caret trim", range);
|
|
2745
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
2746
|
+
if (loose) rangeList = rangeList.filter((comp) => {
|
|
2747
|
+
debug("loose invalid filter", comp, this.options);
|
|
2748
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
2749
|
+
});
|
|
2750
|
+
debug("range list", rangeList);
|
|
2751
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
2752
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
2753
|
+
for (const comp of comparators) {
|
|
2754
|
+
if (isNullSet(comp)) return [comp];
|
|
2755
|
+
rangeMap.set(comp.value, comp);
|
|
2756
|
+
}
|
|
2757
|
+
if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
|
|
2758
|
+
const result = [...rangeMap.values()];
|
|
2759
|
+
cache.set(memoKey, result);
|
|
2760
|
+
return result;
|
|
2761
|
+
}
|
|
2762
|
+
intersects(range, options) {
|
|
2763
|
+
if (!(range instanceof Range)) throw new TypeError("a Range is required");
|
|
2764
|
+
return this.set.some((thisComparators) => {
|
|
2765
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
2766
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
2767
|
+
return rangeComparators.every((rangeComparator) => {
|
|
2768
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
2769
|
+
});
|
|
2770
|
+
});
|
|
2771
|
+
});
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
test(version) {
|
|
2775
|
+
if (!version) return false;
|
|
2776
|
+
if (typeof version === "string") try {
|
|
2777
|
+
version = new SemVer(version, this.options);
|
|
2778
|
+
} catch (er) {
|
|
2779
|
+
return false;
|
|
2780
|
+
}
|
|
2781
|
+
for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
|
|
2782
|
+
return false;
|
|
2783
|
+
}
|
|
2784
|
+
};
|
|
2785
|
+
const cache = new (require_lrucache())();
|
|
2786
|
+
const parseOptions = require_parse_options();
|
|
2787
|
+
const Comparator = require_comparator();
|
|
2788
|
+
const debug = require_debug();
|
|
2789
|
+
const SemVer = require_semver$1();
|
|
2790
|
+
const { safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
2791
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
2792
|
+
const isNullSet = (c) => c.value === "<0.0.0-0";
|
|
2793
|
+
const isAny = (c) => c.value === "";
|
|
2794
|
+
const isSatisfiable = (comparators, options) => {
|
|
2795
|
+
let result = true;
|
|
2796
|
+
const remainingComparators = comparators.slice();
|
|
2797
|
+
let testComparator = remainingComparators.pop();
|
|
2798
|
+
while (result && remainingComparators.length) {
|
|
2799
|
+
result = remainingComparators.every((otherComparator) => {
|
|
2800
|
+
return testComparator.intersects(otherComparator, options);
|
|
2801
|
+
});
|
|
2802
|
+
testComparator = remainingComparators.pop();
|
|
2803
|
+
}
|
|
2804
|
+
return result;
|
|
2805
|
+
};
|
|
2806
|
+
const parseComparator = (comp, options) => {
|
|
2807
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
2808
|
+
debug("comp", comp, options);
|
|
2809
|
+
comp = replaceCarets(comp, options);
|
|
2810
|
+
debug("caret", comp);
|
|
2811
|
+
comp = replaceTildes(comp, options);
|
|
2812
|
+
debug("tildes", comp);
|
|
2813
|
+
comp = replaceXRanges(comp, options);
|
|
2814
|
+
debug("xrange", comp);
|
|
2815
|
+
comp = replaceStars(comp, options);
|
|
2816
|
+
debug("stars", comp);
|
|
2817
|
+
return comp;
|
|
2818
|
+
};
|
|
2819
|
+
const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
2820
|
+
const replaceTildes = (comp, options) => {
|
|
2821
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
2822
|
+
};
|
|
2823
|
+
const replaceTilde = (comp, options) => {
|
|
2824
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
2825
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
2826
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
2827
|
+
let ret;
|
|
2828
|
+
if (isX(M)) ret = "";
|
|
2829
|
+
else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
2830
|
+
else if (isX(p)) ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
2831
|
+
else if (pr) {
|
|
2832
|
+
debug("replaceTilde pr", pr);
|
|
2833
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
2834
|
+
} else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
2835
|
+
debug("tilde return", ret);
|
|
2836
|
+
return ret;
|
|
2837
|
+
});
|
|
2838
|
+
};
|
|
2839
|
+
const replaceCarets = (comp, options) => {
|
|
2840
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
2841
|
+
};
|
|
2842
|
+
const replaceCaret = (comp, options) => {
|
|
2843
|
+
debug("caret", comp, options);
|
|
2844
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
2845
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
2846
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
2847
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
2848
|
+
let ret;
|
|
2849
|
+
if (isX(M)) ret = "";
|
|
2850
|
+
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
2851
|
+
else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
2852
|
+
else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
2853
|
+
else if (pr) {
|
|
2854
|
+
debug("replaceCaret pr", pr);
|
|
2855
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
2856
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
2857
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
2858
|
+
} else {
|
|
2859
|
+
debug("no pr");
|
|
2860
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
|
|
2861
|
+
else ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
|
|
2862
|
+
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
2863
|
+
}
|
|
2864
|
+
debug("caret return", ret);
|
|
2865
|
+
return ret;
|
|
2866
|
+
});
|
|
2867
|
+
};
|
|
2868
|
+
const replaceXRanges = (comp, options) => {
|
|
2869
|
+
debug("replaceXRanges", comp, options);
|
|
2870
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
2871
|
+
};
|
|
2872
|
+
const replaceXRange = (comp, options) => {
|
|
2873
|
+
comp = comp.trim();
|
|
2874
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
2875
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
2876
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
2877
|
+
const xM = isX(M);
|
|
2878
|
+
const xm = xM || isX(m);
|
|
2879
|
+
const xp = xm || isX(p);
|
|
2880
|
+
const anyX = xp;
|
|
2881
|
+
if (gtlt === "=" && anyX) gtlt = "";
|
|
2882
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
2883
|
+
if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
|
|
2884
|
+
else ret = "*";
|
|
2885
|
+
else if (gtlt && anyX) {
|
|
2886
|
+
if (xm) m = 0;
|
|
2887
|
+
p = 0;
|
|
2888
|
+
if (gtlt === ">") {
|
|
2889
|
+
gtlt = ">=";
|
|
2890
|
+
if (xm) {
|
|
2891
|
+
M = +M + 1;
|
|
2892
|
+
m = 0;
|
|
2893
|
+
p = 0;
|
|
2894
|
+
} else {
|
|
2895
|
+
m = +m + 1;
|
|
2896
|
+
p = 0;
|
|
2897
|
+
}
|
|
2898
|
+
} else if (gtlt === "<=") {
|
|
2899
|
+
gtlt = "<";
|
|
2900
|
+
if (xm) M = +M + 1;
|
|
2901
|
+
else m = +m + 1;
|
|
2902
|
+
}
|
|
2903
|
+
if (gtlt === "<") pr = "-0";
|
|
2904
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
2905
|
+
} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
2906
|
+
else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
2907
|
+
debug("xRange return", ret);
|
|
2908
|
+
return ret;
|
|
2909
|
+
});
|
|
2910
|
+
};
|
|
2911
|
+
const replaceStars = (comp, options) => {
|
|
2912
|
+
debug("replaceStars", comp, options);
|
|
2913
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
2914
|
+
};
|
|
2915
|
+
const replaceGTE0 = (comp, options) => {
|
|
2916
|
+
debug("replaceGTE0", comp, options);
|
|
2917
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
2918
|
+
};
|
|
2919
|
+
const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
2920
|
+
if (isX(fM)) from = "";
|
|
2921
|
+
else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
2922
|
+
else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
2923
|
+
else if (fpr) from = `>=${from}`;
|
|
2924
|
+
else from = `>=${from}${incPr ? "-0" : ""}`;
|
|
2925
|
+
if (isX(tM)) to = "";
|
|
2926
|
+
else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
|
|
2927
|
+
else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
|
|
2928
|
+
else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
2929
|
+
else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
2930
|
+
else to = `<=${to}`;
|
|
2931
|
+
return `${from} ${to}`.trim();
|
|
2932
|
+
};
|
|
2933
|
+
const testSet = (set, version, options) => {
|
|
2934
|
+
for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
|
|
2935
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
2936
|
+
for (let i = 0; i < set.length; i++) {
|
|
2937
|
+
debug(set[i].semver);
|
|
2938
|
+
if (set[i].semver === Comparator.ANY) continue;
|
|
2939
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
2940
|
+
const allowed = set[i].semver;
|
|
2941
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
return false;
|
|
2945
|
+
}
|
|
2946
|
+
return true;
|
|
2947
|
+
};
|
|
2948
|
+
}));
|
|
2949
|
+
//#endregion
|
|
2950
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js
|
|
2951
|
+
var require_comparator = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2952
|
+
const ANY = Symbol("SemVer ANY");
|
|
2953
|
+
module.exports = class Comparator {
|
|
2954
|
+
static get ANY() {
|
|
2955
|
+
return ANY;
|
|
2956
|
+
}
|
|
2957
|
+
constructor(comp, options) {
|
|
2958
|
+
options = parseOptions(options);
|
|
2959
|
+
if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
|
|
2960
|
+
else comp = comp.value;
|
|
2961
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
2962
|
+
debug("comparator", comp, options);
|
|
2963
|
+
this.options = options;
|
|
2964
|
+
this.loose = !!options.loose;
|
|
2965
|
+
this.parse(comp);
|
|
2966
|
+
if (this.semver === ANY) this.value = "";
|
|
2967
|
+
else this.value = this.operator + this.semver.version;
|
|
2968
|
+
debug("comp", this);
|
|
2969
|
+
}
|
|
2970
|
+
parse(comp) {
|
|
2971
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
2972
|
+
const m = comp.match(r);
|
|
2973
|
+
if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
|
|
2974
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
2975
|
+
if (this.operator === "=") this.operator = "";
|
|
2976
|
+
if (!m[2]) this.semver = ANY;
|
|
2977
|
+
else this.semver = new SemVer(m[2], this.options.loose);
|
|
2978
|
+
}
|
|
2979
|
+
toString() {
|
|
2980
|
+
return this.value;
|
|
2981
|
+
}
|
|
2982
|
+
test(version) {
|
|
2983
|
+
debug("Comparator.test", version, this.options.loose);
|
|
2984
|
+
if (this.semver === ANY || version === ANY) return true;
|
|
2985
|
+
if (typeof version === "string") try {
|
|
2986
|
+
version = new SemVer(version, this.options);
|
|
2987
|
+
} catch (er) {
|
|
2988
|
+
return false;
|
|
2989
|
+
}
|
|
2990
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
2991
|
+
}
|
|
2992
|
+
intersects(comp, options) {
|
|
2993
|
+
if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
|
|
2994
|
+
if (this.operator === "") {
|
|
2995
|
+
if (this.value === "") return true;
|
|
2996
|
+
return new Range(comp.value, options).test(this.value);
|
|
2997
|
+
} else if (comp.operator === "") {
|
|
2998
|
+
if (comp.value === "") return true;
|
|
2999
|
+
return new Range(this.value, options).test(comp.semver);
|
|
3000
|
+
}
|
|
3001
|
+
options = parseOptions(options);
|
|
3002
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
|
|
3003
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
|
|
3004
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
|
|
3005
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
|
|
3006
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
|
|
3007
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
|
|
3008
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
|
|
3009
|
+
return false;
|
|
3010
|
+
}
|
|
3011
|
+
};
|
|
3012
|
+
const parseOptions = require_parse_options();
|
|
3013
|
+
const { safeRe: re, t } = require_re();
|
|
3014
|
+
const cmp = require_cmp();
|
|
3015
|
+
const debug = require_debug();
|
|
3016
|
+
const SemVer = require_semver$1();
|
|
3017
|
+
const Range = require_range();
|
|
3018
|
+
}));
|
|
3019
|
+
//#endregion
|
|
3020
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js
|
|
3021
|
+
var require_satisfies = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3022
|
+
const Range = require_range();
|
|
3023
|
+
const satisfies = (version, range, options) => {
|
|
3024
|
+
try {
|
|
3025
|
+
range = new Range(range, options);
|
|
3026
|
+
} catch (er) {
|
|
3027
|
+
return false;
|
|
3028
|
+
}
|
|
3029
|
+
return range.test(version);
|
|
3030
|
+
};
|
|
3031
|
+
module.exports = satisfies;
|
|
3032
|
+
}));
|
|
3033
|
+
//#endregion
|
|
3034
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js
|
|
3035
|
+
var require_to_comparators = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3036
|
+
const Range = require_range();
|
|
3037
|
+
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
3038
|
+
module.exports = toComparators;
|
|
3039
|
+
}));
|
|
3040
|
+
//#endregion
|
|
3041
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js
|
|
3042
|
+
var require_max_satisfying = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3043
|
+
const SemVer = require_semver$1();
|
|
3044
|
+
const Range = require_range();
|
|
3045
|
+
const maxSatisfying = (versions, range, options) => {
|
|
3046
|
+
let max = null;
|
|
3047
|
+
let maxSV = null;
|
|
3048
|
+
let rangeObj = null;
|
|
3049
|
+
try {
|
|
3050
|
+
rangeObj = new Range(range, options);
|
|
3051
|
+
} catch (er) {
|
|
3052
|
+
return null;
|
|
3053
|
+
}
|
|
3054
|
+
versions.forEach((v) => {
|
|
3055
|
+
if (rangeObj.test(v)) {
|
|
3056
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
3057
|
+
max = v;
|
|
3058
|
+
maxSV = new SemVer(max, options);
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
});
|
|
3062
|
+
return max;
|
|
3063
|
+
};
|
|
3064
|
+
module.exports = maxSatisfying;
|
|
3065
|
+
}));
|
|
3066
|
+
//#endregion
|
|
3067
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js
|
|
3068
|
+
var require_min_satisfying = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3069
|
+
const SemVer = require_semver$1();
|
|
3070
|
+
const Range = require_range();
|
|
3071
|
+
const minSatisfying = (versions, range, options) => {
|
|
3072
|
+
let min = null;
|
|
3073
|
+
let minSV = null;
|
|
3074
|
+
let rangeObj = null;
|
|
3075
|
+
try {
|
|
3076
|
+
rangeObj = new Range(range, options);
|
|
3077
|
+
} catch (er) {
|
|
3078
|
+
return null;
|
|
3079
|
+
}
|
|
3080
|
+
versions.forEach((v) => {
|
|
3081
|
+
if (rangeObj.test(v)) {
|
|
3082
|
+
if (!min || minSV.compare(v) === 1) {
|
|
3083
|
+
min = v;
|
|
3084
|
+
minSV = new SemVer(min, options);
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
});
|
|
3088
|
+
return min;
|
|
3089
|
+
};
|
|
3090
|
+
module.exports = minSatisfying;
|
|
3091
|
+
}));
|
|
3092
|
+
//#endregion
|
|
3093
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js
|
|
3094
|
+
var require_min_version = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3095
|
+
const SemVer = require_semver$1();
|
|
3096
|
+
const Range = require_range();
|
|
3097
|
+
const gt = require_gt();
|
|
3098
|
+
const minVersion = (range, loose) => {
|
|
3099
|
+
range = new Range(range, loose);
|
|
3100
|
+
let minver = new SemVer("0.0.0");
|
|
3101
|
+
if (range.test(minver)) return minver;
|
|
3102
|
+
minver = new SemVer("0.0.0-0");
|
|
3103
|
+
if (range.test(minver)) return minver;
|
|
3104
|
+
minver = null;
|
|
3105
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
3106
|
+
const comparators = range.set[i];
|
|
3107
|
+
let setMin = null;
|
|
3108
|
+
comparators.forEach((comparator) => {
|
|
3109
|
+
const compver = new SemVer(comparator.semver.version);
|
|
3110
|
+
switch (comparator.operator) {
|
|
3111
|
+
case ">":
|
|
3112
|
+
if (compver.prerelease.length === 0) compver.patch++;
|
|
3113
|
+
else compver.prerelease.push(0);
|
|
3114
|
+
compver.raw = compver.format();
|
|
3115
|
+
case "":
|
|
3116
|
+
case ">=":
|
|
3117
|
+
if (!setMin || gt(compver, setMin)) setMin = compver;
|
|
3118
|
+
break;
|
|
3119
|
+
case "<":
|
|
3120
|
+
case "<=": break;
|
|
3121
|
+
/* istanbul ignore next */
|
|
3122
|
+
default: throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
3123
|
+
}
|
|
3124
|
+
});
|
|
3125
|
+
if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
|
|
3126
|
+
}
|
|
3127
|
+
if (minver && range.test(minver)) return minver;
|
|
3128
|
+
return null;
|
|
3129
|
+
};
|
|
3130
|
+
module.exports = minVersion;
|
|
3131
|
+
}));
|
|
3132
|
+
//#endregion
|
|
3133
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js
|
|
3134
|
+
var require_valid = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3135
|
+
const Range = require_range();
|
|
3136
|
+
const validRange = (range, options) => {
|
|
3137
|
+
try {
|
|
3138
|
+
return new Range(range, options).range || "*";
|
|
3139
|
+
} catch (er) {
|
|
3140
|
+
return null;
|
|
3141
|
+
}
|
|
3142
|
+
};
|
|
3143
|
+
module.exports = validRange;
|
|
3144
|
+
}));
|
|
3145
|
+
//#endregion
|
|
3146
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js
|
|
3147
|
+
var require_outside = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3148
|
+
const SemVer = require_semver$1();
|
|
3149
|
+
const Comparator = require_comparator();
|
|
3150
|
+
const { ANY } = Comparator;
|
|
3151
|
+
const Range = require_range();
|
|
3152
|
+
const satisfies = require_satisfies();
|
|
3153
|
+
const gt = require_gt();
|
|
3154
|
+
const lt = require_lt();
|
|
3155
|
+
const lte = require_lte();
|
|
3156
|
+
const gte = require_gte();
|
|
3157
|
+
const outside = (version, range, hilo, options) => {
|
|
3158
|
+
version = new SemVer(version, options);
|
|
3159
|
+
range = new Range(range, options);
|
|
3160
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
3161
|
+
switch (hilo) {
|
|
3162
|
+
case ">":
|
|
3163
|
+
gtfn = gt;
|
|
3164
|
+
ltefn = lte;
|
|
3165
|
+
ltfn = lt;
|
|
3166
|
+
comp = ">";
|
|
3167
|
+
ecomp = ">=";
|
|
3168
|
+
break;
|
|
3169
|
+
case "<":
|
|
3170
|
+
gtfn = lt;
|
|
3171
|
+
ltefn = gte;
|
|
3172
|
+
ltfn = gt;
|
|
3173
|
+
comp = "<";
|
|
3174
|
+
ecomp = "<=";
|
|
3175
|
+
break;
|
|
3176
|
+
default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
|
|
3177
|
+
}
|
|
3178
|
+
if (satisfies(version, range, options)) return false;
|
|
3179
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
3180
|
+
const comparators = range.set[i];
|
|
3181
|
+
let high = null;
|
|
3182
|
+
let low = null;
|
|
3183
|
+
comparators.forEach((comparator) => {
|
|
3184
|
+
if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
|
|
3185
|
+
high = high || comparator;
|
|
3186
|
+
low = low || comparator;
|
|
3187
|
+
if (gtfn(comparator.semver, high.semver, options)) high = comparator;
|
|
3188
|
+
else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
|
|
3189
|
+
});
|
|
3190
|
+
if (high.operator === comp || high.operator === ecomp) return false;
|
|
3191
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
|
|
3192
|
+
else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
|
|
3193
|
+
}
|
|
3194
|
+
return true;
|
|
3195
|
+
};
|
|
3196
|
+
module.exports = outside;
|
|
3197
|
+
}));
|
|
3198
|
+
//#endregion
|
|
3199
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js
|
|
3200
|
+
var require_gtr = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3201
|
+
const outside = require_outside();
|
|
3202
|
+
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
3203
|
+
module.exports = gtr;
|
|
3204
|
+
}));
|
|
3205
|
+
//#endregion
|
|
3206
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js
|
|
3207
|
+
var require_ltr = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3208
|
+
const outside = require_outside();
|
|
3209
|
+
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
3210
|
+
module.exports = ltr;
|
|
3211
|
+
}));
|
|
3212
|
+
//#endregion
|
|
3213
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js
|
|
3214
|
+
var require_intersects = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3215
|
+
const Range = require_range();
|
|
3216
|
+
const intersects = (r1, r2, options) => {
|
|
3217
|
+
r1 = new Range(r1, options);
|
|
3218
|
+
r2 = new Range(r2, options);
|
|
3219
|
+
return r1.intersects(r2, options);
|
|
3220
|
+
};
|
|
3221
|
+
module.exports = intersects;
|
|
3222
|
+
}));
|
|
3223
|
+
//#endregion
|
|
3224
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js
|
|
3225
|
+
var require_simplify = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3226
|
+
const satisfies = require_satisfies();
|
|
3227
|
+
const compare = require_compare();
|
|
3228
|
+
module.exports = (versions, range, options) => {
|
|
3229
|
+
const set = [];
|
|
3230
|
+
let first = null;
|
|
3231
|
+
let prev = null;
|
|
3232
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
3233
|
+
for (const version of v) if (satisfies(version, range, options)) {
|
|
3234
|
+
prev = version;
|
|
3235
|
+
if (!first) first = version;
|
|
3236
|
+
} else {
|
|
3237
|
+
if (prev) set.push([first, prev]);
|
|
3238
|
+
prev = null;
|
|
3239
|
+
first = null;
|
|
3240
|
+
}
|
|
3241
|
+
if (first) set.push([first, null]);
|
|
3242
|
+
const ranges = [];
|
|
3243
|
+
for (const [min, max] of set) if (min === max) ranges.push(min);
|
|
3244
|
+
else if (!max && min === v[0]) ranges.push("*");
|
|
3245
|
+
else if (!max) ranges.push(`>=${min}`);
|
|
3246
|
+
else if (min === v[0]) ranges.push(`<=${max}`);
|
|
3247
|
+
else ranges.push(`${min} - ${max}`);
|
|
3248
|
+
const simplified = ranges.join(" || ");
|
|
3249
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
3250
|
+
return simplified.length < original.length ? simplified : range;
|
|
3251
|
+
};
|
|
3252
|
+
}));
|
|
3253
|
+
//#endregion
|
|
3254
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js
|
|
3255
|
+
var require_subset = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3256
|
+
const Range = require_range();
|
|
3257
|
+
const Comparator = require_comparator();
|
|
3258
|
+
const { ANY } = Comparator;
|
|
3259
|
+
const satisfies = require_satisfies();
|
|
3260
|
+
const compare = require_compare();
|
|
3261
|
+
const subset = (sub, dom, options = {}) => {
|
|
3262
|
+
if (sub === dom) return true;
|
|
3263
|
+
sub = new Range(sub, options);
|
|
3264
|
+
dom = new Range(dom, options);
|
|
3265
|
+
let sawNonNull = false;
|
|
3266
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
3267
|
+
for (const simpleDom of dom.set) {
|
|
3268
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
3269
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
3270
|
+
if (isSub) continue OUTER;
|
|
3271
|
+
}
|
|
3272
|
+
if (sawNonNull) return false;
|
|
3273
|
+
}
|
|
3274
|
+
return true;
|
|
3275
|
+
};
|
|
3276
|
+
const minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
3277
|
+
const minimumVersion = [new Comparator(">=0.0.0")];
|
|
3278
|
+
const simpleSubset = (sub, dom, options) => {
|
|
3279
|
+
if (sub === dom) return true;
|
|
3280
|
+
if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
|
|
3281
|
+
else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
|
|
3282
|
+
else sub = minimumVersion;
|
|
3283
|
+
if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
|
|
3284
|
+
else dom = minimumVersion;
|
|
3285
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
3286
|
+
let gt, lt;
|
|
3287
|
+
for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
|
|
3288
|
+
else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
|
|
3289
|
+
else eqSet.add(c.semver);
|
|
3290
|
+
if (eqSet.size > 1) return null;
|
|
3291
|
+
let gtltComp;
|
|
3292
|
+
if (gt && lt) {
|
|
3293
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
3294
|
+
if (gtltComp > 0) return null;
|
|
3295
|
+
else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
|
|
3296
|
+
}
|
|
3297
|
+
for (const eq of eqSet) {
|
|
3298
|
+
if (gt && !satisfies(eq, String(gt), options)) return null;
|
|
3299
|
+
if (lt && !satisfies(eq, String(lt), options)) return null;
|
|
3300
|
+
for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
|
|
3301
|
+
return true;
|
|
3302
|
+
}
|
|
3303
|
+
let higher, lower;
|
|
3304
|
+
let hasDomLT, hasDomGT;
|
|
3305
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
3306
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
3307
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
|
|
3308
|
+
for (const c of dom) {
|
|
3309
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
3310
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
3311
|
+
if (gt) {
|
|
3312
|
+
if (needDomGTPre) {
|
|
3313
|
+
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;
|
|
3314
|
+
}
|
|
3315
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
3316
|
+
higher = higherGT(gt, c, options);
|
|
3317
|
+
if (higher === c && higher !== gt) return false;
|
|
3318
|
+
} else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) return false;
|
|
3319
|
+
}
|
|
3320
|
+
if (lt) {
|
|
3321
|
+
if (needDomLTPre) {
|
|
3322
|
+
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;
|
|
3323
|
+
}
|
|
3324
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
3325
|
+
lower = lowerLT(lt, c, options);
|
|
3326
|
+
if (lower === c && lower !== lt) return false;
|
|
3327
|
+
} else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) return false;
|
|
3328
|
+
}
|
|
3329
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
|
|
3330
|
+
}
|
|
3331
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
|
|
3332
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
|
|
3333
|
+
if (needDomGTPre || needDomLTPre) return false;
|
|
3334
|
+
return true;
|
|
3335
|
+
};
|
|
3336
|
+
const higherGT = (a, b, options) => {
|
|
3337
|
+
if (!a) return b;
|
|
3338
|
+
const comp = compare(a.semver, b.semver, options);
|
|
3339
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
3340
|
+
};
|
|
3341
|
+
const lowerLT = (a, b, options) => {
|
|
3342
|
+
if (!a) return b;
|
|
3343
|
+
const comp = compare(a.semver, b.semver, options);
|
|
3344
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
3345
|
+
};
|
|
3346
|
+
module.exports = subset;
|
|
3347
|
+
}));
|
|
3348
|
+
//#endregion
|
|
3349
|
+
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js
|
|
3350
|
+
var require_semver = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
3351
|
+
const internalRe = require_re();
|
|
3352
|
+
const constants = require_constants();
|
|
3353
|
+
const SemVer = require_semver$1();
|
|
3354
|
+
const identifiers = require_identifiers();
|
|
3355
|
+
module.exports = {
|
|
3356
|
+
parse: require_parse(),
|
|
3357
|
+
valid: require_valid$1(),
|
|
3358
|
+
clean: require_clean(),
|
|
3359
|
+
inc: require_inc(),
|
|
3360
|
+
diff: require_diff(),
|
|
3361
|
+
major: require_major(),
|
|
3362
|
+
minor: require_minor(),
|
|
3363
|
+
patch: require_patch(),
|
|
3364
|
+
prerelease: require_prerelease(),
|
|
3365
|
+
compare: require_compare(),
|
|
3366
|
+
rcompare: require_rcompare(),
|
|
3367
|
+
compareLoose: require_compare_loose(),
|
|
3368
|
+
compareBuild: require_compare_build(),
|
|
3369
|
+
sort: require_sort(),
|
|
3370
|
+
rsort: require_rsort(),
|
|
3371
|
+
gt: require_gt(),
|
|
3372
|
+
lt: require_lt(),
|
|
3373
|
+
eq: require_eq(),
|
|
3374
|
+
neq: require_neq(),
|
|
3375
|
+
gte: require_gte(),
|
|
3376
|
+
lte: require_lte(),
|
|
3377
|
+
cmp: require_cmp(),
|
|
3378
|
+
coerce: require_coerce(),
|
|
3379
|
+
Comparator: require_comparator(),
|
|
3380
|
+
Range: require_range(),
|
|
3381
|
+
satisfies: require_satisfies(),
|
|
3382
|
+
toComparators: require_to_comparators(),
|
|
3383
|
+
maxSatisfying: require_max_satisfying(),
|
|
3384
|
+
minSatisfying: require_min_satisfying(),
|
|
3385
|
+
minVersion: require_min_version(),
|
|
3386
|
+
validRange: require_valid(),
|
|
3387
|
+
outside: require_outside(),
|
|
3388
|
+
gtr: require_gtr(),
|
|
3389
|
+
ltr: require_ltr(),
|
|
3390
|
+
intersects: require_intersects(),
|
|
3391
|
+
simplifyRange: require_simplify(),
|
|
3392
|
+
subset: require_subset(),
|
|
3393
|
+
SemVer,
|
|
3394
|
+
re: internalRe.re,
|
|
3395
|
+
src: internalRe.src,
|
|
3396
|
+
tokens: internalRe.t,
|
|
3397
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
3398
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
3399
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
3400
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
3401
|
+
};
|
|
3402
|
+
}));
|
|
3403
|
+
//#endregion
|
|
3404
|
+
//#region ../core/dist/index.js
|
|
3405
|
+
var import_picomatch = /* @__PURE__ */ __toESM$1(require_picomatch(), 1);
|
|
3406
|
+
var import_semver = /* @__PURE__ */ __toESM$1(require_semver(), 1);
|
|
2065
3407
|
var __create = Object.create;
|
|
2066
3408
|
var __defProp = Object.defineProperty;
|
|
2067
3409
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -2136,8 +3478,8 @@ const isFile = (filePath) => {
|
|
|
2136
3478
|
return false;
|
|
2137
3479
|
}
|
|
2138
3480
|
};
|
|
2139
|
-
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx
|
|
2140
|
-
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.js$/i;
|
|
3481
|
+
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
3482
|
+
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
2141
3483
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
2142
3484
|
const GIT_LS_FILES_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
2143
3485
|
const IGNORED_DIRECTORIES = new Set([
|
|
@@ -3025,32 +4367,234 @@ const isPackageJsonReanimatedAware = (packageJson) => {
|
|
|
3025
4367
|
...packageJson.devDependencies,
|
|
3026
4368
|
...packageJson.optionalDependencies
|
|
3027
4369
|
};
|
|
3028
|
-
return Object.hasOwn(allDependencies, REANIMATED_DEPENDENCY_NAME);
|
|
4370
|
+
return Object.hasOwn(allDependencies, REANIMATED_DEPENDENCY_NAME);
|
|
4371
|
+
};
|
|
4372
|
+
const parseZodMajor = (zodVersion) => {
|
|
4373
|
+
if (typeof zodVersion !== "string") return null;
|
|
4374
|
+
return getLowestDependencyMajor(zodVersion);
|
|
4375
|
+
};
|
|
4376
|
+
const hasUpperBoundOnlyPeerRange = (range) => {
|
|
4377
|
+
if (typeof range !== "string") return false;
|
|
4378
|
+
const normalizedRange = normalizeDependencyVersion(range);
|
|
4379
|
+
if (normalizedRange === null) return false;
|
|
4380
|
+
return splitDependencyVersionBranches(normalizedRange).some((branch) => {
|
|
4381
|
+
const normalizedBranch = normalizeDependencyVersion(branch);
|
|
4382
|
+
return normalizedBranch !== null && getBranchLowestMajor(normalizedBranch) === null && hasUpperBoundComparator(normalizedBranch);
|
|
4383
|
+
});
|
|
4384
|
+
};
|
|
4385
|
+
const peerRangeMinMajor = (range) => {
|
|
4386
|
+
if (typeof range !== "string") return null;
|
|
4387
|
+
return getLowestDependencyMajor(range);
|
|
4388
|
+
};
|
|
4389
|
+
const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
|
|
4390
|
+
const installedReactMajor = parseReactMajor(reactVersion);
|
|
4391
|
+
const peerReactRange = packageJson.peerDependencies?.react;
|
|
4392
|
+
if (typeof peerReactRange !== "string") return installedReactMajor;
|
|
4393
|
+
const peerFloor = peerRangeMinMajor(peerReactRange);
|
|
4394
|
+
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
4395
|
+
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
4396
|
+
};
|
|
4397
|
+
const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
|
|
4398
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
4399
|
+
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
4400
|
+
const FETCH_TIMEOUT_MS = 1e4;
|
|
4401
|
+
const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
|
|
4402
|
+
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
4403
|
+
const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
|
|
4404
|
+
const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
4405
|
+
const ES_TARGET_YEAR_BY_NAME = {
|
|
4406
|
+
es3: 1999,
|
|
4407
|
+
es5: 2009,
|
|
4408
|
+
es6: 2015,
|
|
4409
|
+
es2015: 2015,
|
|
4410
|
+
es2016: 2016,
|
|
4411
|
+
es2017: 2017,
|
|
4412
|
+
es2018: 2018,
|
|
4413
|
+
es2019: 2019,
|
|
4414
|
+
es2020: 2020,
|
|
4415
|
+
es2021: 2021,
|
|
4416
|
+
es2022: 2022,
|
|
4417
|
+
es2023: 2023,
|
|
4418
|
+
es2024: 2024,
|
|
4419
|
+
es2025: 2025,
|
|
4420
|
+
esnext: 9999
|
|
4421
|
+
};
|
|
4422
|
+
/**
|
|
4423
|
+
* Project-config files that `StagedFiles.materialize` copies into
|
|
4424
|
+
* the temp directory alongside staged sources so oxlint resolves
|
|
4425
|
+
* `tsconfig` / `package.json` / lint configs the same way it would
|
|
4426
|
+
* in the working tree. Hoisted out of the staged-files helper so
|
|
4427
|
+
* the constant lives next to the rest of the IO budget knobs.
|
|
4428
|
+
*/
|
|
4429
|
+
const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
4430
|
+
"tsconfig.json",
|
|
4431
|
+
"tsconfig.base.json",
|
|
4432
|
+
"package.json",
|
|
4433
|
+
"doctor.config.ts",
|
|
4434
|
+
"doctor.config.mts",
|
|
4435
|
+
"doctor.config.cts",
|
|
4436
|
+
"doctor.config.js",
|
|
4437
|
+
"doctor.config.mjs",
|
|
4438
|
+
"doctor.config.cjs",
|
|
4439
|
+
"doctor.config.json",
|
|
4440
|
+
"doctor.config.jsonc",
|
|
4441
|
+
"oxlint.json",
|
|
4442
|
+
".oxlintrc.json"
|
|
4443
|
+
];
|
|
4444
|
+
const CONFIG_FINGERPRINT_FILENAMES = [
|
|
4445
|
+
"doctor.config.ts",
|
|
4446
|
+
"doctor.config.mts",
|
|
4447
|
+
"doctor.config.cts",
|
|
4448
|
+
"doctor.config.js",
|
|
4449
|
+
"doctor.config.mjs",
|
|
4450
|
+
"doctor.config.cjs",
|
|
4451
|
+
"doctor.config.json",
|
|
4452
|
+
"doctor.config.jsonc",
|
|
4453
|
+
"react-doctor.config.json",
|
|
4454
|
+
"package.json",
|
|
4455
|
+
"pnpm-workspace.yaml",
|
|
4456
|
+
"tsconfig.json",
|
|
4457
|
+
"tsconfig.base.json",
|
|
4458
|
+
".oxlintrc.json",
|
|
4459
|
+
".eslintrc.json",
|
|
4460
|
+
"pnpm-lock.yaml",
|
|
4461
|
+
"package-lock.json",
|
|
4462
|
+
"yarn.lock",
|
|
4463
|
+
"bun.lock",
|
|
4464
|
+
"bun.lockb",
|
|
4465
|
+
".gitignore"
|
|
4466
|
+
];
|
|
4467
|
+
const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
|
|
4468
|
+
const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
|
|
4469
|
+
const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
|
|
4470
|
+
const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
|
|
4471
|
+
const REACT_SERVER_DOM_PACKAGES = [
|
|
4472
|
+
"react-server-dom-webpack",
|
|
4473
|
+
"react-server-dom-parcel",
|
|
4474
|
+
"react-server-dom-turbopack"
|
|
4475
|
+
];
|
|
4476
|
+
const REACT_BLOG_RSC_ADVISORY_URL = "https://react.dev/blog/2025/12/03/critical-security-vulnerability-in-react-server-components";
|
|
4477
|
+
const VERCEL_NEXTJS_SECURITY_RELEASE_URL = "https://vercel.com/changelog/next-js-may-2026-security-release";
|
|
4478
|
+
const DIAGNOSTIC_CATEGORY_BUCKETS = [
|
|
4479
|
+
"Security",
|
|
4480
|
+
"Bugs",
|
|
4481
|
+
"Performance",
|
|
4482
|
+
"Accessibility",
|
|
4483
|
+
"Maintainability"
|
|
4484
|
+
];
|
|
4485
|
+
const APP_ONLY_RULE_KEYS = new Set([
|
|
4486
|
+
"react-hooks-js/static-components",
|
|
4487
|
+
"react-doctor/no-render-prop-children",
|
|
4488
|
+
"react-doctor/prefer-explicit-variants"
|
|
4489
|
+
]);
|
|
4490
|
+
const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
|
|
4491
|
+
const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
|
|
4492
|
+
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
4493
|
+
const CONFIG_CACHE_TTL_MS = 300 * 1e3;
|
|
4494
|
+
const SOCKET_FREE_PURL_API_BASE = "https://firewall-api.socket.dev/purl";
|
|
4495
|
+
const SOCKET_PACKAGE_PAGE_BASE = "https://socket.dev/npm/package";
|
|
4496
|
+
const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
4497
|
+
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
4498
|
+
const SUPPLY_CHAIN_RULE = "low-supply-chain-score";
|
|
4499
|
+
const SUPPLY_CHAIN_CATEGORY = "Security";
|
|
4500
|
+
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
4501
|
+
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
4502
|
+
const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || path$1.isAbsolute(extendsValue);
|
|
4503
|
+
const ensureJsonExtension = (filePath) => path$1.extname(filePath) === "" ? `${filePath}.json` : filePath;
|
|
4504
|
+
const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
4505
|
+
const requireFromConfig = createRequire(path$1.join(fromConfigDirectory, "tsconfig.json"));
|
|
4506
|
+
const candidates = [
|
|
4507
|
+
extendsValue,
|
|
4508
|
+
ensureJsonExtension(extendsValue),
|
|
4509
|
+
`${extendsValue.replace(/\/$/, "")}/tsconfig.json`
|
|
4510
|
+
];
|
|
4511
|
+
for (const candidate of candidates) try {
|
|
4512
|
+
return requireFromConfig.resolve(candidate);
|
|
4513
|
+
} catch {
|
|
4514
|
+
continue;
|
|
4515
|
+
}
|
|
4516
|
+
return null;
|
|
4517
|
+
};
|
|
4518
|
+
const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
4519
|
+
if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(path$1.resolve(fromConfigDirectory, extendsValue));
|
|
4520
|
+
return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
|
|
4521
|
+
};
|
|
4522
|
+
const normalizeCompilerOptions = (compilerOptions) => {
|
|
4523
|
+
if (!isPlainObject(compilerOptions)) return { hasExplicitLib: false };
|
|
4524
|
+
const target = typeof compilerOptions.target === "string" ? compilerOptions.target : void 0;
|
|
4525
|
+
const hasExplicitLib = Object.hasOwn(compilerOptions, "lib");
|
|
4526
|
+
return {
|
|
4527
|
+
target,
|
|
4528
|
+
lib: Array.isArray(compilerOptions.lib) ? compilerOptions.lib.filter((entry) => typeof entry === "string") : void 0,
|
|
4529
|
+
hasExplicitLib
|
|
4530
|
+
};
|
|
3029
4531
|
};
|
|
3030
|
-
const
|
|
3031
|
-
|
|
3032
|
-
|
|
4532
|
+
const readTsConfig = (filePath) => {
|
|
4533
|
+
let content;
|
|
4534
|
+
try {
|
|
4535
|
+
content = fs$1.readFileSync(filePath, "utf-8");
|
|
4536
|
+
} catch {
|
|
4537
|
+
return null;
|
|
4538
|
+
}
|
|
4539
|
+
const parsed = ts.parseConfigFileTextToJson(filePath, content);
|
|
4540
|
+
if (!isPlainObject(parsed.config)) return null;
|
|
4541
|
+
return {
|
|
4542
|
+
extends: typeof parsed.config.extends === "string" ? parsed.config.extends : void 0,
|
|
4543
|
+
compilerOptions: normalizeCompilerOptions(parsed.config.compilerOptions)
|
|
4544
|
+
};
|
|
3033
4545
|
};
|
|
3034
|
-
const
|
|
3035
|
-
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
}
|
|
4546
|
+
const mergeCompilerOptions = (inherited, current) => {
|
|
4547
|
+
const target = current.target ?? inherited?.target;
|
|
4548
|
+
const hasExplicitLib = current.hasExplicitLib || Boolean(inherited?.hasExplicitLib);
|
|
4549
|
+
return {
|
|
4550
|
+
target,
|
|
4551
|
+
lib: current.hasExplicitLib ? current.lib : inherited?.lib,
|
|
4552
|
+
hasExplicitLib
|
|
4553
|
+
};
|
|
4554
|
+
};
|
|
4555
|
+
const readResolvedCompilerOptions = (tsConfigPath, extendsDepth, visitedPaths) => {
|
|
4556
|
+
const realPath = fs$1.realpathSync.native(tsConfigPath);
|
|
4557
|
+
if (visitedPaths.has(realPath)) return null;
|
|
4558
|
+
const tsConfig = readTsConfig(realPath);
|
|
4559
|
+
if (!tsConfig) return null;
|
|
4560
|
+
const nextVisitedPaths = new Set(visitedPaths);
|
|
4561
|
+
nextVisitedPaths.add(realPath);
|
|
4562
|
+
if (tsConfig.extends && extendsDepth < 8) {
|
|
4563
|
+
const parentPath = resolveExtendsPath(tsConfig.extends, path$1.dirname(realPath));
|
|
4564
|
+
if (parentPath && isFile(parentPath)) return mergeCompilerOptions(readResolvedCompilerOptions(parentPath, extendsDepth + 1, nextVisitedPaths), tsConfig.compilerOptions);
|
|
4565
|
+
}
|
|
4566
|
+
return tsConfig.compilerOptions;
|
|
4567
|
+
};
|
|
4568
|
+
const targetYearIsPreES2023 = (target) => {
|
|
4569
|
+
const year = ES_TARGET_YEAR_BY_NAME[target.toLowerCase()];
|
|
4570
|
+
return year !== void 0 && year < 2023;
|
|
4571
|
+
};
|
|
4572
|
+
const libEntryIncludesES2023Array = (entry) => {
|
|
4573
|
+
const normalizedEntry = entry.toLowerCase();
|
|
4574
|
+
if (normalizedEntry === "esnext" || normalizedEntry === "esnext.array") return true;
|
|
4575
|
+
const esYearMatch = /^es(\d{4})(?:\.(.+))?$/.exec(normalizedEntry);
|
|
4576
|
+
if (!esYearMatch) return false;
|
|
4577
|
+
if (Number(esYearMatch[1]) < 2023) return false;
|
|
4578
|
+
const component = esYearMatch[2];
|
|
4579
|
+
return component === void 0 || component === "array";
|
|
4580
|
+
};
|
|
4581
|
+
const libIncludesES2023 = (lib) => lib.some(libEntryIncludesES2023Array);
|
|
4582
|
+
const compilerOptionsArePreES2023 = (compilerOptions) => {
|
|
4583
|
+
if (compilerOptions.hasExplicitLib) return !libIncludesES2023(compilerOptions.lib ?? []);
|
|
4584
|
+
if (compilerOptions.target) return targetYearIsPreES2023(compilerOptions.target);
|
|
4585
|
+
return false;
|
|
3042
4586
|
};
|
|
3043
|
-
const
|
|
3044
|
-
|
|
3045
|
-
|
|
4587
|
+
const compilerOptionsDeclareTargetOrLib = (compilerOptions) => compilerOptions.hasExplicitLib || compilerOptions.target !== void 0;
|
|
4588
|
+
const detectPreES2023FromConfig = (tsConfigPath) => {
|
|
4589
|
+
const compilerOptions = readResolvedCompilerOptions(tsConfigPath, 0, /* @__PURE__ */ new Set());
|
|
4590
|
+
if (!compilerOptions) return false;
|
|
4591
|
+
if (!compilerOptionsDeclareTargetOrLib(compilerOptions)) return false;
|
|
4592
|
+
return compilerOptionsArePreES2023(compilerOptions);
|
|
3046
4593
|
};
|
|
3047
|
-
const
|
|
3048
|
-
const
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
const peerFloor = peerRangeMinMajor(peerReactRange);
|
|
3052
|
-
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
3053
|
-
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
4594
|
+
const detectPreES2023Target = (directory) => {
|
|
4595
|
+
const tsConfigPath = path$1.join(directory, TSCONFIG_FILENAME);
|
|
4596
|
+
if (isFile(tsConfigPath)) return detectPreES2023FromConfig(tsConfigPath);
|
|
4597
|
+
return false;
|
|
3054
4598
|
};
|
|
3055
4599
|
const REACT_DEPENDENCY_NAMES = new Set([
|
|
3056
4600
|
"react",
|
|
@@ -3166,11 +4710,63 @@ const cachedProjectInfos = /* @__PURE__ */ new Map();
|
|
|
3166
4710
|
const clearProjectCache = () => {
|
|
3167
4711
|
cachedProjectInfos.clear();
|
|
3168
4712
|
};
|
|
4713
|
+
/**
|
|
4714
|
+
* Build a `ProjectInfo` for a directory that has no `package.json` of
|
|
4715
|
+
* its own — a monorepo subfolder like `repo/packages`, or any loose tree
|
|
4716
|
+
* of TypeScript/JavaScript files. Dependency + framework detection is
|
|
4717
|
+
* inherited from the enclosing workspace root when there is one, so
|
|
4718
|
+
* scanning a subdirectory of a React monorepo still gets the React
|
|
4719
|
+
* capabilities; a standalone non-React directory simply scans with the
|
|
4720
|
+
* framework-agnostic rules. Throws only when the directory has nothing
|
|
4721
|
+
* to scan (no enclosing project and no source files of its own).
|
|
4722
|
+
*/
|
|
4723
|
+
const discoverProjectWithoutPackageJson = (directory) => {
|
|
4724
|
+
const sourceFileCount = countSourceFiles(directory);
|
|
4725
|
+
const hasOwnTsConfig = fs$1.existsSync(path$1.join(directory, "tsconfig.json"));
|
|
4726
|
+
const monorepoRoot = findMonorepoRoot(directory);
|
|
4727
|
+
const enclosingProject = monorepoRoot !== null && isFile(path$1.join(monorepoRoot, "package.json")) ? discoverProject(monorepoRoot) : null;
|
|
4728
|
+
if (enclosingProject !== null) return {
|
|
4729
|
+
...enclosingProject,
|
|
4730
|
+
rootDirectory: directory,
|
|
4731
|
+
projectName: path$1.basename(directory),
|
|
4732
|
+
hasTypeScript: hasOwnTsConfig || enclosingProject.hasTypeScript,
|
|
4733
|
+
sourceFileCount
|
|
4734
|
+
};
|
|
4735
|
+
if (sourceFileCount === 0) throw new PackageJsonNotFoundError(directory);
|
|
4736
|
+
return {
|
|
4737
|
+
rootDirectory: directory,
|
|
4738
|
+
projectName: path$1.basename(directory),
|
|
4739
|
+
reactVersion: null,
|
|
4740
|
+
reactMajorVersion: null,
|
|
4741
|
+
tailwindVersion: null,
|
|
4742
|
+
zodVersion: null,
|
|
4743
|
+
zodMajorVersion: null,
|
|
4744
|
+
framework: "unknown",
|
|
4745
|
+
hasTypeScript: hasOwnTsConfig,
|
|
4746
|
+
hasReactCompiler: false,
|
|
4747
|
+
hasTanStackQuery: false,
|
|
4748
|
+
preactVersion: null,
|
|
4749
|
+
preactMajorVersion: null,
|
|
4750
|
+
hasReactNativeWorkspace: false,
|
|
4751
|
+
nextjsVersion: null,
|
|
4752
|
+
nextjsMajorVersion: null,
|
|
4753
|
+
expoVersion: null,
|
|
4754
|
+
shopifyFlashListVersion: null,
|
|
4755
|
+
shopifyFlashListMajorVersion: null,
|
|
4756
|
+
hasReanimated: false,
|
|
4757
|
+
isPreES2023Target: hasOwnTsConfig && detectPreES2023Target(directory),
|
|
4758
|
+
sourceFileCount
|
|
4759
|
+
};
|
|
4760
|
+
};
|
|
3169
4761
|
const discoverProject = (directory) => {
|
|
3170
4762
|
const cached = cachedProjectInfos.get(directory);
|
|
3171
4763
|
if (cached !== void 0) return cached;
|
|
3172
4764
|
const packageJsonPath = path$1.join(directory, "package.json");
|
|
3173
|
-
if (!isFile(packageJsonPath))
|
|
4765
|
+
if (!isFile(packageJsonPath)) {
|
|
4766
|
+
const synthesized = discoverProjectWithoutPackageJson(directory);
|
|
4767
|
+
cachedProjectInfos.set(directory, synthesized);
|
|
4768
|
+
return synthesized;
|
|
4769
|
+
}
|
|
3174
4770
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3175
4771
|
let { reactVersion, tailwindVersion, zodVersion, framework } = extractDependencyInfo(packageJson);
|
|
3176
4772
|
const reactDeclaration = getDependencyDeclaration({
|
|
@@ -3256,6 +4852,7 @@ const discoverProject = (directory) => {
|
|
|
3256
4852
|
version: findNextjsVersion(directory, packageJson)
|
|
3257
4853
|
}) : null;
|
|
3258
4854
|
const preactVersion = getPreactVersion(packageJson);
|
|
4855
|
+
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
3259
4856
|
const projectInfo = {
|
|
3260
4857
|
rootDirectory: directory,
|
|
3261
4858
|
projectName,
|
|
@@ -3277,12 +4874,22 @@ const discoverProject = (directory) => {
|
|
|
3277
4874
|
shopifyFlashListVersion,
|
|
3278
4875
|
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
3279
4876
|
hasReanimated,
|
|
4877
|
+
isPreES2023Target,
|
|
3280
4878
|
sourceFileCount
|
|
3281
4879
|
};
|
|
3282
4880
|
cachedProjectInfos.set(directory, projectInfo);
|
|
3283
4881
|
return projectInfo;
|
|
3284
4882
|
};
|
|
3285
|
-
|
|
4883
|
+
/**
|
|
4884
|
+
* A project is worth scanning when it has React/Preact (the framework-
|
|
4885
|
+
* specific rules apply) OR it simply has source files to lint. The
|
|
4886
|
+
* second arm is what lets a plain TypeScript/JavaScript codebase — no
|
|
4887
|
+
* React dependency at all — run the framework-agnostic rules
|
|
4888
|
+
* (security, architecture, zod, bundle-size, …) instead of hard-failing
|
|
4889
|
+
* with "No React dependency". Only a directory with neither React nor a
|
|
4890
|
+
* single source file has nothing to analyze.
|
|
4891
|
+
*/
|
|
4892
|
+
const isAnalyzableProject = (project) => project.reactVersion !== null || project.preactVersion !== null || project.sourceFileCount > 0;
|
|
3286
4893
|
const MAJOR_MINOR_PATTERN = /(\d{1,4})\.(\d{1,4})/;
|
|
3287
4894
|
const MAJOR_ONLY_PATTERN = /(\d{1,4})/;
|
|
3288
4895
|
const UPPER_BOUND_COMPARATOR_PATTERN = /<=?\s{0,8}\d{1,4}(?:\.\d{1,4}){0,2}(?:-[^\s,|]+)?/g;
|
|
@@ -3346,56 +4953,6 @@ const isTailwindAtLeast = (detected, required) => {
|
|
|
3346
4953
|
if (detected.major !== required.major) return detected.major > required.major;
|
|
3347
4954
|
return detected.minor >= required.minor;
|
|
3348
4955
|
};
|
|
3349
|
-
const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
|
|
3350
|
-
const MILLISECONDS_PER_SECOND = 1e3;
|
|
3351
|
-
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
3352
|
-
const FETCH_TIMEOUT_MS = 1e4;
|
|
3353
|
-
const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
|
|
3354
|
-
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
3355
|
-
const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
|
|
3356
|
-
const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
3357
|
-
/**
|
|
3358
|
-
* Project-config files that `StagedFiles.materialize` copies into
|
|
3359
|
-
* the temp directory alongside staged sources so oxlint resolves
|
|
3360
|
-
* `tsconfig` / `package.json` / lint configs the same way it would
|
|
3361
|
-
* in the working tree. Hoisted out of the staged-files helper so
|
|
3362
|
-
* the constant lives next to the rest of the IO budget knobs.
|
|
3363
|
-
*/
|
|
3364
|
-
const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
3365
|
-
"tsconfig.json",
|
|
3366
|
-
"tsconfig.base.json",
|
|
3367
|
-
"package.json",
|
|
3368
|
-
"doctor.config.ts",
|
|
3369
|
-
"doctor.config.mts",
|
|
3370
|
-
"doctor.config.cts",
|
|
3371
|
-
"doctor.config.js",
|
|
3372
|
-
"doctor.config.mjs",
|
|
3373
|
-
"doctor.config.cjs",
|
|
3374
|
-
"doctor.config.json",
|
|
3375
|
-
"doctor.config.jsonc",
|
|
3376
|
-
"oxlint.json",
|
|
3377
|
-
".oxlintrc.json"
|
|
3378
|
-
];
|
|
3379
|
-
const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
|
|
3380
|
-
const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
|
|
3381
|
-
const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
|
|
3382
|
-
const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
|
|
3383
|
-
const DIAGNOSTIC_CATEGORY_BUCKETS = [
|
|
3384
|
-
"Security",
|
|
3385
|
-
"Bugs",
|
|
3386
|
-
"Performance",
|
|
3387
|
-
"Accessibility",
|
|
3388
|
-
"Maintainability"
|
|
3389
|
-
];
|
|
3390
|
-
const APP_ONLY_RULE_KEYS = new Set([
|
|
3391
|
-
"react-hooks-js/static-components",
|
|
3392
|
-
"react-doctor/no-render-prop-children",
|
|
3393
|
-
"react-doctor/prefer-explicit-variants"
|
|
3394
|
-
]);
|
|
3395
|
-
const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
|
|
3396
|
-
const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
|
|
3397
|
-
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
3398
|
-
const CONFIG_CACHE_TTL_MS = 300 * 1e3;
|
|
3399
4956
|
var InvalidGlobPatternError = class extends Error {
|
|
3400
4957
|
pattern;
|
|
3401
4958
|
reason;
|
|
@@ -3706,7 +5263,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
3706
5263
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
3707
5264
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
3708
5265
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
3709
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
3710
5266
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
3711
5267
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
3712
5268
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -4804,51 +6360,51 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
4804
6360
|
{
|
|
4805
6361
|
packageName: "expo-modules-autolinking",
|
|
4806
6362
|
rule: "expo-no-redundant-dependency",
|
|
4807
|
-
message: "\"expo-modules-autolinking\" should not be a direct dependency
|
|
6363
|
+
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",
|
|
4808
6364
|
help: "Remove `expo-modules-autolinking` from your package.json"
|
|
4809
6365
|
},
|
|
4810
6366
|
{
|
|
4811
6367
|
packageName: "expo-dev-launcher",
|
|
4812
6368
|
rule: "expo-no-redundant-dependency",
|
|
4813
|
-
message: "\"expo-dev-launcher\" should not be a direct dependency
|
|
6369
|
+
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",
|
|
4814
6370
|
help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
|
|
4815
6371
|
},
|
|
4816
6372
|
{
|
|
4817
6373
|
packageName: "expo-dev-menu",
|
|
4818
6374
|
rule: "expo-no-redundant-dependency",
|
|
4819
|
-
message: "\"expo-dev-menu\" should not be a direct dependency
|
|
6375
|
+
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",
|
|
4820
6376
|
help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
|
|
4821
6377
|
},
|
|
4822
6378
|
{
|
|
4823
6379
|
packageName: "expo-modules-core",
|
|
4824
6380
|
rule: "expo-no-redundant-dependency",
|
|
4825
|
-
message: "\"expo-modules-core\" should not be a direct dependency
|
|
6381
|
+
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",
|
|
4826
6382
|
help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
|
|
4827
6383
|
},
|
|
4828
6384
|
{
|
|
4829
6385
|
packageName: "@expo/metro-config",
|
|
4830
6386
|
rule: "expo-no-redundant-dependency",
|
|
4831
|
-
message: "\"@expo/metro-config\" should not be a direct dependency
|
|
6387
|
+
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",
|
|
4832
6388
|
help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
|
|
4833
6389
|
},
|
|
4834
6390
|
{
|
|
4835
6391
|
packageName: "@types/react-native",
|
|
4836
6392
|
rule: "expo-no-redundant-dependency",
|
|
4837
|
-
message: "\"@types/react-native\" should not be installed
|
|
6393
|
+
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",
|
|
4838
6394
|
help: "Remove `@types/react-native` from your package.json",
|
|
4839
6395
|
minSdkMajor: 48
|
|
4840
6396
|
},
|
|
4841
6397
|
{
|
|
4842
6398
|
packageName: "@expo/config-plugins",
|
|
4843
6399
|
rule: "expo-no-redundant-dependency",
|
|
4844
|
-
message: "\"@expo/config-plugins\" should not be a direct dependency
|
|
6400
|
+
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",
|
|
4845
6401
|
help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
|
|
4846
6402
|
minSdkMajor: 48
|
|
4847
6403
|
},
|
|
4848
6404
|
{
|
|
4849
6405
|
packageName: "@expo/prebuild-config",
|
|
4850
6406
|
rule: "expo-no-redundant-dependency",
|
|
4851
|
-
message: "\"@expo/prebuild-config\" should not be a direct dependency
|
|
6407
|
+
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",
|
|
4852
6408
|
help: "Remove `@expo/prebuild-config` from your package.json",
|
|
4853
6409
|
minSdkMajor: 53
|
|
4854
6410
|
},
|
|
@@ -4862,28 +6418,28 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
4862
6418
|
{
|
|
4863
6419
|
packageName: "expo-app-loading",
|
|
4864
6420
|
rule: "expo-no-redundant-dependency",
|
|
4865
|
-
message: "\"expo-app-loading\" was removed in SDK 49",
|
|
6421
|
+
message: "\"expo-app-loading\" was removed in SDK 49, so keeping it can leave imports unresolved after upgrading Expo",
|
|
4866
6422
|
help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
|
|
4867
6423
|
minSdkMajor: 49
|
|
4868
6424
|
},
|
|
4869
6425
|
{
|
|
4870
6426
|
packageName: "expo-firebase-analytics",
|
|
4871
6427
|
rule: "expo-no-redundant-dependency",
|
|
4872
|
-
message: "\"expo-firebase-analytics\" was removed in SDK 48",
|
|
6428
|
+
message: "\"expo-firebase-analytics\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
4873
6429
|
help: FIREBASE_HELP,
|
|
4874
6430
|
minSdkMajor: 48
|
|
4875
6431
|
},
|
|
4876
6432
|
{
|
|
4877
6433
|
packageName: "expo-firebase-recaptcha",
|
|
4878
6434
|
rule: "expo-no-redundant-dependency",
|
|
4879
|
-
message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
|
|
6435
|
+
message: "\"expo-firebase-recaptcha\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
4880
6436
|
help: FIREBASE_HELP,
|
|
4881
6437
|
minSdkMajor: 48
|
|
4882
6438
|
},
|
|
4883
6439
|
{
|
|
4884
6440
|
packageName: "expo-firebase-core",
|
|
4885
6441
|
rule: "expo-no-redundant-dependency",
|
|
4886
|
-
message: "\"expo-firebase-core\" was removed in SDK 48",
|
|
6442
|
+
message: "\"expo-firebase-core\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
4887
6443
|
help: FIREBASE_HELP,
|
|
4888
6444
|
minSdkMajor: 48
|
|
4889
6445
|
}
|
|
@@ -4924,7 +6480,7 @@ const checkExpoGitignore = (context) => {
|
|
|
4924
6480
|
}));
|
|
4925
6481
|
if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
|
|
4926
6482
|
rule: "expo-gitignore",
|
|
4927
|
-
message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored
|
|
6483
|
+
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.",
|
|
4928
6484
|
help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
|
|
4929
6485
|
}));
|
|
4930
6486
|
return diagnostics;
|
|
@@ -4986,17 +6542,16 @@ const checkExpoPackageJsonConflicts = (context) => {
|
|
|
4986
6542
|
const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
|
|
4987
6543
|
if (conflictingScriptNames.length > 0) {
|
|
4988
6544
|
const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
|
|
4989
|
-
const shadowsExpoCli = conflictingScriptNames.includes("expo");
|
|
4990
6545
|
diagnostics.push(buildExpoDiagnostic({
|
|
4991
6546
|
rule: "expo-package-json-conflict",
|
|
4992
|
-
message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that
|
|
6547
|
+
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.`,
|
|
4993
6548
|
help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
|
|
4994
6549
|
}));
|
|
4995
6550
|
}
|
|
4996
6551
|
const packageName = packageJson.name;
|
|
4997
6552
|
if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
|
|
4998
6553
|
rule: "expo-package-json-conflict",
|
|
4999
|
-
message: `package.json "name" is "${packageName}", which collides with a dependency of the same name
|
|
6554
|
+
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.`,
|
|
5000
6555
|
help: "Rename your package so it no longer matches one of its dependencies"
|
|
5001
6556
|
}));
|
|
5002
6557
|
return diagnostics;
|
|
@@ -5067,7 +6622,7 @@ const checkExpoRouterReactNavigation = (context) => {
|
|
|
5067
6622
|
if (reactNavigationNames.length === 0) return [];
|
|
5068
6623
|
return [buildExpoDiagnostic({
|
|
5069
6624
|
rule: "expo-router-no-react-navigation",
|
|
5070
|
-
message: `As of SDK 56, expo-router is no longer compatible with react-navigation,
|
|
6625
|
+
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.`,
|
|
5071
6626
|
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/"
|
|
5072
6627
|
})];
|
|
5073
6628
|
};
|
|
@@ -5290,6 +6845,168 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
5290
6845
|
if (!isReactNativeProject(project)) return [];
|
|
5291
6846
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
5292
6847
|
};
|
|
6848
|
+
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
6849
|
+
const DEPENDENCY_SECTIONS = [
|
|
6850
|
+
"dependencies",
|
|
6851
|
+
"devDependencies",
|
|
6852
|
+
"peerDependencies",
|
|
6853
|
+
"optionalDependencies"
|
|
6854
|
+
];
|
|
6855
|
+
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
6856
|
+
"19.0": {
|
|
6857
|
+
rceFixedVersion: "19.0.1",
|
|
6858
|
+
latestSafeVersion: "19.0.6"
|
|
6859
|
+
},
|
|
6860
|
+
"19.1": {
|
|
6861
|
+
rceFixedVersion: "19.1.2",
|
|
6862
|
+
latestSafeVersion: "19.1.7"
|
|
6863
|
+
},
|
|
6864
|
+
"19.2": {
|
|
6865
|
+
rceFixedVersion: "19.2.1",
|
|
6866
|
+
latestSafeVersion: "19.2.6"
|
|
6867
|
+
}
|
|
6868
|
+
};
|
|
6869
|
+
const NEXTJS_OLDEST_AFFECTED_MAJOR = 13;
|
|
6870
|
+
const NEXTJS_RCE_FIXED_BY_MINOR = {
|
|
6871
|
+
"15.0": "15.0.5",
|
|
6872
|
+
"15.1": "15.1.9",
|
|
6873
|
+
"15.2": "15.2.6",
|
|
6874
|
+
"15.3": "15.3.6",
|
|
6875
|
+
"15.4": "15.4.8",
|
|
6876
|
+
"15.5": "15.5.7",
|
|
6877
|
+
"16.0": "16.0.7"
|
|
6878
|
+
};
|
|
6879
|
+
const NEXTJS_LATEST_SAFE_BY_MAJOR = {
|
|
6880
|
+
15: "15.5.18",
|
|
6881
|
+
16: "16.2.6"
|
|
6882
|
+
};
|
|
6883
|
+
const NEXTJS_SUPPORTED_UPGRADE_TARGETS = "15.5.18 or 16.2.6";
|
|
6884
|
+
const buildAdvisoryDiagnostic = (input) => ({
|
|
6885
|
+
filePath: "package.json",
|
|
6886
|
+
plugin: "react-doctor",
|
|
6887
|
+
rule: RULE_KEY,
|
|
6888
|
+
severity: input.severity,
|
|
6889
|
+
message: input.message,
|
|
6890
|
+
help: input.help,
|
|
6891
|
+
line: 0,
|
|
6892
|
+
column: 0,
|
|
6893
|
+
category: "Security"
|
|
6894
|
+
});
|
|
6895
|
+
const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
6896
|
+
const patterns = getWorkspacePatterns(workspaceRoot, readPackageJson(path$1.join(workspaceRoot, "package.json")));
|
|
6897
|
+
const directories = /* @__PURE__ */ new Set();
|
|
6898
|
+
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
6899
|
+
return [...directories];
|
|
6900
|
+
};
|
|
6901
|
+
const readDeclaredSpec = (packageJson, packageName) => {
|
|
6902
|
+
for (const section of DEPENDENCY_SECTIONS) {
|
|
6903
|
+
const spec = packageJson[section]?.[packageName];
|
|
6904
|
+
if (typeof spec === "string") return spec;
|
|
6905
|
+
}
|
|
6906
|
+
return null;
|
|
6907
|
+
};
|
|
6908
|
+
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
6909
|
+
const manifestPath = path$1.join(directory, "node_modules", packageName, "package.json");
|
|
6910
|
+
if (isFile(manifestPath)) {
|
|
6911
|
+
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
6912
|
+
if (installedVersion !== null) return installedVersion;
|
|
6913
|
+
}
|
|
6914
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(path$1.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
6915
|
+
for (const spec of candidateSpecs) {
|
|
6916
|
+
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
6917
|
+
if (pinnedVersion !== null) return pinnedVersion;
|
|
6918
|
+
}
|
|
6919
|
+
return null;
|
|
6920
|
+
};
|
|
6921
|
+
const checkReactServerDomAdvisory = (packageName, version) => {
|
|
6922
|
+
const advisory = REACT_RSC_ADVISORIES_BY_MINOR[`${import_semver.major(version)}.${import_semver.minor(version)}`];
|
|
6923
|
+
if (advisory === void 0) return [];
|
|
6924
|
+
const installedDisplay = `${packageName}@${version}`;
|
|
6925
|
+
const lineDisplay = `${import_semver.major(version)}.${import_semver.minor(version)}`;
|
|
6926
|
+
if (import_semver.lt(version, advisory.rceFixedVersion)) return [buildAdvisoryDiagnostic({
|
|
6927
|
+
severity: "error",
|
|
6928
|
+
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`,
|
|
6929
|
+
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}`
|
|
6930
|
+
})];
|
|
6931
|
+
if (import_semver.lt(version, advisory.latestSafeVersion)) return [buildAdvisoryDiagnostic({
|
|
6932
|
+
severity: "warning",
|
|
6933
|
+
message: `${installedDisplay} is affected by a high-severity React Server Components denial-of-service vulnerability (CVE-2026-23870) patched in ${advisory.latestSafeVersion}`,
|
|
6934
|
+
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}`
|
|
6935
|
+
})];
|
|
6936
|
+
return [];
|
|
6937
|
+
};
|
|
6938
|
+
const checkNextjsAdvisory = (version) => {
|
|
6939
|
+
const major = import_semver.major(version);
|
|
6940
|
+
if (major < NEXTJS_OLDEST_AFFECTED_MAJOR) return [];
|
|
6941
|
+
const installedDisplay = `next@${version}`;
|
|
6942
|
+
const latestSafeVersion = NEXTJS_LATEST_SAFE_BY_MAJOR[major];
|
|
6943
|
+
if (latestSafeVersion === void 0) {
|
|
6944
|
+
if (major >= 15) return [];
|
|
6945
|
+
return [buildAdvisoryDiagnostic({
|
|
6946
|
+
severity: "warning",
|
|
6947
|
+
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`,
|
|
6948
|
+
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}`
|
|
6949
|
+
})];
|
|
6950
|
+
}
|
|
6951
|
+
const rceFixedVersion = NEXTJS_RCE_FIXED_BY_MINOR[`${major}.${import_semver.minor(version)}`];
|
|
6952
|
+
if (rceFixedVersion !== void 0 && import_semver.lt(version, rceFixedVersion)) return [buildAdvisoryDiagnostic({
|
|
6953
|
+
severity: "error",
|
|
6954
|
+
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`,
|
|
6955
|
+
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}`
|
|
6956
|
+
})];
|
|
6957
|
+
if (import_semver.lt(version, latestSafeVersion)) return [buildAdvisoryDiagnostic({
|
|
6958
|
+
severity: "warning",
|
|
6959
|
+
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}`,
|
|
6960
|
+
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}`
|
|
6961
|
+
})];
|
|
6962
|
+
return [];
|
|
6963
|
+
};
|
|
6964
|
+
/**
|
|
6965
|
+
* Flags a project running React Server Components on a version with a known
|
|
6966
|
+
* security advisory — primarily the critical unauthenticated RCE
|
|
6967
|
+
* (CVE-2025-55182), plus the later high-severity DoS (CVE-2026-23870).
|
|
6968
|
+
*
|
|
6969
|
+
* Every candidate directory — the scan root and each workspace package — is
|
|
6970
|
+
* probed independently, so heterogeneous monorepo installs are all seen (a
|
|
6971
|
+
* vulnerable `next` in one workspace isn't masked by an inert one elsewhere).
|
|
6972
|
+
* Next.js vendors its own RSC runtime, so an affected `next` install in a
|
|
6973
|
+
* directory is reported by its `next` version (the fix is a Next.js bump) and
|
|
6974
|
+
* suppresses the standalone `react-server-dom-*` check for that directory only;
|
|
6975
|
+
* every other framework or bundler — Vite, Parcel, React Router, Waku,
|
|
6976
|
+
* RedwoodSDK — is reported by its `react-server-dom-*` version. Dispatch keys
|
|
6977
|
+
* on resolved installs rather than the root framework classification, so a
|
|
6978
|
+
* monorepo whose root is Vite but whose workspace runs Next.js is still
|
|
6979
|
+
* covered. Pure client-side React apps (no RSC packages, no Next.js) are not
|
|
6980
|
+
* affected and stay quiet.
|
|
6981
|
+
*/
|
|
6982
|
+
const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
|
|
6983
|
+
const workspaceRoot = findMonorepoRoot(scanDirectory) ?? project.rootDirectory;
|
|
6984
|
+
const candidateDirectories = [...new Set([
|
|
6985
|
+
scanDirectory,
|
|
6986
|
+
project.rootDirectory,
|
|
6987
|
+
workspaceRoot,
|
|
6988
|
+
...enumerateWorkspaceDirectories(workspaceRoot)
|
|
6989
|
+
])];
|
|
6990
|
+
const diagnostics = [];
|
|
6991
|
+
const seenMessages = /* @__PURE__ */ new Set();
|
|
6992
|
+
const pushUnique = (candidates) => {
|
|
6993
|
+
for (const candidate of candidates) {
|
|
6994
|
+
if (seenMessages.has(candidate.message)) continue;
|
|
6995
|
+
seenMessages.add(candidate.message);
|
|
6996
|
+
diagnostics.push(candidate);
|
|
6997
|
+
}
|
|
6998
|
+
};
|
|
6999
|
+
for (const directory of candidateDirectories) {
|
|
7000
|
+
const nextVersion = resolveVersionInDirectory(directory, "next", directory === scanDirectory ? project.nextjsVersion : null);
|
|
7001
|
+
if (nextVersion !== null) pushUnique(checkNextjsAdvisory(nextVersion));
|
|
7002
|
+
if (nextVersion !== null && import_semver.major(nextVersion) >= NEXTJS_OLDEST_AFFECTED_MAJOR) continue;
|
|
7003
|
+
for (const packageName of REACT_SERVER_DOM_PACKAGES) {
|
|
7004
|
+
const version = resolveVersionInDirectory(directory, packageName, null);
|
|
7005
|
+
if (version !== null) pushUnique(checkReactServerDomAdvisory(packageName, version));
|
|
7006
|
+
}
|
|
7007
|
+
}
|
|
7008
|
+
return diagnostics;
|
|
7009
|
+
};
|
|
5293
7010
|
const REDUCED_MOTION_GREP_PATTERN = "prefers-reduced-motion|useReducedMotion|MotionConfig|reducedMotion";
|
|
5294
7011
|
const REDUCED_MOTION_FILE_GLOBS = [
|
|
5295
7012
|
"*.ts",
|
|
@@ -5420,7 +7137,9 @@ const highlighter = {
|
|
|
5420
7137
|
gray: import_picocolors.default.gray,
|
|
5421
7138
|
bold: import_picocolors.default.bold
|
|
5422
7139
|
};
|
|
5423
|
-
const
|
|
7140
|
+
const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
|
|
7141
|
+
const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
|
|
7142
|
+
const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
|
|
5424
7143
|
const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
|
|
5425
7144
|
const FALSY_VALUES = new Set([
|
|
5426
7145
|
"false",
|
|
@@ -5849,7 +7568,7 @@ const checkDeadCode = async (options) => {
|
|
|
5849
7568
|
plugin: DEAD_CODE_PLUGIN,
|
|
5850
7569
|
rule: "unused-file",
|
|
5851
7570
|
severity: "warning",
|
|
5852
|
-
message: "Unused file
|
|
7571
|
+
message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
|
|
5853
7572
|
help: "Delete the file if it is truly unreachable, or import it from an entry point.",
|
|
5854
7573
|
line: 0,
|
|
5855
7574
|
column: 0,
|
|
@@ -5862,7 +7581,7 @@ const checkDeadCode = async (options) => {
|
|
|
5862
7581
|
plugin: DEAD_CODE_PLUGIN,
|
|
5863
7582
|
rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
|
|
5864
7583
|
severity: "warning",
|
|
5865
|
-
message: `Unused ${label}: \`${unusedExport.name}
|
|
7584
|
+
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.`,
|
|
5866
7585
|
help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
|
|
5867
7586
|
line: unusedExport.line,
|
|
5868
7587
|
column: unusedExport.column,
|
|
@@ -5877,7 +7596,7 @@ const checkDeadCode = async (options) => {
|
|
|
5877
7596
|
rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
|
|
5878
7597
|
severity: "warning",
|
|
5879
7598
|
message: `Unused ${label}: \`${unusedDependency.name}\``,
|
|
5880
|
-
help:
|
|
7599
|
+
help: `An unused ${label} adds install time and supply-chain surface without being used; remove it from package.json if it is genuinely unused.`,
|
|
5881
7600
|
line: 0,
|
|
5882
7601
|
column: 0,
|
|
5883
7602
|
category: DEAD_CODE_CATEGORY
|
|
@@ -5890,7 +7609,7 @@ const checkDeadCode = async (options) => {
|
|
|
5890
7609
|
plugin: DEAD_CODE_PLUGIN,
|
|
5891
7610
|
rule: "circular-dependency",
|
|
5892
7611
|
severity: "warning",
|
|
5893
|
-
message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}
|
|
7612
|
+
message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}. Modules in the cycle can observe partially initialized exports, causing order-dependent bugs.`,
|
|
5894
7613
|
help: "Break the cycle by extracting the shared code into a third module that both files import.",
|
|
5895
7614
|
line: 0,
|
|
5896
7615
|
column: 0,
|
|
@@ -5973,11 +7692,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
|
|
|
5973
7692
|
return filePaths;
|
|
5974
7693
|
};
|
|
5975
7694
|
const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
|
|
5976
|
-
const resolveLintIncludePaths = (rootDirectory, userConfig) => {
|
|
7695
|
+
const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
|
|
5977
7696
|
if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
|
|
5978
7697
|
const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
|
|
5979
7698
|
return listSourceFiles(rootDirectory).filter((filePath) => {
|
|
5980
|
-
if (!
|
|
7699
|
+
if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
|
|
5981
7700
|
return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
|
|
5982
7701
|
});
|
|
5983
7702
|
};
|
|
@@ -6680,6 +8399,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
6680
8399
|
const buildCapabilities = (project) => {
|
|
6681
8400
|
const capabilities = /* @__PURE__ */ new Set();
|
|
6682
8401
|
capabilities.add(project.framework);
|
|
8402
|
+
if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
|
|
6683
8403
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
6684
8404
|
if (project.expoVersion !== null) capabilities.add("expo");
|
|
6685
8405
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
@@ -6705,6 +8425,7 @@ const buildCapabilities = (project) => {
|
|
|
6705
8425
|
capabilities.add("zod");
|
|
6706
8426
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
6707
8427
|
}
|
|
8428
|
+
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
6708
8429
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
6709
8430
|
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
6710
8431
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
@@ -6723,6 +8444,7 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
|
|
|
6723
8444
|
if (requires) {
|
|
6724
8445
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
6725
8446
|
}
|
|
8447
|
+
if (tags?.includes("react-jsx-only") && !capabilities.has("react")) return false;
|
|
6726
8448
|
if (disabledBy) {
|
|
6727
8449
|
for (const capability of disabledBy) if (capabilities.has(capability)) return false;
|
|
6728
8450
|
}
|
|
@@ -8235,6 +9957,214 @@ var Score = class Score extends Context.Service()("react-doctor/Score") {
|
|
|
8235
9957
|
}) }));
|
|
8236
9958
|
static layerOf = (result) => Layer.succeed(Score, Score.of({ compute: () => Effect.succeed(result) }));
|
|
8237
9959
|
};
|
|
9960
|
+
const SocketScoreSchema = Schema.Struct({
|
|
9961
|
+
overall: Schema.Number,
|
|
9962
|
+
license: Schema.Number,
|
|
9963
|
+
maintenance: Schema.Number,
|
|
9964
|
+
quality: Schema.Number,
|
|
9965
|
+
supplyChain: Schema.Number,
|
|
9966
|
+
vulnerability: Schema.Number
|
|
9967
|
+
});
|
|
9968
|
+
const SocketArtifactSchema = Schema.Struct({ score: Schema.optional(SocketScoreSchema) });
|
|
9969
|
+
const decodeArtifact = Schema.decodeUnknownOption(SocketArtifactSchema);
|
|
9970
|
+
const SCORE_AXES = [
|
|
9971
|
+
{
|
|
9972
|
+
key: "supplyChain",
|
|
9973
|
+
label: "supply chain"
|
|
9974
|
+
},
|
|
9975
|
+
{
|
|
9976
|
+
key: "vulnerability",
|
|
9977
|
+
label: "vulnerability"
|
|
9978
|
+
},
|
|
9979
|
+
{
|
|
9980
|
+
key: "maintenance",
|
|
9981
|
+
label: "maintenance"
|
|
9982
|
+
},
|
|
9983
|
+
{
|
|
9984
|
+
key: "quality",
|
|
9985
|
+
label: "quality"
|
|
9986
|
+
},
|
|
9987
|
+
{
|
|
9988
|
+
key: "license",
|
|
9989
|
+
label: "license"
|
|
9990
|
+
}
|
|
9991
|
+
];
|
|
9992
|
+
const clampScore = (value) => {
|
|
9993
|
+
if (!Number.isFinite(value)) return 50;
|
|
9994
|
+
return Math.min(Math.max(value, 0), 100);
|
|
9995
|
+
};
|
|
9996
|
+
const toHundred = (normalizedScore) => Math.round(clampScore(normalizedScore * 100));
|
|
9997
|
+
const resolveOptions = (config) => {
|
|
9998
|
+
const supplyChain = config?.supplyChain ?? {};
|
|
9999
|
+
return {
|
|
10000
|
+
minScore: typeof supplyChain.minScore === "number" ? clampScore(supplyChain.minScore) : 50,
|
|
10001
|
+
severity: supplyChain.severity === "warning" ? "warning" : "error",
|
|
10002
|
+
includeDevDependencies: supplyChain.includeDevDependencies !== false
|
|
10003
|
+
};
|
|
10004
|
+
};
|
|
10005
|
+
const resolveConcreteVersion = (spec) => {
|
|
10006
|
+
const trimmed = spec.trim();
|
|
10007
|
+
if (trimmed.length === 0) return null;
|
|
10008
|
+
if (trimmed.includes(":")) return null;
|
|
10009
|
+
const match = trimmed.match(/\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/);
|
|
10010
|
+
return match ? match[0] : null;
|
|
10011
|
+
};
|
|
10012
|
+
const locateDependencyKey = (packageJsonText, section, name) => {
|
|
10013
|
+
const needle = `"${name}"`;
|
|
10014
|
+
const sectionHeader = new RegExp(`"${section}"\\s*:\\s*\\{`);
|
|
10015
|
+
const lines = packageJsonText.split(/\r?\n/);
|
|
10016
|
+
let depth = 0;
|
|
10017
|
+
let insideSection = false;
|
|
10018
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
|
|
10019
|
+
const lineText = lines[lineIndex];
|
|
10020
|
+
if (!insideSection) {
|
|
10021
|
+
if (sectionHeader.test(lineText)) {
|
|
10022
|
+
insideSection = true;
|
|
10023
|
+
depth = 1;
|
|
10024
|
+
}
|
|
10025
|
+
continue;
|
|
10026
|
+
}
|
|
10027
|
+
const columnIndex = lineText.indexOf(needle);
|
|
10028
|
+
if (columnIndex >= 0 && /^\s*:/.test(lineText.slice(columnIndex + needle.length))) return {
|
|
10029
|
+
line: lineIndex + 1,
|
|
10030
|
+
column: columnIndex + 1
|
|
10031
|
+
};
|
|
10032
|
+
for (const character of lineText) if (character === "{") depth += 1;
|
|
10033
|
+
else if (character === "}") depth -= 1;
|
|
10034
|
+
if (depth <= 0) return null;
|
|
10035
|
+
}
|
|
10036
|
+
return null;
|
|
10037
|
+
};
|
|
10038
|
+
const collectDependenciesToScore = (packageJson, packageJsonText, includeDevDependencies) => {
|
|
10039
|
+
const sectionByName = /* @__PURE__ */ new Map();
|
|
10040
|
+
for (const name of Object.keys(packageJson.dependencies ?? {})) sectionByName.set(name, "dependencies");
|
|
10041
|
+
if (includeDevDependencies) {
|
|
10042
|
+
for (const name of Object.keys(packageJson.devDependencies ?? {})) if (!sectionByName.has(name)) sectionByName.set(name, "devDependencies");
|
|
10043
|
+
}
|
|
10044
|
+
const dependencies = [];
|
|
10045
|
+
for (const [name, section] of sectionByName) {
|
|
10046
|
+
if (SUPPLY_CHAIN_IGNORED_PACKAGES.has(name)) continue;
|
|
10047
|
+
const spec = (packageJson[section] ?? {})[name] ?? "";
|
|
10048
|
+
const version = resolveConcreteVersion(spec);
|
|
10049
|
+
if (version === null) continue;
|
|
10050
|
+
const location = locateDependencyKey(packageJsonText, section, name);
|
|
10051
|
+
dependencies.push({
|
|
10052
|
+
name,
|
|
10053
|
+
version,
|
|
10054
|
+
spec,
|
|
10055
|
+
line: location?.line ?? 0,
|
|
10056
|
+
column: location?.column ?? 0
|
|
10057
|
+
});
|
|
10058
|
+
}
|
|
10059
|
+
return dependencies;
|
|
10060
|
+
};
|
|
10061
|
+
const readPackageJsonText = (packageJsonPath) => {
|
|
10062
|
+
try {
|
|
10063
|
+
return fs$1.readFileSync(packageJsonPath, "utf-8");
|
|
10064
|
+
} catch {
|
|
10065
|
+
return "";
|
|
10066
|
+
}
|
|
10067
|
+
};
|
|
10068
|
+
const toPurl = (dependency) => `pkg:npm/${dependency.name}@${dependency.version}`;
|
|
10069
|
+
const parseScoreFromBody = (body) => {
|
|
10070
|
+
for (const line of body.split("\n")) {
|
|
10071
|
+
if (line.trim().length === 0) continue;
|
|
10072
|
+
let parsed;
|
|
10073
|
+
try {
|
|
10074
|
+
parsed = JSON.parse(line);
|
|
10075
|
+
} catch {
|
|
10076
|
+
continue;
|
|
10077
|
+
}
|
|
10078
|
+
const artifact = Option.getOrNull(decodeArtifact(parsed));
|
|
10079
|
+
if (artifact?.score) return artifact.score;
|
|
10080
|
+
}
|
|
10081
|
+
return null;
|
|
10082
|
+
};
|
|
10083
|
+
const fetchSocketScore = (dependency) => Effect.tryPromise(async (signal) => {
|
|
10084
|
+
const requestUrl = `${SOCKET_FREE_PURL_API_BASE}/${encodeURIComponent(toPurl(dependency))}`;
|
|
10085
|
+
const response = await fetch(requestUrl, {
|
|
10086
|
+
headers: { "User-Agent": SOCKET_FREE_USER_AGENT },
|
|
10087
|
+
signal
|
|
10088
|
+
});
|
|
10089
|
+
if (!response.ok) return null;
|
|
10090
|
+
return parseScoreFromBody(await response.text());
|
|
10091
|
+
}).pipe(Effect.timeout(FETCH_TIMEOUT_MS), Effect.orElseSucceed(() => null), Effect.tap((score) => {
|
|
10092
|
+
const scoreAttributes = {};
|
|
10093
|
+
if (score !== null) {
|
|
10094
|
+
scoreAttributes["socket.score.overall"] = toHundred(score.overall);
|
|
10095
|
+
for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(score[axis.key]);
|
|
10096
|
+
}
|
|
10097
|
+
return Effect.annotateCurrentSpan({
|
|
10098
|
+
"socket.scored": score !== null,
|
|
10099
|
+
...scoreAttributes
|
|
10100
|
+
});
|
|
10101
|
+
}), Effect.withSpan("SupplyChain.fetchScore", { attributes: {
|
|
10102
|
+
"socket.package": dependency.name,
|
|
10103
|
+
"socket.version": dependency.version,
|
|
10104
|
+
"socket.purl": toPurl(dependency)
|
|
10105
|
+
} }));
|
|
10106
|
+
const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
|
|
10107
|
+
const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
10108
|
+
const overall = toHundred(score.overall);
|
|
10109
|
+
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
10110
|
+
return {
|
|
10111
|
+
filePath: "package.json",
|
|
10112
|
+
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
10113
|
+
rule: SUPPLY_CHAIN_RULE,
|
|
10114
|
+
severity: options.severity,
|
|
10115
|
+
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)}.`,
|
|
10116
|
+
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.`,
|
|
10117
|
+
url: packagePageUrl,
|
|
10118
|
+
line: dependency.line,
|
|
10119
|
+
column: dependency.column,
|
|
10120
|
+
category: SUPPLY_CHAIN_CATEGORY
|
|
10121
|
+
};
|
|
10122
|
+
};
|
|
10123
|
+
/**
|
|
10124
|
+
* Scores every direct dependency in the project's `package.json` against
|
|
10125
|
+
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
10126
|
+
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
10127
|
+
* Socket `overall` score is below the configured `minScore`.
|
|
10128
|
+
*
|
|
10129
|
+
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
10130
|
+
* total/fail-open: each per-package lookup already recovers to `null`
|
|
10131
|
+
* (skip) on timeout or network/parse failure, so a flaky Socket API never
|
|
10132
|
+
* sinks the scan. Diagnostics default to `"error"` severity, so a low score
|
|
10133
|
+
* fails the run at the standard `blocking` gate.
|
|
10134
|
+
*/
|
|
10135
|
+
const checkSupplyChain = (input) => Effect.gen(function* () {
|
|
10136
|
+
const options = resolveOptions(input.userConfig);
|
|
10137
|
+
const packageJsonPath = path$1.join(input.rootDirectory, "package.json");
|
|
10138
|
+
const dependencies = collectDependenciesToScore(readPackageJson(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
|
|
10139
|
+
if (dependencies.length === 0) return [];
|
|
10140
|
+
const scores = yield* Effect.forEach(dependencies, fetchSocketScore, { concurrency: 8 });
|
|
10141
|
+
const diagnostics = [];
|
|
10142
|
+
for (let index = 0; index < dependencies.length; index += 1) {
|
|
10143
|
+
const score = scores[index];
|
|
10144
|
+
if (!score) continue;
|
|
10145
|
+
if (toHundred(score.overall) >= options.minScore) continue;
|
|
10146
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, options));
|
|
10147
|
+
}
|
|
10148
|
+
return diagnostics;
|
|
10149
|
+
});
|
|
10150
|
+
/**
|
|
10151
|
+
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
10152
|
+
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
10153
|
+
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
10154
|
+
* Socket score falls below the configured `supplyChain.minScore`.
|
|
10155
|
+
*
|
|
10156
|
+
* Runs by default (one network request per dependency); the orchestrator
|
|
10157
|
+
* provides `layerOf([])` only when the user opts out via
|
|
10158
|
+
* `supplyChain.enabled: false`, and always skips it in `--diff` / `--staged`
|
|
10159
|
+
* mode (dependency health is a whole-project property).
|
|
10160
|
+
* The underlying `checkSupplyChain` Effect is total/fail-open — per-package
|
|
10161
|
+
* timeouts and network failures recover to "skip" — so the stream never
|
|
10162
|
+
* fails, mirroring `DeadCode`'s stream shape so the two compose the same way.
|
|
10163
|
+
*/
|
|
10164
|
+
var SupplyChain = class SupplyChain extends Context.Service()("react-doctor/SupplyChain") {
|
|
10165
|
+
static layerNode = Layer.succeed(SupplyChain, SupplyChain.of({ run: (input) => Stream.unwrap(checkSupplyChain(input).pipe(Effect.map((diagnostics) => Stream.fromIterable(diagnostics)), Effect.withSpan("SupplyChain.run"))) }));
|
|
10166
|
+
static layerOf = (diagnostics) => Layer.succeed(SupplyChain, SupplyChain.of({ run: () => Stream.fromIterable(diagnostics) }));
|
|
10167
|
+
};
|
|
8238
10168
|
const getObjectProperty = (value, propertyName) => {
|
|
8239
10169
|
if (typeof value !== "object" || value === null) return void 0;
|
|
8240
10170
|
return Reflect.get(value, propertyName);
|
|
@@ -8312,6 +10242,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8312
10242
|
const reporterService = yield* Reporter;
|
|
8313
10243
|
const scoreService = yield* Score;
|
|
8314
10244
|
const deadCodeService = yield* DeadCode;
|
|
10245
|
+
const supplyChainService = yield* SupplyChain;
|
|
8315
10246
|
const gitService = yield* Git;
|
|
8316
10247
|
const progressService = yield* Progress;
|
|
8317
10248
|
const partialFailuresRef = yield* LintPartialFailures;
|
|
@@ -8329,7 +10260,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8329
10260
|
directory: scanDirectory,
|
|
8330
10261
|
repo
|
|
8331
10262
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
8332
|
-
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 :
|
|
10263
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
|
|
8333
10264
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
8334
10265
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
8335
10266
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -8347,10 +10278,15 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8347
10278
|
const environmentDiagnostics = isDiffMode ? [] : [
|
|
8348
10279
|
...checkReducedMotion(scanDirectory),
|
|
8349
10280
|
...checkPnpmHardening(scanDirectory),
|
|
10281
|
+
...checkReactServerComponentsAdvisory(scanDirectory, project),
|
|
8350
10282
|
...checkExpoProject(scanDirectory, project),
|
|
8351
10283
|
...checkReactNativeProject(scanDirectory, project)
|
|
8352
10284
|
];
|
|
8353
10285
|
const envCollected = yield* Stream.runCollect(applyPerElementPipeline(Stream.fromIterable(environmentDiagnostics)));
|
|
10286
|
+
const supplyChainCollected = !isDiffMode || (input.supplyChainManifestChanged ?? false) ? yield* Stream.runCollect(applyPerElementPipeline(supplyChainService.run({
|
|
10287
|
+
rootDirectory: scanDirectory,
|
|
10288
|
+
userConfig: resolvedConfig.config
|
|
10289
|
+
}))) : [];
|
|
8354
10290
|
const lintFailure = yield* Ref.make({
|
|
8355
10291
|
didFail: false,
|
|
8356
10292
|
reason: null,
|
|
@@ -8415,6 +10351,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8415
10351
|
yield* reporterService.finalize;
|
|
8416
10352
|
const finalDiagnostics = [
|
|
8417
10353
|
...envCollected,
|
|
10354
|
+
...supplyChainCollected,
|
|
8418
10355
|
...lintCollected,
|
|
8419
10356
|
...deadCodeCollected
|
|
8420
10357
|
];
|
|
@@ -8685,7 +10622,7 @@ const runEditorScan = async (input) => {
|
|
|
8685
10622
|
resolvedDirectory: input.directory,
|
|
8686
10623
|
configSourceDirectory: input.configSourceDirectory ?? null
|
|
8687
10624
|
}) : Config.layerNode;
|
|
8688
|
-
const layers = Layer.mergeAll(Project.layerNode, configLayer, Files.layerNode, Git.layerOf({}), lint ? Linter.layerOxlint : Linter.layerOf([]), LintPartialFailures.layerLive, runDeadCode ? DeadCode.layerNode : DeadCode.layerOf([]), Progress.layerNoop, Reporter.layerNoop, Score.layerOf(null), Layer.succeed(OxlintConcurrency, 1));
|
|
10625
|
+
const layers = Layer.mergeAll(Project.layerNode, configLayer, Files.layerNode, Git.layerOf({}), lint ? Linter.layerOxlint : Linter.layerOf([]), LintPartialFailures.layerLive, runDeadCode ? DeadCode.layerNode : DeadCode.layerOf([]), Progress.layerNoop, Reporter.layerNoop, Score.layerOf(null), SupplyChain.layerOf([]), Layer.succeed(OxlintConcurrency, 1));
|
|
8689
10626
|
const program = runInspect({
|
|
8690
10627
|
directory: input.directory,
|
|
8691
10628
|
includePaths: input.includePaths ?? [],
|
|
@@ -8761,12 +10698,28 @@ const getRuleMetadata = (plugin, rule) => {
|
|
|
8761
10698
|
defaultEnabled: definition.defaultEnabled ?? true
|
|
8762
10699
|
};
|
|
8763
10700
|
};
|
|
10701
|
+
const computeConfigFingerprint = (projectDirectory, version) => {
|
|
10702
|
+
const parts = [`v=${version}`];
|
|
10703
|
+
let directory = projectDirectory;
|
|
10704
|
+
for (;;) {
|
|
10705
|
+
for (const filename of CONFIG_FINGERPRINT_FILENAMES) try {
|
|
10706
|
+
const stat = fs.statSync(path.join(directory, filename));
|
|
10707
|
+
parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
|
|
10708
|
+
} catch {
|
|
10709
|
+
continue;
|
|
10710
|
+
}
|
|
10711
|
+
const parent = path.dirname(directory);
|
|
10712
|
+
if (parent === directory) break;
|
|
10713
|
+
directory = parent;
|
|
10714
|
+
}
|
|
10715
|
+
return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
|
|
10716
|
+
};
|
|
8764
10717
|
//#endregion
|
|
8765
10718
|
//#region ../language-server/dist/index.js
|
|
8766
10719
|
/** Display name used in client-facing messages and progress titles. */
|
|
8767
10720
|
const SERVER_DISPLAY_NAME = "React Doctor";
|
|
8768
10721
|
/** Server version reported in `serverInfo`; injected at build, `dev` from source. */
|
|
8769
|
-
const SERVER_VERSION = "0.
|
|
10722
|
+
const SERVER_VERSION = "0.5.0";
|
|
8770
10723
|
/** `Diagnostic.source` shown next to every published diagnostic. */
|
|
8771
10724
|
const DIAGNOSTIC_SOURCE = "react-doctor";
|
|
8772
10725
|
/**
|
|
@@ -8806,31 +10759,9 @@ const SCANNABLE_EXTENSIONS = [
|
|
|
8806
10759
|
".ts",
|
|
8807
10760
|
".tsx",
|
|
8808
10761
|
".js",
|
|
8809
|
-
".jsx"
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
const CONFIG_WATCH_FILENAMES = [
|
|
8813
|
-
"doctor.config.ts",
|
|
8814
|
-
"doctor.config.mts",
|
|
8815
|
-
"doctor.config.cts",
|
|
8816
|
-
"doctor.config.js",
|
|
8817
|
-
"doctor.config.mjs",
|
|
8818
|
-
"doctor.config.cjs",
|
|
8819
|
-
"doctor.config.json",
|
|
8820
|
-
"doctor.config.jsonc",
|
|
8821
|
-
"react-doctor.config.json",
|
|
8822
|
-
"package.json",
|
|
8823
|
-
"pnpm-workspace.yaml",
|
|
8824
|
-
"tsconfig.json",
|
|
8825
|
-
"tsconfig.base.json",
|
|
8826
|
-
".oxlintrc.json",
|
|
8827
|
-
".eslintrc.json",
|
|
8828
|
-
"pnpm-lock.yaml",
|
|
8829
|
-
"package-lock.json",
|
|
8830
|
-
"yarn.lock",
|
|
8831
|
-
"bun.lock",
|
|
8832
|
-
"bun.lockb",
|
|
8833
|
-
".gitignore"
|
|
10762
|
+
".jsx",
|
|
10763
|
+
".mts",
|
|
10764
|
+
".mjs"
|
|
8834
10765
|
];
|
|
8835
10766
|
const SILENT_LOGGER = {
|
|
8836
10767
|
info: () => {},
|
|
@@ -9448,27 +11379,6 @@ const createProjectGraph = (options) => {
|
|
|
9448
11379
|
}
|
|
9449
11380
|
};
|
|
9450
11381
|
};
|
|
9451
|
-
/**
|
|
9452
|
-
* Fingerprint of everything (outside file content) that affects lint
|
|
9453
|
-
* output for a project: the React Doctor version plus the size + mtime of
|
|
9454
|
-
* each config / manifest / lockfile. A change to any of them invalidates
|
|
9455
|
-
* the persisted per-file lint cache, since rules, capabilities, adopted
|
|
9456
|
-
* configs, and dependency-derived settings all flow from these files.
|
|
9457
|
-
*/
|
|
9458
|
-
const computeConfigFingerprint = (projectDirectory, version) => {
|
|
9459
|
-
const parts = [`v=${version}`];
|
|
9460
|
-
let directory = projectDirectory;
|
|
9461
|
-
for (;;) {
|
|
9462
|
-
for (const filename of CONFIG_WATCH_FILENAMES) try {
|
|
9463
|
-
const stat = fs.statSync(path.join(directory, filename));
|
|
9464
|
-
parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
|
|
9465
|
-
} catch {}
|
|
9466
|
-
const parent = path.dirname(directory);
|
|
9467
|
-
if (parent === directory) break;
|
|
9468
|
-
directory = parent;
|
|
9469
|
-
}
|
|
9470
|
-
return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
|
|
9471
|
-
};
|
|
9472
11382
|
const resolveCacheFilePath = (projectDirectory) => {
|
|
9473
11383
|
const nodeModules = path.join(projectDirectory, "node_modules");
|
|
9474
11384
|
if (fs.existsSync(nodeModules)) return path.join(nodeModules, ".cache", "react-doctor", "lint-cache.json");
|
|
@@ -10252,7 +12162,7 @@ const createServer = (connection, options = {}) => {
|
|
|
10252
12162
|
};
|
|
10253
12163
|
});
|
|
10254
12164
|
connection.onInitialized(() => {
|
|
10255
|
-
if (supportsWatchedFileRegistration) connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: `**/{${
|
|
12165
|
+
if (supportsWatchedFileRegistration) connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: `**/{${CONFIG_FINGERPRINT_FILENAMES.join(",")}}` }, { globPattern: `**/*.{${SCANNABLE_EXTENSIONS.map((extension) => extension.slice(1)).join(",")}}` }] });
|
|
10256
12166
|
if (nodeBinaryPath === null) logger.warn(`${SERVER_DISPLAY_NAME}: no Node binary compatible with the oxlint native binding was found; lint will be skipped until you switch to a supported Node version.`);
|
|
10257
12167
|
if (supportsWorkspaceFolderChange) connection.workspace.onDidChangeWorkspaceFolders((event) => {
|
|
10258
12168
|
const removedRoots = event.removed.map((folder) => normalizeFsPath(uriToFsPath(folder.uri)));
|
|
@@ -10305,7 +12215,7 @@ const createServer = (connection, options = {}) => {
|
|
|
10305
12215
|
for (const change of params.changes) {
|
|
10306
12216
|
const fsPath = uriToFsPath(change.uri);
|
|
10307
12217
|
const baseName = path.basename(fsPath);
|
|
10308
|
-
if (
|
|
12218
|
+
if (CONFIG_FINGERPRINT_FILENAMES.some((watched) => watched === baseName)) {
|
|
10309
12219
|
configChanged = true;
|
|
10310
12220
|
continue;
|
|
10311
12221
|
}
|
|
@@ -10854,5 +12764,5 @@ const startLanguageServer = () => {
|
|
|
10854
12764
|
};
|
|
10855
12765
|
//#endregion
|
|
10856
12766
|
export { startLanguageServer };
|
|
10857
|
-
!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]="
|
|
10858
|
-
//# debugId=
|
|
12767
|
+
!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]="b8f19f83-ee44-560d-a1a8-7ff947324f78")}catch(e){}}();
|
|
12768
|
+
//# debugId=b8f19f83-ee44-560d-a1a8-7ff947324f78
|