Skip to content

Fetch packages from registry directly, not with npm CLI#1258

Open
ecraig12345 wants to merge 3 commits into
mainfrom
next-npm-registry-fetch
Open

Fetch packages from registry directly, not with npm CLI#1258
ecraig12345 wants to merge 3 commits into
mainfrom
next-npm-registry-fetch

Conversation

@ecraig12345
Copy link
Copy Markdown
Member

@ecraig12345 ecraig12345 commented May 14, 2026

Fetch published package info directly from the registry, not with the npm CLI. This should be a significant performance improvement when publishing or syncing many packages. (The tests can only cover public npm, but I manually verified with a private ADO feed.)

The default npmReadConcurrency has been increased to 10 since this is a lighter-weight operation.

A lot of the test changes are due to the new npm read strategy requiring a different mocking approach, plus starting to reduce unnecessary operations in the slow publish tests.

Part of #1112, fixes #1143

(This was originally checked in to v2 (#1114), then had to be reverted (#1145) due to security issues in dependencies of the old npm-registry-fetch version that was required for Node 14.)

Copy link
Copy Markdown

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 replaces npm CLI-based package metadata reads with npm-registry-fetch to improve publish/sync performance, and raises the default read concurrency now that reads are lighter-weight.

Changes:

  • Adds npm-registry-fetch and updates getNpmPackageInfo to fetch package metadata directly from the registry.
  • Updates npm read concurrency defaults/docs from 5 to 10.
  • Reworks npm-related test mocks and Verdaccio functional test setup around direct registry fetches.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/beachball/src/packageManager/getNpmPackageInfo.ts Switches package info reads from npm show to npm-registry-fetch.
packages/beachball/package.json Adds registry fetch dependency and typings.
yarn.lock Locks new registry fetch dependency tree.
packages/beachball/src/env.ts Updates default npm read concurrency.
packages/beachball/src/types/BeachballOptions.ts Updates documented default for npmReadConcurrency.
packages/beachball/README.md Updates concurrency documentation.
docs/overview/configuration.md Updates option default documentation.
packages/beachball/src/__fixtures__/mockNpm.ts Adds mocked npm-registry-fetch behavior.
packages/beachball/src/__fixtures__/mockNpm.test.ts Updates fixture tests for fetch-based reads.
packages/beachball/src/__fixtures__/registry.ts Updates Verdaccio auth/test fixture behavior.
packages/beachball/src/__tests__/packageManager/listPackageVersions.test.ts Updates list-version tests to assert registry fetch usage.
packages/beachball/src/__tests__/publish/getNewPackages.test.ts Updates publish read tests to use fetch mock assertions.
packages/beachball/src/__tests__/publish/validatePackageVersions.test.ts Updates validation tests to use fetch mock assertions.
packages/beachball/src/__functional__/packageManager/getNpmPackageInfo.test.ts Updates functional tests for direct registry fetches.
packages/beachball/src/__functional__/packageManager/packagePublish.test.ts Adjusts local registry publish tests for token/fetch behavior.
packages/beachball/src/__functional__/packageManager/packPackage.test.ts Enables registry fetch mock.
packages/beachball/src/__functional__/publish/publishToRegistry.test.ts Enables registry fetch mock.
packages/beachball/src/__e2e__/publishE2E.test.ts Enables registry fetch mock.
packages/beachball/src/__e2e__/publishNpm.test.ts Updates mocked npm call expectations.
packages/beachball/src/__e2e__/syncE2E.test.ts Enables registry fetch mock.
change/change-c4c002d3-afa6-45c6-a39d-65ee179a9664.json Adds Beachball change entry for the feature.
.vscode/settings.json Narrows ESLint working directory configuration.

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

Comment on lines +55 to +61
const result = (await fetch.json(`/${encodeURIComponent(packageName)}`, {
registry: options.registry,
timeout: options.timeout,
...(authArgs && {
alwaysAuth: true,
[authArgs.key]: authArgs.value,
}),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

looks like this needs #1252 to fully work

Comment thread packages/beachball/src/__fixtures__/registry.ts Outdated
@ecraig12345 ecraig12345 force-pushed the next-npm-registry-fetch branch from b701294 to 8b7e26d Compare May 14, 2026 09:23
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.

Re-enable npm-registry-fetch

2 participants