Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

More DS commands

Kabir Oberai6222518c0eb3
diff --git a/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swift
new file mode 100644
index 0000000..eb6a55b
--- /dev/null
+++ b/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swift
@@ -0,0 +1,79 @@
+import Foundation
+import ArgumentParser
+import Supersign
+import DeveloperAPI
+
+struct DSCertificatesCommand: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "certificates",
+ abstract: "Interact with certificates",
+ subcommands: [
+ DSCertificatesListCommand.self,
+ ],
+ defaultSubcommand: DSCertificatesListCommand.self
+ )
+}
+
+struct DSCertificatesListCommand: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "list",
+ abstract: "List certificates"
+ )
+
+ func run() async throws {
+ let client = DeveloperAPIClient(auth: try AuthToken.saved().authData())
+ let certificates = try await client.certificatesGetCollection().ok.body.json.data
+ for certificate in certificates {
+ print("- id: \(certificate.id)")
+ guard let attributes = certificate.attributes else {
+ continue
+ }
+
+ if let name = attributes.name {
+ print(" name: \(name)")
+ }
+
+ if let certificateType = attributes.certificateType {
+ print(" type: \(certificateType.rawValue)")
+ }
+
+ if let displayName = attributes.displayName {
+ print(" display name: \(displayName)")
+ }
+
+ if let serialNumber = attributes.serialNumber {
+ print(" serial number: \(serialNumber)")
+ }
+
+ if let platform = attributes.platform {
+ print(" platform: \(platform.rawValue)")
+ }
+
+ if let expirationDate = attributes.expirationDate {
+ print(" expiry: \(expirationDate.formatted(.dateTime))")
+ }
+
+ if let contentString = attributes.certificateContent,
+ let content = Data(base64Encoded: contentString) {
+ do {
+ let certificate = try Certificate(data: content)
+ print(" content:")
+ switch Result(catching: { try certificate.developerIdentity() }) {
+ case .success(let id):
+ print(" common name: \(id)")
+ case .failure(let error):
+ print(" common name: error: \(error)")
+ }
+ switch Result(catching: { try certificate.teamID() }) {
+ case .success(let teamID):
+ print(" team id: \(teamID)")
+ case .failure(let error):
+ print(" team id: error: \(error)")
+ }
+ } catch {
+ print(" content: error: \(error)")
+ }
+ }
+ }
+ }
+}
diff --git a/Sources/SupersignCLISupport/DSCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSCommand.swift
similarity index 60%
rename from Sources/SupersignCLISupport/DSCommand.swift
rename to Sources/SupersignCLISupport/DSCommands/DSCommand.swift
index ca9b7be..02e1ac9 100644
--- a/Sources/SupersignCLISupport/DSCommand.swift
+++ b/Sources/SupersignCLISupport/DSCommands/DSCommand.swift
@@ -1,33 +1,8 @@
import Foundation
import Supersign
import ArgumentParser
-import DeveloperAPI
-import OpenAPIRuntime
import Dependencies
-struct DSTeamsListCommand: AsyncParsableCommand {
- static let configuration = CommandConfiguration(
- commandName: "list",
- abstract: "List Developer Services teams"
- )
-
- func run() async throws {
- let token = try AuthToken.saved()
-
- guard case let .xcode(authData) = try token.authData() else {
- throw Console.Error("This command requires password-based authentication")
- }
- let client = DeveloperServicesClient(authData: authData)
- let teams: [DeveloperServicesTeam] = try await client.send(DeveloperServicesListTeamsRequest())
- print(
- teams.map {
- "\($0.name) [\($0.status)]: \($0.id.rawValue)" +
- $0.memberships.map { "\n- \($0.name) (\($0.platform))" }.joined()
- }.joined(separator: "\n")
- )
- }
-}
-
struct DSAnisetteCommand: AsyncParsableCommand {
private final class Provider: RawADIProvider, RawADIProvisioningSession {
func startProvisioning(spim: Data, userID: UUID) async throws -> (RawADIProvisioningSession, Data) {
@@ -74,21 +49,14 @@ struct DSAnisetteCommand: AsyncParsableCommand {
}
}
-struct DSTeamsCommand: ParsableCommand {
- static let configuration = CommandConfiguration(
- commandName: "teams",
- abstract: "Interact with Developer Services teams",
- subcommands: [DSTeamsListCommand.self],
- defaultSubcommand: DSTeamsListCommand.self
- )
-}
-
struct DSCommand: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "ds",
abstract: "Interact with Apple Developer Services",
subcommands: [
DSTeamsCommand.self,
+ DSIdentifiersCommand.self,
+ DSCertificatesCommand.self,
DSAnisetteCommand.self,
]
)
diff --git a/Sources/SupersignCLISupport/DSCommands/DSIdentifiersCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSIdentifiersCommand.swift
new file mode 100644
index 0000000..a7ad3a9
--- /dev/null
+++ b/Sources/SupersignCLISupport/DSCommands/DSIdentifiersCommand.swift
@@ -0,0 +1,45 @@
+import Foundation
+import ArgumentParser
+import Supersign
+import DeveloperAPI
+
+struct DSIdentifiersCommand: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "identifiers",
+ abstract: "Interact with bundle identifiers",
+ subcommands: [
+ DSIdentifiersListCommand.self,
+ ],
+ defaultSubcommand: DSIdentifiersListCommand.self
+ )
+}
+
+struct DSIdentifiersListCommand: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "list",
+ abstract: "List bundle identifiers"
+ )
+
+ func run() async throws {
+ let client = DeveloperAPIClient(auth: try AuthToken.saved().authData())
+ let bundleIDs = try await client.bundleIdsGetCollection().ok.body.json.data
+ for bundleID in bundleIDs {
+ print("- id: \(bundleID.id)")
+ guard let attributes = bundleID.attributes else {
+ continue
+ }
+ if let name = attributes.name {
+ print(" name: \(name)")
+ }
+ if let identifier = attributes.identifier {
+ print(" identifier: \(identifier)")
+ }
+ if let platform = attributes.platform {
+ print(" platform: \(platform.rawValue)")
+ }
+ if let seedId = attributes.seedId {
+ print(" seedId: \(seedId)")
+ }
+ }
+ }
+}
diff --git a/Sources/SupersignCLISupport/DSCommands/DSTeamsCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSTeamsCommand.swift
new file mode 100644
index 0000000..291829d
--- /dev/null
+++ b/Sources/SupersignCLISupport/DSCommands/DSTeamsCommand.swift
@@ -0,0 +1,37 @@
+import Foundation
+import ArgumentParser
+import Supersign
+
+struct DSTeamsCommand: ParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "teams",
+ abstract: "Interact with development teams",
+ subcommands: [
+ DSTeamsListCommand.self
+ ],
+ defaultSubcommand: DSTeamsListCommand.self
+ )
+}
+
+struct DSTeamsListCommand: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "list",
+ abstract: "List teams"
+ )
+
+ func run() async throws {
+ let token = try AuthToken.saved()
+
+ guard case let .xcode(authData) = try token.authData() else {
+ throw Console.Error("This command requires password-based authentication")
+ }
+ let client = DeveloperServicesClient(authData: authData)
+ let teams: [DeveloperServicesTeam] = try await client.send(DeveloperServicesListTeamsRequest())
+ print(
+ teams.map {
+ "\($0.name) [\($0.status)]: \($0.id.rawValue)" +
+ $0.memberships.map { "\n- \($0.name) (\($0.platform))" }.joined()
+ }.joined(separator: "\n")
+ )
+ }
+}
diff --git a/Sources/SupersignCLISupport/DevCommand.swift b/Sources/SupersignCLISupport/DevCommands/DevCommand.swift
similarity index 100%
rename from Sources/SupersignCLISupport/DevCommand.swift
rename to Sources/SupersignCLISupport/DevCommands/DevCommand.swift
diff --git a/Sources/SupersignCLISupport/DevNewCommand.swift b/Sources/SupersignCLISupport/DevCommands/DevNewCommand.swift
similarity index 100%
rename from Sources/SupersignCLISupport/DevNewCommand.swift
rename to Sources/SupersignCLISupport/DevCommands/DevNewCommand.swift
diff --git a/Sources/SupersignCLISupport/DevSDKCommand.swift b/Sources/SupersignCLISupport/DevCommands/DevSDKCommand.swift
similarity index 100%
rename from Sources/SupersignCLISupport/DevSDKCommand.swift
rename to Sources/SupersignCLISupport/DevCommands/DevSDKCommand.swift