Skip to content

fix(cli): force npmjs registry for login and npm cli operations#2213

Merged
ghostdevv merged 3 commits intonpmx-dev:mainfrom
MathurAditya724:patch-3
Mar 23, 2026
Merged

fix(cli): force npmjs registry for login and npm cli operations#2213
ghostdevv merged 3 commits intonpmx-dev:mainfrom
MathurAditya724:patch-3

Conversation

@MathurAditya724
Copy link
Contributor

🔗 Linked issue

Fixes #2179

🧭 Context

npmx-connector should always operate against npmjs. If a user has a custom registry in .npmrc, login and follow-up npm commands can target a mirror, which breaks connector expectations.

📚 Description

  • enforce npmjs registry during login by passing --registry=https://registry.npmjs.org/
  • add a shared registry constant and env builder in the connector npm client
  • enforce npm_config_registry=https://registry.npmjs.org/ for npm command execution paths:
    • standard exec
    • interactive PTY exec
    • package publish flow (packageInit)

@vercel
Copy link

vercel bot commented Mar 22, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 22, 2026 9:23pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 22, 2026 9:23pm
npmx-lunaria Ignored Ignored Mar 22, 2026 9:23pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e75e6771-3472-4bc6-b806-6bc9284a2d62

📥 Commits

Reviewing files that changed from the base of the PR and between a42ac0f and 34ae5ed.

📒 Files selected for processing (1)
  • cli/src/npm-client.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • cli/src/npm-client.ts

📝 Walkthrough

Walkthrough

The changes centralise npm subprocess environment configuration and ensure npm operations target the npmjs registry. A new exported NPM_REGISTRY_URL constant and createNpmEnv(overrides?: Record<string,string>) helper were added to force FORCE_COLOR: '0' and npm_config_registry for npm calls. All npm subprocess invocations (interactive PTY spawn, execFileAsync, and temporary publish steps) now use createNpmEnv(). The runNpmLogin() invocation was updated to include an explicit --registry=${NPM_REGISTRY_URL} CLI argument. No public APIs other than the two exports were changed.

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description directly addresses the changeset, explaining the purpose of enforcing npmjs registry for login and npm operations.
Linked Issues check ✅ Passed The PR successfully implements all requirements from issue #2179: enforces registry during login via --registry flag, centralizes registry configuration, and applies npm_config_registry across all npm execution paths.
Out of Scope Changes check ✅ Passed All changes are directly scoped to enforcing npmjs registry in npm client operations; no unrelated modifications detected.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c63484cc-6993-4710-aaeb-20d4cdde4c07

📥 Commits

Reviewing files that changed from the base of the PR and between db9c411 and a42ac0f.

📒 Files selected for processing (1)
  • cli/src/npm-client.ts

@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@ghostdevv ghostdevv changed the title fix(cli): force npmjs registry for login and npm CLI operations fix(cli): force npmjs registry for login and npm cli operations Mar 22, 2026
@ghostdevv
Copy link
Contributor

there's some info here on that env var for posterity: https://docs.npmjs.com/cli/v10/using-npm/config#environment-variables

@ghostdevv ghostdevv added this pull request to the merge queue Mar 23, 2026
Merged via the queue into npmx-dev:main with commit 5ba693c Mar 23, 2026
20 of 21 checks passed
@github-actions
Copy link

Thanks for your first contribution, @MathurAditya724! ⭐

We'd love to welcome you to the npmx community. Come and say hi on Discord! And once you've joined, visit npmx.wamellow.com to claim the contributor role.

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.

npmx-connector should enforce --registry when executing npm login

2 participants