Skip to content

Use CPAN API for version info rather than HTML parsing#511

Merged
danfiedler-msft merged 2 commits into
mainfrom
danfiedler/cpan-versions
Jul 28, 2025
Merged

Use CPAN API for version info rather than HTML parsing#511
danfiedler-msft merged 2 commits into
mainfrom
danfiedler/cpan-versions

Conversation

@danfiedler-msft
Copy link
Copy Markdown
Contributor

The primary purpose of this PR is to fix a failing (integration) test: CPAN_Download_Version_Succeeds. The test is failing because metacpan.org now returns Fastly JavaScript which causes CPANProjectManager.EnumerateVersionsAsync HTML-parsing to fail. This result of EnumerateVersionsAsync is used by PackageDownloader to select the largest version when the specified purl is missing a version.

This PR changes CPANProjectManager.EnumerateVersionsAsync to obtain the version list from fastapi.metacpan.org's JSON response (rather than parsing HTML.)

This PR also makes a small number of organizational changes:

  • VS Solution folders for src and test with corresponding projects under each
  • One small step towards idiomatic unit tests by introducing a new Shared.Lib.Tests unit testing project, where test organization matches the code under test.
  • The new version metadata logic is in the new smaller, focused CPANMetadataClient class and adopts a few more modern conventions. The new code hopes for dependency injection one day, prefers CancellationToken over HttpClient.Timeout, and uses async over .Result.

@danfiedler-msft danfiedler-msft merged commit 71acbd7 into main Jul 28, 2025
5 checks passed
@danfiedler-msft danfiedler-msft deleted the danfiedler/cpan-versions branch July 28, 2025 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants