Skip to content

Add swift package-registry search subcommand#10125

Draft
plemarquand wants to merge 3 commits into
swiftlang:mainfrom
plemarquand:registry-search
Draft

Add swift package-registry search subcommand#10125
plemarquand wants to merge 3 commits into
swiftlang:mainfrom
plemarquand:registry-search

Conversation

@plemarquand

Copy link
Copy Markdown
Contributor

Motivation:

Implements the SwiftPM client side of the registry search pitch https://forums.swift.org/t/pitch-package-registry-search/86320, swiftlang/swift-evolution#3309.

Modifications:

  • Extends GET /availability to discover advertised capabilities. The available AvailabilityStatus case now carries a Set of capability keys parsed from the response body; an empty body still signals availability (backwards compatible).
  • withAvailabilityCheck gains a requiring: parameter that throws RegistryError.capabilityNotSupported when a registry does not advertise a required capability. All existing call sites are unaffected.
  • Adds RegistryClient.search(query:limit:offset:registry:...) hitting GET /search; 404 maps to capabilityNotSupported, other errors to a new searchFailed case.
  • New swift package-registry search subcommand iterates default and scoped registries (or --registry <url>), runs searches in parallel across all the registries the user has configured, and aggregates with round-robin interleaving. All registries unsupported -> error; some unsupported -> warning naming them (suppressed by --json). Per-result registry annotation appears only when multiple registries contribute.

Result:

The swift package-registry search command allows for users and tools to query their configured registries for packages that match their search criteria.

Implements the SwiftPM client side of the registry search pitch
(https://forums.swift.org/t/pitch-package-registry-search/86320).

- Extends GET /availability to discover advertised capabilities. The
  `available` AvailabilityStatus case now carries a Set<String> of
  capability keys parsed from the response body; an empty body still
  signals availability (backwards compatible).
- `withAvailabilityCheck` gains a `requiring:` parameter that throws
  `RegistryError.capabilityNotSupported` when a registry does not
  advertise a required capability. All existing call sites are
  unaffected.
- Adds `RegistryClient.search(query:limit:offset:registry:...)` hitting
  GET /search; 404 maps to `capabilityNotSupported`, other errors to a
  new `searchFailed` case.
- New `swift package-registry search` subcommand iterates default and
  scoped registries (or `--registry <url>`), runs searches in parallel,
  and aggregates with round-robin interleaving. All registries
  unsupported -> error; some unsupported -> warning naming them
  (suppressed by `--json`). Per-result `registry` annotation appears
  only when multiple registries contribute.
@plemarquand

Copy link
Copy Markdown
Contributor Author

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants