Fetch packages from registry directly, not with npm CLI#1258
Open
ecraig12345 wants to merge 3 commits into
Open
Fetch packages from registry directly, not with npm CLI#1258ecraig12345 wants to merge 3 commits into
ecraig12345 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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-fetchand updatesgetNpmPackageInfoto 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, | ||
| }), |
b701294 to
8b7e26d
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
npmReadConcurrencyhas 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-fetchversion that was required for Node 14.)