Skip to content

feat: Migrate NuGet API from V2 to V3 Registration + Flat Container#13

Merged
Arthurvdv merged 1 commit into
mainfrom
migrate-nuget-v3-registration
Apr 23, 2026
Merged

feat: Migrate NuGet API from V2 to V3 Registration + Flat Container#13
Arthurvdv merged 1 commit into
mainfrom
migrate-nuget-v3-registration

Conversation

@Arthurvdv

Copy link
Copy Markdown
Member

Summary

Migrates the NuGet integration from V2/Flat Container index to V3 Registration API + V3 Flat Container downloads. This matches the approach already used in the VS Code extension (ALCops/vscode-extension#32).

Why

  1. Download statistics: V2 downloads redirect to globalcdn.nuget.org where User-Agent is not tracked. V3 Flat Container serves from the tracked api.nuget.org CDN.
  2. Unlisted versions: The Flat Container version index returns ALL versions including unlisted ones. The Registration API provides catalogEntry.listed per version.

What changed

File Change
shared/http-client.ts New. Gzip-aware HTTPS client with User-Agent support
shared/nuget-registration.ts New. V3 Registration API client with pagination (external pages via Promise.all)
shared/types.ts Added NUGET_REGISTRATION_BASE constant + Registration API interfaces
tasks/install-analyzers/src/nuget-api.ts Rewritten. Uses Registration API for version queries, semver sorting, unlisted filtering
tasks/install-analyzers/src/task-runner.ts Updated for ResolvedVersion type with packageContentUrl
tests/shared/nuget-registration.test.ts New. 13 tests (parsing + HTTP integration)
tests/install-analyzers/nuget-api.test.ts Rewritten. Tests unlisted filtering, semver sorting, User-Agent
.github/ARCHITECTURE.md Documented new modules, updated test counts
.github/copilot-instructions.md Added NuGet API Architecture section

No breaking changes

The YAML contract is unchanged: latest, prerelease, and specific version strings work as before. The behavioral improvement is that unlisted versions are now filtered out.

Tests

199 tests pass (17 new). Build, lint, and bundle all clean.

Replace V2 download URLs and V3 Flat Container version index with:
- V3 Registration API (registration5-gz-semver2) for version queries
- V3 Flat Container for package downloads (tracked CDN)

Key changes:
- Add shared/http-client.ts: gzip-aware HTTPS client with User-Agent
- Add shared/nuget-registration.ts: Registration API client with pagination
- Rewrite nuget-api.ts: semver sorting, unlisted version filtering
- Set User-Agent: ALCops-AzureDevOps on all NuGet requests
- Update ARCHITECTURE.md and copilot-instructions.md

No breaking YAML changes: 'latest' and 'prerelease' inputs unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Arthurvdv Arthurvdv merged commit d41ea69 into main Apr 23, 2026
3 checks passed
@Arthurvdv Arthurvdv deleted the migrate-nuget-v3-registration branch April 23, 2026 11:37
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.

1 participant