Skip to content

Commit a28fd52

Browse files
committed
Basics: 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 ff7ea75 commit a28fd52

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

Sources/Basics/Archiver/TarArchiver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct TarArchiver: Archiver {
2525
private let cancellator: Cancellator
2626

2727
/// The underlying command
28-
internal let tarCommand: String
28+
package let tarCommand: String
2929

3030
/// Creates a `TarArchiver`.
3131
///

Sources/Basics/Archiver/ZipArchiver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public struct ZipArchiver: Archiver, Cancellable {
3131
#if os(Windows)
3232
internal let windowsTar: String
3333
#else
34-
internal let unzip = "unzip"
35-
internal let zip = "zip"
34+
package let unzip = "unzip"
35+
package let zip = "zip"
3636
#endif
3737

3838
#if os(FreeBSD)

Sources/Basics/AuthorizationProvider.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public final class NetrcAuthorizationProvider: AuthorizationProvider, Authorizat
140140
}
141141

142142
// marked internal for testing
143-
internal var machines: [Basics.Netrc.Machine] {
143+
package var machines: [Basics.Netrc.Machine] {
144144
// this ignores any errors reading the file
145145
// initial validation is done at the time of initializing the provider
146146
// and if the file becomes corrupt at runtime it will handle it gracefully
@@ -408,16 +408,16 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori
408408
return item
409409
}
410410

411-
struct ProtocolHostPort: Hashable, CustomStringConvertible {
412-
let `protocol`: String?
413-
let host: String
414-
let port: Int?
411+
package struct ProtocolHostPort: Hashable, CustomStringConvertible {
412+
package let `protocol`: String?
413+
package let host: String
414+
package let port: Int?
415415

416416
var server: String {
417417
self.host
418418
}
419419

420-
var protocolCFString: CFString {
420+
package var protocolCFString: CFString {
421421
// See
422422
// https://developer.apple.com/documentation/security/keychain_services/keychain_items/item_attribute_keys_and_values?language=swift
423423
// for a list of possible values for the `kSecAttrProtocol` attribute.
@@ -431,7 +431,7 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori
431431
}
432432
}
433433

434-
init?(from url: URL) {
434+
package init?(from url: URL) {
435435
guard let host = url.host?.lowercased(), !host.isEmpty else {
436436
return nil
437437
}
@@ -441,7 +441,7 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori
441441
self.port = url.port
442442
}
443443

444-
var description: String {
444+
package var description: String {
445445
"\(self.protocol.map { "\($0)://" } ?? "")\(self.host)\(self.port.map { ":\($0)" } ?? "")"
446446
}
447447
}

Sources/Basics/Cancellator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public final class Cancellator: Cancellable, Sendable {
144144

145145
// marked internal for testing
146146
@discardableResult
147-
internal func _cancel(deadline: DispatchTime? = .none) -> Int {
147+
package func _cancel(deadline: DispatchTime? = .none) -> Int {
148148
self.cancelling.put(true)
149149

150150
self.observabilityScope?

Sources/Basics/Concurrency/SendableBox.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ public actor SendableBox<Value: Sendable> {
2828
}
2929

3030
extension SendableBox where Value == Int {
31-
func increment() {
31+
package func increment() {
3232
self.value = value + 1
3333
}
3434

35-
func decrement() {
35+
package func decrement() {
3636
self.value = value - 1
3737
}
3838
}
3939

4040
extension SendableBox where Value == Date {
41-
func resetDate() {
41+
package func resetDate() {
4242
value = Date()
4343
}
4444
}

Sources/Basics/Graph/AdjacencyMatrix.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// edge exists.
1919
///
2020
/// See https://en.wikipedia.org/wiki/Adjacency_matrix for more details.
21-
struct AdjacencyMatrix {
21+
package struct AdjacencyMatrix {
2222
let columns: Int
2323
let rows: Int
2424
private var bytes: [UInt8]
@@ -27,15 +27,15 @@ struct AdjacencyMatrix {
2727
/// - Parameters:
2828
/// - rows: Number of rows in the matrix.
2929
/// - columns: Number of columns in the matrix.
30-
init(rows: Int, columns: Int) {
30+
package init(rows: Int, columns: Int) {
3131
self.columns = columns
3232
self.rows = rows
3333

3434
let (quotient, remainder) = (rows * columns).quotientAndRemainder(dividingBy: 8)
3535
self.bytes = .init(repeating: 0, count: quotient + (remainder > 0 ? 1 : 0))
3636
}
3737

38-
var bitCount: Int {
38+
package var bitCount: Int {
3939
bytes.count * 8
4040
}
4141

@@ -44,7 +44,7 @@ struct AdjacencyMatrix {
4444
return (byteOffset: totalBitOffset / 8, bitOffsetInByte: totalBitOffset % 8)
4545
}
4646

47-
subscript(row: Int, column: Int) -> Bool {
47+
package subscript(row: Int, column: Int) -> Bool {
4848
get {
4949
let (byteOffset, bitOffsetInByte) = calculateOffsets(row: row, column: column)
5050

Sources/Basics/HTTPClient/HTTPClientHeaders.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public struct HTTPClientHeaders: Sendable {
6464
}
6565

6666
public struct Item: Equatable, Sendable {
67-
let name: String
68-
let value: String
67+
package let name: String
68+
package let value: String
6969

7070
public init(name: String, value: String) {
7171
self.name = name

Sources/Basics/HTTPClient/HTTPMethod.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public enum HTTPMethod: Sendable {
1717
case put
1818
case delete
1919

20-
var string: String {
20+
package var string: String {
2121
switch self {
2222
case .head:
2323
return "HEAD"

Sources/Basics/HTTPClient/URLSessionHTTPClient.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import struct TSCUtility.Versioning
1818
import FoundationNetworking
1919
#endif
2020

21-
final class URLSessionHTTPClient: Sendable {
21+
package final class URLSessionHTTPClient: Sendable {
2222
private let dataSession: URLSession
2323
private let downloadSession: URLSession
2424
private let dataTaskManager: DataTaskManager
2525
private let downloadTaskManager: DownloadTaskManager
2626

27-
init(configuration: URLSessionConfiguration = .default) {
27+
package init(configuration: URLSessionConfiguration = .default) {
2828
let dataDelegateQueue = OperationQueue()
2929
dataDelegateQueue.name = "org.swift.swiftpm.urlsession-http-client-data-delegate"
3030
dataDelegateQueue.maxConcurrentOperationCount = 1
@@ -52,7 +52,7 @@ final class URLSessionHTTPClient: Sendable {
5252
}
5353

5454
@Sendable
55-
func execute(
55+
package func execute(
5656
_ request: HTTPClient.Request,
5757
progress: HTTPClient.ProgressHandler? = nil
5858
) async throws -> LegacyHTTPClient.Response {
@@ -364,7 +364,7 @@ private final class DownloadTaskManager: NSObject, URLSessionDownloadDelegate {
364364
}
365365

366366
extension URLRequest {
367-
init(_ request: LegacyHTTPClient.Request) {
367+
package init(_ request: LegacyHTTPClient.Request) {
368368
self.init(url: request.url)
369369
self.httpMethod = request.method.string
370370
request.headers.forEach { header in

Sources/Basics/Serialization/SerializedJSON.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/// Wrapper type representing serialized escaped JSON strings providing helpers
1414
/// for escaped string interpolations for common types such as `AbsolutePath`.
1515
public struct SerializedJSON {
16-
let underlying: String
16+
package let underlying: String
1717
}
1818

1919
extension SerializedJSON: ExpressibleByStringLiteral {

0 commit comments

Comments
 (0)