Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

fix(cli): use correct yarn command to install packages#518

Merged
ymc9 merged 2 commits intodevfrom
fix/yarn-add
Dec 18, 2025
Merged

fix(cli): use correct yarn command to install packages#518
ymc9 merged 2 commits intodevfrom
fix/yarn-add

Conversation

@ymc9
Copy link
Copy Markdown
Member

@ymc9 ymc9 commented Dec 18, 2025

Summary by CodeRabbit

  • Chores
    • Updated package manager integration during initialization to be more flexible across different package managers.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 18, 2025 13:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 18, 2025

Warning

Rate limit exceeded

@ymc9 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 42 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between dd411a1 and 80dfe84.

📒 Files selected for processing (1)
  • packages/cli/src/actions/init.ts (1 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The pull request updates the CLI initialization action to replace the install package command with add and refines the dev-flag detection for yarn-based package managers by changing from an exact equality check to a startsWith pattern match.

Changes

Cohort / File(s) Summary
Package manager command update
packages/cli/src/actions/init.ts
Changed package installation command from install to add; adjusted yarn dev-flag detection from exact match (pm.agent === 'yarn') to prefix match (pm.agent.startsWith('yarn'))

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the add command behavior is correct across all supported package managers (npm, yarn, pnpm, bun)
  • Confirm startsWith('yarn') handles all yarn variants appropriately without unintended side effects

Poem

🐰 A hop and a skip, commands take flight,
From 'install' to 'add', we polish the sight,
Yarn's detection grows wise, matching near and far,
Init action refined, now we're ready to star! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: using 'add' instead of 'install' for yarn package management, which is the correct yarn command syntax.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Dec 18, 2025

Claude finished @ymc9's task —— View job


PR Review: Fix Yarn Command

Todo List:

  • Read and analyze the changed file
  • Review for code quality and best practices
  • Check for potential bugs or issues
  • Assess performance and security considerations
  • Evaluate test coverage needs
  • Provide comprehensive feedback

Review Summary

This is a focused bug fix that corrects the yarn command usage in the CLI init functionality. The changes are small but important for proper package installation.

Changes Analysis

File: packages/cli/src/actions/init.ts
Lines Changed: 26, 28

  1. Line 26: Changed resolveCommand(pm.agent, 'install', [...]) to resolveCommand(pm.agent, 'add', [...])
  2. Line 28: Improved yarn version detection from pm.agent === 'yarn' to pm.agent.startsWith('yarn')

Code Quality & Best Practices ✅

Positive aspects:

  • Correct command usage: add is the proper command for package installation across npm, yarn, and pnpm
  • Better yarn detection: startsWith('yarn') properly handles both yarn v1 and yarn v2+ (which may be detected as 'yarn@berry')
  • Minimal, focused change: Only touches the specific lines that needed fixing
  • Maintains existing error handling: Preserves the robust error handling pattern

Potential Issues Assessment

No significant issues found:

  • No bugs introduced: The changes fix existing bugs rather than introduce new ones
  • No security concerns: Simple string comparison and command resolution
  • No performance impact: Changes are in initialization code that runs once

Technical Improvements

The fixes address real issues:

  1. Command standardization:

    • install vs add inconsistency could cause failures
    • add is the standard across all modern package managers
  2. Yarn version compatibility:

    • Original: pm.agent === 'yarn' only matched exactly "yarn"
    • Fixed: pm.agent.startsWith('yarn') handles yarn variants like "yarn@berry"

Test Coverage Consideration ⚠️

Gap identified: No specific unit tests found for the init.ts functionality. While this fix is straightforward, the init action would benefit from tests covering:

  • Different package managers (npm, yarn v1, yarn v2+, pnpm)
  • Dev vs production dependency installation
  • Error handling for unsupported package managers

Recommendation: Consider adding unit tests in a follow-up PR to prevent regression.

Security Assessment ✅

No security concerns:

  • Uses established package-manager-detector library
  • No user input directly passed to shell execution
  • Commands are properly resolved and validated

Performance Assessment ✅

Minimal performance impact:

  • Simple string operations
  • No additional dependencies or complexity
  • Runs only during project initialization

Overall Assessment

✅ LGTM - This is a well-executed bug fix that:

  • Solves real compatibility issues
  • Follows existing code patterns
  • Makes minimal, targeted changes
  • Improves yarn version support

Recommendation: Approve and merge. Consider adding unit tests for the init functionality in a future PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the package installation command for yarn by changing from the generic 'install' command to the more specific 'add' command, and updates the yarn version detection logic to support multiple yarn versions (classic, berry, etc.).

Key Changes:

  • Changed resolveCommand from using 'install' to 'add' command for package installation
  • Updated yarn detection from exact match (===) to prefix match (startsWith()) to support different yarn versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/actions/init.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Dec 18, 2025

Claude finished @ymc9's task —— View job


PR Review: Fix Yarn Command

Todo List:

  • Read and analyze the changed file
  • Review for code quality and best practices
  • Check for potential bugs or issues
  • Assess performance and security considerations
  • Evaluate test coverage needs
  • Provide comprehensive feedback

Review Summary

This is a focused bug fix that corrects the yarn command usage in the CLI init functionality. The changes are small but important for proper package installation.

Changes Analysis

File: packages/cli/src/actions/init.ts
Lines Changed: 26, 28

  1. Line 26: Changed resolveCommand(pm.agent, 'install', [...]) to resolveCommand(pm.agent, 'add', [...])
  2. Line 28: Improved yarn version detection from pm.agent === 'yarn' to pm.agent.startsWith('yarn') and added bun support

Code Quality & Best Practices ✅

Positive aspects:

  • Correct command usage: add is the proper command for package installation across npm, yarn, and pnpm
  • Better yarn detection: startsWith('yarn') properly handles both yarn v1 and yarn v2+ (which may be detected as 'yarn@berry')
  • Bun support: Added explicit support for bun's --dev flag
  • Minimal, focused change: Only touches the specific lines that needed fixing
  • Maintains existing error handling: Preserves the robust error handling pattern

Potential Issues Assessment

No significant issues found:

  • No bugs introduced: The changes fix existing bugs rather than introduce new ones
  • No security concerns: Simple string comparison and command resolution
  • No performance impact: Changes are in initialization code that runs once

Technical Improvements

The fixes address real issues:

  1. Command standardization:

    • install vs add inconsistency could cause failures
    • add is the standard across all modern package managers
  2. Package manager compatibility:

    • Original: pm.agent === 'yarn' only matched exactly "yarn"
    • Fixed: pm.agent.startsWith('yarn') || pm.agent === 'bun' handles yarn variants and bun
    • Addresses the Copilot reviewer's feedback about bun support

Test Coverage Consideration ⚠️

Gap identified: The existing test in /packages/cli/test/init.test.ts is currently skipped (describe.skip) due to CI timeout issues. While this fix is straightforward, the init action would benefit from:

  • Enabling and fixing the existing skipped tests
  • Adding tests for different package managers (npm, yarn v1, yarn v2+, pnpm, bun)
  • Testing dev vs production dependency installation
  • Error handling for unsupported package managers

Recommendation: Consider re-enabling and expanding the test suite in a follow-up PR.

Security Assessment ✅

No security concerns:

  • Uses established package-manager-detector library
  • No user input directly passed to shell execution
  • Commands are properly resolved and validated

Performance Assessment ✅

Minimal performance impact:

  • Simple string operations
  • No additional dependencies or complexity
  • Runs only during project initialization

Overall Assessment

✅ LGTM - This is a well-executed bug fix that:

  • Solves real compatibility issues
  • Follows existing code patterns
  • Makes minimal, targeted changes
  • Improves yarn version support
  • Addresses the bun compatibility issue raised by Copilot reviewer

Recommendation: Approve and merge. Consider addressing the test coverage gap in a future PR by re-enabling and expanding the init tests.

@ymc9 ymc9 merged commit b53ff2b into dev Dec 18, 2025
5 checks passed
@ymc9 ymc9 deleted the fix/yarn-add branch December 18, 2025 13:47
@ymc9
Copy link
Copy Markdown
Member Author

ymc9 commented Dec 18, 2025

fixes #494

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants