react-doctor 0.2.15 → 0.2.16-dev.2d1ab24
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/README.md +8 -5
- package/dist/cli.js +672 -313
- package/dist/index.d.ts +7 -6
- package/dist/index.js +266 -144
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -772,12 +772,13 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#e
|
|
|
772
772
|
* Git service runs through Effect's `ChildProcess` (true subprocess
|
|
773
773
|
* spawn, not `spawnSync`).
|
|
774
774
|
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
775
|
+
* Failures propagate as the tagged `ReactDoctorError` (rejected by
|
|
776
|
+
* `Effect.runPromise`) rather than being flattened into a plain
|
|
777
|
+
* `Error`. The message is unchanged — `ReactDoctorError.message`
|
|
778
|
+
* defers to `reason.message` — so message-matching callers keep
|
|
779
|
+
* working, while the CLI can now dispatch on `error.reason._tag` to
|
|
780
|
+
* render diff-base mistakes (`GitBaseBranchInvalid` /
|
|
781
|
+
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
781
782
|
*/
|
|
782
783
|
declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
|
|
783
784
|
declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a56b86f0-1c28-52ae-9677-12f5e67df34f")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as fs$1 from "node:fs";
|
|
@@ -4314,27 +4314,30 @@ var OxlintSpawnTimeoutMs = class extends Context.Reference("react-doctor/OxlintS
|
|
|
4314
4314
|
var OxlintOutputMaxBytes = class extends Context.Reference("react-doctor/OxlintOutputMaxBytes", { defaultValue: () => OXLINT_OUTPUT_MAX_BYTES }) {};
|
|
4315
4315
|
/**
|
|
4316
4316
|
* Number of oxlint subprocesses the lint pass runs in parallel. Defaults
|
|
4317
|
-
* to
|
|
4318
|
-
*
|
|
4319
|
-
*
|
|
4320
|
-
*
|
|
4317
|
+
* to auto-detected CPU cores (parallel) so large repos scan fast out of
|
|
4318
|
+
* the box; `spawnLintBatches` transparently falls back to a single worker
|
|
4319
|
+
* if a parallel run exhausts system resources. The CLI's `--no-parallel`
|
|
4320
|
+
* flag forces serial via `Layer.succeed`; the `REACT_DOCTOR_PARALLEL` env
|
|
4321
|
+
* var seeds the default for programmatic / CI callers that never touch the
|
|
4322
|
+
* flag — parallelism is opt-OUT, so only the explicit serial values pin
|
|
4323
|
+
* one worker:
|
|
4321
4324
|
*
|
|
4322
|
-
* - unset / `
|
|
4323
|
-
* - `
|
|
4324
|
-
* - a positive integer
|
|
4325
|
+
* - unset / `auto` / `true` / `on` → available CPU cores (clamped)
|
|
4326
|
+
* - `0` / `false` / `off` → `1` (serial)
|
|
4327
|
+
* - a positive integer → that many workers (clamped)
|
|
4328
|
+
* - any other value → available CPU cores (clamped)
|
|
4325
4329
|
*
|
|
4326
4330
|
* The resolved value is always within
|
|
4327
4331
|
* `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`.
|
|
4328
4332
|
*/
|
|
4329
4333
|
var OxlintConcurrency = class extends Context.Reference("react-doctor/OxlintConcurrency", { defaultValue: () => {
|
|
4330
4334
|
const raw = process.env["REACT_DOCTOR_PARALLEL"];
|
|
4331
|
-
if (raw === void 0) return
|
|
4335
|
+
if (raw === void 0) return resolveScanConcurrency("auto");
|
|
4332
4336
|
const normalized = raw.trim().toLowerCase();
|
|
4333
|
-
if (normalized === "
|
|
4334
|
-
if (normalized === "auto" || normalized === "true" || normalized === "on") return resolveScanConcurrency("auto");
|
|
4337
|
+
if (normalized === "0" || normalized === "false" || normalized === "off") return 1;
|
|
4335
4338
|
const parsed = Number.parseInt(normalized, 10);
|
|
4336
|
-
if (
|
|
4337
|
-
return resolveScanConcurrency(
|
|
4339
|
+
if (Number.isInteger(parsed) && parsed > 0) return resolveScanConcurrency(parsed);
|
|
4340
|
+
return resolveScanConcurrency("auto");
|
|
4338
4341
|
} }) {};
|
|
4339
4342
|
const DIAGNOSTIC_SURFACES = [
|
|
4340
4343
|
"cli",
|
|
@@ -5309,6 +5312,81 @@ const checkReducedMotion = (rootDirectory) => {
|
|
|
5309
5312
|
if (result.status === 0) return [];
|
|
5310
5313
|
return [MISSING_REDUCED_MOTION_DIAGNOSTIC];
|
|
5311
5314
|
};
|
|
5315
|
+
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5316
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
5317
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
5318
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
5319
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
5320
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
5321
|
+
};
|
|
5322
|
+
let replaceClose = (string, close, replace, index) => {
|
|
5323
|
+
let result = "", cursor = 0;
|
|
5324
|
+
do {
|
|
5325
|
+
result += string.substring(cursor, index) + replace;
|
|
5326
|
+
cursor = index + close.length;
|
|
5327
|
+
index = string.indexOf(close, cursor);
|
|
5328
|
+
} while (~index);
|
|
5329
|
+
return result + string.substring(cursor);
|
|
5330
|
+
};
|
|
5331
|
+
let createColors = (enabled = isColorSupported) => {
|
|
5332
|
+
let f = enabled ? formatter : () => String;
|
|
5333
|
+
return {
|
|
5334
|
+
isColorSupported: enabled,
|
|
5335
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
5336
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
5337
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
5338
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
5339
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
5340
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
5341
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
5342
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
5343
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
5344
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
5345
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
5346
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
5347
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
5348
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
5349
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
5350
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
5351
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
5352
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
5353
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
5354
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
5355
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
5356
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
5357
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
5358
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
5359
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
5360
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
5361
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
5362
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
5363
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
5364
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
5365
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
5366
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
5367
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
5368
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
5369
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
5370
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
5371
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
5372
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
5373
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
5374
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
5375
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
5376
|
+
};
|
|
5377
|
+
};
|
|
5378
|
+
module.exports = createColors();
|
|
5379
|
+
module.exports.createColors = createColors;
|
|
5380
|
+
})))(), 1);
|
|
5381
|
+
const highlighter = {
|
|
5382
|
+
error: import_picocolors.default.red,
|
|
5383
|
+
warn: import_picocolors.default.yellow,
|
|
5384
|
+
info: import_picocolors.default.cyan,
|
|
5385
|
+
success: import_picocolors.default.green,
|
|
5386
|
+
dim: import_picocolors.default.dim,
|
|
5387
|
+
gray: import_picocolors.default.gray,
|
|
5388
|
+
bold: import_picocolors.default.bold
|
|
5389
|
+
};
|
|
5312
5390
|
const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
|
|
5313
5391
|
const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
|
|
5314
5392
|
const FALSY_VALUES = new Set([
|
|
@@ -5928,6 +6006,11 @@ const trimOrNull = (value) => {
|
|
|
5928
6006
|
* `@{` reflog suffix, or any character outside `[A-Za-z0-9_./-]`.
|
|
5929
6007
|
*/
|
|
5930
6008
|
const SAFE_GIT_REVISION_PATTERN = /^[A-Za-z0-9_./-]+$/;
|
|
6009
|
+
/** Human-readable summary of the `isSafeGitRevision` contract, reused across error details. */
|
|
6010
|
+
const GIT_REF_NAME_RULE = "must match [A-Za-z0-9_./-] without leading '-', '..', or '@{'";
|
|
6011
|
+
/** git's two range operators: two-dot (direct) and three-dot (merge-base). */
|
|
6012
|
+
const DIFF_RANGE_OPERATOR = "..";
|
|
6013
|
+
const SYMMETRIC_DIFF_RANGE_OPERATOR = "...";
|
|
5931
6014
|
const isSafeGitRevision = (candidate) => {
|
|
5932
6015
|
if (candidate.length === 0) return false;
|
|
5933
6016
|
if (candidate.startsWith("-")) return false;
|
|
@@ -5935,6 +6018,31 @@ const isSafeGitRevision = (candidate) => {
|
|
|
5935
6018
|
if (candidate.includes("..") || candidate.includes("@{")) return false;
|
|
5936
6019
|
return SAFE_GIT_REVISION_PATTERN.test(candidate);
|
|
5937
6020
|
};
|
|
6021
|
+
/**
|
|
6022
|
+
* Splits a git revision range into its endpoints: three-dot `A...B`
|
|
6023
|
+
* (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
|
|
6024
|
+
* when `value` carries no range operator so the caller falls back to
|
|
6025
|
+
* single-base resolution.
|
|
6026
|
+
*
|
|
6027
|
+
* Only the first operator is split on; any leftover `..` stays inside an
|
|
6028
|
+
* endpoint so `isSafeGitRevision` rejects malformed input like
|
|
6029
|
+
* `A..B..C` instead of silently guessing which pair the user meant.
|
|
6030
|
+
*/
|
|
6031
|
+
const parseGitDiffRange = (value) => {
|
|
6032
|
+
const symmetricIndex = value.indexOf(SYMMETRIC_DIFF_RANGE_OPERATOR);
|
|
6033
|
+
if (symmetricIndex !== -1) return {
|
|
6034
|
+
base: value.slice(0, symmetricIndex),
|
|
6035
|
+
head: value.slice(symmetricIndex + 3),
|
|
6036
|
+
symmetric: true
|
|
6037
|
+
};
|
|
6038
|
+
const rangeIndex = value.indexOf(DIFF_RANGE_OPERATOR);
|
|
6039
|
+
if (rangeIndex !== -1) return {
|
|
6040
|
+
base: value.slice(0, rangeIndex),
|
|
6041
|
+
head: value.slice(rangeIndex + 2),
|
|
6042
|
+
symmetric: false
|
|
6043
|
+
};
|
|
6044
|
+
return null;
|
|
6045
|
+
};
|
|
5938
6046
|
const parseGithubRepoFromRemoteUrl = (remoteUrl) => {
|
|
5939
6047
|
const withoutGitSuffix = remoteUrl.trim().replace(/\.git$/, "");
|
|
5940
6048
|
const sshMatch = /^git@github\.com:([^/\s]+)\/([^/\s]+)$/.exec(withoutGitSuffix);
|
|
@@ -6086,6 +6194,49 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6086
6194
|
if (result.status !== 0) return null;
|
|
6087
6195
|
return parseGithubViewerPermission(result.stdout);
|
|
6088
6196
|
}).pipe(Effect.catch(() => Effect.succeed(null)));
|
|
6197
|
+
/**
|
|
6198
|
+
* Resolves a `--diff A..B` / `A...B` commit range into a changed-file
|
|
6199
|
+
* selection. Each endpoint is validated with `isSafeGitRevision`
|
|
6200
|
+
* BEFORE it reaches `git` (so the range syntax can't smuggle a
|
|
6201
|
+
* `--upload-pack=…`-style option past the CVE-2018-17456 guard) and
|
|
6202
|
+
* verified to exist, then the diff runs between the two commits with
|
|
6203
|
+
* the same `--diff-filter=ACMR` shape the single-base path uses.
|
|
6204
|
+
*/
|
|
6205
|
+
const resolveDiffRange = (input) => Effect.gen(function* () {
|
|
6206
|
+
if (input.range.base.length === 0 && input.range.head.length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" must name at least one commit (e.g. "main..feature").` }) }));
|
|
6207
|
+
const baseRef = input.range.base.length === 0 ? "HEAD" : input.range.base;
|
|
6208
|
+
const headRef = input.range.head.length === 0 ? "HEAD" : input.range.head;
|
|
6209
|
+
for (const endpoint of [baseRef, headRef]) if (!isSafeGitRevision(endpoint)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" has an invalid endpoint "${endpoint}" (${GIT_REF_NAME_RULE}).` }) }));
|
|
6210
|
+
for (const endpoint of [baseRef, headRef]) if (!(yield* branchExists(input.directory, endpoint))) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: endpoint }) }));
|
|
6211
|
+
let diffBaseRef = baseRef;
|
|
6212
|
+
if (input.range.symmetric) {
|
|
6213
|
+
const mergeBase = yield* runGit(input.directory, [
|
|
6214
|
+
"merge-base",
|
|
6215
|
+
baseRef,
|
|
6216
|
+
headRef
|
|
6217
|
+
]);
|
|
6218
|
+
if (mergeBase.status !== 0) return null;
|
|
6219
|
+
const mergeBaseRef = trimOrNull(mergeBase.stdout);
|
|
6220
|
+
if (mergeBaseRef === null) return null;
|
|
6221
|
+
diffBaseRef = mergeBaseRef;
|
|
6222
|
+
}
|
|
6223
|
+
const diff = yield* runGit(input.directory, [
|
|
6224
|
+
"diff",
|
|
6225
|
+
"-z",
|
|
6226
|
+
"--name-only",
|
|
6227
|
+
"--diff-filter=ACMR",
|
|
6228
|
+
"--relative",
|
|
6229
|
+
diffBaseRef,
|
|
6230
|
+
headRef
|
|
6231
|
+
]);
|
|
6232
|
+
if (diff.status !== 0) return null;
|
|
6233
|
+
return {
|
|
6234
|
+
currentBranch: yield* currentBranch(input.directory),
|
|
6235
|
+
baseBranch: baseRef,
|
|
6236
|
+
changedFiles: splitNullSeparated(diff.stdout),
|
|
6237
|
+
isCurrentChanges: false
|
|
6238
|
+
};
|
|
6239
|
+
});
|
|
6089
6240
|
return Git.of({
|
|
6090
6241
|
currentBranch,
|
|
6091
6242
|
defaultBranch,
|
|
@@ -6095,7 +6246,15 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6095
6246
|
branchExists,
|
|
6096
6247
|
diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
|
|
6097
6248
|
if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
|
|
6098
|
-
if (explicitBaseBranch !== void 0
|
|
6249
|
+
if (explicitBaseBranch !== void 0) {
|
|
6250
|
+
const range = parseGitDiffRange(explicitBaseBranch);
|
|
6251
|
+
if (range !== null) return yield* resolveDiffRange({
|
|
6252
|
+
directory,
|
|
6253
|
+
range,
|
|
6254
|
+
raw: explicitBaseBranch
|
|
6255
|
+
});
|
|
6256
|
+
if (!isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (${GIT_REF_NAME_RULE}).` }) }));
|
|
6257
|
+
}
|
|
6099
6258
|
const resolvedCurrentBranch = yield* currentBranch(directory);
|
|
6100
6259
|
if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
|
|
6101
6260
|
const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
|
|
@@ -7404,6 +7563,21 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
|
|
|
7404
7563
|
resolve(output);
|
|
7405
7564
|
});
|
|
7406
7565
|
});
|
|
7566
|
+
const PARALLELISM_EXHAUSTION_ERROR_CODES = new Set([
|
|
7567
|
+
"EAGAIN",
|
|
7568
|
+
"EMFILE",
|
|
7569
|
+
"ENFILE",
|
|
7570
|
+
"ENOMEM"
|
|
7571
|
+
]);
|
|
7572
|
+
const isParallelismRelatedSpawnError = (error) => {
|
|
7573
|
+
if (!(error instanceof ReactDoctorError)) return false;
|
|
7574
|
+
const { reason } = error;
|
|
7575
|
+
if (reason._tag !== "OxlintSpawnFailed") return false;
|
|
7576
|
+
const { cause } = reason;
|
|
7577
|
+
if (typeof cause !== "object" || cause === null || !("code" in cause)) return false;
|
|
7578
|
+
const { code } = cause;
|
|
7579
|
+
return typeof code === "string" && PARALLELISM_EXHAUSTION_ERROR_CODES.has(code);
|
|
7580
|
+
};
|
|
7407
7581
|
/**
|
|
7408
7582
|
* Runs every prebuilt file batch through oxlint, with binary-split
|
|
7409
7583
|
* retry on the splittable error classes (timeout / output-too-large /
|
|
@@ -7412,66 +7586,83 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
|
|
|
7412
7586
|
* (surfaced via `onPartialFailure`) so JSON-mode consumers see WHICH
|
|
7413
7587
|
* files were skipped instead of silently losing them.
|
|
7414
7588
|
*
|
|
7415
|
-
*
|
|
7416
|
-
*
|
|
7417
|
-
*
|
|
7418
|
-
*
|
|
7589
|
+
* Parallel runs (concurrency > 1) get one extra safety net: if the pass
|
|
7590
|
+
* fails with a resource-exhaustion error that's exclusive to running
|
|
7591
|
+
* many oxlint subprocesses at once (EAGAIN / EMFILE / ENFILE / ENOMEM —
|
|
7592
|
+
* see `isParallelismRelatedSpawnError`), the whole pass replays once
|
|
7593
|
+
* with a single worker. That's the only failure a serial replay can
|
|
7594
|
+
* clear, so every other error class is left to propagate.
|
|
7595
|
+
*
|
|
7596
|
+
* Errors that aren't splittable and aren't parallelism-related (oxlint
|
|
7597
|
+
* config crash, JS plugin resolution failure, etc.) propagate to the
|
|
7598
|
+
* caller — the `runOxlint` retry-without-extends fallback re-spawns this
|
|
7599
|
+
* loop with a slimmer config in that case.
|
|
7419
7600
|
*/
|
|
7420
7601
|
const spawnLintBatches = async (input) => {
|
|
7421
7602
|
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes } = input;
|
|
7422
|
-
const
|
|
7603
|
+
const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
|
|
7423
7604
|
const totalFileCount = fileBatches.reduce((sum, batch) => sum + batch.length, 0);
|
|
7424
|
-
const
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
const
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7605
|
+
const runBatchPass = async (concurrency) => {
|
|
7606
|
+
const allDiagnostics = [];
|
|
7607
|
+
const droppedFiles = [];
|
|
7608
|
+
let firstDropReason = null;
|
|
7609
|
+
const spawnLintBatch = async (batch) => {
|
|
7610
|
+
const batchArgs = [...baseArgs, ...batch];
|
|
7611
|
+
try {
|
|
7612
|
+
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes), project, rootDirectory);
|
|
7613
|
+
} catch (error) {
|
|
7614
|
+
if (!isSplittableReactDoctorError(error)) throw error;
|
|
7615
|
+
if (batch.length <= 1) {
|
|
7616
|
+
droppedFiles.push(...batch);
|
|
7617
|
+
if (firstDropReason === null) firstDropReason = error.message;
|
|
7618
|
+
return [];
|
|
7619
|
+
}
|
|
7620
|
+
const splitIndex = Math.ceil(batch.length / 2);
|
|
7621
|
+
return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
|
|
7437
7622
|
}
|
|
7438
|
-
|
|
7439
|
-
|
|
7623
|
+
};
|
|
7624
|
+
let startedFileCount = 0;
|
|
7625
|
+
let scannedFileCount = 0;
|
|
7626
|
+
let displayedFileCount = 0;
|
|
7627
|
+
const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
|
|
7628
|
+
const ceiling = Math.min(startedFileCount, totalFileCount - 1);
|
|
7629
|
+
if (displayedFileCount < ceiling) {
|
|
7630
|
+
displayedFileCount += 1;
|
|
7631
|
+
onFileProgress(displayedFileCount, totalFileCount);
|
|
7632
|
+
}
|
|
7633
|
+
}, 50) : null;
|
|
7634
|
+
progressTimer?.unref?.();
|
|
7635
|
+
try {
|
|
7636
|
+
const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
|
|
7637
|
+
startedFileCount += batch.length;
|
|
7638
|
+
const batchDiagnostics = await spawnLintBatch(batch);
|
|
7639
|
+
scannedFileCount += batch.length;
|
|
7640
|
+
if (onFileProgress) {
|
|
7641
|
+
displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
|
|
7642
|
+
onFileProgress(displayedFileCount, totalFileCount);
|
|
7643
|
+
}
|
|
7644
|
+
return batchDiagnostics;
|
|
7645
|
+
});
|
|
7646
|
+
for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
|
|
7647
|
+
} finally {
|
|
7648
|
+
if (progressTimer !== null) clearInterval(progressTimer);
|
|
7440
7649
|
}
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
const ceiling = Math.min(startedFileCount, totalFileCount - 1);
|
|
7447
|
-
if (displayedFileCount < ceiling) {
|
|
7448
|
-
displayedFileCount += 1;
|
|
7449
|
-
onFileProgress(displayedFileCount, totalFileCount);
|
|
7650
|
+
if (droppedFiles.length > 0 && onPartialFailure) {
|
|
7651
|
+
const previewFiles = droppedFiles.slice(0, 3).join(", ");
|
|
7652
|
+
const remainderHint = droppedFiles.length > 3 ? `, +${droppedFiles.length - 3} more` : "";
|
|
7653
|
+
const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
|
|
7654
|
+
onPartialFailure(`${droppedFiles.length} file(s) failed to lint and were skipped (${previewFiles}${remainderHint})${reasonHint}`);
|
|
7450
7655
|
}
|
|
7451
|
-
|
|
7452
|
-
|
|
7656
|
+
return allDiagnostics;
|
|
7657
|
+
};
|
|
7658
|
+
let diagnostics;
|
|
7453
7659
|
try {
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
if (onFileProgress) {
|
|
7459
|
-
displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
|
|
7460
|
-
onFileProgress(displayedFileCount, totalFileCount);
|
|
7461
|
-
}
|
|
7462
|
-
return batchDiagnostics;
|
|
7463
|
-
});
|
|
7464
|
-
for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
|
|
7465
|
-
} finally {
|
|
7466
|
-
if (progressTimer !== null) clearInterval(progressTimer);
|
|
7467
|
-
}
|
|
7468
|
-
if (droppedFiles.length > 0 && onPartialFailure) {
|
|
7469
|
-
const previewFiles = droppedFiles.slice(0, 3).join(", ");
|
|
7470
|
-
const remainderHint = droppedFiles.length > 3 ? `, +${droppedFiles.length - 3} more` : "";
|
|
7471
|
-
const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
|
|
7472
|
-
onPartialFailure(`${droppedFiles.length} file(s) failed to lint and were skipped (${previewFiles}${remainderHint})${reasonHint}`);
|
|
7660
|
+
diagnostics = await runBatchPass(requestedConcurrency);
|
|
7661
|
+
} catch (error) {
|
|
7662
|
+
if (requestedConcurrency <= 1 || !isParallelismRelatedSpawnError(error)) throw error;
|
|
7663
|
+
diagnostics = await runBatchPass(1);
|
|
7473
7664
|
}
|
|
7474
|
-
return dedupeDiagnostics(
|
|
7665
|
+
return dedupeDiagnostics(diagnostics);
|
|
7475
7666
|
};
|
|
7476
7667
|
let didValidate = false;
|
|
7477
7668
|
/**
|
|
@@ -8030,7 +8221,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8030
8221
|
reason: null
|
|
8031
8222
|
});
|
|
8032
8223
|
const scanConcurrency = yield* OxlintConcurrency;
|
|
8033
|
-
const workerCountSuffix = scanConcurrency > 1 ? `
|
|
8224
|
+
const workerCountSuffix = scanConcurrency > 1 ? ` ${highlighter.dim(`[~${scanConcurrency} workers]`)}` : "";
|
|
8034
8225
|
const scanProgress = yield* progressService.start("Scanning...");
|
|
8035
8226
|
const scanStartTime = Date.now();
|
|
8036
8227
|
let lastReportedTotalFileCount = 0;
|
|
@@ -8453,12 +8644,13 @@ const buildSkippedChecks = (input) => {
|
|
|
8453
8644
|
* Git service runs through Effect's `ChildProcess` (true subprocess
|
|
8454
8645
|
* spawn, not `spawnSync`).
|
|
8455
8646
|
*
|
|
8456
|
-
*
|
|
8457
|
-
*
|
|
8458
|
-
*
|
|
8459
|
-
*
|
|
8460
|
-
*
|
|
8461
|
-
*
|
|
8647
|
+
* Failures propagate as the tagged `ReactDoctorError` (rejected by
|
|
8648
|
+
* `Effect.runPromise`) rather than being flattened into a plain
|
|
8649
|
+
* `Error`. The message is unchanged — `ReactDoctorError.message`
|
|
8650
|
+
* defers to `reason.message` — so message-matching callers keep
|
|
8651
|
+
* working, while the CLI can now dispatch on `error.reason._tag` to
|
|
8652
|
+
* render diff-base mistakes (`GitBaseBranchInvalid` /
|
|
8653
|
+
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
8462
8654
|
*/
|
|
8463
8655
|
const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.gen(function* () {
|
|
8464
8656
|
const selection = yield* (yield* Git).diffSelection({
|
|
@@ -8472,78 +8664,8 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
|
|
|
8472
8664
|
changedFiles: [...selection.changedFiles],
|
|
8473
8665
|
...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
|
|
8474
8666
|
};
|
|
8475
|
-
}).pipe(Effect.provide(Git.layerNode)
|
|
8476
|
-
GitBaseBranchInvalid: (reason) => Effect.die(new Error(reason.detail)),
|
|
8477
|
-
GitBaseBranchMissing: (reason) => Effect.die(new Error(reason.message))
|
|
8478
|
-
})));
|
|
8667
|
+
}).pipe(Effect.provide(Git.layerNode)));
|
|
8479
8668
|
const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
|
|
8480
|
-
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8481
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
8482
|
-
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
8483
|
-
let formatter = (open, close, replace = open) => (input) => {
|
|
8484
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
8485
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
8486
|
-
};
|
|
8487
|
-
let replaceClose = (string, close, replace, index) => {
|
|
8488
|
-
let result = "", cursor = 0;
|
|
8489
|
-
do {
|
|
8490
|
-
result += string.substring(cursor, index) + replace;
|
|
8491
|
-
cursor = index + close.length;
|
|
8492
|
-
index = string.indexOf(close, cursor);
|
|
8493
|
-
} while (~index);
|
|
8494
|
-
return result + string.substring(cursor);
|
|
8495
|
-
};
|
|
8496
|
-
let createColors = (enabled = isColorSupported) => {
|
|
8497
|
-
let f = enabled ? formatter : () => String;
|
|
8498
|
-
return {
|
|
8499
|
-
isColorSupported: enabled,
|
|
8500
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
8501
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
8502
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
8503
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
8504
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
8505
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
8506
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
8507
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
8508
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
8509
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
8510
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
8511
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
8512
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
8513
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
8514
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
8515
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
8516
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
8517
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
8518
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
8519
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
8520
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
8521
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
8522
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
8523
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
8524
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
8525
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
8526
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
8527
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
8528
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
8529
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
8530
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
8531
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
8532
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
8533
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
8534
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
8535
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
8536
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
8537
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
8538
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
8539
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
8540
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
8541
|
-
};
|
|
8542
|
-
};
|
|
8543
|
-
module.exports = createColors();
|
|
8544
|
-
module.exports.createColors = createColors;
|
|
8545
|
-
})))(), 1);
|
|
8546
|
-
import_picocolors.default.red, import_picocolors.default.yellow, import_picocolors.default.cyan, import_picocolors.default.green, import_picocolors.default.dim, import_picocolors.default.gray, import_picocolors.default.bold;
|
|
8547
8669
|
/**
|
|
8548
8670
|
* Back-compat alias: the streaming pipeline holds its caches in
|
|
8549
8671
|
* per-pipeline closures that are garbage-collected when the pipeline
|
|
@@ -8620,4 +8742,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8620
8742
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8621
8743
|
|
|
8622
8744
|
//# sourceMappingURL=index.js.map
|
|
8623
|
-
//# debugId=
|
|
8745
|
+
//# debugId=a56b86f0-1c28-52ae-9677-12f5e67df34f
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16-dev.2d1ab24",
|
|
4
4
|
"description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"oxlint": "^1.66.0",
|
|
64
64
|
"prompts": "^2.4.2",
|
|
65
65
|
"typescript": ">=5.0.4 <7",
|
|
66
|
-
"oxlint-plugin-react-doctor": "0.2.
|
|
66
|
+
"oxlint-plugin-react-doctor": "0.2.16-dev.2d1ab24"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"@xterm/headless": "^6.0.0",
|
|
72
72
|
"commander": "^14.0.3",
|
|
73
73
|
"ora": "^9.4.0",
|
|
74
|
-
"@react-doctor/
|
|
75
|
-
"@react-doctor/
|
|
74
|
+
"@react-doctor/core": "0.2.16",
|
|
75
|
+
"@react-doctor/api": "0.2.16"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": "^20.19.0 || >=22.12.0"
|