Skip to content

Commit f9481da

Browse files
committed
PackageRegistryCommand: 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 b421f3e commit f9481da

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ private func readpassword(_ prompt: String) throws -> String {
9797
#endif
9898

9999
extension PackageRegistryCommand {
100-
struct Login: AsyncSwiftCommand {
100+
package struct Login: AsyncSwiftCommand {
101101

102-
static func loginURL(from registryURL: URL, loginAPIPath: String?) throws -> URL {
102+
package static func loginURL(from registryURL: URL, loginAPIPath: String?) throws -> URL {
103103
// Login URL must be HTTPS
104104
var loginURLComponents = URLComponents(url: registryURL, resolvingAgainstBaseURL: true)
105105
loginURLComponents?.scheme = "https"
@@ -112,7 +112,7 @@ extension PackageRegistryCommand {
112112
return loginURL
113113
}
114114

115-
static let configuration = CommandConfiguration(
115+
package static let configuration = CommandConfiguration(
116116
abstract: "Log in to a registry."
117117
)
118118

@@ -123,7 +123,7 @@ extension PackageRegistryCommand {
123123
static let passwordBufferSize = Self.maxPasswordLength + 2
124124

125125
@OptionGroup(visibility: .hidden)
126-
var globalOptions: GlobalOptions
126+
package var globalOptions: GlobalOptions
127127

128128
@Argument(help: "The registry URL.")
129129
var url: URL?
@@ -152,7 +152,9 @@ extension PackageRegistryCommand {
152152

153153
private static let PLACEHOLDER_TOKEN_USER = "token"
154154

155-
func run(_ swiftCommandState: SwiftCommandState) async throws {
155+
package init() {}
156+
157+
package func run(_ swiftCommandState: SwiftCommandState) async throws {
156158
// We need to be able to read/write credentials
157159
// Make sure credentials store is available before proceeding
158160
let authorizationProvider: AuthorizationProvider?

Sources/PackageRegistryCommand/PackageRegistryCommand+Publish.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import struct TSCBasic.SHA256
3434
import struct TSCUtility.Version
3535

3636
extension PackageRegistryCommand {
37-
struct Publish: AsyncSwiftCommand {
38-
static let metadataFilename = "package-metadata.json"
37+
package struct Publish: AsyncSwiftCommand {
38+
package static let metadataFilename = "package-metadata.json"
3939

40-
static let configuration = CommandConfiguration(
40+
package static let configuration = CommandConfiguration(
4141
abstract: "Publish to a registry."
4242
)
4343

4444
@OptionGroup(visibility: .hidden)
45-
var globalOptions: GlobalOptions
45+
package var globalOptions: GlobalOptions
4646

4747
@Argument(help: .init("The package identifier.", valueName: "package-id"))
4848
var packageIdentity: PackageIdentity
@@ -89,7 +89,9 @@ extension PackageRegistryCommand {
8989
@Flag(help: "Dry run only; prepare the archive and sign it but do not publish to the registry.")
9090
var dryRun: Bool = false
9191

92-
func run(_ swiftCommandState: SwiftCommandState) async throws {
92+
package init() {}
93+
94+
package func run(_ swiftCommandState: SwiftCommandState) async throws {
9395
// Require both local and user-level registries config
9496
let configuration = try getRegistriesConfig(swiftCommandState, global: false).configuration
9597

@@ -460,8 +462,8 @@ enum PackageArchiveSigner {
460462
}
461463
}
462464

463-
enum PackageArchiver {
464-
static func archive(
465+
package enum PackageArchiver {
466+
package static func archive(
465467
packageIdentity: PackageIdentity,
466468
packageVersion: Version,
467469
packageDirectory: AbsolutePath,

Sources/PackageRegistryCommand/PackageRegistryCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public struct PackageRegistryCommand: AsyncParsableCommand {
166166
}
167167

168168
extension URL {
169-
func validateRegistryURL(allowHTTP: Bool = false) throws {
169+
package func validateRegistryURL(allowHTTP: Bool = false) throws {
170170
guard self.scheme == "https" || (self.scheme == "http" && allowHTTP) else {
171171
throw PackageRegistryCommand.ValidationError.invalidURL(self)
172172
}

0 commit comments

Comments
 (0)