react-doctor 0.2.16-dev.2d1ab24 → 0.2.16-dev.ec5d58c
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 +205 -60
- 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]="83b0602f-f294-5164-861f-82491ff58bf0")}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";
|
|
@@ -41,11 +41,11 @@ import * as Exit from "effect/Exit";
|
|
|
41
41
|
import { stripVTControlCharacters } from "node:util";
|
|
42
42
|
import tty from "node:tty";
|
|
43
43
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
44
|
+
import Conf from "conf";
|
|
44
45
|
import { createHash, randomUUID } from "node:crypto";
|
|
45
46
|
import basePrompts from "prompts";
|
|
46
47
|
import { SKILL_MANIFEST_FILE, detectInstalledSkillAgents, getSkillAgentConfig, getSkillAgentTypes, installSkillsFromSource } from "agent-install";
|
|
47
48
|
import { fileURLToPath } from "node:url";
|
|
48
|
-
import Conf from "conf";
|
|
49
49
|
import { generateCode, loadFile, writeFile } from "magicast";
|
|
50
50
|
import { getConfigFromVariableDeclaration, getDefaultExportOptions } from "magicast/helpers";
|
|
51
51
|
//#region \0rolldown/runtime.js
|
|
@@ -11851,6 +11851,9 @@ const detectCodingAgent = () => {
|
|
|
11851
11851
|
const isCodingAgentEnvironment = () => detectCodingAgent() !== null;
|
|
11852
11852
|
const isCiOrCodingAgentEnvironment = () => isCiEnvironment() || isCodingAgentEnvironment();
|
|
11853
11853
|
//#endregion
|
|
11854
|
+
//#region src/cli/utils/is-git-hook-environment.ts
|
|
11855
|
+
const isGitHookEnvironment = () => Boolean(process.env.GIT_DIR);
|
|
11856
|
+
//#endregion
|
|
11854
11857
|
//#region src/cli/utils/is-non-interactive-environment.ts
|
|
11855
11858
|
const NON_INTERACTIVE_ENVIRONMENT_VARIABLES = [
|
|
11856
11859
|
"CI",
|
|
@@ -11871,6 +11874,8 @@ const isNonInteractiveEnvironment = () => NON_INTERACTIVE_ENVIRONMENT_VARIABLES.
|
|
|
11871
11874
|
//#endregion
|
|
11872
11875
|
//#region src/cli/utils/constants.ts
|
|
11873
11876
|
const STAGED_FILES_TEMP_DIR_PREFIX = "react-doctor-staged-";
|
|
11877
|
+
const WELCOME_EXPLANATION_HOLD_MS = 2e3;
|
|
11878
|
+
const WELCOME_HOLD_MS = 1e3;
|
|
11874
11879
|
const INTERNAL_ERROR_JSON_FALLBACK = "{\"schemaVersion\":1,\"ok\":false,\"error\":{\"message\":\"Internal error\",\"name\":\"Error\",\"chain\":[]}}\n";
|
|
11875
11880
|
const SENTRY_FLUSH_TIMEOUT_MS = 2e3;
|
|
11876
11881
|
const NANOSECONDS_PER_SECOND = 1000000000n;
|
|
@@ -11942,7 +11947,7 @@ const makeNoopConsole = () => ({
|
|
|
11942
11947
|
});
|
|
11943
11948
|
//#endregion
|
|
11944
11949
|
//#region src/cli/utils/version.ts
|
|
11945
|
-
const VERSION = "0.2.16-dev.
|
|
11950
|
+
const VERSION = "0.2.16-dev.ec5d58c";
|
|
11946
11951
|
//#endregion
|
|
11947
11952
|
//#region src/cli/utils/json-mode.ts
|
|
11948
11953
|
let context = null;
|
|
@@ -12044,7 +12049,7 @@ const detectNodeMajor = () => {
|
|
|
12044
12049
|
return Number.isNaN(major) ? 0 : major;
|
|
12045
12050
|
};
|
|
12046
12051
|
const detectOrigin = () => {
|
|
12047
|
-
if (
|
|
12052
|
+
if (isGitHookEnvironment()) return "git-hook";
|
|
12048
12053
|
if (isCodingAgentEnvironment()) return "agent";
|
|
12049
12054
|
if (isCiEnvironment()) return "ci";
|
|
12050
12055
|
return "cli";
|
|
@@ -12288,13 +12293,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12288
12293
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12289
12294
|
* standard `SENTRY_RELEASE` override.
|
|
12290
12295
|
*/
|
|
12291
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.16-dev.
|
|
12296
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.16-dev.ec5d58c`;
|
|
12292
12297
|
/**
|
|
12293
12298
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12294
12299
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12295
12300
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12296
12301
|
*/
|
|
12297
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.16-dev.
|
|
12302
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.16-dev.ec5d58c") ? "development" : "production");
|
|
12298
12303
|
/**
|
|
12299
12304
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12300
12305
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -15877,6 +15882,9 @@ const buildCodeFrame = (input) => {
|
|
|
15877
15882
|
//#region src/cli/utils/build-section-divider.ts
|
|
15878
15883
|
const buildSectionDivider = () => highlighter.dim(` ${"─".repeat(60)}`);
|
|
15879
15884
|
//#endregion
|
|
15885
|
+
//#region src/cli/utils/ease-out-cubic.ts
|
|
15886
|
+
const easeOutCubic = (progress) => 1 - (1 - progress) ** 3;
|
|
15887
|
+
//#endregion
|
|
15880
15888
|
//#region src/cli/utils/indent-multiline-text.ts
|
|
15881
15889
|
const indentMultilineText = (text, linePrefix) => text.split("\n").map((lineText) => `${linePrefix}${lineText}`).join("\n");
|
|
15882
15890
|
//#endregion
|
|
@@ -15916,6 +15924,11 @@ const wrapTextToWidth = (text, width, options = {}) => {
|
|
|
15916
15924
|
return text.split("\n").flatMap((lineText) => wrapLine(lineText, width, breakLongWords));
|
|
15917
15925
|
};
|
|
15918
15926
|
//#endregion
|
|
15927
|
+
//#region src/cli/utils/write-stdout.ts
|
|
15928
|
+
const writeStdout = (text) => Effect.sync(() => {
|
|
15929
|
+
process.stdout.write(text);
|
|
15930
|
+
});
|
|
15931
|
+
//#endregion
|
|
15919
15932
|
//#region src/cli/utils/render-diagnostics.ts
|
|
15920
15933
|
const POINTER = isUnicodeSupported() ? "›" : ">";
|
|
15921
15934
|
const colorizeBySeverity = (text, severity) => severity === "error" ? highlighter.error(text) : highlighter.warn(text);
|
|
@@ -15949,14 +15962,26 @@ const buildCategoryDiagnosticGroups = (diagnostics, rulePriority) => {
|
|
|
15949
15962
|
return categoryGroupA.category.localeCompare(categoryGroupB.category);
|
|
15950
15963
|
});
|
|
15951
15964
|
};
|
|
15952
|
-
const
|
|
15953
|
-
const errorCount = categoryGroup.diagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
15954
|
-
const warningCount = categoryGroup.diagnostics.filter((diagnostic) => diagnostic.severity === "warning").length;
|
|
15965
|
+
const formatCategoryTallyLine = (tally, errorShown, warningShown) => {
|
|
15955
15966
|
const parts = [];
|
|
15956
|
-
if (errorCount > 0) parts.push(highlighter.error(`${
|
|
15957
|
-
if (warningCount > 0) parts.push(highlighter.warn(highlighter.dim(`${
|
|
15958
|
-
return ` ${highlighter.bold(
|
|
15959
|
-
};
|
|
15967
|
+
if (tally.errorCount > 0) parts.push(highlighter.error(`${errorShown} ${errorShown === 1 ? "error" : "errors"}`));
|
|
15968
|
+
if (tally.warningCount > 0) parts.push(highlighter.warn(highlighter.dim(`${warningShown} ${warningShown === 1 ? "warning" : "warnings"}`)));
|
|
15969
|
+
return ` ${highlighter.bold(tally.category)} ${highlighter.dim(POINTER)} ${parts.join(highlighter.dim(", "))}`;
|
|
15970
|
+
};
|
|
15971
|
+
const buildCategoryTally = (categoryGroup) => ({
|
|
15972
|
+
category: categoryGroup.category,
|
|
15973
|
+
errorCount: categoryGroup.diagnostics.filter((diagnostic) => diagnostic.severity === "error").length,
|
|
15974
|
+
warningCount: categoryGroup.diagnostics.filter((diagnostic) => diagnostic.severity === "warning").length
|
|
15975
|
+
});
|
|
15976
|
+
const buildCategoryTallyLines = (tallies) => tallies.map((tally) => formatCategoryTallyLine(tally, tally.errorCount, tally.warningCount));
|
|
15977
|
+
const printCategoryCountUp = (tallies) => Effect.gen(function* () {
|
|
15978
|
+
for (let frame = 0; frame <= 16; frame += 1) {
|
|
15979
|
+
const fraction = easeOutCubic(frame / 16);
|
|
15980
|
+
const lines = tallies.map((tally) => formatCategoryTallyLine(tally, Math.round(tally.errorCount * fraction), Math.round(tally.warningCount * fraction)));
|
|
15981
|
+
yield* writeStdout(`${frame === 0 ? "" : `\x1b[${tallies.length}A`}\r${lines.join("\n\r")}\n`);
|
|
15982
|
+
if (frame < 16) yield* Effect.sleep(45);
|
|
15983
|
+
}
|
|
15984
|
+
});
|
|
15960
15985
|
const TOP_ERROR_DETAIL_INDENT = " ";
|
|
15961
15986
|
const pickRepresentativeDiagnostic = (ruleDiagnostics) => ruleDiagnostics.find((diagnostic) => diagnostic.line > 0) ?? ruleDiagnostics[0];
|
|
15962
15987
|
const FRAME_CONTEXT_REACH_LINES = 3;
|
|
@@ -16014,7 +16039,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
|
|
|
16014
16039
|
const { severity } = representative;
|
|
16015
16040
|
const trailingBadge = formatTrailingSiteBadge(ruleDiagnostics.length);
|
|
16016
16041
|
const headline = colorizeBySeverity(`${representative.category}: ${representative.title ?? ruleKey}`, severity);
|
|
16017
|
-
const lines = [` ${colorizeBySeverity(severity === "error" ? "
|
|
16042
|
+
const lines = [` ${colorizeBySeverity(severity === "error" ? "✖" : "⚠", severity)} ${headline}${trailingBadge}`];
|
|
16018
16043
|
if (renderEverySite && !isAgentEnvironment) {
|
|
16019
16044
|
const learnMoreLine = formatLearnMoreLine(representative);
|
|
16020
16045
|
if (learnMoreLine) lines.push(`${TOP_ERROR_DETAIL_INDENT}${highlighter.info(learnMoreLine)}`);
|
|
@@ -16048,33 +16073,48 @@ const buildOverflowSummaryLine = (diagnostics, rulePriority) => {
|
|
|
16048
16073
|
parts.push(highlighter.bold(highlighter.warn(`+${warningCount} optional ${warningNoun}`)));
|
|
16049
16074
|
}
|
|
16050
16075
|
const command = highlighter.bold(highlighter.info("npx react-doctor@latest --verbose"));
|
|
16051
|
-
return ` ${parts.length > 0 ? `${parts.join(highlighter.dim(" and "))} ${highlighter.dim("
|
|
16076
|
+
return ` ${parts.length > 0 ? `${parts.join(highlighter.dim(" and "))} ${highlighter.dim("- run")}` : highlighter.dim("Run")} ${command} ${highlighter.dim("for details")}`;
|
|
16052
16077
|
};
|
|
16053
16078
|
const getTopErrorRuleKeys = (diagnostics, limit, rulePriority) => new Set(selectTopErrorRuleGroups(diagnostics, limit, rulePriority).map(([ruleKey]) => ruleKey));
|
|
16054
|
-
const
|
|
16079
|
+
const buildTopErrorsSection = (diagnostics, resolveSourceRoot, rulePriority) => {
|
|
16055
16080
|
const topRuleGroups = selectErrorRuleGroups(diagnostics, rulePriority).slice(0, 3);
|
|
16056
|
-
if (topRuleGroups.length === 0) return
|
|
16081
|
+
if (topRuleGroups.length === 0) return {
|
|
16082
|
+
lines: [],
|
|
16083
|
+
blockOffsets: []
|
|
16084
|
+
};
|
|
16057
16085
|
const lines = [
|
|
16058
16086
|
buildSectionDivider(),
|
|
16059
16087
|
` ${highlighter.bold(`Top ${topRuleGroups.length} ${topRuleGroups.length === 1 ? "error" : "errors"} you should fix`)}`,
|
|
16060
16088
|
""
|
|
16061
16089
|
];
|
|
16090
|
+
const blockOffsets = [];
|
|
16062
16091
|
for (const [ruleKey, ruleDiagnostics] of topRuleGroups) {
|
|
16092
|
+
blockOffsets.push(lines.length);
|
|
16063
16093
|
lines.push(...buildRuleDetailBlock(ruleKey, ruleDiagnostics, resolveSourceRoot, false, false));
|
|
16064
16094
|
lines.push("");
|
|
16065
16095
|
}
|
|
16066
|
-
return
|
|
16096
|
+
return {
|
|
16097
|
+
lines,
|
|
16098
|
+
blockOffsets
|
|
16099
|
+
};
|
|
16067
16100
|
};
|
|
16068
|
-
const buildCategoryBreakdownLines = (diagnostics, rulePriority) => buildCategoryDiagnosticGroups(diagnostics, rulePriority).map(buildCompactCategoryLine);
|
|
16069
16101
|
const joinSections = (...sections) => {
|
|
16070
16102
|
const lines = [];
|
|
16103
|
+
const sectionStarts = [];
|
|
16071
16104
|
for (const section of sections) {
|
|
16072
|
-
if (section.length === 0)
|
|
16105
|
+
if (section.length === 0) {
|
|
16106
|
+
sectionStarts.push(null);
|
|
16107
|
+
continue;
|
|
16108
|
+
}
|
|
16073
16109
|
if (lines.length > 0) lines.push("");
|
|
16110
|
+
sectionStarts.push(lines.length);
|
|
16074
16111
|
lines.push(...section);
|
|
16075
16112
|
}
|
|
16076
16113
|
if (lines.length > 0 && lines[lines.length - 1] !== "") lines.push("");
|
|
16077
|
-
return
|
|
16114
|
+
return {
|
|
16115
|
+
lines,
|
|
16116
|
+
sectionStarts
|
|
16117
|
+
};
|
|
16078
16118
|
};
|
|
16079
16119
|
const buildCountsSummaryLines = (diagnostics) => {
|
|
16080
16120
|
const totalIssueCount = diagnostics.length;
|
|
@@ -16089,16 +16129,36 @@ const buildCountsSummaryLines = (diagnostics) => {
|
|
|
16089
16129
|
* single Effect.forEach over Console.log so failures or fiber
|
|
16090
16130
|
* interruption produce predictable partial output.
|
|
16091
16131
|
*/
|
|
16092
|
-
const printDiagnostics = (diagnostics, isVerbose, sourceRoot, rulePriority, isAgentEnvironment = false) => Effect.gen(function* () {
|
|
16132
|
+
const printDiagnostics = (diagnostics, isVerbose, sourceRoot, rulePriority, isAgentEnvironment = false, onboarding = {}) => Effect.gen(function* () {
|
|
16133
|
+
const sectionPause = onboarding.sectionPause ?? Effect.void;
|
|
16134
|
+
const animateCountUp = onboarding.animateCountUp ?? false;
|
|
16093
16135
|
const resolveSourceRoot = typeof sourceRoot === "function" ? sourceRoot : () => sourceRoot;
|
|
16094
16136
|
let detailLines;
|
|
16095
|
-
|
|
16096
|
-
|
|
16137
|
+
let topErrorBlockOffsets = [];
|
|
16138
|
+
if (!isVerbose) {
|
|
16139
|
+
const topErrors = buildTopErrorsSection(diagnostics, resolveSourceRoot, rulePriority);
|
|
16140
|
+
detailLines = topErrors.lines;
|
|
16141
|
+
topErrorBlockOffsets = topErrors.blockOffsets;
|
|
16142
|
+
} else detailLines = buildSortedRuleGroups(diagnostics, rulePriority).flatMap(([ruleKey, ruleDiagnostics]) => {
|
|
16097
16143
|
return [...buildRuleDetailBlock(ruleKey, ruleDiagnostics, resolveSourceRoot, true, isAgentEnvironment), ""];
|
|
16098
16144
|
});
|
|
16099
16145
|
const overflowLine = isVerbose ? void 0 : buildOverflowSummaryLine(diagnostics, rulePriority);
|
|
16100
|
-
const
|
|
16101
|
-
|
|
16146
|
+
const categoryTallies = buildCategoryDiagnosticGroups(diagnostics, rulePriority).map(buildCategoryTally);
|
|
16147
|
+
const categoryLines = buildCategoryTallyLines(categoryTallies);
|
|
16148
|
+
const { lines, sectionStarts } = joinSections(categoryLines, buildCountsSummaryLines(diagnostics), detailLines, overflowLine ? [overflowLine] : []);
|
|
16149
|
+
const [categoryStart, , detailStart] = sectionStarts;
|
|
16150
|
+
const pauseBeforeLineIndices = detailStart == null ? /* @__PURE__ */ new Set() : new Set(topErrorBlockOffsets.map((offset) => detailStart + offset));
|
|
16151
|
+
let lineIndex = 0;
|
|
16152
|
+
while (lineIndex < lines.length) {
|
|
16153
|
+
if (animateCountUp && lineIndex === categoryStart && categoryLines.length > 0) {
|
|
16154
|
+
yield* printCategoryCountUp(categoryTallies);
|
|
16155
|
+
lineIndex += categoryLines.length;
|
|
16156
|
+
continue;
|
|
16157
|
+
}
|
|
16158
|
+
if (pauseBeforeLineIndices.has(lineIndex)) yield* sectionPause;
|
|
16159
|
+
yield* Console.log(lines[lineIndex]);
|
|
16160
|
+
lineIndex += 1;
|
|
16161
|
+
}
|
|
16102
16162
|
});
|
|
16103
16163
|
const formatElapsedTime = (elapsedMilliseconds) => {
|
|
16104
16164
|
if (elapsedMilliseconds < 1e3) return `${Math.round(elapsedMilliseconds)}ms`;
|
|
@@ -16136,6 +16196,45 @@ const computeProjectedScore = async (topErrorSource, rescoreSource, currentScore
|
|
|
16136
16196
|
if (!potentialScore || potentialScore.score <= currentScore.score) return null;
|
|
16137
16197
|
return potentialScore.score;
|
|
16138
16198
|
};
|
|
16199
|
+
const FORCE_ONBOARDING_ENV_VAR = "REACT_DOCTOR_FORCE_ONBOARDING";
|
|
16200
|
+
const FALSY_FLAG_VALUES = new Set([
|
|
16201
|
+
"",
|
|
16202
|
+
"0",
|
|
16203
|
+
"false"
|
|
16204
|
+
]);
|
|
16205
|
+
const isOnboardingForced = (environment = process.env) => {
|
|
16206
|
+
const value = environment[FORCE_ONBOARDING_ENV_VAR];
|
|
16207
|
+
return value !== void 0 && !FALSY_FLAG_VALUES.has(value.toLowerCase());
|
|
16208
|
+
};
|
|
16209
|
+
const onboardingSectionPause = (shouldPace) => shouldPace ? Effect.sleep(850) : Effect.void;
|
|
16210
|
+
const shouldRecordOnboarding = (input) => input.paceOnboardingSections && !input.forceOnboarding && !input.verbose && !input.isNonInteractiveEnvironment;
|
|
16211
|
+
const canAnimateOnboarding = (stream = process.stdout) => {
|
|
16212
|
+
if (!(stream.isTTY === true && (stream.columns ?? 0) > 0 && process.env.TERM !== "dumb")) return false;
|
|
16213
|
+
if (isOnboardingForced()) return true;
|
|
16214
|
+
return !isGitHookEnvironment() && !isCiEnvironment();
|
|
16215
|
+
};
|
|
16216
|
+
//#endregion
|
|
16217
|
+
//#region src/cli/utils/onboarding-state.ts
|
|
16218
|
+
const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
|
|
16219
|
+
const ONBOARDED_AT_KEY = "onboardedAt";
|
|
16220
|
+
const getOnboardingStore = (options = {}) => new Conf({
|
|
16221
|
+
projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
|
|
16222
|
+
cwd: options.cwd
|
|
16223
|
+
});
|
|
16224
|
+
const hasCompletedOnboarding = (options = {}) => {
|
|
16225
|
+
try {
|
|
16226
|
+
return typeof getOnboardingStore(options).get(ONBOARDED_AT_KEY) === "string";
|
|
16227
|
+
} catch {
|
|
16228
|
+
return true;
|
|
16229
|
+
}
|
|
16230
|
+
};
|
|
16231
|
+
const markOnboardingComplete = (options = {}) => {
|
|
16232
|
+
try {
|
|
16233
|
+
const store = getOnboardingStore(options);
|
|
16234
|
+
if (typeof store.get(ONBOARDED_AT_KEY) === "string") return;
|
|
16235
|
+
store.set(ONBOARDED_AT_KEY, (/* @__PURE__ */ new Date()).toISOString());
|
|
16236
|
+
} catch {}
|
|
16237
|
+
};
|
|
16139
16238
|
//#endregion
|
|
16140
16239
|
//#region src/cli/utils/render-project-detection.ts
|
|
16141
16240
|
const printProjectDetection = (_input) => Effect.void;
|
|
@@ -16152,8 +16251,6 @@ const RAINBOW_HUE_SHIFT_PER_FRAME = 9;
|
|
|
16152
16251
|
const RAINBOW_GRADIENT_WIDTH = 80;
|
|
16153
16252
|
const RAINBOW_OKLCH_LIGHTNESS = .638;
|
|
16154
16253
|
const RAINBOW_OKLCH_CHROMA = .129;
|
|
16155
|
-
const easeOutCubic = (progress) => 1 - (1 - progress) ** 3;
|
|
16156
|
-
const sleep = (milliseconds) => Effect.promise(() => new Promise((resolve) => setTimeout(resolve, milliseconds)));
|
|
16157
16254
|
const buildScoreBarSegments = (filledCount) => {
|
|
16158
16255
|
const emptyCount = 50 - filledCount;
|
|
16159
16256
|
return {
|
|
@@ -16223,9 +16320,6 @@ const buildFaceRenderedLines = (score) => {
|
|
|
16223
16320
|
const colorize = (text) => colorizeByScore(text, score);
|
|
16224
16321
|
return buildRawFaceLines(score).map(colorize);
|
|
16225
16322
|
};
|
|
16226
|
-
const writeScoreHeaderLine = (line) => Effect.sync(() => {
|
|
16227
|
-
process.stdout.write(line);
|
|
16228
|
-
});
|
|
16229
16323
|
const buildScoreLine = (displayScore, finalScore, label) => {
|
|
16230
16324
|
const scoreNumber = colorizeByScore(`${displayScore}`, finalScore);
|
|
16231
16325
|
const scoreLabel = colorizeByScore(label, finalScore);
|
|
@@ -16264,37 +16358,37 @@ const printAnimatedScore = (scoreFaceLine, barFaceLine, score, label, potentialS
|
|
|
16264
16358
|
const progress = easeOutCubic(frame / 40);
|
|
16265
16359
|
const animatedScore = Math.round(score * progress);
|
|
16266
16360
|
if (isPerfectScore) {
|
|
16267
|
-
yield*
|
|
16361
|
+
yield* writeStdout(`${frame === 0 ? "" : "\x1B[4A"}\r${buildRainbowScoreHeaderFrame({
|
|
16268
16362
|
score,
|
|
16269
16363
|
displayScore: animatedScore,
|
|
16270
16364
|
label,
|
|
16271
16365
|
frame
|
|
16272
16366
|
})}`);
|
|
16273
|
-
if (frame < 40) yield* sleep(50);
|
|
16367
|
+
if (frame < 40) yield* Effect.sleep(50);
|
|
16274
16368
|
continue;
|
|
16275
16369
|
}
|
|
16276
16370
|
const animatedScoreLine = buildScoreLine(animatedScore, score, label);
|
|
16277
16371
|
const animatedBarLine = frame === 40 && potentialScore !== void 0 ? buildProjectedScoreBar(score, potentialScore) : buildScoreBar(animatedScore, score);
|
|
16278
|
-
yield*
|
|
16279
|
-
if (frame < 40) yield* sleep(50);
|
|
16372
|
+
yield* writeStdout(`${frame === 0 ? "" : "\x1B[2A"}\r${buildScoreHeaderLine(scoreFaceLine, animatedScoreLine)}\n\r${buildScoreHeaderLine(barFaceLine, animatedBarLine)}\n`);
|
|
16373
|
+
if (frame < 40) yield* Effect.sleep(50);
|
|
16280
16374
|
}
|
|
16281
16375
|
if (!isPerfectScore) return;
|
|
16282
16376
|
for (let frame = 0; frame < 16; frame += 1) {
|
|
16283
|
-
yield*
|
|
16377
|
+
yield* writeStdout(`\x1b[4A\r${buildRainbowScoreHeaderFrame({
|
|
16284
16378
|
score,
|
|
16285
16379
|
displayScore: score,
|
|
16286
16380
|
label,
|
|
16287
16381
|
frame
|
|
16288
16382
|
})}`);
|
|
16289
|
-
yield* sleep(50);
|
|
16383
|
+
yield* Effect.sleep(50);
|
|
16290
16384
|
}
|
|
16291
|
-
yield*
|
|
16385
|
+
yield* writeStdout(`\x1b[4A\r${buildFinalPerfectScoreHeaderFrame(score, label, 16)}\x1b[2A`);
|
|
16292
16386
|
});
|
|
16293
16387
|
const printScoreHeader = (scoreResult, potentialScore) => Effect.gen(function* () {
|
|
16294
16388
|
const isPerfectScore = scoreResult.score === 100;
|
|
16295
16389
|
const renderedFaceLines = buildFaceRenderedLines(scoreResult.score);
|
|
16296
16390
|
const rawFaceLines = buildRawFaceLines(scoreResult.score);
|
|
16297
|
-
const shouldAnimate = !isSpinnerSilent() &&
|
|
16391
|
+
const shouldAnimate = !isSpinnerSilent() && canAnimateOnboarding(process.stdout);
|
|
16298
16392
|
const displayScore = shouldAnimate ? 0 : scoreResult.score;
|
|
16299
16393
|
const rightColumnLines = [
|
|
16300
16394
|
buildScoreLine(displayScore, scoreResult.score, scoreResult.label),
|
|
@@ -16320,9 +16414,19 @@ const printScoreHeader = (scoreResult, potentialScore) => Effect.gen(function* (
|
|
|
16320
16414
|
}));
|
|
16321
16415
|
yield* Console.log("");
|
|
16322
16416
|
if (shouldAnimate) {
|
|
16323
|
-
yield*
|
|
16417
|
+
yield* writeStdout("\x1B[5A");
|
|
16324
16418
|
yield* printAnimatedScore(renderedFaceLines[0], renderedFaceLines[1], scoreResult.score, scoreResult.label, potentialScore);
|
|
16325
|
-
yield*
|
|
16419
|
+
yield* writeStdout("\x1B[3B");
|
|
16420
|
+
}
|
|
16421
|
+
});
|
|
16422
|
+
const animateScoreProjection = (scoreResult, potentialScore, linesBelowBar) => Effect.gen(function* () {
|
|
16423
|
+
if (scoreResult.score === 100 || potentialScore <= scoreResult.score) return;
|
|
16424
|
+
const barFaceLine = buildFaceRenderedLines(scoreResult.score)[1] ?? "";
|
|
16425
|
+
for (let frame = 1; frame <= 16; frame += 1) {
|
|
16426
|
+
const progress = easeOutCubic(frame / 16);
|
|
16427
|
+
const displayedPotential = scoreResult.score + (potentialScore - scoreResult.score) * progress;
|
|
16428
|
+
yield* writeStdout(`\x1b[${linesBelowBar}A\r${buildScoreHeaderLine(barFaceLine, buildProjectedScoreBar(scoreResult.score, displayedPotential))}\x1b[${linesBelowBar}B\r`);
|
|
16429
|
+
if (frame < 16) yield* Effect.sleep(35);
|
|
16326
16430
|
}
|
|
16327
16431
|
});
|
|
16328
16432
|
const printBrandingOnlyHeader = Effect.gen(function* () {
|
|
@@ -16375,10 +16479,12 @@ const printFooter = (input) => Effect.gen(function* () {
|
|
|
16375
16479
|
});
|
|
16376
16480
|
const printSummary = (input) => Effect.gen(function* () {
|
|
16377
16481
|
if (input.scoreResult) {
|
|
16378
|
-
|
|
16482
|
+
const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
|
|
16483
|
+
yield* printScoreHeader(input.scoreResult, animateProjection ? void 0 : input.potentialScore ?? void 0);
|
|
16379
16484
|
if (input.potentialScore != null) {
|
|
16380
16485
|
const improvement = input.potentialScore - input.scoreResult.score;
|
|
16381
16486
|
yield* Console.log(highlighter.gray(" You could improve ") + colorizeByScore(`+${improvement}%`, input.potentialScore) + highlighter.gray(` by fixing the top 3 issues`));
|
|
16487
|
+
if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
|
|
16382
16488
|
}
|
|
16383
16489
|
} else yield* printNoScoreHeader(input.noScoreMessage);
|
|
16384
16490
|
const diagnosticsDirectory = yield* Effect.try({
|
|
@@ -16646,9 +16752,12 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
16646
16752
|
else runConsole(Console.error(highlighter.error(lintFailureReason)));
|
|
16647
16753
|
const inspectDiagnostics = output.diagnostics;
|
|
16648
16754
|
const score = didLintFail ? null : output.score;
|
|
16755
|
+
const elapsedMilliseconds = performance.now() - startTime;
|
|
16756
|
+
const forceOnboarding = isOnboardingForced();
|
|
16757
|
+
const paceOnboardingSections = !options.silent && !options.scoreOnly && !options.suppressRendering && !options.verbose && canAnimateOnboarding(process.stdout) && (forceOnboarding || !hasCompletedOnboarding());
|
|
16649
16758
|
const finalizeInput = {
|
|
16650
16759
|
options,
|
|
16651
|
-
elapsedMilliseconds
|
|
16760
|
+
elapsedMilliseconds,
|
|
16652
16761
|
diagnostics: inspectDiagnostics,
|
|
16653
16762
|
score,
|
|
16654
16763
|
project: output.project,
|
|
@@ -16664,6 +16773,12 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
16664
16773
|
scanElapsedMilliseconds: output.scanElapsedMilliseconds
|
|
16665
16774
|
};
|
|
16666
16775
|
const result = await Effect.runPromise(finalizeAndRender(finalizeInput).pipe(options.silent ? Effect.provideService(Console.Console, silentConsole) : (program) => program));
|
|
16776
|
+
if (shouldRecordOnboarding({
|
|
16777
|
+
paceOnboardingSections,
|
|
16778
|
+
forceOnboarding,
|
|
16779
|
+
verbose: options.verbose,
|
|
16780
|
+
isNonInteractiveEnvironment: options.isNonInteractiveEnvironment
|
|
16781
|
+
})) markOnboardingComplete();
|
|
16667
16782
|
recordScanMetrics({
|
|
16668
16783
|
result,
|
|
16669
16784
|
mode: isDiffMode ? "diff" : "full",
|
|
@@ -16707,16 +16822,20 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
16707
16822
|
else yield* Console.log(highlighter.gray(noScoreMessage));
|
|
16708
16823
|
return buildResult();
|
|
16709
16824
|
}
|
|
16825
|
+
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
16826
|
+
const pause = onboardingSectionPause(animateRender);
|
|
16710
16827
|
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
16711
16828
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
16712
16829
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
16713
16830
|
if (surfaceDiagnostics.length === 0) {
|
|
16831
|
+
yield* pause;
|
|
16714
16832
|
if (hasSkippedChecks) {
|
|
16715
16833
|
const skippedLabel = skippedChecks.join(" and ");
|
|
16716
16834
|
yield* Console.warn(highlighter.warn(`No issues detected, but ${skippedLabel} checks failed — results are incomplete.`));
|
|
16717
16835
|
} else if (demotedDiagnosticCount > 0) yield* Console.log(highlighter.success(`No issues found! (${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface — see config.surfaces.)`));
|
|
16718
16836
|
else yield* Console.log(highlighter.success("No issues found!"));
|
|
16719
16837
|
yield* Console.log("");
|
|
16838
|
+
yield* pause;
|
|
16720
16839
|
if (hasSkippedChecks) {
|
|
16721
16840
|
yield* printBrandingOnlyHeader;
|
|
16722
16841
|
yield* Console.log(highlighter.gray(" Score not shown — some checks could not complete."));
|
|
@@ -16724,8 +16843,12 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
16724
16843
|
else yield* printNoScoreHeader(noScoreMessage);
|
|
16725
16844
|
return buildResult();
|
|
16726
16845
|
}
|
|
16846
|
+
yield* pause;
|
|
16727
16847
|
yield* Console.log("");
|
|
16728
|
-
yield* printDiagnostics([...surfaceDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment()
|
|
16848
|
+
yield* printDiagnostics([...surfaceDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment(), {
|
|
16849
|
+
sectionPause: pause,
|
|
16850
|
+
animateCountUp: animateRender
|
|
16851
|
+
});
|
|
16729
16852
|
if (options.isNonInteractiveEnvironment && options.outputSurface !== "prComment") yield* printAgentGuidance();
|
|
16730
16853
|
if (demotedDiagnosticCount > 0) {
|
|
16731
16854
|
yield* Console.log(highlighter.gray(` ${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface (e.g. design cleanup) — run \`npx react-doctor@latest .\` locally for the full list.`));
|
|
@@ -16733,6 +16856,7 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
16733
16856
|
}
|
|
16734
16857
|
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...surfaceDiagnostics], [...surfaceDiagnostics], score)) : null;
|
|
16735
16858
|
const shouldShowShareLink = !options.noScore && options.share && !options.isCi;
|
|
16859
|
+
yield* pause;
|
|
16736
16860
|
yield* printSummary({
|
|
16737
16861
|
diagnostics: [...surfaceDiagnostics],
|
|
16738
16862
|
elapsedMilliseconds,
|
|
@@ -16740,13 +16864,15 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
16740
16864
|
potentialScore,
|
|
16741
16865
|
totalSourceFileCount: lintSourceFileCount,
|
|
16742
16866
|
noScoreMessage,
|
|
16743
|
-
verbose: options.verbose
|
|
16867
|
+
verbose: options.verbose,
|
|
16868
|
+
animateProjection: animateRender
|
|
16744
16869
|
});
|
|
16745
16870
|
if (hasSkippedChecks) {
|
|
16746
16871
|
const skippedLabel = skippedChecks.join(" and ");
|
|
16747
16872
|
yield* Console.log("");
|
|
16748
16873
|
yield* Console.warn(highlighter.warn(` Note: ${skippedLabel} checks failed — score may be incomplete.`));
|
|
16749
16874
|
}
|
|
16875
|
+
yield* pause;
|
|
16750
16876
|
yield* printFooter({
|
|
16751
16877
|
diagnostics: [...surfaceDiagnostics],
|
|
16752
16878
|
scoreResult: score,
|
|
@@ -18189,7 +18315,6 @@ const copyToClipboard = (text) => {
|
|
|
18189
18315
|
//#endregion
|
|
18190
18316
|
//#region src/cli/utils/handoff-to-agent.ts
|
|
18191
18317
|
const CLIPBOARD_CHOICE = "clipboard";
|
|
18192
|
-
const PRINT_CHOICE = "print";
|
|
18193
18318
|
const SKIP_CHOICE = "skip";
|
|
18194
18319
|
const printPayload = (payload) => {
|
|
18195
18320
|
cliLogger.break();
|
|
@@ -18207,7 +18332,7 @@ const handoffToAgent = async (input) => {
|
|
|
18207
18332
|
const { handoffTarget } = await prompts({
|
|
18208
18333
|
type: "select",
|
|
18209
18334
|
name: "handoffTarget",
|
|
18210
|
-
message: "
|
|
18335
|
+
message: "Would you like to spawn an agent to fix these issues?",
|
|
18211
18336
|
choices: [
|
|
18212
18337
|
...(await detectLaunchableAgents()).map((agentId) => ({
|
|
18213
18338
|
title: getSkillAgentConfig(agentId).displayName,
|
|
@@ -18219,11 +18344,6 @@ const handoffToAgent = async (input) => {
|
|
|
18219
18344
|
description: "Paste into any agent or chat",
|
|
18220
18345
|
value: CLIPBOARD_CHOICE
|
|
18221
18346
|
},
|
|
18222
|
-
{
|
|
18223
|
-
title: "Print prompt",
|
|
18224
|
-
description: "Show the prompt below",
|
|
18225
|
-
value: PRINT_CHOICE
|
|
18226
|
-
},
|
|
18227
18347
|
{
|
|
18228
18348
|
title: "Skip",
|
|
18229
18349
|
description: "Don't hand off",
|
|
@@ -18235,7 +18355,6 @@ const handoffToAgent = async (input) => {
|
|
|
18235
18355
|
let handoffOutcome = "launch";
|
|
18236
18356
|
if (handoffTarget === void 0) handoffOutcome = "cancel";
|
|
18237
18357
|
else if (handoffTarget === SKIP_CHOICE) handoffOutcome = "skip";
|
|
18238
|
-
else if (handoffTarget === PRINT_CHOICE) handoffOutcome = "print";
|
|
18239
18358
|
else if (handoffTarget === CLIPBOARD_CHOICE) handoffOutcome = "clipboard";
|
|
18240
18359
|
recordCount(METRIC.agentHandoff, 1, {
|
|
18241
18360
|
outcome: handoffOutcome,
|
|
@@ -18247,10 +18366,6 @@ const handoffToAgent = async (input) => {
|
|
|
18247
18366
|
diagnostics: input.diagnostics,
|
|
18248
18367
|
projectName: input.projectName
|
|
18249
18368
|
});
|
|
18250
|
-
if (handoffTarget === PRINT_CHOICE) {
|
|
18251
|
-
printPayload(payload);
|
|
18252
|
-
return;
|
|
18253
|
-
}
|
|
18254
18369
|
if (handoffTarget === CLIPBOARD_CHOICE) {
|
|
18255
18370
|
if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
|
|
18256
18371
|
else printPayload(payload);
|
|
@@ -18367,6 +18482,35 @@ const printBrandedHeader = Effect.gen(function* () {
|
|
|
18367
18482
|
yield* Console.log("");
|
|
18368
18483
|
});
|
|
18369
18484
|
//#endregion
|
|
18485
|
+
//#region src/cli/utils/render-welcome.ts
|
|
18486
|
+
const HAPPY_FACE_LINES = [
|
|
18487
|
+
"┌─────┐",
|
|
18488
|
+
"│ ◠ ◠ │",
|
|
18489
|
+
"│ ▽ │",
|
|
18490
|
+
"└─────┘"
|
|
18491
|
+
];
|
|
18492
|
+
const typeLine = (linePrefix, text, style) => Effect.gen(function* () {
|
|
18493
|
+
const characters = [...text];
|
|
18494
|
+
for (let length = 1; length <= characters.length; length += 1) {
|
|
18495
|
+
yield* writeStdout(`\r${linePrefix}${style(characters.slice(0, length).join(""))}\x1b[K`);
|
|
18496
|
+
yield* Effect.sleep(32);
|
|
18497
|
+
}
|
|
18498
|
+
});
|
|
18499
|
+
const playWelcomeScene = () => Effect.gen(function* () {
|
|
18500
|
+
const face = HAPPY_FACE_LINES.map((line) => highlighter.success(line));
|
|
18501
|
+
const mouthPrefix = ` ${face[2] ?? ""} `;
|
|
18502
|
+
yield* writeStdout(`\n${face.map((line) => ` ${line}`).join("\n")}\n`);
|
|
18503
|
+
yield* writeStdout("\x1B[3A");
|
|
18504
|
+
yield* typeLine(` ${face[1] ?? ""} `, "Welcome to React Doctor", (fragment) => highlighter.bold(fragment));
|
|
18505
|
+
yield* Effect.sleep(500);
|
|
18506
|
+
yield* writeStdout("\x1B[1B");
|
|
18507
|
+
yield* typeLine(mouthPrefix, "I diagnose your React code for bugs, security & performance.", (fragment) => highlighter.dim(fragment));
|
|
18508
|
+
yield* Effect.sleep(WELCOME_EXPLANATION_HOLD_MS);
|
|
18509
|
+
yield* typeLine(mouthPrefix, "Let's scan your codebase...", (fragment) => highlighter.dim(fragment));
|
|
18510
|
+
yield* Effect.sleep(WELCOME_HOLD_MS);
|
|
18511
|
+
yield* writeStdout("\x1B[3A\r\x1B[0J");
|
|
18512
|
+
});
|
|
18513
|
+
//#endregion
|
|
18370
18514
|
//#region src/cli/utils/report-error.ts
|
|
18371
18515
|
/**
|
|
18372
18516
|
* Sends an error to Sentry — enriched with a fresh snapshot of the current run
|
|
@@ -18828,7 +18972,7 @@ const runExplain = async (fileLineArgument, context) => {
|
|
|
18828
18972
|
}
|
|
18829
18973
|
for (const diagnostic of matchingDiagnostics) {
|
|
18830
18974
|
const ruleIdentifier = `${diagnostic.plugin}/${diagnostic.rule}`;
|
|
18831
|
-
const severitySymbol = diagnostic.severity === "error" ? "
|
|
18975
|
+
const severitySymbol = diagnostic.severity === "error" ? "✖" : "⚠";
|
|
18832
18976
|
const colorizedRule = colorizeRuleByDiagnostic(ruleIdentifier, diagnostic.severity);
|
|
18833
18977
|
const severityLabel = colorizeRuleByDiagnostic(diagnostic.severity, diagnostic.severity);
|
|
18834
18978
|
cliLogger.log(`${severitySymbol} ${colorizedRule} ${highlighter.dim(`(${severityLabel})`)} — ${diagnostic.message}`);
|
|
@@ -18947,7 +19091,8 @@ const inspectAction = async (directory, flags) => {
|
|
|
18947
19091
|
});
|
|
18948
19092
|
return;
|
|
18949
19093
|
}
|
|
18950
|
-
if (!isQuiet) Effect.
|
|
19094
|
+
if (!isQuiet) if ((isOnboardingForced() || !hasCompletedOnboarding()) && canAnimateOnboarding(process.stdout)) await Effect.runPromise(playWelcomeScene());
|
|
19095
|
+
else Effect.runSync(printBrandedHeader);
|
|
18951
19096
|
const scanOptions = resolveCliInspectOptions(flags, userConfig);
|
|
18952
19097
|
const skipPrompts = shouldSkipPrompts({
|
|
18953
19098
|
yes: flags.yes,
|
|
@@ -20016,4 +20161,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
|
20016
20161
|
export {};
|
|
20017
20162
|
|
|
20018
20163
|
//# sourceMappingURL=cli.js.map
|
|
20019
|
-
//# debugId=
|
|
20164
|
+
//# debugId=83b0602f-f294-5164-861f-82491ff58bf0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.16-dev.
|
|
3
|
+
"version": "0.2.16-dev.ec5d58c",
|
|
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.16-dev.
|
|
66
|
+
"oxlint-plugin-react-doctor": "0.2.16-dev.ec5d58c"
|
|
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/api": "0.2.16",
|
|
75
|
+
"@react-doctor/core": "0.2.16"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": "^20.19.0 || >=22.12.0"
|