Repository navigation
Fix NpmRunner to handle multi-version npm view output - #15739
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15739Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15739" |
There was a problem hiding this comment.
Pull request overview
Fixes aspire new npm package resolution when npm view <pkg>@<range> version returns multiple matching versions (multi-line output), by extracting a single resolvable version string before passing it to SemVersion.TryParse().
Changes:
- Update
NpmRunner.ResolvePackageAsync()to use a new helper that extracts the last version fromnpm viewoutput. - Add
NpmRunner.ExtractLastVersion()to handle both single-line and multi-line npm output formats (including Windows line endings). - Add unit tests covering the parsing behavior for single/multiple versions, whitespace/empty output, and prerelease cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Npm/NpmRunner.cs | Extracts the last/highest version from multi-line npm view output before SemVer parsing. |
| tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs | Adds coverage for the new version-extraction logic across common output variants. |
57bf5c1 to
a19a5cd
Compare
When a version range like >=0.1.1 matches multiple published versions, npm view returns multi-line output instead of a single version string. The existing code tried to parse the entire multi-line output as a single SemVersion, which failed. Extract the last (highest) version from the multi-line output format: @scope/pkg@version 'version' Also bumps the @playwright/cli version range from >=0.1.1 to >=0.1.3. Fixes #15738 Co-authored-by: Copilot <[email protected]>
a19a5cd to
17374ad
Compare
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23829835738 |
|
/backport to release/13.2 |
|
Started backporting to |
|
No documentation PR is required for this change. This PR is a bug fix for
|
Description
When
npm view @playwright/cli@>=0.1.1 versionmatches multiple published versions, npm returns multi-line output in the format@scope/pkg@version 'version'per line.NpmRunner.ResolvePackageAsync()was calling.Trim()on the entire multi-line string and passing it toSemVersion.TryParse(), which failed.This broke after versions 0.1.2 and 0.1.3 of
@playwright/cliwere published on March 31, 2026 — previously only 0.1.1 matched the range, so the output was a single parseable version string.The fix adds an
ExtractLastVersion()method that parses the last (highest) version from multi-line npm output, handling both single-version and multi-version formats.Fixes #15738
Checklist