-
Notifications
You must be signed in to change notification settings - Fork 663
[npm-check-fork] - Replace package-json and throat dependencies #5565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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
NpmRegistryClientimplemented with Node.jshttp/https(plus a basic test file). - Refactored
GetLatestFromRegistryto useNpmRegistryClientand introducedgetNpmInfoBatchwith configurable concurrency. - Updated types/exports and removed the external dependencies from
package.jsonand 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
|
@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. |
|
@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. |
|
@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. |
…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>
Summary
Removes external dependencies
package-json(ESM-only, ~500KB dependency tree) andthroat(redundant concurrency limiter) from@rushstack/npm-check-fork.Replaced with:
NpmRegistryClient- minimal registry client using Node.js built-inhttpsmodulePromise.allbatch processing for concurrent requestsDetails
New files:
src/NpmRegistryClient.ts- registry client withfetchPackageMetadataAsyncsrc/tests/NpmRegistryClient.test.tsModified files:
src/GetLatestFromRegistry.ts- uses NpmRegistryClient instead of package-jsonsrc/interfaces/INpmCheckRegistry.ts- added registry response typessrc/index.ts- exports new client andgetNpmInfoBatchfunctionInternal refactoring only.
How it was tested
rush build --to @rushstack/npm-check-fork- passesrush test --only @rushstack/npm-check-fork- passesrush upgrade-interactiveImpacted documentation
None - internal implementation change only.