Skip to content

Conversation

@TheLarkInn
Copy link
Member

@TheLarkInn TheLarkInn commented Jan 24, 2026

Summary

Removes external dependencies package-json (ESM-only, ~500KB dependency tree) and throat (redundant concurrency limiter) from @rushstack/npm-check-fork.

Replaced with:

  • NpmRegistryClient - minimal registry client using Node.js built-in https module
    • Next step here would be to extract WebClient from rush-lib into its own package and then use here.
  • Promise.all batch processing for concurrent requests

Details

New files:

  • src/NpmRegistryClient.ts - registry client with fetchPackageMetadataAsync
  • src/tests/NpmRegistryClient.test.ts

Modified files:

  • src/GetLatestFromRegistry.ts - uses NpmRegistryClient instead of package-json
  • src/interfaces/INpmCheckRegistry.ts - added registry response types
  • src/index.ts - exports new client and getNpmInfoBatch function

Internal refactoring only.

How it was tested

  • rush build --to @rushstack/npm-check-fork - passes
  • rush test --only @rushstack/npm-check-fork - passes
  • Ready for manual verification with rush upgrade-interactive

Impacted documentation

None - internal implementation change only.

Add INpmRegistryPackageResponse and INpmRegistryVersionMetadata interfaces
to support the upcoming replacement of the package-json dependency with a
local implementation using WebClient.

- INpmRegistryVersionMetadata extends INpmCheckPackageVersion for backward
  compatibility
- INpmRegistryPackageResponse models the full npm registry API response
- Added JSDoc with links to npm registry API documentation
…data

Implement NpmRegistryClient class to replace external package-json dependency
with a self-contained HTTP client using Node.js built-in modules.

Features:
- INpmRegistryClientOptions for configuring registry URL, user agent, timeout
- INpmRegistryClientResult for consistent error handling
- Automatic scoped package URL encoding (@scope/name -> @scope%2Fname)
- Support for gzip/deflate response decompression
- Proper error handling for 404, HTTP errors, network errors, and timeouts
Replace package-json and throat dependencies with NpmRegistryClient for
fetching npm registry metadata. Preserves existing version sorting and
homepage extraction logic.

Changes:
- Remove package-json and throat imports
- Add lazy-initialized module-level NpmRegistryClient instance
- Update getNpmInfo to use fetchPackageMetadataAsync
- Preserve lodash/semver version sorting
- Preserve bestGuessHomepage extraction
…hing

Add batch fetching function to retrieve metadata for multiple packages
concurrently with configurable concurrency limit.

Features:
- getNpmInfoBatch(packageNames, concurrency) returns Map<string, INpmRegistryInfo>
- Default concurrency matches CPU count (like original throat behavior)
- Processes packages in batches using Promise.all
Remove external dependencies that have been replaced by NpmRegistryClient:
- package-json: replaced by NpmRegistryClient
- throat: replaced by Promise.all batch processing

Update tests to mock NpmRegistryClient instead of package-json.
Add basic unit tests for NpmRegistryClient constructor options.
Update GetLatestFromRegistry tests with improved module mocking.
Document the removal of package-json and throat dependencies in favor of
internal NpmRegistryClient implementation.
@TheLarkInn TheLarkInn marked this pull request as ready for review January 24, 2026 18:35
Copy link

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

Removes the external package-json and throat dependencies from @rushstack/npm-check-fork by introducing a lightweight npm registry client and updating registry lookup logic accordingly.

Changes:

  • Added NpmRegistryClient implemented with Node.js http/https (plus a basic test file).
  • Refactored GetLatestFromRegistry to use NpmRegistryClient and introduced getNpmInfoBatch with configurable concurrency.
  • Updated types/exports and removed the external dependencies from package.json and lockfiles.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
libraries/npm-check-fork/src/NpmRegistryClient.ts New minimal registry client implemented via Node http/https.
libraries/npm-check-fork/src/GetLatestFromRegistry.ts Swaps registry fetch to NpmRegistryClient and adds batched lookup helper.
libraries/npm-check-fork/src/interfaces/INpmCheckRegistry.ts Adds registry response types used by the new client/refactor.
libraries/npm-check-fork/src/index.ts Exports the new client/types and getNpmInfoBatch.
libraries/npm-check-fork/src/tests/GetLatestFromRegistry.test.ts Updates tests to mock NpmRegistryClient instead of package-json.
libraries/npm-check-fork/src/tests/NpmRegistryClient.test.ts Adds initial (currently minimal) test scaffolding for the new client.
libraries/npm-check-fork/package.json Removes package-json/throat, adds @rushstack/node-core-library.
libraries/npm-check-fork/CHANGELOG.md Adds a new version entry describing the dependency replacement.
common/changes/@rushstack/npm-check-fork/atomic-style-claude_2026-01-24-18-36.json Changeset for the patch release.
common/config/subspaces/**/pnpm-lock.yaml, repo-state.json Lockfile/hash updates reflecting dependency changes.
Files not reviewed (2)
  • common/config/subspaces/build-tests-subspace/pnpm-lock.yaml: Language not supported
  • common/config/subspaces/default/pnpm-lock.yaml: Language not supported

Copy link
Contributor

Copilot AI commented Jan 24, 2026

@TheLarkInn I've opened a new pull request, #5566, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 24, 2026

@TheLarkInn I've opened a new pull request, #5567, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 24, 2026

@TheLarkInn I've opened a new pull request, #5568, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits January 24, 2026 16:18
…esn't (#5567)

* Initial plan

* docs: reword JSDoc for structural compatibility instead of extends

Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>
…5568)

* Initial plan

* test(npm-check-fork): add comprehensive unit tests for NpmRegistryClient with http mocking

Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TheLarkInn <3408176+TheLarkInn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants