Skip to content

Conversation

@clydin
Copy link
Member

@clydin clydin commented Dec 1, 2025

This commit fully refactors the ng add command to use the new, centralized package manager abstraction.

All package installation and metadata fetching logic now goes through the new API. This includes:

  • Using createPackageManager to detect the project's package manager.
  • Replacing fetchPackageMetadata with packageManager.getRegistryMetadata.
  • Replacing fetchPackageManifest with packageManager.getManifest.
  • Replacing the install and installTemp methods with the packageManager.add and packageManager.acquireTempPackage methods.

@angular-robot angular-robot bot added area: performance Issues related to performance area: @angular/cli labels Dec 1, 2025
@clydin clydin force-pushed the ng-add/pm-abstraction branch 24 times, most recently from 6404b94 to b346764 Compare December 4, 2025 16:49
…action

This commit fully refactors the `ng add` command to use the new, centralized package manager abstraction.

All package installation and metadata fetching logic now goes through the new API. This includes:

- Using `createPackageManager` to detect the project's package manager.
- Replacing `fetchPackageMetadata` with `packageManager.getRegistryMetadata`.
- Replacing `fetchPackageManifest` with `packageManager.getManifest`.
- Replacing the `install` and `installTemp` methods with the `packageManager.add` and `packageManager.acquireTempPackage` methods.

This change improves security by eliminating `shell: true` execution as well as enhances reliability with better error handling and caching.
The `ng add` command's version discovery mechanism could be slow when the `latest` tag of a package was incompatible, as it would fall back to exhaustively fetching the manifest for every available version.

This commit introduces a performance optimization that uses a heuristic-based search. The new logic first identifies the latest release within each major version line and checks only those for compatibility. This dramatically reduces the number of network requests in the common case where peer dependency conflicts align with major versions.

The exhaustive, version-by-version search is retained as a fallback to ensure correctness in edge cases.
Removes the `viewCommandFieldArgFormatter` from the `bun` package manager descriptor. While `bun` supports field-filtered registry views, it is limited to a single field at a time. The current package manager abstraction requires support for multiple fields.

This change ensures that the package manager abstraction for `bun` is more accurate and avoids potential issues with unsupported command arguments.
@clydin clydin force-pushed the ng-add/pm-abstraction branch from b346764 to 927a262 Compare December 4, 2025 18:24
@clydin clydin force-pushed the ng-add/pm-abstraction branch 4 times, most recently from fe82d7a to 639bf98 Compare December 4, 2025 21:58
@clydin clydin force-pushed the ng-add/pm-abstraction branch from 639bf98 to 3277317 Compare December 4, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/cli area: performance Issues related to performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant