Repository navigation
fix(@angular/cli): resolve the package name inside npm workspace members - #34302
Arthur031221 wants to merge 1 commit into
Conversation
Inside an npm workspace member, `npm pkg get name` prints an object keyed by the workspace name instead of a JSON string. `getCurrentPackageName` returned that object, so the workspace lookup in `parseNpmLikeDependencies` never matched and `ng update` saw no dependencies for the member. The name is now only taken from the command output when it is a string. Otherwise it is read from the package.json of the current directory. Fixes #32787
There was a problem hiding this comment.
Code Review
This pull request updates the PackageManager to handle cases where npm prints an object keyed by the workspace name instead of a string. If the parsed output is not a string, it falls back to reading the package.json file. Unit tests have been added to verify this behavior and to test listing dependencies of an npm workspace member. I have no feedback to provide as there are no review comments.
|
Thank you for the contribution! Closing in favor of #34308, which also prioritizes reading |
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
PR Type
What is the current behavior?
Issue Number: #32787
Running
ng update @angular/corefrom an Angular app inside an npm workspace printsFound 0 dependencies.and fails withPackage '@angular/core' is not a dependency.An outdated CLI hands over to a temporary install of the latest one, so upgrading from an older version fails the same way. The issue has 23 reactions and several users report the same failure.getCurrentPackageNameparses the output ofnpm pkg get name. Inside a workspace member npm prints an object keyed by the workspace name ({ "app": "app" }) instead of a string. That object was used as the package name, soparseNpmLikeDependenciesnever found the member's dependencies.What is the new behavior?
The command output is only used if it's a string. Otherwise the name comes from the
package.jsonin the current directory.ng updatenow lists the dependencies of the workspace member.Added specs for the name and the dependencies of a workspace member.
pnpm bazel test //packages/angular/cli:testpasses.Does this PR introduce a breaking change?
Assisted by Claude/Codex.
Closes #32787