Add asc-client v0.1.0
Swift CLI for the App Store Connect API. Commands for managing apps, versions, localizations, screenshots/previews, builds, and review submission. Includes interactive credential setup and media upload with retry support for stuck processing items.
This commit is contained in:
54
Sources/asc-client/Commands/BuildsCommand.swift
Normal file
54
Sources/asc-client/Commands/BuildsCommand.swift
Normal file
@@ -0,0 +1,54 @@
|
||||
import AppStoreAPI
|
||||
import AppStoreConnect
|
||||
import ArgumentParser
|
||||
import Foundation
|
||||
|
||||
struct BuildsCommand: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: "builds",
|
||||
abstract: "Manage builds.",
|
||||
subcommands: [List.self]
|
||||
)
|
||||
|
||||
struct List: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration(
|
||||
abstract: "List builds."
|
||||
)
|
||||
|
||||
@Option(name: .long, help: "Filter by bundle identifier.")
|
||||
var bundleID: String?
|
||||
|
||||
func run() async throws {
|
||||
let client = try ClientFactory.makeClient()
|
||||
|
||||
var filterApp: [String]?
|
||||
if let bundleID {
|
||||
let app = try await findApp(bundleID: bundleID, client: client)
|
||||
filterApp = [app.id]
|
||||
}
|
||||
|
||||
var allBuilds: [(String, String, String)] = []
|
||||
|
||||
let request = Resources.v1.builds.get(
|
||||
filterApp: filterApp,
|
||||
sort: [.minusUploadedDate]
|
||||
)
|
||||
|
||||
for try await page in client.pages(request) {
|
||||
for build in page.data {
|
||||
let version = build.attributes?.version ?? "—"
|
||||
let state = build.attributes?.processingState
|
||||
.map { "\($0)" } ?? "—"
|
||||
let uploaded = build.attributes?.uploadedDate
|
||||
.map { formatDate($0) } ?? "—"
|
||||
allBuilds.append((version, state, uploaded))
|
||||
}
|
||||
}
|
||||
|
||||
Table.print(
|
||||
headers: ["Version", "State", "Uploaded"],
|
||||
rows: allBuilds.map { [$0.0, $0.1, $0.2] }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user