react-doctor 0.4.0-dev.a5c6993 → 0.4.0-dev.dc35070
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 +198 -27
- package/package.json +4 -4
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]="301c4437-ca87-5afb-b69d-b7a7c3678175")}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";
|
|
@@ -12191,7 +12191,7 @@ const makeNoopConsole = () => ({
|
|
|
12191
12191
|
});
|
|
12192
12192
|
//#endregion
|
|
12193
12193
|
//#region src/cli/utils/version.ts
|
|
12194
|
-
const VERSION = "0.4.0-dev.
|
|
12194
|
+
const VERSION = "0.4.0-dev.dc35070";
|
|
12195
12195
|
//#endregion
|
|
12196
12196
|
//#region src/cli/utils/json-mode.ts
|
|
12197
12197
|
let context = null;
|
|
@@ -12549,13 +12549,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12549
12549
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12550
12550
|
* standard `SENTRY_RELEASE` override.
|
|
12551
12551
|
*/
|
|
12552
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0-dev.
|
|
12552
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0-dev.dc35070`;
|
|
12553
12553
|
/**
|
|
12554
12554
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12555
12555
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12556
12556
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12557
12557
|
*/
|
|
12558
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0-dev.
|
|
12558
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0-dev.dc35070") ? "development" : "production");
|
|
12559
12559
|
/**
|
|
12560
12560
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12561
12561
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -16752,10 +16752,10 @@ const canAnimateOnboarding = (stream = process.stdout) => {
|
|
|
16752
16752
|
};
|
|
16753
16753
|
//#endregion
|
|
16754
16754
|
//#region src/cli/utils/onboarding-state.ts
|
|
16755
|
-
const GLOBAL_CONFIG_PROJECT_NAME$
|
|
16755
|
+
const GLOBAL_CONFIG_PROJECT_NAME$2 = "react-doctor";
|
|
16756
16756
|
const ONBOARDED_AT_KEY = "onboardedAt";
|
|
16757
16757
|
const getOnboardingStore = (options = {}) => new Conf({
|
|
16758
|
-
projectName: GLOBAL_CONFIG_PROJECT_NAME$
|
|
16758
|
+
projectName: GLOBAL_CONFIG_PROJECT_NAME$2,
|
|
16759
16759
|
cwd: options.cwd
|
|
16760
16760
|
});
|
|
16761
16761
|
const hasCompletedOnboarding = (options = {}) => {
|
|
@@ -17719,9 +17719,9 @@ const buildHandoffPayload = (input) => {
|
|
|
17719
17719
|
};
|
|
17720
17720
|
//#endregion
|
|
17721
17721
|
//#region src/cli/utils/is-command-available.ts
|
|
17722
|
-
const isWindows = process.platform === "win32";
|
|
17722
|
+
const isWindows$1 = process.platform === "win32";
|
|
17723
17723
|
const candidateFileNames = (command) => {
|
|
17724
|
-
if (!isWindows || path$1.extname(command)) return [command];
|
|
17724
|
+
if (!isWindows$1 || path$1.extname(command)) return [command];
|
|
17725
17725
|
return [command, ...(process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean).map((extension) => `${command}${extension}`)];
|
|
17726
17726
|
};
|
|
17727
17727
|
const isCommandAvailable = (command) => {
|
|
@@ -17730,7 +17730,7 @@ const isCommandAvailable = (command) => {
|
|
|
17730
17730
|
const binaryPath = path$1.join(directory, fileName);
|
|
17731
17731
|
try {
|
|
17732
17732
|
if (!fs$1.statSync(binaryPath).isFile()) continue;
|
|
17733
|
-
if (!isWindows) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
|
|
17733
|
+
if (!isWindows$1) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
|
|
17734
17734
|
return true;
|
|
17735
17735
|
} catch {}
|
|
17736
17736
|
}
|
|
@@ -18143,6 +18143,11 @@ permissions:
|
|
|
18143
18143
|
# comments (PRs are issues under the hood). Not exercised on \`push\`
|
|
18144
18144
|
# events, so safe to drop if you only run on \`main\`.
|
|
18145
18145
|
issues: write
|
|
18146
|
+
# Lets the action publish a commit status with the score + error/warning
|
|
18147
|
+
# counts (links to the run). This is how a \`push\` to \`main\` surfaces its
|
|
18148
|
+
# result, since the PR comment is skipped off pull requests. Drop it to
|
|
18149
|
+
# disable the status (or set \`commit-status: false\` below).
|
|
18150
|
+
statuses: write
|
|
18146
18151
|
|
|
18147
18152
|
# Cancels any in-flight scan for the same PR (or branch, on push) the moment
|
|
18148
18153
|
# a new commit arrives, so reviewers only ever see the latest run.
|
|
@@ -18156,20 +18161,42 @@ jobs:
|
|
|
18156
18161
|
steps:
|
|
18157
18162
|
- uses: actions/checkout@v5
|
|
18158
18163
|
|
|
18159
|
-
- uses: millionco/react-doctor@
|
|
18164
|
+
- uses: millionco/react-doctor@v2
|
|
18160
18165
|
# Common configuration knobs — uncomment any to override the default.
|
|
18161
18166
|
# Full reference: https://www.react.doctor/ci
|
|
18162
18167
|
# with:
|
|
18163
|
-
#
|
|
18164
|
-
#
|
|
18168
|
+
# blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
|
|
18169
|
+
# scope: full # On PRs, scan the whole project instead of just changed files
|
|
18165
18170
|
# comment: false # Disable the sticky PR summary comment
|
|
18166
|
-
#
|
|
18167
|
-
#
|
|
18171
|
+
# review-comments: false # Disable inline review comments on changed lines
|
|
18172
|
+
# commit-status: false # Disable the commit status (score + counts, links to the run)
|
|
18173
|
+
# version: "0.4.0" # Pin to a specific react-doctor version instead of "latest"
|
|
18168
18174
|
# directory: apps/web # Scan a sub-directory (default: ".")
|
|
18169
18175
|
# project: "web,admin" # In a monorepo, scan specific workspace project(s)
|
|
18170
18176
|
`;
|
|
18171
18177
|
const getReactDoctorWorkflowPath = (projectRoot) => path$1.join(projectRoot, ".github", "workflows", "react-doctor.yml");
|
|
18172
18178
|
const isReactDoctorWorkflowInstalled = (projectRoot) => fs$1.existsSync(getReactDoctorWorkflowPath(projectRoot));
|
|
18179
|
+
const V1_FLOATING_ACTION_REF = String.raw`millionco/react-doctor@v1(?![\w.])`;
|
|
18180
|
+
const V2_FLOATING_ACTION_REF = "millionco/react-doctor@v2";
|
|
18181
|
+
const readReactDoctorWorkflow = (projectRoot) => {
|
|
18182
|
+
const workflowPath = getReactDoctorWorkflowPath(projectRoot);
|
|
18183
|
+
try {
|
|
18184
|
+
return {
|
|
18185
|
+
workflowPath,
|
|
18186
|
+
content: fs$1.readFileSync(workflowPath, "utf8")
|
|
18187
|
+
};
|
|
18188
|
+
} catch {
|
|
18189
|
+
return null;
|
|
18190
|
+
}
|
|
18191
|
+
};
|
|
18192
|
+
const workflowUsesV1Action = (content) => new RegExp(V1_FLOATING_ACTION_REF).test(content);
|
|
18193
|
+
const upgradeWorkflowActionToV2 = (content) => {
|
|
18194
|
+
const upgraded = content.replace(new RegExp(V1_FLOATING_ACTION_REF, "g"), V2_FLOATING_ACTION_REF);
|
|
18195
|
+
return {
|
|
18196
|
+
content: upgraded,
|
|
18197
|
+
changed: upgraded !== content
|
|
18198
|
+
};
|
|
18199
|
+
};
|
|
18173
18200
|
const installReactDoctorWorkflow = (projectRoot) => {
|
|
18174
18201
|
const workflowPath = getReactDoctorWorkflowPath(projectRoot);
|
|
18175
18202
|
if (fs$1.existsSync(workflowPath)) return {
|
|
@@ -18999,6 +19026,41 @@ const runInstallReactDoctor = async (options = {}) => {
|
|
|
18999
19026
|
for (const agent of selectedAgents) recordCount(METRIC.installAgent, 1, { agent });
|
|
19000
19027
|
};
|
|
19001
19028
|
//#endregion
|
|
19029
|
+
//#region src/cli/utils/hash-project-root.ts
|
|
19030
|
+
const hashProjectRoot = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
|
|
19031
|
+
//#endregion
|
|
19032
|
+
//#region src/cli/utils/action-upgrade-prompt.ts
|
|
19033
|
+
const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
|
|
19034
|
+
const getActionUpgradeStore = (options = {}) => new Conf({
|
|
19035
|
+
projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
|
|
19036
|
+
cwd: options.cwd
|
|
19037
|
+
});
|
|
19038
|
+
const hasHandledActionUpgrade = (projectRoot, storeOptions = {}) => {
|
|
19039
|
+
try {
|
|
19040
|
+
const upgrades = getActionUpgradeStore(storeOptions).get("actionUpgrades", {});
|
|
19041
|
+
return Boolean(upgrades[hashProjectRoot(projectRoot)]);
|
|
19042
|
+
} catch {
|
|
19043
|
+
return true;
|
|
19044
|
+
}
|
|
19045
|
+
};
|
|
19046
|
+
const recordActionUpgradeDecision = (projectRoot, outcome, storeOptions = {}) => {
|
|
19047
|
+
try {
|
|
19048
|
+
const store = getActionUpgradeStore(storeOptions);
|
|
19049
|
+
const upgrades = store.get("actionUpgrades", {});
|
|
19050
|
+
store.set("actionUpgrades", {
|
|
19051
|
+
...upgrades,
|
|
19052
|
+
[hashProjectRoot(projectRoot)]: {
|
|
19053
|
+
rootDirectory: path$1.resolve(projectRoot),
|
|
19054
|
+
outcome,
|
|
19055
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
19056
|
+
}
|
|
19057
|
+
});
|
|
19058
|
+
return true;
|
|
19059
|
+
} catch {
|
|
19060
|
+
return false;
|
|
19061
|
+
}
|
|
19062
|
+
};
|
|
19063
|
+
//#endregion
|
|
19002
19064
|
//#region src/cli/utils/install-skill-for-agent.ts
|
|
19003
19065
|
const installReactDoctorSkillForAgent = async (agent, projectRoot) => {
|
|
19004
19066
|
const source = getSkillSourceDirectory();
|
|
@@ -19049,9 +19111,9 @@ const openUrl = (url) => {
|
|
|
19049
19111
|
//#endregion
|
|
19050
19112
|
//#region src/cli/utils/open-workflow-pull-request.ts
|
|
19051
19113
|
const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
|
|
19052
|
-
const
|
|
19053
|
-
const
|
|
19054
|
-
const
|
|
19114
|
+
const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
|
|
19115
|
+
const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
|
|
19116
|
+
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
19117
|
|
|
19056
19118
|
Docs: https://www.react.doctor/ci`;
|
|
19057
19119
|
const execFileAsync = promisify(execFile);
|
|
@@ -19103,6 +19165,9 @@ const findUniqueBranchName = async (cwd) => {
|
|
|
19103
19165
|
};
|
|
19104
19166
|
const openWorkflowPullRequest = async (params) => {
|
|
19105
19167
|
const workflowPath = path$1.resolve(params.workflowPath);
|
|
19168
|
+
const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
|
|
19169
|
+
const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
|
|
19170
|
+
const prBody = params.prBody ?? DEFAULT_PR_BODY;
|
|
19106
19171
|
const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], path$1.dirname(workflowPath));
|
|
19107
19172
|
if (!repoRootProbe.success) return {
|
|
19108
19173
|
status: "not-attempted",
|
|
@@ -19169,7 +19234,7 @@ const openWorkflowPullRequest = async (params) => {
|
|
|
19169
19234
|
if (!(await run("git", [
|
|
19170
19235
|
"commit",
|
|
19171
19236
|
"-m",
|
|
19172
|
-
|
|
19237
|
+
commitMessage
|
|
19173
19238
|
], cwd)).success) {
|
|
19174
19239
|
await restoreToPreviousBranch(true);
|
|
19175
19240
|
return {
|
|
@@ -19193,9 +19258,9 @@ const openWorkflowPullRequest = async (params) => {
|
|
|
19193
19258
|
"pr",
|
|
19194
19259
|
"create",
|
|
19195
19260
|
"--title",
|
|
19196
|
-
|
|
19261
|
+
prTitle,
|
|
19197
19262
|
"--body",
|
|
19198
|
-
|
|
19263
|
+
prBody,
|
|
19199
19264
|
"--base",
|
|
19200
19265
|
defaultBranch,
|
|
19201
19266
|
"--head",
|
|
@@ -19223,6 +19288,7 @@ const stageWorkflowFile = async (params) => {
|
|
|
19223
19288
|
};
|
|
19224
19289
|
//#endregion
|
|
19225
19290
|
//#region src/cli/utils/launch-agent.ts
|
|
19291
|
+
const isWindows = process.platform === "win32";
|
|
19226
19292
|
const CLI_AGENT_BINARIES = {
|
|
19227
19293
|
"claude-code": "claude",
|
|
19228
19294
|
codex: "codex",
|
|
@@ -19233,14 +19299,47 @@ const CLI_AGENT_AUTO_FLAGS = {
|
|
|
19233
19299
|
codex: ["--yolo"],
|
|
19234
19300
|
cursor: ["--force"]
|
|
19235
19301
|
};
|
|
19236
|
-
const
|
|
19237
|
-
|
|
19302
|
+
const resolveWindowsCmdEntryScript = (command) => {
|
|
19303
|
+
if (!isWindows) return null;
|
|
19304
|
+
const pathDirectories = (process.env.PATH ?? "").split(path$1.delimiter).filter(Boolean);
|
|
19305
|
+
for (const directory of pathDirectories) {
|
|
19306
|
+
const cmdFilePath = path$1.join(directory, `${command}.cmd`);
|
|
19307
|
+
try {
|
|
19308
|
+
if (!fs$1.statSync(cmdFilePath).isFile()) continue;
|
|
19309
|
+
} catch {
|
|
19310
|
+
continue;
|
|
19311
|
+
}
|
|
19312
|
+
try {
|
|
19313
|
+
const entryScriptMatch = fs$1.readFileSync(cmdFilePath, "utf8").match(/"%(?:~dp0|dp0%)\\([^"]+\.(?:m?js|cjs))"/);
|
|
19314
|
+
if (!entryScriptMatch) continue;
|
|
19315
|
+
const resolvedScriptPath = path$1.resolve(directory, entryScriptMatch[1]);
|
|
19316
|
+
if (fs$1.statSync(resolvedScriptPath).isFile()) return resolvedScriptPath;
|
|
19317
|
+
} catch {}
|
|
19318
|
+
}
|
|
19319
|
+
return null;
|
|
19320
|
+
};
|
|
19321
|
+
const spawnAgent = (command, args, cwd, shell = false) => new Promise((resolve, reject) => {
|
|
19322
|
+
const child = spawn(command, [...args], {
|
|
19238
19323
|
cwd,
|
|
19239
|
-
stdio: "inherit"
|
|
19324
|
+
stdio: "inherit",
|
|
19325
|
+
shell
|
|
19240
19326
|
});
|
|
19241
19327
|
child.on("error", reject);
|
|
19242
19328
|
child.on("close", (code) => resolve(code ?? 0));
|
|
19243
19329
|
});
|
|
19330
|
+
const launchCliAgent = async (agentId, prompt, cwd) => {
|
|
19331
|
+
const binary = CLI_AGENT_BINARIES[agentId];
|
|
19332
|
+
const agentArgs = [...CLI_AGENT_AUTO_FLAGS[agentId], prompt];
|
|
19333
|
+
if (isWindows) {
|
|
19334
|
+
const entryScript = resolveWindowsCmdEntryScript(binary);
|
|
19335
|
+
if (entryScript) return spawnAgent(process.execPath, [entryScript, ...agentArgs], cwd);
|
|
19336
|
+
}
|
|
19337
|
+
try {
|
|
19338
|
+
return await spawnAgent(binary, agentArgs, cwd);
|
|
19339
|
+
} catch {
|
|
19340
|
+
throw new Error(`Failed to launch ${binary}`);
|
|
19341
|
+
}
|
|
19342
|
+
};
|
|
19244
19343
|
const CLIPBOARD_COMMANDS = [
|
|
19245
19344
|
{
|
|
19246
19345
|
binary: "pbcopy",
|
|
@@ -19313,6 +19412,77 @@ const setUpGitHubActions = async (rootDirectory) => {
|
|
|
19313
19412
|
}
|
|
19314
19413
|
cliLogger.log(` Learn more: ${highlighter.info(CI_URL)}`);
|
|
19315
19414
|
};
|
|
19415
|
+
const UPGRADE_YES_CHOICE = "upgrade-yes";
|
|
19416
|
+
const UPGRADE_NO_CHOICE = "upgrade-no";
|
|
19417
|
+
const UPGRADE_COMMIT_MESSAGE = "ci: upgrade React Doctor GitHub Action to v2";
|
|
19418
|
+
const UPGRADE_PR_TITLE = "Upgrade React Doctor Action to v2";
|
|
19419
|
+
const UPGRADE_PR_BODY = `Bumps the React Doctor GitHub Actions workflow to the action's latest major, \`millionco/react-doctor@v2\`.
|
|
19420
|
+
|
|
19421
|
+
Docs: https://www.react.doctor/ci`;
|
|
19422
|
+
const askUpgradeActionVersion = async () => {
|
|
19423
|
+
const { upgradeChoice } = await prompts({
|
|
19424
|
+
type: "select",
|
|
19425
|
+
name: "upgradeChoice",
|
|
19426
|
+
message: "A new major of the React Doctor Action (v2) is out. Upgrade this repo's workflow?",
|
|
19427
|
+
hint: " ",
|
|
19428
|
+
choices: [{
|
|
19429
|
+
title: "Yes (recommended)",
|
|
19430
|
+
description: "Open a PR bumping the workflow to millionco/react-doctor@v2",
|
|
19431
|
+
value: UPGRADE_YES_CHOICE
|
|
19432
|
+
}, {
|
|
19433
|
+
title: "No, thanks",
|
|
19434
|
+
description: "Keep @v1 — won't ask again for this repo",
|
|
19435
|
+
value: UPGRADE_NO_CHOICE
|
|
19436
|
+
}],
|
|
19437
|
+
initial: 0
|
|
19438
|
+
}, { onCancel: () => true });
|
|
19439
|
+
if (upgradeChoice === void 0) return "cancel";
|
|
19440
|
+
return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
|
|
19441
|
+
};
|
|
19442
|
+
const upgradeGitHubActionsWorkflow = async (workflow) => {
|
|
19443
|
+
const { content, changed } = upgradeWorkflowActionToV2(workflow.content);
|
|
19444
|
+
if (!changed) return false;
|
|
19445
|
+
const upgradeSpinner = spinner("Opening a pull request to upgrade React Doctor to v2...").start();
|
|
19446
|
+
try {
|
|
19447
|
+
fs$1.writeFileSync(workflow.workflowPath, content);
|
|
19448
|
+
} catch {
|
|
19449
|
+
upgradeSpinner.fail("Couldn't update the workflow file.");
|
|
19450
|
+
return false;
|
|
19451
|
+
}
|
|
19452
|
+
const pullRequestResult = await openWorkflowPullRequest({
|
|
19453
|
+
workflowPath: workflow.workflowPath,
|
|
19454
|
+
commitMessage: UPGRADE_COMMIT_MESSAGE,
|
|
19455
|
+
prTitle: UPGRADE_PR_TITLE,
|
|
19456
|
+
prBody: UPGRADE_PR_BODY
|
|
19457
|
+
});
|
|
19458
|
+
if (pullRequestResult.status === "pr-opened") upgradeSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
|
|
19459
|
+
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}`);
|
|
19460
|
+
else {
|
|
19461
|
+
upgradeSpinner.stop();
|
|
19462
|
+
try {
|
|
19463
|
+
fs$1.writeFileSync(workflow.workflowPath, content);
|
|
19464
|
+
} catch {
|
|
19465
|
+
cliLogger.log(" Couldn't finish the upgrade. Re-run React Doctor to try again.");
|
|
19466
|
+
return false;
|
|
19467
|
+
}
|
|
19468
|
+
const didStage = await stageWorkflowFile({ workflowPath: workflow.workflowPath });
|
|
19469
|
+
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.");
|
|
19470
|
+
}
|
|
19471
|
+
return true;
|
|
19472
|
+
};
|
|
19473
|
+
const maybeOfferActionUpgrade = async (projectRoot) => {
|
|
19474
|
+
const workflow = readReactDoctorWorkflow(projectRoot);
|
|
19475
|
+
if (!workflow || !workflowUsesV1Action(workflow.content)) return;
|
|
19476
|
+
if (hasHandledActionUpgrade(projectRoot)) return;
|
|
19477
|
+
const outcome = await askUpgradeActionVersion();
|
|
19478
|
+
if (outcome === "cancel") return;
|
|
19479
|
+
recordCount(METRIC.agentHandoff, 1, { outcome: outcome === "yes" ? "upgrade-accepted" : "upgrade-declined" });
|
|
19480
|
+
if (outcome === "no") {
|
|
19481
|
+
recordActionUpgradeDecision(projectRoot, "declined");
|
|
19482
|
+
return;
|
|
19483
|
+
}
|
|
19484
|
+
if (await upgradeGitHubActionsWorkflow(workflow)) recordActionUpgradeDecision(projectRoot, "accepted");
|
|
19485
|
+
};
|
|
19316
19486
|
const SGR_BOLD_OFF = "\x1B[22m";
|
|
19317
19487
|
const ciQuestionMessage = [
|
|
19318
19488
|
"Add React Doctor to GitHub Actions?",
|
|
@@ -19360,7 +19530,8 @@ const detectLaunchableAgents = async () => {
|
|
|
19360
19530
|
const handoffToAgent = async (input) => {
|
|
19361
19531
|
if (!input.interactive || input.diagnostics.length === 0) return;
|
|
19362
19532
|
cliLogger.break();
|
|
19363
|
-
|
|
19533
|
+
const projectRootForCi = findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory;
|
|
19534
|
+
if (!isReactDoctorWorkflowInstalled(projectRootForCi)) {
|
|
19364
19535
|
const ciOutcome = await askAddToGitHubActions();
|
|
19365
19536
|
recordCount(METRIC.agentHandoff, 1, {
|
|
19366
19537
|
outcome: `ci-${ciOutcome}`,
|
|
@@ -19371,7 +19542,7 @@ const handoffToAgent = async (input) => {
|
|
|
19371
19542
|
await setUpGitHubActions(input.rootDirectory);
|
|
19372
19543
|
cliLogger.break();
|
|
19373
19544
|
}
|
|
19374
|
-
}
|
|
19545
|
+
} else await maybeOfferActionUpgrade(projectRootForCi);
|
|
19375
19546
|
const { handoffTarget } = await prompts({
|
|
19376
19547
|
type: "select",
|
|
19377
19548
|
name: "handoffTarget",
|
|
@@ -19705,7 +19876,7 @@ const getSetupPromptStore = (options = {}) => new Conf({
|
|
|
19705
19876
|
projectName: GLOBAL_CONFIG_PROJECT_NAME,
|
|
19706
19877
|
cwd: options.cwd
|
|
19707
19878
|
});
|
|
19708
|
-
const getSetupPromptProjectKey = (projectRoot) =>
|
|
19879
|
+
const getSetupPromptProjectKey = (projectRoot) => hashProjectRoot(projectRoot);
|
|
19709
19880
|
const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
|
|
19710
19881
|
try {
|
|
19711
19882
|
return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
|
|
@@ -21277,4 +21448,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
21277
21448
|
export {};
|
|
21278
21449
|
|
|
21279
21450
|
//# sourceMappingURL=cli.js.map
|
|
21280
|
-
//# debugId=
|
|
21451
|
+
//# debugId=301c4437-ca87-5afb-b69d-b7a7c3678175
|
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.dc35070",
|
|
4
4
|
"description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -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.dc35070"
|
|
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/api": "0.2.20",
|
|
77
78
|
"@react-doctor/core": "0.3.0",
|
|
78
|
-
"@react-doctor/language-server": "0.2.12"
|
|
79
|
-
"@react-doctor/api": "0.2.20"
|
|
79
|
+
"@react-doctor/language-server": "0.2.12"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": "^20.19.0 || >=22.12.0"
|