Skip to content

fix: strip -y flag from npm init before PM conversion#7693

Merged
AmanVarshney01 merged 3 commits intomainfrom
fix/remove-init-y-flag
Mar 30, 2026
Merged

fix: strip -y flag from npm init before PM conversion#7693
AmanVarshney01 merged 3 commits intomainfrom
fix/remove-init-y-flag

Conversation

@AmanVarshney01
Copy link
Copy Markdown
Member

@AmanVarshney01 AmanVarshney01 commented Mar 23, 2026

Summary

  • npm-to-yarn converts npm init -y to pnpm init -y and bun init -y, but neither pnpm nor bun support the -y flag for init (they're always non-interactive)
  • Strips -y from npm init -y before passing to convert() in all three source.config.ts files (docs, blog, eclipse)
  • This ensures all package managers get a clean init command

Summary by CodeRabbit

  • Bug Fixes
    • Normalized npm init -y to npm init before converting commands for npm, pnpm, yarn, and bun, ensuring more consistent and predictable package-manager command conversions (including multi-line inputs and bun-specific transformations).

npm-to-yarn converts `npm init -y` to `pnpm init -y` and `bun init -y`,
but neither pnpm nor bun support the -y flag for init (they're always
non-interactive). Strip -y before conversion so all package managers
get a clean `init` command.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Mar 30, 2026 0:56am
docs Ready Ready Preview, Comment Mar 30, 2026 0:56am
eclipse Ready Ready Preview, Comment Mar 30, 2026 0:56am
site Ready Ready Preview, Comment Mar 30, 2026 0:56am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b68d3ea5-5d58-4ee3-b9d7-31e8fbc2b834

📥 Commits

Reviewing files that changed from the base of the PR and between 70073ca and bc7007c.

📒 Files selected for processing (1)
  • apps/docs/source.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/docs/source.config.ts

Walkthrough

Three app config files were changed to normalize the exact command npm init -y to npm init before it is passed into their package-manager conversion logic, altering how npm initialization commands are transformed for other package managers.

Changes

Cohort / File(s) Summary
npm init command normalization
apps/blog/source.config.ts, apps/docs/source.config.ts, apps/eclipse/source.config.ts
Each file now replaces an exact npm init -y input with npm init prior to invoking package-manager conversion. apps/docs applies the normalization in convertLine (pre-npm-to-yarn); apps/blog and apps/eclipse apply it in their packageManagers conversion handlers. The bun branch in Eclipse and Blog now receives the normalized input and retains its post-conversion bun specific replacement logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ 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 clearly and concisely summarizes the primary change: stripping the -y flag from npm init commands before package manager conversion across multiple configuration files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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


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

Copy link
Copy Markdown
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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/eclipse/source.config.ts (1)

49-61: Optional: Extract shared utility across apps.

All three configs (docs, blog, eclipse) now contain nearly identical packageManagers logic with the -y normalization. If you find yourself updating this pattern again, consider extracting a shared utility (e.g., in a common package or shared config file) that all three apps import. This would make future fixes a single-point change.

Not blocking—just something to consider for long-term maintainability.

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

In `@apps/eclipse/source.config.ts` around lines 49 - 61, The three configs
duplicate the packageManagers logic (the array using convert and the npm init -y
normalization); extract this into a shared utility (e.g., export a function like
getNormalizedPackageManagers or normalizePackageManagers that returns the array)
and replace the inline packageManagers in each config (docs, blog, eclipse) with
a call/import of that utility; ensure the utility preserves the bun special-case
transformation (the replace(/^bun x /, 'bunx --bun ')) and keeps references to
convert so behaviour remains identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/blog/source.config.ts`:
- Around line 70-75: The current command normalizer uses cmd.replace(/^npm init
-y$/, "npm init") inside the command lambdas (refer to the command properties
that call convert and the convert(...) call), which only matches single-line
exact strings and will miss multi-line code blocks; update the logic to split
the incoming cmd on '\n', run the replacement on each line (or reuse/implement a
convertLine helper like in docs), then rejoin with '\n' before passing to
convert so multi-line commands such as "npm init -y\nnpm install ..." are
normalized correctly.

In `@apps/eclipse/source.config.ts`:
- Around line 50-55: The command arrow functions currently use an anchored regex
replace (cmd.replace(/^npm init -y$/, 'npm init')) which fails if cmd contains
newlines; update these entries (the anonymous command functions that call
convert and the const converted for 'bun') to use the existing convertLine
helper (or equivalent line-by-line processing) instead of the anchored regex so
each line is normalised before calling convert (apply the change to the 'npm',
'pnpm', 'yarn' and 'bun' command handlers and ensure convertLine is
imported/available).

---

Nitpick comments:
In `@apps/eclipse/source.config.ts`:
- Around line 49-61: The three configs duplicate the packageManagers logic (the
array using convert and the npm init -y normalization); extract this into a
shared utility (e.g., export a function like getNormalizedPackageManagers or
normalizePackageManagers that returns the array) and replace the inline
packageManagers in each config (docs, blog, eclipse) with a call/import of that
utility; ensure the utility preserves the bun special-case transformation (the
replace(/^bun x /, 'bunx --bun ')) and keeps references to convert so behaviour
remains identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5916d395-b3d0-4baf-b6e1-a9f59e805bca

📥 Commits

Reviewing files that changed from the base of the PR and between 52d993a and 70073ca.

📒 Files selected for processing (3)
  • apps/blog/source.config.ts
  • apps/docs/source.config.ts
  • apps/eclipse/source.config.ts

@argos-ci
Copy link
Copy Markdown

argos-ci bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Mar 30, 2026, 1:11 PM

@AmanVarshney01 AmanVarshney01 merged commit 7a5b77c into main Mar 30, 2026
11 of 12 checks passed
@AmanVarshney01 AmanVarshney01 deleted the fix/remove-init-y-flag branch March 30, 2026 13:02
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.

2 participants