Skip to content

Commit f0548e8

Browse files
committed
Merge branch 'release/0.4.2'
2 parents f7cd8d7 + d98870c commit f0548e8

File tree

10 files changed

+57
-46
lines changed

10 files changed

+57
-46
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
## [0.4.2] - 2023-08-28Z
6+
* [#63](https://github.com/blackjacx/assist/pull/63): Add token subcommand to keys - [@Blackjacx](https://github.com/blackjacx).
7+
* [#61](https://github.com/blackjacx/assist/pull/61): Switch to Swift 5.9 - [@Blackjacx](https://github.com/blackjacx).
8+
59
## [0.4.1] - 2023-08-24Z
610
* Add log to show which tester is processed - [@Blackjacx](https://github.com/blackjacx).
711

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.8
1+
// swift-tools-version:5.9
22
import PackageDescription
33

44
let package = Package(
@@ -17,7 +17,7 @@ let package = Package(
1717
],
1818
dependencies: [
1919
.package(url: "https://github.com/blackjacx/Engine", from: "0.0.3"),
20-
.package(url: "https://github.com/blackjacx/ASCKit", from: "0.2.1"),
20+
.package(url: "https://github.com/blackjacx/ASCKit", from: "0.2.2"),
2121
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
2222
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.1.0"),
2323
.package(url: "https://github.com/kareman/SwiftShell", from: "5.1.0")

Sources/ASC/commands/sub/Keys.swift

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension ASC {
1717

1818
static var configuration = CommandConfiguration(
1919
abstract: "Lists, registers and deletes App Store Connect API keys on your Mac.",
20-
subcommands: [List.self, Activate.self, Register.self, Delete.self],
20+
subcommands: [List.self, Activate.self, Register.self, Delete.self, Token.self],
2121
defaultSubcommand: List.self)
2222
}
2323
}
@@ -28,8 +28,6 @@ extension ASC.Keys {
2828
struct List: ParsableCommand {
2929
static var configuration = CommandConfiguration(abstract: "List locally stored App Store Connect API keys.")
3030

31-
// The `@OptionGroup` attribute includes the flags, options, and arguments defined by another
32-
// `ParsableArguments` type.
3331
@OptionGroup()
3432
var options: Options
3533

@@ -42,16 +40,14 @@ extension ASC.Keys {
4240
struct Activate: ParsableCommand {
4341
static var configuration = CommandConfiguration(abstract: "Makes a registered API key the default one.")
4442

45-
// The `@OptionGroup` attribute includes the flags, options, and arguments defined by another
46-
// `ParsableArguments` type.
4743
@OptionGroup()
4844
var options: Options
4945

5046
@Option(name: .shortAndLong, help: "The key's id.")
51-
var id: String
47+
var keyId: String
5248

5349
func run() throws {
54-
let activatedKey = try ASCService.activateApiKey(id: id)
50+
let activatedKey = try ASCService.activateApiKey(id: keyId)
5551
print(activatedKey)
5652
}
5753
}
@@ -60,13 +56,11 @@ extension ASC.Keys {
6056
struct Register: ParsableCommand {
6157
static var configuration = CommandConfiguration(abstract: "Registers App Store Connect API keys locally.")
6258

63-
// The `@OptionGroup` attribute includes the flags, options, and arguments defined by another
64-
// `ParsableArguments` type.
6559
@OptionGroup()
6660
var options: Options
6761

6862
@Option(name: .shortAndLong, help: "The key's id.")
69-
var id: String
63+
var keyId: String
7064

7165
@Option(name: .shortAndLong, help: "The key's name you. You can choose freely.")
7266
var name: String
@@ -78,7 +72,7 @@ extension ASC.Keys {
7872
var issuerId: String
7973

8074
func run() throws {
81-
let key = ApiKey(id: id, name: name, source: .localFilePath(path: path), issuerId: issuerId)
75+
let key = ApiKey(id: keyId, name: name, source: .localFilePath(path: path), issuerId: issuerId)
8276
let registeredKey = try ASCService.registerApiKey(key: key)
8377
print(registeredKey)
8478
}
@@ -88,17 +82,28 @@ extension ASC.Keys {
8882
struct Delete: ParsableCommand {
8983
static var configuration = CommandConfiguration(abstract: "Delete locally stored App Store Connect API keys.")
9084

91-
// The `@OptionGroup` attribute includes the flags, options, and arguments defined by another
92-
// `ParsableArguments` type.
9385
@OptionGroup()
9486
var options: Options
9587

9688
@Option(name: .shortAndLong, help: "The key's id.")
97-
var id: String
89+
var keyId: String
9890

9991
func run() throws {
100-
let deletedKey = try ASCService.deleteApiKey(id: id)
92+
let deletedKey = try ASCService.deleteApiKey(id: keyId)
10193
print(deletedKey)
10294
}
10395
}
96+
97+
/// Generate a token from a locally stored App Store Connect API keys.
98+
struct Token: ParsableCommand {
99+
static var configuration = CommandConfiguration(abstract: "Generate a token from a locally stored App Store Connect API keys.")
100+
101+
@OptionGroup()
102+
var options: ApiKeyOptions
103+
104+
func run() throws {
105+
let token = try ASCService.createAccessToken(keyId: options.keyId)
106+
print(token)
107+
}
108+
}
104109
}

Sources/Core/Core.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
import Foundation
99

1010
public struct Constants {
11-
public static let version = "0.4.1"
11+
public static let version = "0.4.2"
1212
}

Sources/Core/Logger.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ public extension Logger {
6363

6464
var name: String {
6565
switch self {
66-
case .warn: return "Warn"
67-
case .info: return "Info"
68-
case .error: return "Error"
66+
case .warn: "Warn"
67+
case .info: "Info"
68+
case .error: "Error"
6969
}
7070
}
7171

7272
var emoji: String {
7373
switch self {
74-
case .warn: return "🟡"
75-
case .info: return "🟢"
76-
case .error: return "🔴"
74+
case .warn: "🟡"
75+
case .info: "🟢"
76+
case .error: "🔴"
7777
}
7878
}
7979
}

Sources/Core/Networking/JSONWebToken.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ public struct JSONWebToken {
3232
}
3333

3434
public static func token(for service: Service) async throws -> String {
35-
3635
switch service {
37-
case .apns(let credentials): return try token(credentials: credentials)
38-
case .fcm(let credentials): return try await token(credentials: credentials)
36+
case .apns(let credentials): try token(credentials: credentials)
37+
case .fcm(let credentials): try await token(credentials: credentials)
3938
}
4039
}
4140

Sources/Core/Shell/Xcodebuild.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public struct Xcodebuild {
4646

4747
var name: String {
4848
switch self {
49-
case .buildForTesting: return "build-for-testing"
50-
case .testWithoutBuilding: return "test-without-building"
49+
case .buildForTesting: "build-for-testing"
50+
case .testWithoutBuilding: "test-without-building"
5151
}
5252
}
5353
}

Sources/Push/PushEndpoint.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,35 @@ extension PushEndpoint: Endpoint {
2222

2323
var host: String {
2424
switch self {
25-
case .pushViaApns(_, let endpoint, _, _, _): return endpoint.host
26-
case .pushViaFcm: return "fcm.googleapis.com"
25+
case .pushViaApns(_, let endpoint, _, _, _): endpoint.host
26+
case .pushViaFcm: "fcm.googleapis.com"
2727
}
2828
}
2929

3030
var port: Int? {
3131
switch self {
32-
case .pushViaApns: return 443
33-
case .pushViaFcm: return nil
32+
case .pushViaApns: 443
33+
case .pushViaFcm: nil
3434
}
3535
}
3636

3737
var path: String {
3838
switch self {
39-
case let .pushViaApns(_, _, deviceToken, _, _): return "/3/device/\(deviceToken)"
40-
case let .pushViaFcm(_, _, credentials): return "/v1/projects/\(credentials.projectId)/messages:send"
39+
case let .pushViaApns(_, _, deviceToken, _, _): "/3/device/\(deviceToken)"
40+
case let .pushViaFcm(_, _, credentials): "/v1/projects/\(credentials.projectId)/messages:send"
4141
}
4242
}
4343

4444
var queryItems: [URLQueryItem] {
4545
switch self {
46-
case .pushViaApns: return []
47-
case .pushViaFcm: return []
46+
case .pushViaApns: []
47+
case .pushViaFcm: []
4848
}
4949
}
5050

5151
var method: HTTPMethod {
5252
switch self {
53-
case .pushViaApns, .pushViaFcm:
54-
return .post
53+
case .pushViaApns, .pushViaFcm: .post
5554
}
5655
}
5756

@@ -100,16 +99,20 @@ extension PushEndpoint: Endpoint {
10099
var parameters: [String : Any]? {
101100
switch self {
102101
case let .pushViaApns(_, _, _, _, message):
103-
return ["aps": ["alert": message]]
102+
[
103+
"aps": [
104+
"alert": message
105+
]
106+
]
104107
case let .pushViaFcm(deviceToken, message, _):
105-
return [
108+
[
106109
"message": [
107110
"notification": [
108111
"title": "Hello FCM",
109112
"body": message
110113
],
111114
"token": deviceToken
112-
] as [String: Any]
115+
]
113116
]
114117
}
115118
}

Sources/Push/commands/sub/Apns.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ extension Push {
1919

2020
var host: String {
2121
switch self {
22-
case .sandbox: return "api.sandbox.push.apple.com"
23-
case .production: return "api.push.apple.com"
22+
case .sandbox: "api.sandbox.push.apple.com"
23+
case .production: "api.push.apple.com"
2424
}
2525
}
2626
}

0 commit comments

Comments
 (0)