fix(@angular/cli): robustly parse npm manifest from array#33147
fix(@angular/cli): robustly parse npm manifest from array#33147clydin merged 2 commits intoangular:mainfrom
Conversation
Update `parseNpmLikeManifest` to find the manifest with the highest version instead of assuming the last item in the array is the correct one. This makes the parsing robust against out-of-order results from `npm view` or similar commands without incurring performance penalties. This change ensures that the latest relevant version is always selected when a range is queried and multiple versions are returned, improving reliability in edge cases where registry output might not be sorted.
There was a problem hiding this comment.
Code Review
This pull request updates the parseNpmLikeManifest function to handle multiple manifests by selecting the highest versioned entry, supported by a new validation helper and expanded unit tests. Review feedback suggests further strengthening the validation logic to verify semantic version formats using the semver package, refining debug log messages for clarity, and adding test coverage for invalid version strings.
c6cf19b to
07ce1e4
Compare
alan-agius4
left a comment
There was a problem hiding this comment.
LGTM, after the lint issue is fixed.
07ce1e4 to
4f0385f
Compare
…rsing Introduce a reusable `isValidManifest` type guard to ensure that parsed manifests contain both `name` and `version` strings. This applies to both single object responses and elements within an array response from the package manager.
4f0385f to
4a78ddc
Compare
|
Hey there, thanks for your quick response to issue #33146 and implementing a fix. I see that you only added validation steps to the final PR that was merged into main and 21.2.x. But the key problem - sorting for the latest version - that you initially fixed in 5c1db4e (Line 241 to 257) was not picked for the final PR. Why is that? |
Update
parseNpmLikeManifestto find the manifest with the highest version instead of assuming the last item in the array is the correct one. This makes the parsing robust against out-of-order results fromnpm viewor similar commands without incurring performance penalties.This change ensures that the latest relevant version is always selected when a range is queried and multiple versions are returned, improving reliability in edge cases where registry output might not be sorted.