Skip to content

Commit

Permalink
Merge branch 'release/0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackjacx committed Aug 28, 2023
2 parents f7cd8d7 + d98870c commit f0548e8
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

## [0.4.2] - 2023-08-28Z
* [#63](https://github.com/blackjacx/assist/pull/63): Add token subcommand to keys - [@Blackjacx](https://github.com/blackjacx).
* [#61](https://github.com/blackjacx/assist/pull/61): Switch to Swift 5.9 - [@Blackjacx](https://github.com/blackjacx).

## [0.4.1] - 2023-08-24Z
* Add log to show which tester is processed - [@Blackjacx](https://github.com/blackjacx).

Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/blackjacx/ASCKit",
"state" : {
"revision" : "bf8165371166baf312ee202361df4e25c4c0bce2",
"version" : "0.2.1"
"revision" : "66450c6527d737a2bd26be11c19d6b951e221ad1",
"version" : "0.2.2"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand All @@ -17,7 +17,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/blackjacx/Engine", from: "0.0.3"),
.package(url: "https://github.com/blackjacx/ASCKit", from: "0.2.1"),
.package(url: "https://github.com/blackjacx/ASCKit", from: "0.2.2"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.1.0"),
.package(url: "https://github.com/kareman/SwiftShell", from: "5.1.0")
Expand Down
35 changes: 20 additions & 15 deletions Sources/ASC/commands/sub/Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension ASC {

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

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

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

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

@Option(name: .shortAndLong, help: "The key's id.")
var id: String
var keyId: String

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

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

@Option(name: .shortAndLong, help: "The key's id.")
var id: String
var keyId: String

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

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

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

@Option(name: .shortAndLong, help: "The key's id.")
var id: String
var keyId: String

func run() throws {
let deletedKey = try ASCService.deleteApiKey(id: id)
let deletedKey = try ASCService.deleteApiKey(id: keyId)
print(deletedKey)
}
}

/// Generate a token from a locally stored App Store Connect API keys.
struct Token: ParsableCommand {
static var configuration = CommandConfiguration(abstract: "Generate a token from a locally stored App Store Connect API keys.")

@OptionGroup()
var options: ApiKeyOptions

func run() throws {
let token = try ASCService.createAccessToken(keyId: options.keyId)
print(token)
}
}
}
2 changes: 1 addition & 1 deletion Sources/Core/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

public struct Constants {
public static let version = "0.4.1"
public static let version = "0.4.2"
}
12 changes: 6 additions & 6 deletions Sources/Core/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public extension Logger {

var name: String {
switch self {
case .warn: return "Warn"
case .info: return "Info"
case .error: return "Error"
case .warn: "Warn"
case .info: "Info"
case .error: "Error"
}
}

var emoji: String {
switch self {
case .warn: return "🟡"
case .info: return "🟢"
case .error: return "🔴"
case .warn: "🟡"
case .info: "🟢"
case .error: "🔴"
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions Sources/Core/Networking/JSONWebToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ public struct JSONWebToken {
}

public static func token(for service: Service) async throws -> String {

switch service {
case .apns(let credentials): return try token(credentials: credentials)
case .fcm(let credentials): return try await token(credentials: credentials)
case .apns(let credentials): try token(credentials: credentials)
case .fcm(let credentials): try await token(credentials: credentials)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Core/Shell/Xcodebuild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public struct Xcodebuild {

var name: String {
switch self {
case .buildForTesting: return "build-for-testing"
case .testWithoutBuilding: return "test-without-building"
case .buildForTesting: "build-for-testing"
case .testWithoutBuilding: "test-without-building"
}
}
}
Expand Down
29 changes: 16 additions & 13 deletions Sources/Push/PushEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,35 @@ extension PushEndpoint: Endpoint {

var host: String {
switch self {
case .pushViaApns(_, let endpoint, _, _, _): return endpoint.host
case .pushViaFcm: return "fcm.googleapis.com"
case .pushViaApns(_, let endpoint, _, _, _): endpoint.host
case .pushViaFcm: "fcm.googleapis.com"
}
}

var port: Int? {
switch self {
case .pushViaApns: return 443
case .pushViaFcm: return nil
case .pushViaApns: 443
case .pushViaFcm: nil
}
}

var path: String {
switch self {
case let .pushViaApns(_, _, deviceToken, _, _): return "/3/device/\(deviceToken)"
case let .pushViaFcm(_, _, credentials): return "/v1/projects/\(credentials.projectId)/messages:send"
case let .pushViaApns(_, _, deviceToken, _, _): "/3/device/\(deviceToken)"
case let .pushViaFcm(_, _, credentials): "/v1/projects/\(credentials.projectId)/messages:send"
}
}

var queryItems: [URLQueryItem] {
switch self {
case .pushViaApns: return []
case .pushViaFcm: return []
case .pushViaApns: []
case .pushViaFcm: []
}
}

var method: HTTPMethod {
switch self {
case .pushViaApns, .pushViaFcm:
return .post
case .pushViaApns, .pushViaFcm: .post
}
}

Expand Down Expand Up @@ -100,16 +99,20 @@ extension PushEndpoint: Endpoint {
var parameters: [String : Any]? {
switch self {
case let .pushViaApns(_, _, _, _, message):
return ["aps": ["alert": message]]
[
"aps": [
"alert": message
]
]
case let .pushViaFcm(deviceToken, message, _):
return [
[
"message": [
"notification": [
"title": "Hello FCM",
"body": message
],
"token": deviceToken
] as [String: Any]
]
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Push/commands/sub/Apns.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ extension Push {

var host: String {
switch self {
case .sandbox: return "api.sandbox.push.apple.com"
case .production: return "api.push.apple.com"
case .sandbox: "api.sandbox.push.apple.com"
case .production: "api.push.apple.com"
}
}
}
Expand Down

0 comments on commit f0548e8

Please sign in to comment.