react-doctor 0.4.0-dev.f75ec7a → 0.4.0-dev.fe5f3de

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 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@v1
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
- `@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:
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@b612664043a9be414166e3c6a69b355e39a8dcf4 # v1.1.1
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]="3c457dc9-865a-5459-b923-a0fb762b158f")}catch(e){}}();
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]="646273cf-f6f6-5523-a0f4-a333f73e0d4f")}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";
@@ -6004,6 +6004,11 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
6004
6004
  if (!isFile(monorepoPackageJsonPath)) return version;
6005
6005
  return resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
6006
6006
  };
6007
+ const getNextjsDependencySpec = (packageJson) => {
6008
+ const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
6009
+ return typeof spec === "string" ? spec : null;
6010
+ };
6011
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
6007
6012
  const getPreactVersion = (packageJson) => {
6008
6013
  return {
6009
6014
  ...packageJson.peerDependencies,
@@ -6253,6 +6258,12 @@ const discoverProject = (directory) => {
6253
6258
  version: findShopifyFlashListVersion(directory, packageJson)
6254
6259
  }) : null;
6255
6260
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
6261
+ const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
6262
+ rootDirectory: directory,
6263
+ rootPackageJson: packageJson,
6264
+ packageName: "next",
6265
+ version: findNextjsVersion(directory, packageJson)
6266
+ }) : null;
6256
6267
  const preactVersion = getPreactVersion(packageJson);
6257
6268
  const projectInfo = {
6258
6269
  rootDirectory: directory,
@@ -6269,6 +6280,8 @@ const discoverProject = (directory) => {
6269
6280
  preactVersion,
6270
6281
  preactMajorVersion: parseReactMajor(preactVersion),
6271
6282
  hasReactNativeWorkspace,
6283
+ nextjsVersion,
6284
+ nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
6272
6285
  expoVersion,
6273
6286
  shopifyFlashListVersion,
6274
6287
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
@@ -8394,6 +8407,7 @@ const checkReducedMotion = (rootDirectory) => {
8394
8407
  if (!hasMotionLibrary) return [];
8395
8408
  const result = spawnSync("git", [
8396
8409
  "grep",
8410
+ "--untracked",
8397
8411
  "-ql",
8398
8412
  "-E",
8399
8413
  REDUCED_MOTION_GREP_PATTERN,
@@ -9764,6 +9778,7 @@ const buildCapabilities = (project) => {
9764
9778
  capabilities.add(project.framework);
9765
9779
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
9766
9780
  if (project.expoVersion !== null) capabilities.add("expo");
9781
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
9767
9782
  const reactMajor = project.reactMajorVersion;
9768
9783
  if (reactMajor !== null) {
9769
9784
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -10708,7 +10723,12 @@ const SANITIZED_ENV = (() => {
10708
10723
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
10709
10724
  const child = spawn(nodeBinaryPath, args, {
10710
10725
  cwd: rootDirectory,
10711
- env: SANITIZED_ENV
10726
+ env: SANITIZED_ENV,
10727
+ stdio: [
10728
+ "ignore",
10729
+ "pipe",
10730
+ "pipe"
10731
+ ]
10712
10732
  });
10713
10733
  const timeoutHandle = setTimeout(() => {
10714
10734
  child.kill("SIGKILL");
@@ -12191,7 +12211,7 @@ const makeNoopConsole = () => ({
12191
12211
  });
12192
12212
  //#endregion
12193
12213
  //#region src/cli/utils/version.ts
12194
- const VERSION = "0.4.0-dev.f75ec7a";
12214
+ const VERSION = "0.4.0-dev.fe5f3de";
12195
12215
  //#endregion
12196
12216
  //#region src/cli/utils/json-mode.ts
12197
12217
  let context = null;
@@ -12549,13 +12569,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12549
12569
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12550
12570
  * standard `SENTRY_RELEASE` override.
12551
12571
  */
12552
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0-dev.f75ec7a`;
12572
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0-dev.fe5f3de`;
12553
12573
  /**
12554
12574
  * Deployment environment shown in Sentry's environment filter. Defaults to
12555
12575
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12556
12576
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12557
12577
  */
12558
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0-dev.f75ec7a") ? "development" : "production");
12578
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0-dev.fe5f3de") ? "development" : "production");
12559
12579
  /**
12560
12580
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12561
12581
  * (set to `0` to disable tracing) and falls back to
@@ -16752,10 +16772,10 @@ const canAnimateOnboarding = (stream = process.stdout) => {
16752
16772
  };
16753
16773
  //#endregion
16754
16774
  //#region src/cli/utils/onboarding-state.ts
16755
- const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
16775
+ const GLOBAL_CONFIG_PROJECT_NAME$2 = "react-doctor";
16756
16776
  const ONBOARDED_AT_KEY = "onboardedAt";
16757
16777
  const getOnboardingStore = (options = {}) => new Conf({
16758
- projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
16778
+ projectName: GLOBAL_CONFIG_PROJECT_NAME$2,
16759
16779
  cwd: options.cwd
16760
16780
  });
16761
16781
  const hasCompletedOnboarding = (options = {}) => {
@@ -17719,9 +17739,9 @@ const buildHandoffPayload = (input) => {
17719
17739
  };
17720
17740
  //#endregion
17721
17741
  //#region src/cli/utils/is-command-available.ts
17722
- const isWindows = process.platform === "win32";
17742
+ const isWindows$1 = process.platform === "win32";
17723
17743
  const candidateFileNames = (command) => {
17724
- if (!isWindows || path$1.extname(command)) return [command];
17744
+ if (!isWindows$1 || path$1.extname(command)) return [command];
17725
17745
  return [command, ...(process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean).map((extension) => `${command}${extension}`)];
17726
17746
  };
17727
17747
  const isCommandAvailable = (command) => {
@@ -17730,7 +17750,7 @@ const isCommandAvailable = (command) => {
17730
17750
  const binaryPath = path$1.join(directory, fileName);
17731
17751
  try {
17732
17752
  if (!fs$1.statSync(binaryPath).isFile()) continue;
17733
- if (!isWindows) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
17753
+ if (!isWindows$1) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
17734
17754
  return true;
17735
17755
  } catch {}
17736
17756
  }
@@ -18143,6 +18163,11 @@ permissions:
18143
18163
  # comments (PRs are issues under the hood). Not exercised on \`push\`
18144
18164
  # events, so safe to drop if you only run on \`main\`.
18145
18165
  issues: write
18166
+ # Lets the action publish a commit status with the score + error/warning
18167
+ # counts (links to the run). This is how a \`push\` to \`main\` surfaces its
18168
+ # result, since the PR comment is skipped off pull requests. Drop it to
18169
+ # disable the status (or set \`commit-status: false\` below).
18170
+ statuses: write
18146
18171
 
18147
18172
  # Cancels any in-flight scan for the same PR (or branch, on push) the moment
18148
18173
  # a new commit arrives, so reviewers only ever see the latest run.
@@ -18156,20 +18181,42 @@ jobs:
18156
18181
  steps:
18157
18182
  - uses: actions/checkout@v5
18158
18183
 
18159
- - uses: millionco/react-doctor@v1
18184
+ - uses: millionco/react-doctor@v2
18160
18185
  # Common configuration knobs — uncomment any to override the default.
18161
18186
  # Full reference: https://www.react.doctor/ci
18162
18187
  # with:
18163
- # non-blocking: true # Report findings but always exit 0 (won't fail the PR check)
18164
- # fail-on: warning # Gate level: "error" (default) | "warning" | "none"
18188
+ # blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
18189
+ # scope: full # On PRs, scan the whole project instead of just changed files
18165
18190
  # comment: false # Disable the sticky PR summary comment
18166
- # annotations: false # Disable inline GitHub Actions annotations on changed files
18167
- # version: "0.2.18" # Pin to a specific react-doctor version instead of "latest"
18191
+ # review-comments: false # Disable inline review comments on changed lines
18192
+ # commit-status: false # Disable the commit status (score + counts, links to the run)
18193
+ # version: "0.4.0" # Pin to a specific react-doctor version instead of "latest"
18168
18194
  # directory: apps/web # Scan a sub-directory (default: ".")
18169
18195
  # project: "web,admin" # In a monorepo, scan specific workspace project(s)
18170
18196
  `;
18171
18197
  const getReactDoctorWorkflowPath = (projectRoot) => path$1.join(projectRoot, ".github", "workflows", "react-doctor.yml");
18172
18198
  const isReactDoctorWorkflowInstalled = (projectRoot) => fs$1.existsSync(getReactDoctorWorkflowPath(projectRoot));
18199
+ const V1_FLOATING_ACTION_REF = String.raw`millionco/react-doctor@v1(?![\w.])`;
18200
+ const V2_FLOATING_ACTION_REF = "millionco/react-doctor@v2";
18201
+ const readReactDoctorWorkflow = (projectRoot) => {
18202
+ const workflowPath = getReactDoctorWorkflowPath(projectRoot);
18203
+ try {
18204
+ return {
18205
+ workflowPath,
18206
+ content: fs$1.readFileSync(workflowPath, "utf8")
18207
+ };
18208
+ } catch {
18209
+ return null;
18210
+ }
18211
+ };
18212
+ const workflowUsesV1Action = (content) => new RegExp(V1_FLOATING_ACTION_REF).test(content);
18213
+ const upgradeWorkflowActionToV2 = (content) => {
18214
+ const upgraded = content.replace(new RegExp(V1_FLOATING_ACTION_REF, "g"), V2_FLOATING_ACTION_REF);
18215
+ return {
18216
+ content: upgraded,
18217
+ changed: upgraded !== content
18218
+ };
18219
+ };
18173
18220
  const installReactDoctorWorkflow = (projectRoot) => {
18174
18221
  const workflowPath = getReactDoctorWorkflowPath(projectRoot);
18175
18222
  if (fs$1.existsSync(workflowPath)) return {
@@ -18999,6 +19046,41 @@ const runInstallReactDoctor = async (options = {}) => {
18999
19046
  for (const agent of selectedAgents) recordCount(METRIC.installAgent, 1, { agent });
19000
19047
  };
19001
19048
  //#endregion
19049
+ //#region src/cli/utils/hash-project-root.ts
19050
+ const hashProjectRoot = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
19051
+ //#endregion
19052
+ //#region src/cli/utils/action-upgrade-prompt.ts
19053
+ const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
19054
+ const getActionUpgradeStore = (options = {}) => new Conf({
19055
+ projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
19056
+ cwd: options.cwd
19057
+ });
19058
+ const hasHandledActionUpgrade = (projectRoot, storeOptions = {}) => {
19059
+ try {
19060
+ const upgrades = getActionUpgradeStore(storeOptions).get("actionUpgrades", {});
19061
+ return Boolean(upgrades[hashProjectRoot(projectRoot)]);
19062
+ } catch {
19063
+ return true;
19064
+ }
19065
+ };
19066
+ const recordActionUpgradeDecision = (projectRoot, outcome, storeOptions = {}) => {
19067
+ try {
19068
+ const store = getActionUpgradeStore(storeOptions);
19069
+ const upgrades = store.get("actionUpgrades", {});
19070
+ store.set("actionUpgrades", {
19071
+ ...upgrades,
19072
+ [hashProjectRoot(projectRoot)]: {
19073
+ rootDirectory: path$1.resolve(projectRoot),
19074
+ outcome,
19075
+ at: (/* @__PURE__ */ new Date()).toISOString()
19076
+ }
19077
+ });
19078
+ return true;
19079
+ } catch {
19080
+ return false;
19081
+ }
19082
+ };
19083
+ //#endregion
19002
19084
  //#region src/cli/utils/install-skill-for-agent.ts
19003
19085
  const installReactDoctorSkillForAgent = async (agent, projectRoot) => {
19004
19086
  const source = getSkillSourceDirectory();
@@ -19049,9 +19131,9 @@ const openUrl = (url) => {
19049
19131
  //#endregion
19050
19132
  //#region src/cli/utils/open-workflow-pull-request.ts
19051
19133
  const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
19052
- const COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
19053
- const PR_TITLE = "Add React Doctor to GitHub Actions";
19054
- const 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.
19134
+ const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
19135
+ const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
19136
+ 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
19137
 
19056
19138
  Docs: https://www.react.doctor/ci`;
19057
19139
  const execFileAsync = promisify(execFile);
@@ -19103,6 +19185,9 @@ const findUniqueBranchName = async (cwd) => {
19103
19185
  };
19104
19186
  const openWorkflowPullRequest = async (params) => {
19105
19187
  const workflowPath = path$1.resolve(params.workflowPath);
19188
+ const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
19189
+ const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
19190
+ const prBody = params.prBody ?? DEFAULT_PR_BODY;
19106
19191
  const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], path$1.dirname(workflowPath));
19107
19192
  if (!repoRootProbe.success) return {
19108
19193
  status: "not-attempted",
@@ -19169,7 +19254,7 @@ const openWorkflowPullRequest = async (params) => {
19169
19254
  if (!(await run("git", [
19170
19255
  "commit",
19171
19256
  "-m",
19172
- COMMIT_MESSAGE
19257
+ commitMessage
19173
19258
  ], cwd)).success) {
19174
19259
  await restoreToPreviousBranch(true);
19175
19260
  return {
@@ -19193,9 +19278,9 @@ const openWorkflowPullRequest = async (params) => {
19193
19278
  "pr",
19194
19279
  "create",
19195
19280
  "--title",
19196
- PR_TITLE,
19281
+ prTitle,
19197
19282
  "--body",
19198
- PR_BODY,
19283
+ prBody,
19199
19284
  "--base",
19200
19285
  defaultBranch,
19201
19286
  "--head",
@@ -19223,6 +19308,7 @@ const stageWorkflowFile = async (params) => {
19223
19308
  };
19224
19309
  //#endregion
19225
19310
  //#region src/cli/utils/launch-agent.ts
19311
+ const isWindows = process.platform === "win32";
19226
19312
  const CLI_AGENT_BINARIES = {
19227
19313
  "claude-code": "claude",
19228
19314
  codex: "codex",
@@ -19233,14 +19319,47 @@ const CLI_AGENT_AUTO_FLAGS = {
19233
19319
  codex: ["--yolo"],
19234
19320
  cursor: ["--force"]
19235
19321
  };
19236
- const launchCliAgent = (agentId, prompt, cwd) => new Promise((resolve, reject) => {
19237
- const child = spawn(CLI_AGENT_BINARIES[agentId], [...CLI_AGENT_AUTO_FLAGS[agentId], prompt], {
19322
+ const resolveWindowsCmdEntryScript = (command) => {
19323
+ if (!isWindows) return null;
19324
+ const pathDirectories = (process.env.PATH ?? "").split(path$1.delimiter).filter(Boolean);
19325
+ for (const directory of pathDirectories) {
19326
+ const cmdFilePath = path$1.join(directory, `${command}.cmd`);
19327
+ try {
19328
+ if (!fs$1.statSync(cmdFilePath).isFile()) continue;
19329
+ } catch {
19330
+ continue;
19331
+ }
19332
+ try {
19333
+ const entryScriptMatch = fs$1.readFileSync(cmdFilePath, "utf8").match(/"%(?:~dp0|dp0%)\\([^"]+\.(?:m?js|cjs))"/);
19334
+ if (!entryScriptMatch) continue;
19335
+ const resolvedScriptPath = path$1.resolve(directory, entryScriptMatch[1]);
19336
+ if (fs$1.statSync(resolvedScriptPath).isFile()) return resolvedScriptPath;
19337
+ } catch {}
19338
+ }
19339
+ return null;
19340
+ };
19341
+ const spawnAgent = (command, args, cwd, shell = false) => new Promise((resolve, reject) => {
19342
+ const child = spawn(command, [...args], {
19238
19343
  cwd,
19239
- stdio: "inherit"
19344
+ stdio: "inherit",
19345
+ shell
19240
19346
  });
19241
19347
  child.on("error", reject);
19242
19348
  child.on("close", (code) => resolve(code ?? 0));
19243
19349
  });
19350
+ const launchCliAgent = async (agentId, prompt, cwd) => {
19351
+ const binary = CLI_AGENT_BINARIES[agentId];
19352
+ const agentArgs = [...CLI_AGENT_AUTO_FLAGS[agentId], prompt];
19353
+ if (isWindows) {
19354
+ const entryScript = resolveWindowsCmdEntryScript(binary);
19355
+ if (entryScript) return spawnAgent(process.execPath, [entryScript, ...agentArgs], cwd);
19356
+ }
19357
+ try {
19358
+ return await spawnAgent(binary, agentArgs, cwd);
19359
+ } catch {
19360
+ throw new Error(`Failed to launch ${binary}`);
19361
+ }
19362
+ };
19244
19363
  const CLIPBOARD_COMMANDS = [
19245
19364
  {
19246
19365
  binary: "pbcopy",
@@ -19313,6 +19432,77 @@ const setUpGitHubActions = async (rootDirectory) => {
19313
19432
  }
19314
19433
  cliLogger.log(` Learn more: ${highlighter.info(CI_URL)}`);
19315
19434
  };
19435
+ const UPGRADE_YES_CHOICE = "upgrade-yes";
19436
+ const UPGRADE_NO_CHOICE = "upgrade-no";
19437
+ const UPGRADE_COMMIT_MESSAGE = "ci: upgrade React Doctor GitHub Action to v2";
19438
+ const UPGRADE_PR_TITLE = "Upgrade React Doctor Action to v2";
19439
+ const UPGRADE_PR_BODY = `Bumps the React Doctor GitHub Actions workflow to the action's latest major, \`millionco/react-doctor@v2\`.
19440
+
19441
+ Docs: https://www.react.doctor/ci`;
19442
+ const askUpgradeActionVersion = async () => {
19443
+ const { upgradeChoice } = await prompts({
19444
+ type: "select",
19445
+ name: "upgradeChoice",
19446
+ message: "A new major of the React Doctor Action (v2) is out. Upgrade this repo's workflow?",
19447
+ hint: " ",
19448
+ choices: [{
19449
+ title: "Yes (recommended)",
19450
+ description: "Open a PR bumping the workflow to millionco/react-doctor@v2",
19451
+ value: UPGRADE_YES_CHOICE
19452
+ }, {
19453
+ title: "No, thanks",
19454
+ description: "Keep @v1 — won't ask again for this repo",
19455
+ value: UPGRADE_NO_CHOICE
19456
+ }],
19457
+ initial: 0
19458
+ }, { onCancel: () => true });
19459
+ if (upgradeChoice === void 0) return "cancel";
19460
+ return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
19461
+ };
19462
+ const upgradeGitHubActionsWorkflow = async (workflow) => {
19463
+ const { content, changed } = upgradeWorkflowActionToV2(workflow.content);
19464
+ if (!changed) return false;
19465
+ const upgradeSpinner = spinner("Opening a pull request to upgrade React Doctor to v2...").start();
19466
+ try {
19467
+ fs$1.writeFileSync(workflow.workflowPath, content);
19468
+ } catch {
19469
+ upgradeSpinner.fail("Couldn't update the workflow file.");
19470
+ return false;
19471
+ }
19472
+ const pullRequestResult = await openWorkflowPullRequest({
19473
+ workflowPath: workflow.workflowPath,
19474
+ commitMessage: UPGRADE_COMMIT_MESSAGE,
19475
+ prTitle: UPGRADE_PR_TITLE,
19476
+ prBody: UPGRADE_PR_BODY
19477
+ });
19478
+ if (pullRequestResult.status === "pr-opened") upgradeSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
19479
+ 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}`);
19480
+ else {
19481
+ upgradeSpinner.stop();
19482
+ try {
19483
+ fs$1.writeFileSync(workflow.workflowPath, content);
19484
+ } catch {
19485
+ cliLogger.log(" Couldn't finish the upgrade. Re-run React Doctor to try again.");
19486
+ return false;
19487
+ }
19488
+ const didStage = await stageWorkflowFile({ workflowPath: workflow.workflowPath });
19489
+ 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.");
19490
+ }
19491
+ return true;
19492
+ };
19493
+ const maybeOfferActionUpgrade = async (projectRoot) => {
19494
+ const workflow = readReactDoctorWorkflow(projectRoot);
19495
+ if (!workflow || !workflowUsesV1Action(workflow.content)) return;
19496
+ if (hasHandledActionUpgrade(projectRoot)) return;
19497
+ const outcome = await askUpgradeActionVersion();
19498
+ if (outcome === "cancel") return;
19499
+ recordCount(METRIC.agentHandoff, 1, { outcome: outcome === "yes" ? "upgrade-accepted" : "upgrade-declined" });
19500
+ if (outcome === "no") {
19501
+ recordActionUpgradeDecision(projectRoot, "declined");
19502
+ return;
19503
+ }
19504
+ if (await upgradeGitHubActionsWorkflow(workflow)) recordActionUpgradeDecision(projectRoot, "accepted");
19505
+ };
19316
19506
  const SGR_BOLD_OFF = "\x1B[22m";
19317
19507
  const ciQuestionMessage = [
19318
19508
  "Add React Doctor to GitHub Actions?",
@@ -19360,7 +19550,8 @@ const detectLaunchableAgents = async () => {
19360
19550
  const handoffToAgent = async (input) => {
19361
19551
  if (!input.interactive || input.diagnostics.length === 0) return;
19362
19552
  cliLogger.break();
19363
- if (!isReactDoctorWorkflowInstalled(findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory)) {
19553
+ const projectRootForCi = findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory;
19554
+ if (!isReactDoctorWorkflowInstalled(projectRootForCi)) {
19364
19555
  const ciOutcome = await askAddToGitHubActions();
19365
19556
  recordCount(METRIC.agentHandoff, 1, {
19366
19557
  outcome: `ci-${ciOutcome}`,
@@ -19371,7 +19562,7 @@ const handoffToAgent = async (input) => {
19371
19562
  await setUpGitHubActions(input.rootDirectory);
19372
19563
  cliLogger.break();
19373
19564
  }
19374
- }
19565
+ } else await maybeOfferActionUpgrade(projectRootForCi);
19375
19566
  const { handoffTarget } = await prompts({
19376
19567
  type: "select",
19377
19568
  name: "handoffTarget",
@@ -19705,7 +19896,7 @@ const getSetupPromptStore = (options = {}) => new Conf({
19705
19896
  projectName: GLOBAL_CONFIG_PROJECT_NAME,
19706
19897
  cwd: options.cwd
19707
19898
  });
19708
- const getSetupPromptProjectKey = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
19899
+ const getSetupPromptProjectKey = (projectRoot) => hashProjectRoot(projectRoot);
19709
19900
  const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
19710
19901
  try {
19711
19902
  return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
@@ -21277,4 +21468,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
21277
21468
  export {};
21278
21469
 
21279
21470
  //# sourceMappingURL=cli.js.map
21280
- //# debugId=3c457dc9-865a-5459-b923-a0fb762b158f
21471
+ //# debugId=646273cf-f6f6-5523-a0f4-a333f73e0d4f
package/dist/index.d.ts CHANGED
@@ -453,6 +453,8 @@ interface ProjectInfo {
453
453
  * — no `rn-*` rules load for the project at all.
454
454
  */
455
455
  hasReactNativeWorkspace: boolean;
456
+ nextjsVersion: string | null;
457
+ nextjsMajorVersion: number | null;
456
458
  /**
457
459
  * The declared `expo` package version spec (e.g. `"~51.0.0"`), looked up
458
460
  * in the project or any of its workspace packages, or `null` when `expo`
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]="44e73f8d-b81f-599b-a04e-22497cd72bb2")}catch(e){}}();
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]="3118af5e-d2d7-5885-a74e-4011b2abc203")}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";
@@ -2981,6 +2981,11 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
2981
2981
  if (!isFile(monorepoPackageJsonPath)) return version;
2982
2982
  return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
2983
2983
  };
2984
+ const getNextjsDependencySpec = (packageJson) => {
2985
+ const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
2986
+ return typeof spec === "string" ? spec : null;
2987
+ };
2988
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
2984
2989
  const getPreactVersion = (packageJson) => {
2985
2990
  return {
2986
2991
  ...packageJson.peerDependencies,
@@ -3233,6 +3238,12 @@ const discoverProject = (directory) => {
3233
3238
  version: findShopifyFlashListVersion(directory, packageJson)
3234
3239
  }) : null;
3235
3240
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3241
+ const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
3242
+ rootDirectory: directory,
3243
+ rootPackageJson: packageJson,
3244
+ packageName: "next",
3245
+ version: findNextjsVersion(directory, packageJson)
3246
+ }) : null;
3236
3247
  const preactVersion = getPreactVersion(packageJson);
3237
3248
  const projectInfo = {
3238
3249
  rootDirectory: directory,
@@ -3249,6 +3260,8 @@ const discoverProject = (directory) => {
3249
3260
  preactVersion,
3250
3261
  preactMajorVersion: parseReactMajor(preactVersion),
3251
3262
  hasReactNativeWorkspace,
3263
+ nextjsVersion,
3264
+ nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
3252
3265
  expoVersion,
3253
3266
  shopifyFlashListVersion,
3254
3267
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
@@ -5343,6 +5356,7 @@ const checkReducedMotion = (rootDirectory) => {
5343
5356
  if (!hasMotionLibrary) return [];
5344
5357
  const result = spawnSync("git", [
5345
5358
  "grep",
5359
+ "--untracked",
5346
5360
  "-ql",
5347
5361
  "-E",
5348
5362
  REDUCED_MOTION_GREP_PATTERN,
@@ -6697,6 +6711,7 @@ const buildCapabilities = (project) => {
6697
6711
  capabilities.add(project.framework);
6698
6712
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6699
6713
  if (project.expoVersion !== null) capabilities.add("expo");
6714
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
6700
6715
  const reactMajor = project.reactMajorVersion;
6701
6716
  if (reactMajor !== null) {
6702
6717
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -7641,7 +7656,12 @@ const SANITIZED_ENV = (() => {
7641
7656
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
7642
7657
  const child = spawn(nodeBinaryPath, args, {
7643
7658
  cwd: rootDirectory,
7644
- env: SANITIZED_ENV
7659
+ env: SANITIZED_ENV,
7660
+ stdio: [
7661
+ "ignore",
7662
+ "pipe",
7663
+ "pipe"
7664
+ ]
7645
7665
  });
7646
7666
  const timeoutHandle = setTimeout(() => {
7647
7667
  child.kill("SIGKILL");
@@ -8929,4 +8949,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8929
8949
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8930
8950
 
8931
8951
  //# sourceMappingURL=index.js.map
8932
- //# debugId=44e73f8d-b81f-599b-a04e-22497cd72bb2
8952
+ //# debugId=3118af5e-d2d7-5885-a74e-4011b2abc203
package/dist/lsp.js CHANGED
@@ -2992,6 +2992,11 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
2992
2992
  if (!isFile(monorepoPackageJsonPath)) return version;
2993
2993
  return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
2994
2994
  };
2995
+ const getNextjsDependencySpec = (packageJson) => {
2996
+ const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
2997
+ return typeof spec === "string" ? spec : null;
2998
+ };
2999
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
2995
3000
  const getPreactVersion = (packageJson) => {
2996
3001
  return {
2997
3002
  ...packageJson.peerDependencies,
@@ -3244,6 +3249,12 @@ const discoverProject = (directory) => {
3244
3249
  version: findShopifyFlashListVersion(directory, packageJson)
3245
3250
  }) : null;
3246
3251
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3252
+ const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
3253
+ rootDirectory: directory,
3254
+ rootPackageJson: packageJson,
3255
+ packageName: "next",
3256
+ version: findNextjsVersion(directory, packageJson)
3257
+ }) : null;
3247
3258
  const preactVersion = getPreactVersion(packageJson);
3248
3259
  const projectInfo = {
3249
3260
  rootDirectory: directory,
@@ -3260,6 +3271,8 @@ const discoverProject = (directory) => {
3260
3271
  preactVersion,
3261
3272
  preactMajorVersion: parseReactMajor(preactVersion),
3262
3273
  hasReactNativeWorkspace,
3274
+ nextjsVersion,
3275
+ nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
3263
3276
  expoVersion,
3264
3277
  shopifyFlashListVersion,
3265
3278
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
@@ -5280,6 +5293,7 @@ const checkReducedMotion = (rootDirectory) => {
5280
5293
  if (!hasMotionLibrary) return [];
5281
5294
  const result = spawnSync("git", [
5282
5295
  "grep",
5296
+ "--untracked",
5283
5297
  "-ql",
5284
5298
  "-E",
5285
5299
  REDUCED_MOTION_GREP_PATTERN,
@@ -6634,6 +6648,7 @@ const buildCapabilities = (project) => {
6634
6648
  capabilities.add(project.framework);
6635
6649
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6636
6650
  if (project.expoVersion !== null) capabilities.add("expo");
6651
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
6637
6652
  const reactMajor = project.reactMajorVersion;
6638
6653
  if (reactMajor !== null) {
6639
6654
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -7578,7 +7593,12 @@ const SANITIZED_ENV = (() => {
7578
7593
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
7579
7594
  const child = spawn(nodeBinaryPath, args, {
7580
7595
  cwd: rootDirectory,
7581
- env: SANITIZED_ENV
7596
+ env: SANITIZED_ENV,
7597
+ stdio: [
7598
+ "ignore",
7599
+ "pipe",
7600
+ "pipe"
7601
+ ]
7582
7602
  });
7583
7603
  const timeoutHandle = setTimeout(() => {
7584
7604
  child.kill("SIGKILL");
@@ -10800,5 +10820,5 @@ const startLanguageServer = () => {
10800
10820
  };
10801
10821
  //#endregion
10802
10822
  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]="367f0c6f-8633-512f-b006-f1bb7ab5a35a")}catch(e){}}();
10804
- //# debugId=367f0c6f-8633-512f-b006-f1bb7ab5a35a
10823
+ !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]="87d08504-e094-5770-8f0d-a1195e0df93c")}catch(e){}}();
10824
+ //# debugId=87d08504-e094-5770-8f0d-a1195e0df93c
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.4.0-dev.f75ec7a",
3
+ "version": "0.4.0-dev.fe5f3de",
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.19",
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.f75ec7a"
69
+ "oxlint-plugin-react-doctor": "0.4.0-dev.fe5f3de"
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",
78
77
  "@react-doctor/core": "0.3.0",
79
- "@react-doctor/language-server": "0.2.12"
78
+ "@react-doctor/language-server": "0.2.12",
79
+ "@react-doctor/api": "0.2.20"
80
80
  },
81
81
  "engines": {
82
82
  "node": "^20.19.0 || >=22.12.0"