fix(@angular/cli): copy project config files to temp directory during ng update#32959
fix(@angular/cli): copy project config files to temp directory during ng update#32959ptu14 wants to merge 1 commit intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a copyConfigFromProject flag to the package manager descriptors to ensure that project-specific configuration files are correctly copied into temporary directories during package acquisition. This change improves support for private registries and custom configurations. I have identified two potential issues: first, the flag is missing from the modern Yarn descriptor, which may lead to inconsistencies; second, including pnpm-workspace.yaml in the configFiles list for pnpm might trigger unintended workspace-related behavior in the isolated temporary environment.
| ignoreScriptsFlag: '--ignore-scripts', | ||
| ignorePeerDependenciesFlag: '--strict-peer-dependencies=false', | ||
| configFiles: ['.npmrc', 'pnpm-workspace.yaml'], | ||
| copyConfigFromProject: true, |
There was a problem hiding this comment.
Enabling copyConfigFromProject for pnpm will cause pnpm-workspace.yaml to be copied into the temporary directory (as it is listed in configFiles on line 238). This might cause pnpm to attempt workspace-related operations in an isolated temporary directory, which could lead to unexpected behavior or errors if the workspace structure is incomplete. Consider if pnpm-workspace.yaml should be removed from the configFiles list if only registry settings from .npmrc are required for temporary package acquisition.
There was a problem hiding this comment.
Only .npmrc is needed for registry settings. Added a comment explaining the exclusion.
Worth noting that pnpm-workspace.yaml was never actually copied before this change since copyConfigFromProject was disabled for pnpm, so this is not a regression.
6aa2cd4 to
7613be7
Compare
Fixes #27163
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
During
ng update, the CLI installs a temporary version of itself in a system temp directory (e.g./tmp/angular-cli-packages-xxx). Since this directory is outside the project tree, npm/pnpm/yarn-classic cannot find the project's.npmrcand falls back to the user-level~/.npmrc. This causes registry settings defined in the project's.npmrcto be ignored.Issue Number: #27163
What is the new behavior?
Project configuration files (
.npmrc,.yarnrc,pnpm-workspace.yaml) are now copied to the temporary directory before runningnpm install. This reuses the existingcopyConfigFromProjectmechanism (previously only enabled for bun) for npm, pnpm, and yarn-classic.Does this PR introduce a breaking change?