react-doctor 0.4.0-dev.a5c6993 → 0.4.0-dev.ee980d9
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 +4 -3
- package/dist/cli.js +199 -27
- package/dist/index.js +3 -2
- package/dist/lsp.js +3 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ permissions:
|
|
|
66
66
|
contents: read
|
|
67
67
|
pull-requests: write
|
|
68
68
|
issues: write
|
|
69
|
+
statuses: write # lets the action publish the score as a commit status
|
|
69
70
|
|
|
70
71
|
concurrency:
|
|
71
72
|
group: react-doctor-${{ github.event.pull_request.number || github.ref }}
|
|
@@ -78,15 +79,15 @@ jobs:
|
|
|
78
79
|
- uses: actions/checkout@v5
|
|
79
80
|
with:
|
|
80
81
|
fetch-depth: 0 # so React Doctor can diff against the merge-base for new-vs-existing
|
|
81
|
-
- uses: millionco/react-doctor@
|
|
82
|
+
- uses: millionco/react-doctor@v2
|
|
82
83
|
```
|
|
83
84
|
|
|
84
85
|
`fetch-depth: 0` is recommended so the baseline comparison can read the base commit; without enough history the Action falls back to reporting every finding in the changed files.
|
|
85
86
|
|
|
86
|
-
`@
|
|
87
|
+
`@v2` always resolves to the latest `v2.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:
|
|
87
88
|
|
|
88
89
|
```yaml
|
|
89
|
-
- uses: millionco/react-doctor@
|
|
90
|
+
- uses: millionco/react-doctor@75932719d11ef50e110eac01ce04acdc05fde074 # v2.0.1
|
|
90
91
|
```
|
|
91
92
|
|
|
92
93
|
[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]="97daaac0-bc19-511e-baba-f43ac0b855ea")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
@@ -8394,6 +8394,7 @@ const checkReducedMotion = (rootDirectory) => {
|
|
|
8394
8394
|
if (!hasMotionLibrary) return [];
|
|
8395
8395
|
const result = spawnSync("git", [
|
|
8396
8396
|
"grep",
|
|
8397
|
+
"--untracked",
|
|
8397
8398
|
"-ql",
|
|
8398
8399
|
"-E",
|
|
8399
8400
|
REDUCED_MOTION_GREP_PATTERN,
|
|
@@ -12191,7 +12192,7 @@ const makeNoopConsole = () => ({
|
|
|
12191
12192
|
});
|
|
12192
12193
|
//#endregion
|
|
12193
12194
|
//#region src/cli/utils/version.ts
|
|
12194
|
-
const VERSION = "0.4.0-dev.
|
|
12195
|
+
const VERSION = "0.4.0-dev.ee980d9";
|
|
12195
12196
|
//#endregion
|
|
12196
12197
|
//#region src/cli/utils/json-mode.ts
|
|
12197
12198
|
let context = null;
|
|
@@ -12549,13 +12550,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12549
12550
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12550
12551
|
* standard `SENTRY_RELEASE` override.
|
|
12551
12552
|
*/
|
|
12552
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0-dev.
|
|
12553
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0-dev.ee980d9`;
|
|
12553
12554
|
/**
|
|
12554
12555
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12555
12556
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12556
12557
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12557
12558
|
*/
|
|
12558
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0-dev.
|
|
12559
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0-dev.ee980d9") ? "development" : "production");
|
|
12559
12560
|
/**
|
|
12560
12561
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12561
12562
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -16752,10 +16753,10 @@ const canAnimateOnboarding = (stream = process.stdout) => {
|
|
|
16752
16753
|
};
|
|
16753
16754
|
//#endregion
|
|
16754
16755
|
//#region src/cli/utils/onboarding-state.ts
|
|
16755
|
-
const GLOBAL_CONFIG_PROJECT_NAME$
|
|
16756
|
+
const GLOBAL_CONFIG_PROJECT_NAME$2 = "react-doctor";
|
|
16756
16757
|
const ONBOARDED_AT_KEY = "onboardedAt";
|
|
16757
16758
|
const getOnboardingStore = (options = {}) => new Conf({
|
|
16758
|
-
projectName: GLOBAL_CONFIG_PROJECT_NAME$
|
|
16759
|
+
projectName: GLOBAL_CONFIG_PROJECT_NAME$2,
|
|
16759
16760
|
cwd: options.cwd
|
|
16760
16761
|
});
|
|
16761
16762
|
const hasCompletedOnboarding = (options = {}) => {
|
|
@@ -17719,9 +17720,9 @@ const buildHandoffPayload = (input) => {
|
|
|
17719
17720
|
};
|
|
17720
17721
|
//#endregion
|
|
17721
17722
|
//#region src/cli/utils/is-command-available.ts
|
|
17722
|
-
const isWindows = process.platform === "win32";
|
|
17723
|
+
const isWindows$1 = process.platform === "win32";
|
|
17723
17724
|
const candidateFileNames = (command) => {
|
|
17724
|
-
if (!isWindows || path$1.extname(command)) return [command];
|
|
17725
|
+
if (!isWindows$1 || path$1.extname(command)) return [command];
|
|
17725
17726
|
return [command, ...(process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean).map((extension) => `${command}${extension}`)];
|
|
17726
17727
|
};
|
|
17727
17728
|
const isCommandAvailable = (command) => {
|
|
@@ -17730,7 +17731,7 @@ const isCommandAvailable = (command) => {
|
|
|
17730
17731
|
const binaryPath = path$1.join(directory, fileName);
|
|
17731
17732
|
try {
|
|
17732
17733
|
if (!fs$1.statSync(binaryPath).isFile()) continue;
|
|
17733
|
-
if (!isWindows) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
|
|
17734
|
+
if (!isWindows$1) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
|
|
17734
17735
|
return true;
|
|
17735
17736
|
} catch {}
|
|
17736
17737
|
}
|
|
@@ -18143,6 +18144,11 @@ permissions:
|
|
|
18143
18144
|
# comments (PRs are issues under the hood). Not exercised on \`push\`
|
|
18144
18145
|
# events, so safe to drop if you only run on \`main\`.
|
|
18145
18146
|
issues: write
|
|
18147
|
+
# Lets the action publish a commit status with the score + error/warning
|
|
18148
|
+
# counts (links to the run). This is how a \`push\` to \`main\` surfaces its
|
|
18149
|
+
# result, since the PR comment is skipped off pull requests. Drop it to
|
|
18150
|
+
# disable the status (or set \`commit-status: false\` below).
|
|
18151
|
+
statuses: write
|
|
18146
18152
|
|
|
18147
18153
|
# Cancels any in-flight scan for the same PR (or branch, on push) the moment
|
|
18148
18154
|
# a new commit arrives, so reviewers only ever see the latest run.
|
|
@@ -18156,20 +18162,42 @@ jobs:
|
|
|
18156
18162
|
steps:
|
|
18157
18163
|
- uses: actions/checkout@v5
|
|
18158
18164
|
|
|
18159
|
-
- uses: millionco/react-doctor@
|
|
18165
|
+
- uses: millionco/react-doctor@v2
|
|
18160
18166
|
# Common configuration knobs — uncomment any to override the default.
|
|
18161
18167
|
# Full reference: https://www.react.doctor/ci
|
|
18162
18168
|
# with:
|
|
18163
|
-
#
|
|
18164
|
-
#
|
|
18169
|
+
# blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
|
|
18170
|
+
# scope: full # On PRs, scan the whole project instead of just changed files
|
|
18165
18171
|
# comment: false # Disable the sticky PR summary comment
|
|
18166
|
-
#
|
|
18167
|
-
#
|
|
18172
|
+
# review-comments: false # Disable inline review comments on changed lines
|
|
18173
|
+
# commit-status: false # Disable the commit status (score + counts, links to the run)
|
|
18174
|
+
# version: "0.4.0" # Pin to a specific react-doctor version instead of "latest"
|
|
18168
18175
|
# directory: apps/web # Scan a sub-directory (default: ".")
|
|
18169
18176
|
# project: "web,admin" # In a monorepo, scan specific workspace project(s)
|
|
18170
18177
|
`;
|
|
18171
18178
|
const getReactDoctorWorkflowPath = (projectRoot) => path$1.join(projectRoot, ".github", "workflows", "react-doctor.yml");
|
|
18172
18179
|
const isReactDoctorWorkflowInstalled = (projectRoot) => fs$1.existsSync(getReactDoctorWorkflowPath(projectRoot));
|
|
18180
|
+
const V1_FLOATING_ACTION_REF = String.raw`millionco/react-doctor@v1(?![\w.])`;
|
|
18181
|
+
const V2_FLOATING_ACTION_REF = "millionco/react-doctor@v2";
|
|
18182
|
+
const readReactDoctorWorkflow = (projectRoot) => {
|
|
18183
|
+
const workflowPath = getReactDoctorWorkflowPath(projectRoot);
|
|
18184
|
+
try {
|
|
18185
|
+
return {
|
|
18186
|
+
workflowPath,
|
|
18187
|
+
content: fs$1.readFileSync(workflowPath, "utf8")
|
|
18188
|
+
};
|
|
18189
|
+
} catch {
|
|
18190
|
+
return null;
|
|
18191
|
+
}
|
|
18192
|
+
};
|
|
18193
|
+
const workflowUsesV1Action = (content) => new RegExp(V1_FLOATING_ACTION_REF).test(content);
|
|
18194
|
+
const upgradeWorkflowActionToV2 = (content) => {
|
|
18195
|
+
const upgraded = content.replace(new RegExp(V1_FLOATING_ACTION_REF, "g"), V2_FLOATING_ACTION_REF);
|
|
18196
|
+
return {
|
|
18197
|
+
content: upgraded,
|
|
18198
|
+
changed: upgraded !== content
|
|
18199
|
+
};
|
|
18200
|
+
};
|
|
18173
18201
|
const installReactDoctorWorkflow = (projectRoot) => {
|
|
18174
18202
|
const workflowPath = getReactDoctorWorkflowPath(projectRoot);
|
|
18175
18203
|
if (fs$1.existsSync(workflowPath)) return {
|
|
@@ -18999,6 +19027,41 @@ const runInstallReactDoctor = async (options = {}) => {
|
|
|
18999
19027
|
for (const agent of selectedAgents) recordCount(METRIC.installAgent, 1, { agent });
|
|
19000
19028
|
};
|
|
19001
19029
|
//#endregion
|
|
19030
|
+
//#region src/cli/utils/hash-project-root.ts
|
|
19031
|
+
const hashProjectRoot = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
|
|
19032
|
+
//#endregion
|
|
19033
|
+
//#region src/cli/utils/action-upgrade-prompt.ts
|
|
19034
|
+
const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
|
|
19035
|
+
const getActionUpgradeStore = (options = {}) => new Conf({
|
|
19036
|
+
projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
|
|
19037
|
+
cwd: options.cwd
|
|
19038
|
+
});
|
|
19039
|
+
const hasHandledActionUpgrade = (projectRoot, storeOptions = {}) => {
|
|
19040
|
+
try {
|
|
19041
|
+
const upgrades = getActionUpgradeStore(storeOptions).get("actionUpgrades", {});
|
|
19042
|
+
return Boolean(upgrades[hashProjectRoot(projectRoot)]);
|
|
19043
|
+
} catch {
|
|
19044
|
+
return true;
|
|
19045
|
+
}
|
|
19046
|
+
};
|
|
19047
|
+
const recordActionUpgradeDecision = (projectRoot, outcome, storeOptions = {}) => {
|
|
19048
|
+
try {
|
|
19049
|
+
const store = getActionUpgradeStore(storeOptions);
|
|
19050
|
+
const upgrades = store.get("actionUpgrades", {});
|
|
19051
|
+
store.set("actionUpgrades", {
|
|
19052
|
+
...upgrades,
|
|
19053
|
+
[hashProjectRoot(projectRoot)]: {
|
|
19054
|
+
rootDirectory: path$1.resolve(projectRoot),
|
|
19055
|
+
outcome,
|
|
19056
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
19057
|
+
}
|
|
19058
|
+
});
|
|
19059
|
+
return true;
|
|
19060
|
+
} catch {
|
|
19061
|
+
return false;
|
|
19062
|
+
}
|
|
19063
|
+
};
|
|
19064
|
+
//#endregion
|
|
19002
19065
|
//#region src/cli/utils/install-skill-for-agent.ts
|
|
19003
19066
|
const installReactDoctorSkillForAgent = async (agent, projectRoot) => {
|
|
19004
19067
|
const source = getSkillSourceDirectory();
|
|
@@ -19049,9 +19112,9 @@ const openUrl = (url) => {
|
|
|
19049
19112
|
//#endregion
|
|
19050
19113
|
//#region src/cli/utils/open-workflow-pull-request.ts
|
|
19051
19114
|
const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
|
|
19052
|
-
const
|
|
19053
|
-
const
|
|
19054
|
-
const
|
|
19115
|
+
const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
|
|
19116
|
+
const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
|
|
19117
|
+
const DEFAULT_PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
|
|
19055
19118
|
|
|
19056
19119
|
Docs: https://www.react.doctor/ci`;
|
|
19057
19120
|
const execFileAsync = promisify(execFile);
|
|
@@ -19103,6 +19166,9 @@ const findUniqueBranchName = async (cwd) => {
|
|
|
19103
19166
|
};
|
|
19104
19167
|
const openWorkflowPullRequest = async (params) => {
|
|
19105
19168
|
const workflowPath = path$1.resolve(params.workflowPath);
|
|
19169
|
+
const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
|
|
19170
|
+
const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
|
|
19171
|
+
const prBody = params.prBody ?? DEFAULT_PR_BODY;
|
|
19106
19172
|
const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], path$1.dirname(workflowPath));
|
|
19107
19173
|
if (!repoRootProbe.success) return {
|
|
19108
19174
|
status: "not-attempted",
|
|
@@ -19169,7 +19235,7 @@ const openWorkflowPullRequest = async (params) => {
|
|
|
19169
19235
|
if (!(await run("git", [
|
|
19170
19236
|
"commit",
|
|
19171
19237
|
"-m",
|
|
19172
|
-
|
|
19238
|
+
commitMessage
|
|
19173
19239
|
], cwd)).success) {
|
|
19174
19240
|
await restoreToPreviousBranch(true);
|
|
19175
19241
|
return {
|
|
@@ -19193,9 +19259,9 @@ const openWorkflowPullRequest = async (params) => {
|
|
|
19193
19259
|
"pr",
|
|
19194
19260
|
"create",
|
|
19195
19261
|
"--title",
|
|
19196
|
-
|
|
19262
|
+
prTitle,
|
|
19197
19263
|
"--body",
|
|
19198
|
-
|
|
19264
|
+
prBody,
|
|
19199
19265
|
"--base",
|
|
19200
19266
|
defaultBranch,
|
|
19201
19267
|
"--head",
|
|
@@ -19223,6 +19289,7 @@ const stageWorkflowFile = async (params) => {
|
|
|
19223
19289
|
};
|
|
19224
19290
|
//#endregion
|
|
19225
19291
|
//#region src/cli/utils/launch-agent.ts
|
|
19292
|
+
const isWindows = process.platform === "win32";
|
|
19226
19293
|
const CLI_AGENT_BINARIES = {
|
|
19227
19294
|
"claude-code": "claude",
|
|
19228
19295
|
codex: "codex",
|
|
@@ -19233,14 +19300,47 @@ const CLI_AGENT_AUTO_FLAGS = {
|
|
|
19233
19300
|
codex: ["--yolo"],
|
|
19234
19301
|
cursor: ["--force"]
|
|
19235
19302
|
};
|
|
19236
|
-
const
|
|
19237
|
-
|
|
19303
|
+
const resolveWindowsCmdEntryScript = (command) => {
|
|
19304
|
+
if (!isWindows) return null;
|
|
19305
|
+
const pathDirectories = (process.env.PATH ?? "").split(path$1.delimiter).filter(Boolean);
|
|
19306
|
+
for (const directory of pathDirectories) {
|
|
19307
|
+
const cmdFilePath = path$1.join(directory, `${command}.cmd`);
|
|
19308
|
+
try {
|
|
19309
|
+
if (!fs$1.statSync(cmdFilePath).isFile()) continue;
|
|
19310
|
+
} catch {
|
|
19311
|
+
continue;
|
|
19312
|
+
}
|
|
19313
|
+
try {
|
|
19314
|
+
const entryScriptMatch = fs$1.readFileSync(cmdFilePath, "utf8").match(/"%(?:~dp0|dp0%)\\([^"]+\.(?:m?js|cjs))"/);
|
|
19315
|
+
if (!entryScriptMatch) continue;
|
|
19316
|
+
const resolvedScriptPath = path$1.resolve(directory, entryScriptMatch[1]);
|
|
19317
|
+
if (fs$1.statSync(resolvedScriptPath).isFile()) return resolvedScriptPath;
|
|
19318
|
+
} catch {}
|
|
19319
|
+
}
|
|
19320
|
+
return null;
|
|
19321
|
+
};
|
|
19322
|
+
const spawnAgent = (command, args, cwd, shell = false) => new Promise((resolve, reject) => {
|
|
19323
|
+
const child = spawn(command, [...args], {
|
|
19238
19324
|
cwd,
|
|
19239
|
-
stdio: "inherit"
|
|
19325
|
+
stdio: "inherit",
|
|
19326
|
+
shell
|
|
19240
19327
|
});
|
|
19241
19328
|
child.on("error", reject);
|
|
19242
19329
|
child.on("close", (code) => resolve(code ?? 0));
|
|
19243
19330
|
});
|
|
19331
|
+
const launchCliAgent = async (agentId, prompt, cwd) => {
|
|
19332
|
+
const binary = CLI_AGENT_BINARIES[agentId];
|
|
19333
|
+
const agentArgs = [...CLI_AGENT_AUTO_FLAGS[agentId], prompt];
|
|
19334
|
+
if (isWindows) {
|
|
19335
|
+
const entryScript = resolveWindowsCmdEntryScript(binary);
|
|
19336
|
+
if (entryScript) return spawnAgent(process.execPath, [entryScript, ...agentArgs], cwd);
|
|
19337
|
+
}
|
|
19338
|
+
try {
|
|
19339
|
+
return await spawnAgent(binary, agentArgs, cwd);
|
|
19340
|
+
} catch {
|
|
19341
|
+
throw new Error(`Failed to launch ${binary}`);
|
|
19342
|
+
}
|
|
19343
|
+
};
|
|
19244
19344
|
const CLIPBOARD_COMMANDS = [
|
|
19245
19345
|
{
|
|
19246
19346
|
binary: "pbcopy",
|
|
@@ -19313,6 +19413,77 @@ const setUpGitHubActions = async (rootDirectory) => {
|
|
|
19313
19413
|
}
|
|
19314
19414
|
cliLogger.log(` Learn more: ${highlighter.info(CI_URL)}`);
|
|
19315
19415
|
};
|
|
19416
|
+
const UPGRADE_YES_CHOICE = "upgrade-yes";
|
|
19417
|
+
const UPGRADE_NO_CHOICE = "upgrade-no";
|
|
19418
|
+
const UPGRADE_COMMIT_MESSAGE = "ci: upgrade React Doctor GitHub Action to v2";
|
|
19419
|
+
const UPGRADE_PR_TITLE = "Upgrade React Doctor Action to v2";
|
|
19420
|
+
const UPGRADE_PR_BODY = `Bumps the React Doctor GitHub Actions workflow to the action's latest major, \`millionco/react-doctor@v2\`.
|
|
19421
|
+
|
|
19422
|
+
Docs: https://www.react.doctor/ci`;
|
|
19423
|
+
const askUpgradeActionVersion = async () => {
|
|
19424
|
+
const { upgradeChoice } = await prompts({
|
|
19425
|
+
type: "select",
|
|
19426
|
+
name: "upgradeChoice",
|
|
19427
|
+
message: "A new major of the React Doctor Action (v2) is out. Upgrade this repo's workflow?",
|
|
19428
|
+
hint: " ",
|
|
19429
|
+
choices: [{
|
|
19430
|
+
title: "Yes (recommended)",
|
|
19431
|
+
description: "Open a PR bumping the workflow to millionco/react-doctor@v2",
|
|
19432
|
+
value: UPGRADE_YES_CHOICE
|
|
19433
|
+
}, {
|
|
19434
|
+
title: "No, thanks",
|
|
19435
|
+
description: "Keep @v1 — won't ask again for this repo",
|
|
19436
|
+
value: UPGRADE_NO_CHOICE
|
|
19437
|
+
}],
|
|
19438
|
+
initial: 0
|
|
19439
|
+
}, { onCancel: () => true });
|
|
19440
|
+
if (upgradeChoice === void 0) return "cancel";
|
|
19441
|
+
return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
|
|
19442
|
+
};
|
|
19443
|
+
const upgradeGitHubActionsWorkflow = async (workflow) => {
|
|
19444
|
+
const { content, changed } = upgradeWorkflowActionToV2(workflow.content);
|
|
19445
|
+
if (!changed) return false;
|
|
19446
|
+
const upgradeSpinner = spinner("Opening a pull request to upgrade React Doctor to v2...").start();
|
|
19447
|
+
try {
|
|
19448
|
+
fs$1.writeFileSync(workflow.workflowPath, content);
|
|
19449
|
+
} catch {
|
|
19450
|
+
upgradeSpinner.fail("Couldn't update the workflow file.");
|
|
19451
|
+
return false;
|
|
19452
|
+
}
|
|
19453
|
+
const pullRequestResult = await openWorkflowPullRequest({
|
|
19454
|
+
workflowPath: workflow.workflowPath,
|
|
19455
|
+
commitMessage: UPGRADE_COMMIT_MESSAGE,
|
|
19456
|
+
prTitle: UPGRADE_PR_TITLE,
|
|
19457
|
+
prBody: UPGRADE_PR_BODY
|
|
19458
|
+
});
|
|
19459
|
+
if (pullRequestResult.status === "pr-opened") upgradeSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
|
|
19460
|
+
else if (pullRequestResult.status === "branch-pushed") upgradeSpinner.warn(`Pushed branch ${highlighter.bold(pullRequestResult.branch)} but couldn't open a PR. Open one with: gh pr create --head ${pullRequestResult.branch}`);
|
|
19461
|
+
else {
|
|
19462
|
+
upgradeSpinner.stop();
|
|
19463
|
+
try {
|
|
19464
|
+
fs$1.writeFileSync(workflow.workflowPath, content);
|
|
19465
|
+
} catch {
|
|
19466
|
+
cliLogger.log(" Couldn't finish the upgrade. Re-run React Doctor to try again.");
|
|
19467
|
+
return false;
|
|
19468
|
+
}
|
|
19469
|
+
const didStage = await stageWorkflowFile({ workflowPath: workflow.workflowPath });
|
|
19470
|
+
cliLogger.log(didStage ? " Updated the workflow to @v2 and staged it. Commit it to finish the upgrade." : " Updated the workflow to @v2. Commit the change to finish the upgrade.");
|
|
19471
|
+
}
|
|
19472
|
+
return true;
|
|
19473
|
+
};
|
|
19474
|
+
const maybeOfferActionUpgrade = async (projectRoot) => {
|
|
19475
|
+
const workflow = readReactDoctorWorkflow(projectRoot);
|
|
19476
|
+
if (!workflow || !workflowUsesV1Action(workflow.content)) return;
|
|
19477
|
+
if (hasHandledActionUpgrade(projectRoot)) return;
|
|
19478
|
+
const outcome = await askUpgradeActionVersion();
|
|
19479
|
+
if (outcome === "cancel") return;
|
|
19480
|
+
recordCount(METRIC.agentHandoff, 1, { outcome: outcome === "yes" ? "upgrade-accepted" : "upgrade-declined" });
|
|
19481
|
+
if (outcome === "no") {
|
|
19482
|
+
recordActionUpgradeDecision(projectRoot, "declined");
|
|
19483
|
+
return;
|
|
19484
|
+
}
|
|
19485
|
+
if (await upgradeGitHubActionsWorkflow(workflow)) recordActionUpgradeDecision(projectRoot, "accepted");
|
|
19486
|
+
};
|
|
19316
19487
|
const SGR_BOLD_OFF = "\x1B[22m";
|
|
19317
19488
|
const ciQuestionMessage = [
|
|
19318
19489
|
"Add React Doctor to GitHub Actions?",
|
|
@@ -19360,7 +19531,8 @@ const detectLaunchableAgents = async () => {
|
|
|
19360
19531
|
const handoffToAgent = async (input) => {
|
|
19361
19532
|
if (!input.interactive || input.diagnostics.length === 0) return;
|
|
19362
19533
|
cliLogger.break();
|
|
19363
|
-
|
|
19534
|
+
const projectRootForCi = findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory;
|
|
19535
|
+
if (!isReactDoctorWorkflowInstalled(projectRootForCi)) {
|
|
19364
19536
|
const ciOutcome = await askAddToGitHubActions();
|
|
19365
19537
|
recordCount(METRIC.agentHandoff, 1, {
|
|
19366
19538
|
outcome: `ci-${ciOutcome}`,
|
|
@@ -19371,7 +19543,7 @@ const handoffToAgent = async (input) => {
|
|
|
19371
19543
|
await setUpGitHubActions(input.rootDirectory);
|
|
19372
19544
|
cliLogger.break();
|
|
19373
19545
|
}
|
|
19374
|
-
}
|
|
19546
|
+
} else await maybeOfferActionUpgrade(projectRootForCi);
|
|
19375
19547
|
const { handoffTarget } = await prompts({
|
|
19376
19548
|
type: "select",
|
|
19377
19549
|
name: "handoffTarget",
|
|
@@ -19705,7 +19877,7 @@ const getSetupPromptStore = (options = {}) => new Conf({
|
|
|
19705
19877
|
projectName: GLOBAL_CONFIG_PROJECT_NAME,
|
|
19706
19878
|
cwd: options.cwd
|
|
19707
19879
|
});
|
|
19708
|
-
const getSetupPromptProjectKey = (projectRoot) =>
|
|
19880
|
+
const getSetupPromptProjectKey = (projectRoot) => hashProjectRoot(projectRoot);
|
|
19709
19881
|
const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
|
|
19710
19882
|
try {
|
|
19711
19883
|
return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
|
|
@@ -21277,4 +21449,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
21277
21449
|
export {};
|
|
21278
21450
|
|
|
21279
21451
|
//# sourceMappingURL=cli.js.map
|
|
21280
|
-
//# debugId=
|
|
21452
|
+
//# debugId=97daaac0-bc19-511e-baba-f43ac0b855ea
|
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]="122e86e2-7fd2-5262-b325-14cf4d9fee78")}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";
|
|
@@ -5343,6 +5343,7 @@ const checkReducedMotion = (rootDirectory) => {
|
|
|
5343
5343
|
if (!hasMotionLibrary) return [];
|
|
5344
5344
|
const result = spawnSync("git", [
|
|
5345
5345
|
"grep",
|
|
5346
|
+
"--untracked",
|
|
5346
5347
|
"-ql",
|
|
5347
5348
|
"-E",
|
|
5348
5349
|
REDUCED_MOTION_GREP_PATTERN,
|
|
@@ -8929,4 +8930,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8929
8930
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8930
8931
|
|
|
8931
8932
|
//# sourceMappingURL=index.js.map
|
|
8932
|
-
//# debugId=
|
|
8933
|
+
//# debugId=122e86e2-7fd2-5262-b325-14cf4d9fee78
|
package/dist/lsp.js
CHANGED
|
@@ -5280,6 +5280,7 @@ const checkReducedMotion = (rootDirectory) => {
|
|
|
5280
5280
|
if (!hasMotionLibrary) return [];
|
|
5281
5281
|
const result = spawnSync("git", [
|
|
5282
5282
|
"grep",
|
|
5283
|
+
"--untracked",
|
|
5283
5284
|
"-ql",
|
|
5284
5285
|
"-E",
|
|
5285
5286
|
REDUCED_MOTION_GREP_PATTERN,
|
|
@@ -10800,5 +10801,5 @@ const startLanguageServer = () => {
|
|
|
10800
10801
|
};
|
|
10801
10802
|
//#endregion
|
|
10802
10803
|
export { startLanguageServer };
|
|
10803
|
-
!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]="
|
|
10804
|
-
//# debugId=
|
|
10804
|
+
!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]="f0bc459c-958b-51a1-8126-2e157a9bb5d3")}catch(e){}}();
|
|
10805
|
+
//# debugId=f0bc459c-958b-51a1-8126-2e157a9bb5d3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.ee980d9",
|
|
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.20",
|
|
59
59
|
"effect": "4.0.0-beta.70",
|
|
60
60
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
61
61
|
"jiti": "^2.7.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vscode-languageserver": "^9.0.1",
|
|
67
67
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
68
68
|
"vscode-uri": "^3.1.0",
|
|
69
|
-
"oxlint-plugin-react-doctor": "0.4.0-dev.
|
|
69
|
+
"oxlint-plugin-react-doctor": "0.4.0-dev.ee980d9"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"@xterm/headless": "^6.0.0",
|
|
75
75
|
"commander": "^14.0.3",
|
|
76
76
|
"ora": "^9.4.0",
|
|
77
|
-
"@react-doctor/
|
|
77
|
+
"@react-doctor/api": "0.2.20",
|
|
78
78
|
"@react-doctor/language-server": "0.2.12",
|
|
79
|
-
"@react-doctor/
|
|
79
|
+
"@react-doctor/core": "0.3.0"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": "^20.19.0 || >=22.12.0"
|