Skip to content

Commit 09a9bd8

Browse files
committed
integrate registry dependencies into dependency resolution
motivation: support registries changes: * create RegistryPackageContainer to handle dependencies from registry, integrated with the previously introduces registry client * update workspace to create RegistryPackageContainer when dealing with registry dependencies * update registry client (RegitryManager) to perform download request (buffered) when downloading the package archive * update registry client manifest listing and handling so it supportes multi-manifest setups. simplified the client to return the manifest content instead of attempting to load it which is done in RegistryPackageContainer which has additional context * update registry client to use Codable * add testing infrastructure to MockWorkspace to mock registry dependencies * add basic tests for regsitry scenarios
1 parent 9e0124e commit 09a9bd8

16 files changed

+1408
-441
lines changed

Sources/Basics/HTTPClient.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,11 @@ public struct HTTPClientResponse {
387387

388388
extension HTTPClientResponse {
389389
public static func okay(body: String? = nil) -> HTTPClientResponse {
390-
return HTTPClientResponse(statusCode: 200, body: body?.data(using: .utf8))
390+
return .okay(body: body?.data(using: .utf8))
391+
}
392+
393+
public static func okay(body: Data?) -> HTTPClientResponse {
394+
return HTTPClientResponse(statusCode: 200, body: body)
391395
}
392396

393397
public static func notFound(reason: String? = nil) -> HTTPClientResponse {

Sources/PackageGraph/PackageGraph+Loading.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ private func createResolvedPackages(
247247
case .remote(let url):
248248
dependencyLocation = url.absoluteString
249249
}
250-
case .registry:
251-
// FIXME
252-
fatalError("registry based dependencies not implemented yet")
250+
case .registry(let settings):
251+
// TODO: this is
252+
dependencyLocation = settings.identity.description
253253
}
254254

255255
// Otherwise, look it up by its identity.

Sources/PackageLoading/ToolsVersionLoader.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,13 @@ public struct ToolsVersionLoader: ToolsVersionLoaderProtocol {
353353
guard let manifestContentsDecodedWithUTF8 = manifestContents.validDescription else {
354354
throw Error.nonUTF8EncodedManifest(path: file)
355355
}
356-
356+
357+
return try self.load(utf8String: manifestContentsDecodedWithUTF8)
358+
}
359+
360+
public func load(utf8String: String) throws -> ToolsVersion {
357361
/// The manifest represented in its constituent parts.
358-
let manifestComponents = ToolsVersionLoader.split(manifestContentsDecodedWithUTF8)
362+
let manifestComponents = ToolsVersionLoader.split(utf8String)
359363
/// The Swift tools version specification represented in its constituent parts.
360364
let toolsVersionSpecificationComponents = manifestComponents.toolsVersionSpecificationComponents
361365

Sources/PackageModel/PackageIdentity.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ public struct PackageIdentity: CustomStringConvertible {
6565
}
6666

6767
// TODO: formalize package registry identifier
68-
public var scopeAndName: (Scope, Name)? {
68+
public var scopeAndName: (scope: Scope, name: Name)? {
6969
let components = description.split(separator: ".", maxSplits: 1, omittingEmptySubsequences: true)
7070
guard components.count == 2,
7171
let scope = Scope(components.first),
7272
let name = Name(components.last)
73-
else { return nil }
73+
else { return .none }
7474

75-
return (scope, name)
75+
return (scope: scope, name: name)
7676
}
7777
}
7878

Sources/PackageRegistry/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
add_library(PackageRegistry
1010
Registry.swift
1111
RegistryConfiguration.swift
12-
RegistryManager.swift
12+
RegistryClient.swift
1313
SourceArchiver.swift)
1414
target_link_libraries(PackageRegistry PUBLIC
1515
Basics

0 commit comments

Comments
 (0)