Skip to content

Conversation

@clydin
Copy link
Member

@clydin clydin commented Jan 9, 2026

The 'ng add' command now attempts to use '.angular/cache' or 'node_modules' as the base for temporary directories when acquiring packages. This ensures that the package manager can inherit project-specific configuration (like '.npmrc' or '.yarnrc') during the installation of temporary packages.

clydin added 2 commits January 9, 2026 11:06
… manager abstraction

This change introduces the ability to specify a base temporary directory when creating a `PackageManager` instance. This allows for creating temporary directories within the project structure (e.g., `node_modules/.tmp`), which enables package managers to correctly inherit project-specific configurations like `.npmrc` or `.yarnrc` during operations like `acquireTempPackage`.
The 'ng add' command now attempts to use '.angular/cache' or 'node_modules' as the base for temporary directories when acquiring packages. This ensures that the package manager can inherit project-specific configuration (like '.npmrc' or '.yarnrc') during the installation of temporary packages.

The implementation uses a fallback strategy, checking for candidate directories and defaulting to the system's temporary directory if none are found.
…on in ng add

This change enhances the error handling in the 'ng add' command's 'installPackageTask'. It now specifically catches 'PackageManagerError' exceptions and surfaces the standard output or standard error from the underlying package manager process. This provides users with more actionable information when a package installation fails.
@clydin clydin force-pushed the package-managers/temp-package-dir branch 8 times, most recently from 29a6564 to d89b476 Compare January 9, 2026 19:28
…ackages in bun

This change introduces a 'project-root' strategy for acquiring temporary packages, which is now enabled for Bun. Bun has difficulty discovering and using configuration files (like '.npmrc') when executed in an isolated temporary directory.

With the 'project-root' strategy, 'bun add' is executed directly in the project's root directory using the '--no-save' flag. This ensures correct configuration inheritance and reliable package resolution. The cleanup for this strategy is currently a no-op to avoid potentially destructive deletions within the project's 'node_modules'.
@clydin clydin force-pushed the package-managers/temp-package-dir branch from d89b476 to f1c95a4 Compare January 9, 2026 20:27
When resolving package manifests from file, git, or remote URLs, the CLI relies on installing the package into an isolated temporary directory to identify the package's name. This change forces the 'acquireTempPackage' method to use the 'temporary-directory' strategy for these lookups, ensuring that the package identification logic remains correct even when the package manager (like Bun) defaults to a 'project-root' strategy.
This change updates the 'ng add' command to dynamically determine the base directory for temporary package manager operations by consulting the workspace configuration. If caching is enabled and the cache path is located within the workspace root, it is added to the list of candidate directories alongside 'node_modules'.

This ensures that the package manager correctly inherits project settings even when the user has customized the location of the '.angular' directory, while maintaining the requirement that the directory must be within the project context for configuration inheritance to work.
@clydin clydin marked this pull request as ready for review January 12, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant