react-doctor 0.2.17-dev.5614b32 → 0.2.18-dev.8d13ba3
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/dist/cli.js +80 -47
- package/dist/index.d.ts +16 -1
- package/dist/index.js +8 -26
- package/package.json +4 -4
package/dist/cli.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]="07713237-df07-5858-b7a4-7b12c0e7b293")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as Path from "node:path";
|
|
@@ -5054,33 +5054,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
5054
5054
|
value: mod,
|
|
5055
5055
|
enumerable: true
|
|
5056
5056
|
}) : target, mod));
|
|
5057
|
-
/**
|
|
5058
|
-
* Narrow errors raised by the project-discovery helpers
|
|
5059
|
-
* (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
|
|
5060
|
-
*
|
|
5061
|
-
* These extend `Error` directly — they are NOT the tagged
|
|
5062
|
-
* `ReactDoctorError` from `../errors.js` (that one wraps every
|
|
5063
|
-
* runtime-pipeline failure as a `Schema.TaggedErrorClass` for
|
|
5064
|
-
* `Effect.catchReasons` dispatch). The split is intentional:
|
|
5065
|
-
*
|
|
5066
|
-
* - Discovery happens BEFORE the Effect runtime takes over — at the
|
|
5067
|
-
* `diagnose()` / CLI entry point — and throws plain JS exceptions
|
|
5068
|
-
* so callers can `try/catch` without an Effect-layer-aware
|
|
5069
|
-
* `instanceof` check.
|
|
5070
|
-
* - The Project service (`services/project.ts → translateProjectInfoError`)
|
|
5071
|
-
* translates each of these into the equivalent tagged-error
|
|
5072
|
-
* `reason` before re-raising inside the Effect pipeline, so the
|
|
5073
|
-
* runtime never sees a non-tagged failure.
|
|
5074
|
-
*
|
|
5075
|
-
* If you're inside the Effect runtime, use the tagged
|
|
5076
|
-
* `ReactDoctorError` from `../errors.js` instead.
|
|
5077
|
-
*/
|
|
5078
5057
|
var ProjectNotFoundError = class extends Error {
|
|
5079
5058
|
name = "ProjectNotFoundError";
|
|
5080
5059
|
directory;
|
|
5060
|
+
kind;
|
|
5081
5061
|
constructor(directory, options) {
|
|
5082
|
-
|
|
5062
|
+
const kind = options?.kind ?? "no-project";
|
|
5063
|
+
super(kind === "missing-path" ? `Scan target "${directory}" does not exist. Check the path and try again.` : `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
|
|
5083
5064
|
this.directory = directory;
|
|
5065
|
+
this.kind = kind;
|
|
5084
5066
|
}
|
|
5085
5067
|
};
|
|
5086
5068
|
var NoReactDependencyError = class extends Error {
|
|
@@ -5117,6 +5099,7 @@ var AmbiguousProjectError = class extends Error {
|
|
|
5117
5099
|
this.candidates = candidates;
|
|
5118
5100
|
}
|
|
5119
5101
|
};
|
|
5102
|
+
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
5120
5103
|
const isFile = (filePath) => {
|
|
5121
5104
|
try {
|
|
5122
5105
|
return fs.statSync(filePath).isFile();
|
|
@@ -7701,7 +7684,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
|
|
|
7701
7684
|
const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
|
|
7702
7685
|
const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
|
|
7703
7686
|
const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
|
|
7704
|
-
if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory);
|
|
7687
|
+
if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
|
|
7705
7688
|
return {
|
|
7706
7689
|
resolvedDirectory,
|
|
7707
7690
|
requestedDirectory: absoluteRequested,
|
|
@@ -9203,7 +9186,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
9203
9186
|
if (result.status !== 0) return null;
|
|
9204
9187
|
const branch = trimOrNull(result.stdout);
|
|
9205
9188
|
return branch === "HEAD" ? null : branch;
|
|
9206
|
-
}));
|
|
9189
|
+
}), Effect.orElseSucceed(() => null));
|
|
9207
9190
|
const defaultBranch = (directory) => Effect.gen(function* () {
|
|
9208
9191
|
const symref = yield* runGit(directory, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
|
|
9209
9192
|
if (symref.status === 0) {
|
|
@@ -11948,7 +11931,7 @@ const makeNoopConsole = () => ({
|
|
|
11948
11931
|
});
|
|
11949
11932
|
//#endregion
|
|
11950
11933
|
//#region src/cli/utils/version.ts
|
|
11951
|
-
const VERSION = "0.2.
|
|
11934
|
+
const VERSION = "0.2.18-dev.8d13ba3";
|
|
11952
11935
|
//#endregion
|
|
11953
11936
|
//#region src/cli/utils/json-mode.ts
|
|
11954
11937
|
let context = null;
|
|
@@ -12294,13 +12277,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12294
12277
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12295
12278
|
* standard `SENTRY_RELEASE` override.
|
|
12296
12279
|
*/
|
|
12297
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.
|
|
12280
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.8d13ba3`;
|
|
12298
12281
|
/**
|
|
12299
12282
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12300
12283
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12301
12284
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12302
12285
|
*/
|
|
12303
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.
|
|
12286
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.8d13ba3") ? "development" : "production");
|
|
12304
12287
|
/**
|
|
12305
12288
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12306
12289
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -17019,6 +17002,49 @@ const handleUserError = (error, options = {}) => {
|
|
|
17019
17002
|
process.exitCode = 1;
|
|
17020
17003
|
};
|
|
17021
17004
|
//#endregion
|
|
17005
|
+
//#region src/cli/utils/cli-input-error.ts
|
|
17006
|
+
/**
|
|
17007
|
+
* A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
|
|
17008
|
+
* argument, mutually exclusive flags, or an unknown `--project` name. This is
|
|
17009
|
+
* user input, not a react-doctor bug, so `isExpectedUserError` routes it
|
|
17010
|
+
* through `handleUserError`: a clean, single-line message with no Sentry
|
|
17011
|
+
* report and no "Something went wrong, open a prefilled issue" block.
|
|
17012
|
+
*
|
|
17013
|
+
* The `message` is rendered verbatim, so it must read as a complete,
|
|
17014
|
+
* human-readable sentence that tells the user how to fix their invocation.
|
|
17015
|
+
*/
|
|
17016
|
+
var CliInputError = class extends Error {
|
|
17017
|
+
name = "CliInputError";
|
|
17018
|
+
};
|
|
17019
|
+
//#endregion
|
|
17020
|
+
//#region src/cli/utils/is-expected-user-error.ts
|
|
17021
|
+
/**
|
|
17022
|
+
* Whether `error` is an expected, user-actionable failure — the user's project
|
|
17023
|
+
* or input, not a react-doctor bug. Such failures must be kept out of crash
|
|
17024
|
+
* reporting (Sentry + the alertable error-rate metric) and rendered via
|
|
17025
|
+
* `handleUserError` (a plain message — no "Something went wrong", prefilled
|
|
17026
|
+
* issue, Discord link, or Sentry reference), since there is no bug to report.
|
|
17027
|
+
*
|
|
17028
|
+
* Three distinct shapes reach the CLI's catch blocks:
|
|
17029
|
+
*
|
|
17030
|
+
* - **Project-discovery failures** (`NoReactDependencyError`,
|
|
17031
|
+
* `ProjectNotFoundError`, `PackageJsonNotFoundError`, `NotADirectoryError`,
|
|
17032
|
+
* `AmbiguousProjectError`) arrive as their plain legacy classes (so
|
|
17033
|
+
* `isReactDoctorError` is `false` for them) — narrow with
|
|
17034
|
+
* `isProjectDiscoveryError`. Running react-doctor against a directory that
|
|
17035
|
+
* has no React, or a path that doesn't exist, is the canonical example.
|
|
17036
|
+
* - **CLI invocation mistakes** (`CliInputError`): a malformed
|
|
17037
|
+
* `<file>:<line>` argument, mutually exclusive flags, or an unknown
|
|
17038
|
+
* `--project` name.
|
|
17039
|
+
* - **Bad `--diff` input** (`GitBaseBranchInvalid` / `GitBaseBranchMissing`)
|
|
17040
|
+
* stays the tagged `ReactDoctorError`, so dispatch on the reason `_tag`.
|
|
17041
|
+
*
|
|
17042
|
+
* This composes the existing core narrowers rather than introducing a new
|
|
17043
|
+
* error-shape helper (AGENTS.md): it encodes CLI-layer reporting policy, not
|
|
17044
|
+
* knowledge of the `ReactDoctorError` shape.
|
|
17045
|
+
*/
|
|
17046
|
+
const isExpectedUserError = (error) => error instanceof CliInputError || isProjectDiscoveryError(error) || isReactDoctorError(error) && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
|
|
17047
|
+
//#endregion
|
|
17022
17048
|
//#region src/cli/utils/build-handoff-payload.ts
|
|
17023
17049
|
const buildHandoffPayload = (input) => {
|
|
17024
17050
|
const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
|
|
@@ -18543,6 +18569,7 @@ const playWelcomeScene = () => Effect.gen(function* () {
|
|
|
18543
18569
|
*/
|
|
18544
18570
|
const reportErrorToSentry = async (error) => {
|
|
18545
18571
|
if (!Sentry.isInitialized()) return void 0;
|
|
18572
|
+
if (isExpectedUserError(error)) return void 0;
|
|
18546
18573
|
try {
|
|
18547
18574
|
const { tags, contexts } = buildSentryScope();
|
|
18548
18575
|
let reason = "unknown";
|
|
@@ -18682,7 +18709,11 @@ const getSetupPromptStore = (options = {}) => new Conf({
|
|
|
18682
18709
|
});
|
|
18683
18710
|
const getSetupPromptProjectKey = (projectRoot) => createHash("sha256").update(path.resolve(projectRoot)).digest("hex");
|
|
18684
18711
|
const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
|
|
18685
|
-
|
|
18712
|
+
try {
|
|
18713
|
+
return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
|
|
18714
|
+
} catch {
|
|
18715
|
+
return false;
|
|
18716
|
+
}
|
|
18686
18717
|
};
|
|
18687
18718
|
const resolveInstallSetupProjectRoot = (options) => {
|
|
18688
18719
|
if (options.scanDirectories.length === 0) return findNearestPackageDirectory(options.scanRoot) ?? options.scanRoot;
|
|
@@ -18900,12 +18931,12 @@ const findOwningProjectDirectory = (rootDirectory, filePath) => {
|
|
|
18900
18931
|
//#region src/cli/utils/parse-file-line-argument.ts
|
|
18901
18932
|
const parseFileLineArgument = (rawArgument) => {
|
|
18902
18933
|
const lastColonIndex = rawArgument.lastIndexOf(":");
|
|
18903
|
-
if (lastColonIndex < 0) throw new
|
|
18934
|
+
if (lastColonIndex < 0) throw new CliInputError(`Expected "<file>:<line>" (e.g. "src/foo.tsx:42"), got "${rawArgument}".`);
|
|
18904
18935
|
const filePath = rawArgument.slice(0, lastColonIndex);
|
|
18905
18936
|
const lineText = rawArgument.slice(lastColonIndex + 1);
|
|
18906
|
-
if (filePath.length === 0) throw new
|
|
18937
|
+
if (filePath.length === 0) throw new CliInputError(`Missing file path in "${rawArgument}".`);
|
|
18907
18938
|
const line = Number.parseInt(lineText, 10);
|
|
18908
|
-
if (!Number.isFinite(line) || line <= 0 || String(line) !== lineText.trim()) throw new
|
|
18939
|
+
if (!Number.isFinite(line) || line <= 0 || String(line) !== lineText.trim()) throw new CliInputError(`Expected a positive line number in "${rawArgument}".`);
|
|
18909
18940
|
return {
|
|
18910
18941
|
filePath,
|
|
18911
18942
|
line
|
|
@@ -18934,10 +18965,7 @@ const resolveProjectFlag = (projectFlag, workspacePackages) => {
|
|
|
18934
18965
|
const resolvedDirectories = [];
|
|
18935
18966
|
for (const requestedName of requestedNames) {
|
|
18936
18967
|
const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || path.basename(workspacePackage.directory) === requestedName);
|
|
18937
|
-
if (!matched) {
|
|
18938
|
-
const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
|
|
18939
|
-
throw new Error(`Project "${requestedName}" not found. Available: ${availableNames}`);
|
|
18940
|
-
}
|
|
18968
|
+
if (!matched) throw new CliInputError(`Project "${requestedName}" not found. Available: ${workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
|
|
18941
18969
|
resolvedDirectories.push(matched.directory);
|
|
18942
18970
|
}
|
|
18943
18971
|
return resolvedDirectories;
|
|
@@ -19017,14 +19045,14 @@ const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
|
|
|
19017
19045
|
const validateModeFlags = (flags) => {
|
|
19018
19046
|
const coercedDiff = coerceDiffValue(flags.diff);
|
|
19019
19047
|
const exclusiveModes = [flags.staged ? "--staged" : null, coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null].filter((modeName) => modeName !== null);
|
|
19020
|
-
if (exclusiveModes.length > 1) throw new
|
|
19021
|
-
if (flags.yes && flags.full) throw new
|
|
19022
|
-
if (flags.score && flags.json) throw new
|
|
19023
|
-
if (flags.score && flags.telemetry === false) throw new
|
|
19024
|
-
if (flags.prComment && (flags.json || flags.score)) throw new
|
|
19025
|
-
if (flags.annotations && flags.score) throw new
|
|
19026
|
-
if (flags.explain !== void 0 && flags.why !== void 0) throw new
|
|
19027
|
-
if ((flags.explain ?? flags.why) !== void 0 && (flags.json || flags.score || flags.annotations || flags.staged)) throw new
|
|
19048
|
+
if (exclusiveModes.length > 1) throw new CliInputError(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
|
|
19049
|
+
if (flags.yes && flags.full) throw new CliInputError("Cannot combine --yes and --full; pick one.");
|
|
19050
|
+
if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
|
|
19051
|
+
if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
|
|
19052
|
+
if (flags.prComment && (flags.json || flags.score)) throw new CliInputError("--pr-comment cannot be combined with --json or --score.");
|
|
19053
|
+
if (flags.annotations && flags.score) throw new CliInputError("--annotations cannot be combined with --score.");
|
|
19054
|
+
if (flags.explain !== void 0 && flags.why !== void 0) throw new CliInputError("Use --explain or --why, not both — they're aliases of the same flag.");
|
|
19055
|
+
if ((flags.explain ?? flags.why) !== void 0 && (flags.json || flags.score || flags.annotations || flags.staged)) throw new CliInputError("--explain cannot be combined with --json, --score, --annotations, or --staged.");
|
|
19028
19056
|
};
|
|
19029
19057
|
//#endregion
|
|
19030
19058
|
//#region src/cli/commands/inspect.ts
|
|
@@ -19272,7 +19300,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
19272
19300
|
}
|
|
19273
19301
|
}
|
|
19274
19302
|
} catch (error) {
|
|
19275
|
-
const isUserError =
|
|
19303
|
+
const isUserError = isExpectedUserError(error);
|
|
19276
19304
|
const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
|
|
19277
19305
|
if (isJsonMode) {
|
|
19278
19306
|
writeJsonErrorReport(error);
|
|
@@ -20166,15 +20194,20 @@ if (process.argv.includes("-V") && !strippedArgv.includes("-V")) {
|
|
|
20166
20194
|
applyColorPreference(strippedArgv);
|
|
20167
20195
|
const argv = normalizeHelpInvocation(strippedArgv, knownCommands);
|
|
20168
20196
|
program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
20169
|
-
const
|
|
20197
|
+
const isUserError = isExpectedUserError(error);
|
|
20198
|
+
const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
|
|
20170
20199
|
if (isJsonModeActive()) {
|
|
20171
20200
|
writeJsonErrorReport(error);
|
|
20172
20201
|
process.exit(1);
|
|
20173
20202
|
}
|
|
20203
|
+
if (isUserError) {
|
|
20204
|
+
handleUserError(error);
|
|
20205
|
+
return;
|
|
20206
|
+
}
|
|
20174
20207
|
handleError(error, { sentryEventId });
|
|
20175
20208
|
});
|
|
20176
20209
|
//#endregion
|
|
20177
20210
|
export {};
|
|
20178
20211
|
|
|
20179
20212
|
//# sourceMappingURL=cli.js.map
|
|
20180
|
-
//# debugId=
|
|
20213
|
+
//# debugId=07713237-df07-5858-b7a4-7b12c0e7b293
|
package/dist/index.d.ts
CHANGED
|
@@ -610,10 +610,25 @@ interface JsonReport {
|
|
|
610
610
|
* If you're inside the Effect runtime, use the tagged
|
|
611
611
|
* `ReactDoctorError` from `../errors.js` instead.
|
|
612
612
|
*/
|
|
613
|
+
/**
|
|
614
|
+
* Distinguishes the two situations that both surface as "no project here", so
|
|
615
|
+
* the rendered message matches reality:
|
|
616
|
+
*
|
|
617
|
+
* - `no-project` (default): the path exists but has no React project — no
|
|
618
|
+
* `package.json` at the root and no discoverable nested React subproject.
|
|
619
|
+
* - `missing-path`: the resolved scan target does not exist on disk at all
|
|
620
|
+
* (a typo, a stale temp path, a monorepo subdir that isn't present). The
|
|
621
|
+
* generic "expected a package.json" guidance is misleading here, so point
|
|
622
|
+
* at the missing path instead.
|
|
623
|
+
*/
|
|
624
|
+
interface ProjectNotFoundOptions extends ErrorOptions {
|
|
625
|
+
readonly kind?: "no-project" | "missing-path";
|
|
626
|
+
}
|
|
613
627
|
declare class ProjectNotFoundError extends Error {
|
|
614
628
|
readonly name = "ProjectNotFoundError";
|
|
615
629
|
readonly directory: string;
|
|
616
|
-
|
|
630
|
+
readonly kind: "no-project" | "missing-path";
|
|
631
|
+
constructor(directory: string, options?: ProjectNotFoundOptions);
|
|
617
632
|
}
|
|
618
633
|
declare class NoReactDependencyError extends Error {
|
|
619
634
|
readonly name = "NoReactDependencyError";
|
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]="9b91fa51-6642-5351-a848-af91945dec6f")}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";
|
|
@@ -2027,33 +2027,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
2027
2027
|
value: mod,
|
|
2028
2028
|
enumerable: true
|
|
2029
2029
|
}) : target, mod));
|
|
2030
|
-
/**
|
|
2031
|
-
* Narrow errors raised by the project-discovery helpers
|
|
2032
|
-
* (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
|
|
2033
|
-
*
|
|
2034
|
-
* These extend `Error` directly — they are NOT the tagged
|
|
2035
|
-
* `ReactDoctorError` from `../errors.js` (that one wraps every
|
|
2036
|
-
* runtime-pipeline failure as a `Schema.TaggedErrorClass` for
|
|
2037
|
-
* `Effect.catchReasons` dispatch). The split is intentional:
|
|
2038
|
-
*
|
|
2039
|
-
* - Discovery happens BEFORE the Effect runtime takes over — at the
|
|
2040
|
-
* `diagnose()` / CLI entry point — and throws plain JS exceptions
|
|
2041
|
-
* so callers can `try/catch` without an Effect-layer-aware
|
|
2042
|
-
* `instanceof` check.
|
|
2043
|
-
* - The Project service (`services/project.ts → translateProjectInfoError`)
|
|
2044
|
-
* translates each of these into the equivalent tagged-error
|
|
2045
|
-
* `reason` before re-raising inside the Effect pipeline, so the
|
|
2046
|
-
* runtime never sees a non-tagged failure.
|
|
2047
|
-
*
|
|
2048
|
-
* If you're inside the Effect runtime, use the tagged
|
|
2049
|
-
* `ReactDoctorError` from `../errors.js` instead.
|
|
2050
|
-
*/
|
|
2051
2030
|
var ProjectNotFoundError = class extends Error {
|
|
2052
2031
|
name = "ProjectNotFoundError";
|
|
2053
2032
|
directory;
|
|
2033
|
+
kind;
|
|
2054
2034
|
constructor(directory, options) {
|
|
2055
|
-
|
|
2035
|
+
const kind = options?.kind ?? "no-project";
|
|
2036
|
+
super(kind === "missing-path" ? `Scan target "${directory}" does not exist. Check the path and try again.` : `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
|
|
2056
2037
|
this.directory = directory;
|
|
2038
|
+
this.kind = kind;
|
|
2057
2039
|
}
|
|
2058
2040
|
};
|
|
2059
2041
|
var NoReactDependencyError = class extends Error {
|
|
@@ -4651,7 +4633,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
|
|
|
4651
4633
|
const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
|
|
4652
4634
|
const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
|
|
4653
4635
|
const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
|
|
4654
|
-
if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory);
|
|
4636
|
+
if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
|
|
4655
4637
|
return {
|
|
4656
4638
|
resolvedDirectory,
|
|
4657
4639
|
requestedDirectory: absoluteRequested,
|
|
@@ -6137,7 +6119,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6137
6119
|
if (result.status !== 0) return null;
|
|
6138
6120
|
const branch = trimOrNull(result.stdout);
|
|
6139
6121
|
return branch === "HEAD" ? null : branch;
|
|
6140
|
-
}));
|
|
6122
|
+
}), Effect.orElseSucceed(() => null));
|
|
6141
6123
|
const defaultBranch = (directory) => Effect.gen(function* () {
|
|
6142
6124
|
const symref = yield* runGit(directory, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
|
|
6143
6125
|
if (symref.status === 0) {
|
|
@@ -8742,4 +8724,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8742
8724
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8743
8725
|
|
|
8744
8726
|
//# sourceMappingURL=index.js.map
|
|
8745
|
-
//# debugId=
|
|
8727
|
+
//# debugId=9b91fa51-6642-5351-a848-af91945dec6f
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18-dev.8d13ba3",
|
|
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.18-dev.8d13ba3"
|
|
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/api": "0.2.
|
|
75
|
-
"@react-doctor/core": "0.2.
|
|
74
|
+
"@react-doctor/api": "0.2.18",
|
|
75
|
+
"@react-doctor/core": "0.2.18"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": "^20.19.0 || >=22.12.0"
|