Skip to content

refactor: migrate nypm to package-manager-detector#951

Merged
antfu merged 2 commits intomainfrom
antfu/migrate-nypm-to-pmd
Mar 17, 2026
Merged

refactor: migrate nypm to package-manager-detector#951
antfu merged 2 commits intomainfrom
antfu/migrate-nypm-to-pmd

Conversation

@antfu
Copy link
Member

@antfu antfu commented Mar 17, 2026

Summary

Replace nypm with package-manager-detector for package manager detection. This reduces bundled code size since package-manager-detector is a lighter, more focused package that provides the same detection capability without unnecessary install/uninstall/update operations.

Changes:

  • Migrate imports and function calls in packages/devtools/src/server-rpc/npm.ts
  • Update dependency in packages/devtools/package.json
  • Add new inlined catalog to pnpm-workspace.yaml for bundled dependencies
  • Update lockfile

🤖 Generated with Claude Code

Replace nypm with package-manager-detector for package manager detection, reducing bundled code size. package-manager-detector is a lighter, more focused package that provides the same detection capability. Since inlineDependencies is enabled, this removes unnecessary bundled functionality.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 17, 2026

Deploying nuxt-devtools with  Cloudflare Pages  Cloudflare Pages

Latest commit: c84b79d
Status:🚫  Build failed.

View logs

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2cacdec-8dab-49fb-862e-9f86823b6195

📥 Commits

Reviewing files that changed from the base of the PR and between f581ae7 and c84b79d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/devtools/package.json

📝 Walkthrough

Walkthrough

The PR replaces the nypm package-manager detector with package-manager-detector in the devtools package. Changes update package.json (remove nypm, add package-manager-detector in dependencies and devDependencies), pnpm-workspace.yaml (add inlined package-manager-detector, remove nypm), and source usage: import type DetectResult from package-manager-detector/detect, change detectPromise to Promise<DetectResult | null> | undefined, and call detect({ cwd: nuxt.options.rootDir }) instead of detectPackageManager(...).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely describes the main change: migrating from nypm to package-manager-detector, which aligns with the changeset modifications across all three files.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale for replacing nypm with package-manager-detector and outlining the specific files modified in the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch antfu/migrate-nypm-to-pmd
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/devtools/src/server-rpc/npm.ts (1)

35-35: ⚠️ Potential issue | 🟠 Major

Fix yarn version detection to handle undefined version safely.

The version property on DetectResult is optional (version?: string). When it's undefined, !agent?.version?.startsWith('1.') evaluates to true, causing yarn without a detected version to be treated as yarn berry and incorrectly omit --ignore-scripts. Add a fallback to safely include the flag when version is undefined:

(name === 'yarn' && agent?.version && !agent.version.startsWith('1.')) ? '' : '--ignore-scripts',

This ensures the flag is included by default unless we can confirm it's yarn berry (v2+).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/devtools/src/server-rpc/npm.ts` at line 35, The yarn version check
treats undefined agent.version as Yarn Berry; update the conditional that builds
the npm args so it only treats yarn as Berry when a version string exists and
does not start with "1." — change the expression involving name, agent and
version (the ternary that currently uses (name === 'yarn' &&
!agent?.version?.startsWith('1.')) ? '' : '--ignore-scripts') to require
agent?.version before calling startsWith, so '--ignore-scripts' is included by
default unless agent.version is present and indicates v2+.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/devtools/src/server-rpc/npm.ts`:
- Line 35: The yarn version check treats undefined agent.version as Yarn Berry;
update the conditional that builds the npm args so it only treats yarn as Berry
when a version string exists and does not start with "1." — change the
expression involving name, agent and version (the ternary that currently uses
(name === 'yarn' && !agent?.version?.startsWith('1.')) ? '' :
'--ignore-scripts') to require agent?.version before calling startsWith, so
'--ignore-scripts' is included by default unless agent.version is present and
indicates v2+.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9e8ed61-73eb-49ab-836d-68cee75edc12

📥 Commits

Reviewing files that changed from the base of the PR and between 52d8312 and f581ae7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/devtools/package.json
  • packages/devtools/src/server-rpc/npm.ts
  • pnpm-workspace.yaml

@antfu antfu merged commit f82457d into main Mar 17, 2026
2 of 5 checks passed
@antfu antfu deleted the antfu/migrate-nypm-to-pmd branch March 17, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant