Repository navigation
fix(@angular/cli): resolve the package name inside npm workspace members - #34302
Open
Arthur031221 wants to merge 1 commit into
Open
Arthur031221 wants to merge 1 commit into
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 angular#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.