Skip to content

Commit

Permalink
Add activity indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
finnvoor committed Dec 21, 2023
1 parent 613a814 commit 4a935dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Finnvoor/SwiftTUI.git",
"state" : {
"revision" : "0076c2ab58d5478a3c6cb11faa9068c92e8371ac",
"version" : "1.0.1"
"revision" : "226ef40ab1c9199b0d2f0a35a20d75debd4a7d9a",
"version" : "1.0.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
.package(url: "https://github.com/AvdLee/appstoreconnect-swift-sdk.git", from: "3.0.1"),
.package(url: "https://github.com/Finnvoor/SwiftTUI.git", from: "1.0.1")
.package(url: "https://github.com/Finnvoor/SwiftTUI.git", from: "1.0.2")
],
targets: [
.executableTarget(
Expand Down
12 changes: 10 additions & 2 deletions Sources/xcc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import SwiftTUI
)
let provider = APIProvider(configuration: configuration)

ActivityIndicator.start()
let bundleIDs = try await provider.request(
APIEndpoint.v1.bundleIDs.get(parameters: .init(fieldsBundleIDs: [.identifier], limit: 200))
).data
Expand All @@ -56,6 +57,7 @@ import SwiftTUI
include: [.bundleID]
))
).data
ActivityIndicator.stop()

// Some products have the internal ASC bundleID ID
// instead of the identifier for some reason
Expand All @@ -76,9 +78,11 @@ import SwiftTUI
throw Error.couldNotFindProduct(availableProducts: products)
}

ActivityIndicator.start()
let workflows = try await provider.request(
APIEndpoint.v1.ciProducts.id(selectedProduct.id).workflows.get()
).data
ActivityIndicator.stop()

let selectedWorkflow = if let workflow {
workflows.first(where: { $0.attributes?.name == workflow })
Expand All @@ -89,13 +93,15 @@ import SwiftTUI
throw Error.couldNotFindWorkflow(availableWorkflows: workflows)
}

ActivityIndicator.start()
let repository = try await provider.request(
APIEndpoint.v1.ciWorkflows.id(selectedWorkflow.id).repository.get()
).data

let gitReferences = try await provider.request(
APIEndpoint.v1.scmRepositories.id(repository.id).gitReferences.get()
).data
ActivityIndicator.stop()

let selectedGitReference = if let reference {
gitReferences.first(where: { $0.attributes?.name == reference })
Expand All @@ -105,8 +111,9 @@ import SwiftTUI
guard let selectedGitReference else {
throw Error.couldNotFindReference(availableReferences: gitReferences)
}

_ = try? await provider.request(APIEndpoint.v1.ciBuildRuns.post(.init(

ActivityIndicator.start()
_ = try await provider.request(APIEndpoint.v1.ciBuildRuns.post(.init(
data: .init(
type: .ciBuildRuns,
relationships: .init(
Expand All @@ -121,6 +128,7 @@ import SwiftTUI
)
)
))).data
ActivityIndicator.stop()

print("".brightGreen.bold + "Build started")
}
Expand Down

0 comments on commit 4a935dc

Please sign in to comment.