react-doctor 0.2.18-dev.caf46a7 → 0.2.18-dev.e3b106e
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 +1 -1
- package/dist/cli.js +249 -17
- package/dist/index.js +8 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ jobs:
|
|
|
70
70
|
`@v1` always resolves to the latest `v1.x` release of the Action. For hardened CI — recommended whenever the workflow is granted `pull-requests: write` — pin to a full commit SHA instead and let Dependabot or Renovate keep it current:
|
|
71
71
|
|
|
72
72
|
```yaml
|
|
73
|
-
|
|
73
|
+
- uses: millionco/react-doctor@b612664043a9be414166e3c6a69b355e39a8dcf4 # v1.1.1
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
[Add GitHub Action →](https://github.com/marketplace/actions/react-doctor)
|
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]="9cef6163-49df-51ef-9157-780c4c678e81")}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";
|
|
@@ -36,13 +36,13 @@ import * as ts from "typescript";
|
|
|
36
36
|
import { gzipSync } from "node:zlib";
|
|
37
37
|
import * as Sentry from "@sentry/node";
|
|
38
38
|
import { performance } from "node:perf_hooks";
|
|
39
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
39
40
|
import * as Tracer from "effect/Tracer";
|
|
40
41
|
import * as Exit from "effect/Exit";
|
|
41
42
|
import { stripVTControlCharacters } from "node:util";
|
|
42
43
|
import tty from "node:tty";
|
|
43
44
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
44
45
|
import Conf from "conf";
|
|
45
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
46
46
|
import basePrompts from "prompts";
|
|
47
47
|
import { SKILL_MANIFEST_FILE, detectInstalledSkillAgents, getSkillAgentConfig, getSkillAgentTypes, installSkillsFromSource } from "agent-install";
|
|
48
48
|
import { fileURLToPath } from "node:url";
|
|
@@ -5157,7 +5157,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
|
5157
5157
|
"EACCES",
|
|
5158
5158
|
"EPERM",
|
|
5159
5159
|
"ENOENT",
|
|
5160
|
-
"ENOTDIR"
|
|
5160
|
+
"ENOTDIR",
|
|
5161
|
+
"EINVAL",
|
|
5162
|
+
"ELOOP",
|
|
5163
|
+
"ENAMETOOLONG"
|
|
5161
5164
|
]);
|
|
5162
5165
|
const isIgnorableReaddirError = (error) => {
|
|
5163
5166
|
if (typeof error !== "object" || error === null) return false;
|
|
@@ -11096,6 +11099,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
11096
11099
|
...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
|
|
11097
11100
|
...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
|
|
11098
11101
|
...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
|
|
11102
|
+
...options.metadata?.runId ? { runId: options.metadata.runId } : {},
|
|
11099
11103
|
...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
|
|
11100
11104
|
...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
|
|
11101
11105
|
...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
|
|
@@ -11335,6 +11339,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
11335
11339
|
sourceFileCount: project.sourceFileCount,
|
|
11336
11340
|
...defaultBranch !== null ? { defaultBranch } : {},
|
|
11337
11341
|
...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
|
|
11342
|
+
...input.runId !== void 0 ? { runId: input.runId } : {},
|
|
11338
11343
|
...githubActionsScoreMetadata,
|
|
11339
11344
|
...githubViewerPermission !== null ? { githubViewerPermission } : {}
|
|
11340
11345
|
};
|
|
@@ -11791,6 +11796,14 @@ const CI_PROVIDER_BY_ENVIRONMENT_VARIABLE = [
|
|
|
11791
11796
|
["TRAVIS", "travis"],
|
|
11792
11797
|
["DRONE", "drone"]
|
|
11793
11798
|
];
|
|
11799
|
+
const GITHUB_ACTION_MARKER_ENVIRONMENT_VARIABLE = "REACT_DOCTOR_GITHUB_ACTION";
|
|
11800
|
+
const ACTION_INPUT_ENVIRONMENT_VARIABLES = {
|
|
11801
|
+
failOn: "REACT_DOCTOR_ACTION_FAIL_ON",
|
|
11802
|
+
nonBlocking: "REACT_DOCTOR_ACTION_NON_BLOCKING",
|
|
11803
|
+
comment: "REACT_DOCTOR_ACTION_COMMENT",
|
|
11804
|
+
annotations: "REACT_DOCTOR_ACTION_ANNOTATIONS",
|
|
11805
|
+
version: "REACT_DOCTOR_ACTION_VERSION"
|
|
11806
|
+
};
|
|
11794
11807
|
const CODING_AGENT_BY_ENVIRONMENT_VARIABLE = [
|
|
11795
11808
|
["CLAUDECODE", "claude-code"],
|
|
11796
11809
|
["CLAUDE_CODE", "claude-code"],
|
|
@@ -11817,6 +11830,9 @@ const detectCiProvider = () => {
|
|
|
11817
11830
|
for (const [environmentVariable, provider] of CI_PROVIDER_BY_ENVIRONMENT_VARIABLE) if (process.env[environmentVariable]) return provider;
|
|
11818
11831
|
return isCiFlagSet(process.env.CI) ? "unknown" : null;
|
|
11819
11832
|
};
|
|
11833
|
+
const isOfficialGithubAction = () => Boolean(process.env[GITHUB_ACTION_MARKER_ENVIRONMENT_VARIABLE]);
|
|
11834
|
+
const detectCiEventName = () => process.env.GITHUB_EVENT_NAME?.trim() || null;
|
|
11835
|
+
const detectRunnerOs = () => process.env.RUNNER_OS?.trim() || null;
|
|
11820
11836
|
const detectCodingAgentFromValue = () => {
|
|
11821
11837
|
for (const environmentVariable of CODING_AGENT_ENVIRONMENT_VALUE_VARIABLES) {
|
|
11822
11838
|
const value = process.env[environmentVariable]?.toLowerCase();
|
|
@@ -11931,7 +11947,7 @@ const makeNoopConsole = () => ({
|
|
|
11931
11947
|
});
|
|
11932
11948
|
//#endregion
|
|
11933
11949
|
//#region src/cli/utils/version.ts
|
|
11934
|
-
const VERSION = "0.2.18-dev.
|
|
11950
|
+
const VERSION = "0.2.18-dev.e3b106e";
|
|
11935
11951
|
//#endregion
|
|
11936
11952
|
//#region src/cli/utils/json-mode.ts
|
|
11937
11953
|
let context = null;
|
|
@@ -12004,6 +12020,13 @@ const writeJsonErrorReport = (error) => {
|
|
|
12004
12020
|
}
|
|
12005
12021
|
};
|
|
12006
12022
|
//#endregion
|
|
12023
|
+
//#region src/cli/utils/run-id.ts
|
|
12024
|
+
let cachedRunId;
|
|
12025
|
+
const getRunId = () => {
|
|
12026
|
+
cachedRunId ??= randomUUID();
|
|
12027
|
+
return cachedRunId;
|
|
12028
|
+
};
|
|
12029
|
+
//#endregion
|
|
12007
12030
|
//#region src/cli/utils/scrub-sensitive-text.ts
|
|
12008
12031
|
const HOME_DIRECTORY = os.homedir();
|
|
12009
12032
|
const USER_HOME_PATTERNS = [/[A-Za-z]:[\\/]Users[\\/][^\\/]+/gi, /(?:\/Users\/|\/home\/)[^/\\]+/gi];
|
|
@@ -12058,6 +12081,7 @@ const buildRunContext = () => {
|
|
|
12058
12081
|
const userArguments = process.argv.slice(2);
|
|
12059
12082
|
return {
|
|
12060
12083
|
version: VERSION,
|
|
12084
|
+
runId: getRunId(),
|
|
12061
12085
|
origin: detectOrigin(),
|
|
12062
12086
|
command: detectCommand(userArguments),
|
|
12063
12087
|
argv: scrubSensitivePaths(userArguments.join(" ")),
|
|
@@ -12068,6 +12092,8 @@ const buildRunContext = () => {
|
|
|
12068
12092
|
arch: process.arch,
|
|
12069
12093
|
ci: isCiEnvironment(),
|
|
12070
12094
|
ciProvider: detectCiProvider(),
|
|
12095
|
+
eventName: detectCiEventName(),
|
|
12096
|
+
viaAction: isOfficialGithubAction(),
|
|
12071
12097
|
codingAgent: detectCodingAgent(),
|
|
12072
12098
|
interactive: !isNonInteractiveEnvironment(),
|
|
12073
12099
|
jsonMode: isJsonModeActive(),
|
|
@@ -12136,6 +12162,8 @@ const buildSentryScope = (runContext = buildRunContext()) => {
|
|
|
12136
12162
|
command: runContext.command,
|
|
12137
12163
|
ci: runContext.ci,
|
|
12138
12164
|
ciProvider: runContext.ciProvider,
|
|
12165
|
+
eventName: runContext.eventName,
|
|
12166
|
+
viaAction: runContext.viaAction,
|
|
12139
12167
|
codingAgent: runContext.codingAgent,
|
|
12140
12168
|
interactive: runContext.interactive,
|
|
12141
12169
|
jsonMode: runContext.jsonMode,
|
|
@@ -12277,13 +12305,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12277
12305
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12278
12306
|
* standard `SENTRY_RELEASE` override.
|
|
12279
12307
|
*/
|
|
12280
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.
|
|
12308
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.e3b106e`;
|
|
12281
12309
|
/**
|
|
12282
12310
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12283
12311
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12284
12312
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12285
12313
|
*/
|
|
12286
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.
|
|
12314
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.e3b106e") ? "development" : "production");
|
|
12287
12315
|
/**
|
|
12288
12316
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12289
12317
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -15740,6 +15768,152 @@ const recordScanMetrics = (input) => {
|
|
|
15740
15768
|
});
|
|
15741
15769
|
};
|
|
15742
15770
|
//#endregion
|
|
15771
|
+
//#region src/cli/utils/should-fail-for-diagnostics.ts
|
|
15772
|
+
const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
|
|
15773
|
+
if (failOnLevel === "none") return false;
|
|
15774
|
+
if (failOnLevel === "warning") return diagnostics.length > 0;
|
|
15775
|
+
return diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
15776
|
+
};
|
|
15777
|
+
//#endregion
|
|
15778
|
+
//#region src/cli/utils/build-run-event.ts
|
|
15779
|
+
const FAIL_ON_LEVELS = new Set([
|
|
15780
|
+
"error",
|
|
15781
|
+
"warning",
|
|
15782
|
+
"none"
|
|
15783
|
+
]);
|
|
15784
|
+
const readEnvBoolean = (name) => {
|
|
15785
|
+
const value = process.env[name];
|
|
15786
|
+
if (value === void 0) return null;
|
|
15787
|
+
return value.toLowerCase() === "true" || value === "1";
|
|
15788
|
+
};
|
|
15789
|
+
const resolveVersionPin = (versionInput) => {
|
|
15790
|
+
if (versionInput === void 0 || versionInput.trim() === "") return null;
|
|
15791
|
+
if (versionInput === "latest") return "latest";
|
|
15792
|
+
if (/^(\.\.?\/|\/)/.test(versionInput)) return "local";
|
|
15793
|
+
return "pinned";
|
|
15794
|
+
};
|
|
15795
|
+
const resolveTelemetryFailOn = (userConfig) => {
|
|
15796
|
+
const fromAction = process.env[ACTION_INPUT_ENVIRONMENT_VARIABLES.failOn];
|
|
15797
|
+
if (fromAction !== void 0 && FAIL_ON_LEVELS.has(fromAction)) return fromAction;
|
|
15798
|
+
return userConfig?.failOn ?? "none";
|
|
15799
|
+
};
|
|
15800
|
+
const toCategoryKey = (category) => category.toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
15801
|
+
const buildOutcomeAttributes = (input) => {
|
|
15802
|
+
if (input.result === void 0) {
|
|
15803
|
+
const error = input.error;
|
|
15804
|
+
const known = isReactDoctorError(error);
|
|
15805
|
+
return {
|
|
15806
|
+
outcome: "error",
|
|
15807
|
+
exitCode: 1,
|
|
15808
|
+
knownError: known,
|
|
15809
|
+
errorTag: known ? error.reason._tag : error instanceof Error ? error.name : null
|
|
15810
|
+
};
|
|
15811
|
+
}
|
|
15812
|
+
const result = input.result;
|
|
15813
|
+
const summary = summarizeDiagnostics(result.diagnostics);
|
|
15814
|
+
const failOnLevel = resolveTelemetryFailOn(input.userConfig);
|
|
15815
|
+
const gateDiagnostics = filterDiagnosticsForSurface(result.diagnostics, "ciFailure", input.userConfig);
|
|
15816
|
+
const wouldBlock = !input.scoreOnly && shouldFailForDiagnostics(gateDiagnostics, failOnLevel);
|
|
15817
|
+
const hasSkippedChecks = result.skippedChecks.length > 0;
|
|
15818
|
+
const isClean = result.diagnostics.length === 0 && !hasSkippedChecks;
|
|
15819
|
+
const outcome = wouldBlock ? "blocked" : isClean ? "clean" : "ok";
|
|
15820
|
+
const firings = summarizeRuleFirings(result.diagnostics);
|
|
15821
|
+
const countByRule = /* @__PURE__ */ new Map();
|
|
15822
|
+
const countByCategory = /* @__PURE__ */ new Map();
|
|
15823
|
+
for (const firing of firings) {
|
|
15824
|
+
countByRule.set(firing.rule, (countByRule.get(firing.rule) ?? 0) + firing.count);
|
|
15825
|
+
countByCategory.set(firing.category, (countByCategory.get(firing.category) ?? 0) + firing.count);
|
|
15826
|
+
}
|
|
15827
|
+
let topRule = null;
|
|
15828
|
+
let topRuleCount = 0;
|
|
15829
|
+
for (const [rule, count] of countByRule) if (count > topRuleCount) {
|
|
15830
|
+
topRule = rule;
|
|
15831
|
+
topRuleCount = count;
|
|
15832
|
+
}
|
|
15833
|
+
const attributes = {
|
|
15834
|
+
outcome,
|
|
15835
|
+
exitCode: wouldBlock ? 1 : 0,
|
|
15836
|
+
wouldBlock,
|
|
15837
|
+
failOn: failOnLevel,
|
|
15838
|
+
scanClean: isClean,
|
|
15839
|
+
totalDiagnostics: summary.totalDiagnosticCount,
|
|
15840
|
+
errorCount: summary.errorCount,
|
|
15841
|
+
warningCount: summary.warningCount,
|
|
15842
|
+
affectedFiles: summary.affectedFileCount,
|
|
15843
|
+
distinctRulesFired: countByRule.size,
|
|
15844
|
+
topRule,
|
|
15845
|
+
scannedFileCount: result.scannedFileCount ?? null,
|
|
15846
|
+
elapsedMs: result.elapsedMilliseconds,
|
|
15847
|
+
scanPhaseMs: result.scanElapsedMilliseconds ?? null,
|
|
15848
|
+
score: result.score ? result.score.score : null,
|
|
15849
|
+
scoreLabel: result.score ? result.score.label : null,
|
|
15850
|
+
scoreAvailable: result.score !== null,
|
|
15851
|
+
skippedCheckCount: result.skippedChecks.length,
|
|
15852
|
+
didLintFail: input.didLintFail ?? null,
|
|
15853
|
+
lintFailureReasonKind: input.lintFailureReasonKind ?? null,
|
|
15854
|
+
lintPartialFailureCount: input.lintPartialFailureCount ?? null,
|
|
15855
|
+
didDeadCodeFail: input.didDeadCodeFail ?? null
|
|
15856
|
+
};
|
|
15857
|
+
for (const [category, count] of countByCategory) attributes[`diag.category.${toCategoryKey(category)}`] = count;
|
|
15858
|
+
return attributes;
|
|
15859
|
+
};
|
|
15860
|
+
const buildCiAttributes = () => {
|
|
15861
|
+
const { githubActorAssociation } = resolveGithubActionsScoreMetadata();
|
|
15862
|
+
return {
|
|
15863
|
+
actorAssociation: githubActorAssociation ?? null,
|
|
15864
|
+
runnerOs: detectRunnerOs(),
|
|
15865
|
+
nonBlocking: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.nonBlocking),
|
|
15866
|
+
comment: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.comment),
|
|
15867
|
+
annotations: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.annotations),
|
|
15868
|
+
versionPin: resolveVersionPin(process.env[ACTION_INPUT_ENVIRONMENT_VARIABLES.version])
|
|
15869
|
+
};
|
|
15870
|
+
};
|
|
15871
|
+
const buildConfigAttributes = (input) => {
|
|
15872
|
+
const ruleOverrides = input.userConfig?.rules ?? {};
|
|
15873
|
+
const ruleKeys = Object.keys(ruleOverrides);
|
|
15874
|
+
return {
|
|
15875
|
+
mode: input.mode,
|
|
15876
|
+
parallel: input.parallel,
|
|
15877
|
+
workerCount: input.workerCount ?? null,
|
|
15878
|
+
lint: input.lint,
|
|
15879
|
+
deadCode: input.deadCode,
|
|
15880
|
+
scoreOnly: input.scoreOnly,
|
|
15881
|
+
noScore: input.noScore,
|
|
15882
|
+
respectInlineDisables: input.respectInlineDisables,
|
|
15883
|
+
showWarnings: input.showWarnings,
|
|
15884
|
+
ignoredTagCount: input.ignoredTagCount,
|
|
15885
|
+
hasCustomConfig: input.hasCustomConfig,
|
|
15886
|
+
rulesConfigured: ruleKeys.length,
|
|
15887
|
+
rulesDisabled: ruleKeys.filter((key) => ruleOverrides[key] === "off").length
|
|
15888
|
+
};
|
|
15889
|
+
};
|
|
15890
|
+
/**
|
|
15891
|
+
* Projects a scan into the flat attribute set for its root span — the canonical
|
|
15892
|
+
* per-scan "wide event". Pure and exported so the projection (outcome
|
|
15893
|
+
* precedence, rule/category rollups, CI knobs, config shape) is unit-testable
|
|
15894
|
+
* without a live Sentry client. `null` values are dropped so absent signals
|
|
15895
|
+
* never become misleading `"null"` attributes. The run + project base context
|
|
15896
|
+
* (version, command, ci/provider, framework, …) is already on the span from
|
|
15897
|
+
* `withSentryRunSpan` / `recordSentryProjectContext`, so this adds only what
|
|
15898
|
+
* those don't carry.
|
|
15899
|
+
*/
|
|
15900
|
+
const buildRunEventAttributes = (input) => toSpanAttributes({
|
|
15901
|
+
...buildConfigAttributes(input),
|
|
15902
|
+
...buildCiAttributes(),
|
|
15903
|
+
...buildOutcomeAttributes(input)
|
|
15904
|
+
});
|
|
15905
|
+
/**
|
|
15906
|
+
* Stamps the wide-event attributes onto the run's root span. A guarded no-op
|
|
15907
|
+
* when tracing is off (no `rootSpan`) and swallow-on-throw, so telemetry can
|
|
15908
|
+
* never break the run.
|
|
15909
|
+
*/
|
|
15910
|
+
const recordRunEvent = (rootSpan, input) => {
|
|
15911
|
+
if (!rootSpan) return;
|
|
15912
|
+
try {
|
|
15913
|
+
rootSpan.setAttributes(buildRunEventAttributes(input));
|
|
15914
|
+
} catch {}
|
|
15915
|
+
};
|
|
15916
|
+
//#endregion
|
|
15743
15917
|
//#region src/cli/utils/build-no-score-message.ts
|
|
15744
15918
|
const ENTERPRISE_CONTACT_HINT = `Want something custom to your company? Contact us at ${ENTERPRISE_CONTACT_URL}.`;
|
|
15745
15919
|
const buildNoScoreMessage = (isScoreDisabled) => {
|
|
@@ -16044,7 +16218,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
|
|
|
16044
16218
|
const fixRecipeLine = formatFixRecipeLine(representative);
|
|
16045
16219
|
if (fixRecipeLine) lines.push(highlighter.gray(`${TOP_ERROR_DETAIL_INDENT}${fixRecipeLine}`));
|
|
16046
16220
|
}
|
|
16047
|
-
const renderCodeFrame = severity === "error"
|
|
16221
|
+
const renderCodeFrame = severity === "error";
|
|
16048
16222
|
const sites = renderEverySite ? ruleDiagnostics : [representative];
|
|
16049
16223
|
for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
|
|
16050
16224
|
return lines;
|
|
@@ -16670,6 +16844,19 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
16670
16844
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
16671
16845
|
concurrency: inputOptions.concurrency
|
|
16672
16846
|
});
|
|
16847
|
+
const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
16848
|
+
parallel: options.concurrency !== void 0,
|
|
16849
|
+
workerCount: options.concurrency,
|
|
16850
|
+
lint: options.lint,
|
|
16851
|
+
deadCode: options.deadCode,
|
|
16852
|
+
scoreOnly: options.scoreOnly,
|
|
16853
|
+
noScore: options.noScore,
|
|
16854
|
+
respectInlineDisables: options.respectInlineDisables,
|
|
16855
|
+
showWarnings: options.warnings,
|
|
16856
|
+
ignoredTagCount: options.ignoredTags.size,
|
|
16857
|
+
hasCustomConfig,
|
|
16858
|
+
userConfig
|
|
16859
|
+
});
|
|
16673
16860
|
const inspect = async (directory, inputOptions = {}) => {
|
|
16674
16861
|
const startTime = performance.now();
|
|
16675
16862
|
resetSentryRunState();
|
|
@@ -16691,7 +16878,18 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
16691
16878
|
const wasSpinnerSilent = isSpinnerSilent();
|
|
16692
16879
|
if (options.silent) setSpinnerSilent(true);
|
|
16693
16880
|
try {
|
|
16694
|
-
const result = await withSentryRunSpan((rootSentrySpan) =>
|
|
16881
|
+
const result = await withSentryRunSpan(async (rootSentrySpan) => {
|
|
16882
|
+
try {
|
|
16883
|
+
return await runInspectWithRuntime(scanDirectory, options, userConfig, hasConfigOverride, configSourceDirectory, startTime, rootSentrySpan);
|
|
16884
|
+
} catch (error) {
|
|
16885
|
+
recordRunEvent(rootSentrySpan, {
|
|
16886
|
+
...buildRunEventConfig(options, userConfig, userConfig !== null),
|
|
16887
|
+
mode: options.includePaths.length > 0 ? "diff" : "full",
|
|
16888
|
+
error
|
|
16889
|
+
});
|
|
16890
|
+
throw error;
|
|
16891
|
+
}
|
|
16892
|
+
});
|
|
16695
16893
|
resetSentryRunState();
|
|
16696
16894
|
return result;
|
|
16697
16895
|
} finally {
|
|
@@ -16726,6 +16924,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
16726
16924
|
runDeadCode: options.deadCode,
|
|
16727
16925
|
isCi: options.isCi,
|
|
16728
16926
|
doctorVersion: VERSION,
|
|
16927
|
+
runId: getRunId(),
|
|
16729
16928
|
resolveLocalGithubViewerPermission: !options.noScore,
|
|
16730
16929
|
suppressScanSummary: options.suppressRendering
|
|
16731
16930
|
}, { beforeLint: (projectInfo, lintIncludePaths) => Effect.gen(function* () {
|
|
@@ -16789,6 +16988,15 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
16789
16988
|
lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
|
|
16790
16989
|
didDeadCodeFail: output.didDeadCodeFail
|
|
16791
16990
|
});
|
|
16991
|
+
recordRunEvent(rootSentrySpan, {
|
|
16992
|
+
...buildRunEventConfig(options, userConfig, userConfig !== null),
|
|
16993
|
+
result,
|
|
16994
|
+
mode: isDiffMode ? "diff" : "full",
|
|
16995
|
+
didLintFail,
|
|
16996
|
+
lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
|
|
16997
|
+
lintPartialFailureCount: output.lintPartialFailures.length,
|
|
16998
|
+
didDeadCodeFail: output.didDeadCodeFail
|
|
16999
|
+
});
|
|
16792
17000
|
return result;
|
|
16793
17001
|
};
|
|
16794
17002
|
const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
@@ -18611,7 +18819,13 @@ const isSafeRelativePath = (filePath) => {
|
|
|
18611
18819
|
return normalized === filePath;
|
|
18612
18820
|
};
|
|
18613
18821
|
const readChangedFilesFrom = (filePath) => {
|
|
18614
|
-
|
|
18822
|
+
let raw;
|
|
18823
|
+
try {
|
|
18824
|
+
raw = fs.readFileSync(filePath, "utf8");
|
|
18825
|
+
} catch (error) {
|
|
18826
|
+
const errorCode = error?.code;
|
|
18827
|
+
throw new CliInputError(`Could not read the --changed-files-from file "${filePath}"${errorCode ? ` (${errorCode})` : ""}. Pass a path to a readable text file that lists changed files, one per line.`);
|
|
18828
|
+
}
|
|
18615
18829
|
const uniqueFiles = /* @__PURE__ */ new Set();
|
|
18616
18830
|
for (const line of raw.split(/\r?\n/)) {
|
|
18617
18831
|
const candidate = toForwardSlashes(line.trim());
|
|
@@ -19034,13 +19248,6 @@ const runExplain = async (fileLineArgument, context) => {
|
|
|
19034
19248
|
}
|
|
19035
19249
|
};
|
|
19036
19250
|
//#endregion
|
|
19037
|
-
//#region src/cli/utils/should-fail-for-diagnostics.ts
|
|
19038
|
-
const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
|
|
19039
|
-
if (failOnLevel === "none") return false;
|
|
19040
|
-
if (failOnLevel === "warning") return diagnostics.length > 0;
|
|
19041
|
-
return diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
19042
|
-
};
|
|
19043
|
-
//#endregion
|
|
19044
19251
|
//#region src/cli/utils/validate-mode-flags.ts
|
|
19045
19252
|
const validateModeFlags = (flags) => {
|
|
19046
19253
|
const coercedDiff = coerceDiffValue(flags.diff);
|
|
@@ -19936,6 +20143,30 @@ const exitGracefully = () => {
|
|
|
19936
20143
|
process.exit(130);
|
|
19937
20144
|
};
|
|
19938
20145
|
//#endregion
|
|
20146
|
+
//#region src/cli/utils/guard-stdin.ts
|
|
20147
|
+
const TERMINAL_HANGUP_CODES = new Set(["EIO", "ENXIO"]);
|
|
20148
|
+
/**
|
|
20149
|
+
* Handles a `process.stdin` `'error'` event. A terminal hangup mid-read
|
|
20150
|
+
* (`read EIO`) is environmental, not a bug, so exit like an interrupted run
|
|
20151
|
+
* instead of crashing. Re-throws anything else so genuine stdin failures keep
|
|
20152
|
+
* funneling to the crash reporter exactly as they did before this guard.
|
|
20153
|
+
*/
|
|
20154
|
+
const handleStdinError = (error) => {
|
|
20155
|
+
if (error.code !== void 0 && TERMINAL_HANGUP_CODES.has(error.code)) process.exit(129);
|
|
20156
|
+
throw error;
|
|
20157
|
+
};
|
|
20158
|
+
/**
|
|
20159
|
+
* Arms a `process.stdin` error guard at startup. The only thing that reads
|
|
20160
|
+
* stdin is the interactive `prompts` UI, which opens the TTY in raw mode and
|
|
20161
|
+
* never attaches an `'error'` listener of its own. Without a listener Node
|
|
20162
|
+
* turns a `read EIO` from a vanished terminal into a fatal uncaught exception
|
|
20163
|
+
* (reported to Sentry as a crash); with one, {@link handleStdinError} exits
|
|
20164
|
+
* cleanly on a hangup. Mirrors the stdout EPIPE guard in `cli/index.ts`.
|
|
20165
|
+
*/
|
|
20166
|
+
const guardStdin = () => {
|
|
20167
|
+
process.stdin.on("error", handleStdinError);
|
|
20168
|
+
};
|
|
20169
|
+
//#endregion
|
|
19939
20170
|
//#region src/cli/utils/normalize-help-command.ts
|
|
19940
20171
|
/**
|
|
19941
20172
|
* 12-factor CLI Apps (#1, "Great help is essential"): `mycli help` and
|
|
@@ -20130,6 +20361,7 @@ initializeSentry();
|
|
|
20130
20361
|
process.on("SIGINT", exitGracefully);
|
|
20131
20362
|
process.on("SIGTERM", exitGracefully);
|
|
20132
20363
|
unrefStdin();
|
|
20364
|
+
guardStdin();
|
|
20133
20365
|
const formatExampleLines = (examples) => {
|
|
20134
20366
|
const width = Math.max(...examples.map(([command]) => command.length));
|
|
20135
20367
|
return examples.map(([command, description]) => ` $ ${command.padEnd(width)} ${highlighter.dim(`# ${description}`)}`).join("\n");
|
|
@@ -20210,4 +20442,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
|
20210
20442
|
export {};
|
|
20211
20443
|
|
|
20212
20444
|
//# sourceMappingURL=cli.js.map
|
|
20213
|
-
//# debugId=
|
|
20445
|
+
//# debugId=9cef6163-49df-51ef-9157-780c4c678e81
|
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]="57d81746-a846-5f9f-a2db-54b118de6334")}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";
|
|
@@ -2130,7 +2130,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
|
2130
2130
|
"EACCES",
|
|
2131
2131
|
"EPERM",
|
|
2132
2132
|
"ENOENT",
|
|
2133
|
-
"ENOTDIR"
|
|
2133
|
+
"ENOTDIR",
|
|
2134
|
+
"EINVAL",
|
|
2135
|
+
"ELOOP",
|
|
2136
|
+
"ENAMETOOLONG"
|
|
2134
2137
|
]);
|
|
2135
2138
|
const isIgnorableReaddirError = (error) => {
|
|
2136
2139
|
if (typeof error !== "object" || error === null) return false;
|
|
@@ -8029,6 +8032,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
8029
8032
|
...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
|
|
8030
8033
|
...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
|
|
8031
8034
|
...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
|
|
8035
|
+
...options.metadata?.runId ? { runId: options.metadata.runId } : {},
|
|
8032
8036
|
...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
|
|
8033
8037
|
...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
|
|
8034
8038
|
...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
|
|
@@ -8268,6 +8272,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8268
8272
|
sourceFileCount: project.sourceFileCount,
|
|
8269
8273
|
...defaultBranch !== null ? { defaultBranch } : {},
|
|
8270
8274
|
...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
|
|
8275
|
+
...input.runId !== void 0 ? { runId: input.runId } : {},
|
|
8271
8276
|
...githubActionsScoreMetadata,
|
|
8272
8277
|
...githubViewerPermission !== null ? { githubViewerPermission } : {}
|
|
8273
8278
|
};
|
|
@@ -8724,4 +8729,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8724
8729
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8725
8730
|
|
|
8726
8731
|
//# sourceMappingURL=index.js.map
|
|
8727
|
-
//# debugId=
|
|
8732
|
+
//# debugId=57d81746-a846-5f9f-a2db-54b118de6334
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.18-dev.
|
|
3
|
+
"version": "0.2.18-dev.e3b106e",
|
|
4
4
|
"description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"agent-install": "0.0.5",
|
|
56
56
|
"conf": "^15.1.0",
|
|
57
57
|
"confbox": "^0.2.4",
|
|
58
|
-
"deslop-js": "^0.0.
|
|
58
|
+
"deslop-js": "^0.0.15",
|
|
59
59
|
"effect": "4.0.0-beta.70",
|
|
60
60
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
61
61
|
"jiti": "^2.7.0",
|
|
@@ -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.18-dev.
|
|
66
|
+
"oxlint-plugin-react-doctor": "0.2.18-dev.e3b106e"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/babel__code-frame": "^7.27.0",
|