Skip to content

Commit 23bb3ed

Browse files
committed
PackageRegistry: make some of the private API more public
This extends the visibility of some of the private implementation to the package level to allow use for testing without `@testable` imports.
1 parent 88da821 commit 23bb3ed

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

Sources/PackageRegistry/ChecksumTOFU.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import Foundation
2020

2121
import struct TSCUtility.Version
2222

23-
struct PackageVersionChecksumTOFU {
23+
package struct PackageVersionChecksumTOFU {
2424
private let fingerprintStorage: PackageFingerprintStorage?
2525
private let fingerprintCheckingMode: FingerprintCheckingMode
2626
private let versionMetadataProvider: (PackageIdentity.RegistryIdentity, Version) async throws -> RegistryClient
2727
.PackageVersionMetadata
2828

29-
init(
29+
package init(
3030
fingerprintStorage: PackageFingerprintStorage?,
3131
fingerprintCheckingMode: FingerprintCheckingMode,
3232
versionMetadataProvider: @escaping (PackageIdentity.RegistryIdentity, Version) async throws -> RegistryClient
@@ -38,7 +38,7 @@ struct PackageVersionChecksumTOFU {
3838
}
3939

4040
// MARK: - source archive
41-
func validateSourceArchive(
41+
package func validateSourceArchive(
4242
registry: Registry,
4343
package: PackageIdentity.RegistryIdentity,
4444
version: Version,
@@ -139,7 +139,7 @@ struct PackageVersionChecksumTOFU {
139139
return checksum
140140
}
141141

142-
func validateManifest(
142+
package func validateManifest(
143143
registry: Registry,
144144
package: PackageIdentity.RegistryIdentity,
145145
version: Version,

Sources/PackageRegistry/RegistryClient.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ public final class RegistryClient: AsyncCancellable {
13371337
}
13381338

13391339
@available(*, deprecated, message: "Use the async alternative")
1340-
func checkAvailability(
1340+
package func checkAvailability(
13411341
registry: Registry,
13421342
timeout: DispatchTimeInterval? = .none,
13431343
observabilityScope: ObservabilityScope,
@@ -1354,7 +1354,7 @@ public final class RegistryClient: AsyncCancellable {
13541354
}
13551355

13561356
// marked internal for testing
1357-
func checkAvailability(
1357+
package func checkAvailability(
13581358
registry: Registry,
13591359
timeout: DispatchTimeInterval? = .none,
13601360
observabilityScope: ObservabilityScope
@@ -1818,7 +1818,7 @@ extension RegistryClient {
18181818
case error(String)
18191819

18201820
// marked internal for testing
1821-
static var unavailableStatusCodes = [404, 501]
1821+
package static var unavailableStatusCodes = [404, 501]
18221822
}
18231823
}
18241824

Sources/PackageRegistry/RegistryConfiguration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ extension RegistryConfiguration {
145145
}
146146

147147
// for testing
148-
init(
148+
package init(
149149
default: Global,
150150
registryOverrides: [String: RegistryOverride] = [:],
151151
scopeOverrides: [PackageIdentity.Scope: ScopePackageOverride] = [:],
@@ -165,7 +165,7 @@ extension RegistryConfiguration {
165165
}
166166

167167
// for testing
168-
init(signing: Signing) {
168+
package init(signing: Signing) {
169169
self.signing = signing
170170
}
171171
}

Sources/PackageRegistry/RegistryDownloadsManager.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ extension RegistryDownloadsManager {
365365
public let fromCache: Bool
366366
/// Indicates whether the repository was already present in the cache and updated or if a clean fetch was performed.
367367
public let updatedCache: Bool
368+
369+
package init(fromCache: Bool, updatedCache: Bool) {
370+
self.fromCache = fromCache
371+
self.updatedCache = updatedCache
372+
}
368373
}
369374
}
370375

@@ -385,7 +390,7 @@ extension PackageIdentity {
385390
return try RelativePath(validating: registryIdentity.scope.description).appending(component: registryIdentity.name.description)
386391
}
387392

388-
internal func downloadPath(version: Version) throws -> Basics.RelativePath {
393+
package func downloadPath(version: Version) throws -> Basics.RelativePath {
389394
try self.downloadPath().appending(component: version.description)
390395
}
391396
}

Sources/PackageRegistry/SignatureValidation.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import TSCBasic
2222

2323
import struct TSCUtility.Version
2424

25-
protocol SignatureValidationDelegate {
25+
package protocol SignatureValidationDelegate {
2626
func onUnsigned(registry: Registry, package: PackageIdentity, version: Version, completion: (Bool) -> Void)
2727
func onUntrusted(registry: Registry, package: PackageIdentity, version: Version, completion: (Bool) -> Void)
2828
}
2929

30-
struct SignatureValidation {
31-
typealias Delegate = SignatureValidationDelegate
30+
package struct SignatureValidation {
31+
package typealias Delegate = SignatureValidationDelegate
3232

3333
private let skipSignatureValidation: Bool
3434
private let signingEntityTOFU: PackageSigningEntityTOFU
@@ -40,7 +40,7 @@ struct SignatureValidation {
4040
case passthrough(Error)
4141
}
4242

43-
init(
43+
package init(
4444
skipSignatureValidation: Bool,
4545
signingEntityStorage: PackageSigningEntityStorage?,
4646
signingEntityCheckingMode: SigningEntityCheckingMode,
@@ -58,7 +58,7 @@ struct SignatureValidation {
5858
}
5959

6060
// MARK: - source archive
61-
func validate(
61+
package func validate(
6262
registry: Registry,
6363
package: PackageIdentity.RegistryIdentity,
6464
version: Version,
@@ -313,7 +313,7 @@ struct SignatureValidation {
313313
}
314314

315315
// MARK: - manifests
316-
func validate(
316+
package func validate(
317317
registry: Registry,
318318
package: PackageIdentity.RegistryIdentity,
319319
version: Version,

Sources/PackageRegistry/SigningEntityTOFU.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import PackageSigning
1919

2020
import struct TSCUtility.Version
2121

22-
struct PackageSigningEntityTOFU {
22+
package struct PackageSigningEntityTOFU {
2323
private let signingEntityStorage: PackageSigningEntityStorage?
2424
private let signingEntityCheckingMode: SigningEntityCheckingMode
2525

26-
init(
26+
package init(
2727
signingEntityStorage: PackageSigningEntityStorage?,
2828
signingEntityCheckingMode: SigningEntityCheckingMode
2929
) {

0 commit comments

Comments
 (0)