Skip to content

Commit

Permalink
Change module names and add DocC catalogs (#1)
Browse files Browse the repository at this point in the history
* Change module names and add DocC catalog
  • Loading branch information
fpseverino authored Dec 25, 2024
1 parent 991ba4a commit d0b0b4d
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ jobs:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
with:
with_linting: true
with_musl: true
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [Passes, Orders]
- documentation_targets: [WalletPasses, WalletOrders]
17 changes: 8 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,44 @@ let package = Package(
.macOS(.v11)
],
products: [
.library(name: "Passes", targets: ["Passes"]),
.library(name: "Orders", targets: ["Orders"]),
.library(name: "WalletPasses", targets: ["WalletPasses"]),
.library(name: "WalletOrders", targets: ["WalletOrders"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-certificates.git", from: "1.6.1"),
.package(url: "https://github.com/vapor-community/Zip.git", from: "2.2.4"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
.target(
name: "Passes",
name: "WalletPasses",
dependencies: [
.product(name: "X509", package: "swift-certificates"),
.product(name: "Zip", package: "zip"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "PassesTests",
name: "WalletPassesTests",
dependencies: [
.target(name: "Passes")
.target(name: "WalletPasses")
],
resources: [
.copy("SourceFiles")
],
swiftSettings: swiftSettings
),
.target(
name: "Orders",
name: "WalletOrders",
dependencies: [
.product(name: "X509", package: "swift-certificates"),
.product(name: "Zip", package: "zip"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "OrdersTests",
name: "WalletOrdersTests",
dependencies: [
.target(name: "Orders")
.target(name: "WalletOrders")
],
resources: [
.copy("SourceFiles")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Use the SPM string to easily include the dependendency in your `Package.swift` f
and add the product you want to use to your target's dependencies:

```swift
.product(name: "Passes", package: "swift-wallet")
.product(name: "WalletPasses", package: "swift-wallet")
```

```swift
.product(name: "Orders", package: "swift-wallet")
.product(name: "WalletOrders", package: "swift-wallet")
```
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct OrderBuilder: Sendable {
// Swift Crypto doesn't support encrypted PEM private keys, so we have to use OpenSSL for that.
if let pemPrivateKeyPassword {
guard FileManager.default.fileExists(atPath: self.openSSLURL.path) else {
throw OrdersError.noOpenSSLExecutable
throw WalletOrdersError.noOpenSSLExecutable
}

let dir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
Expand Down Expand Up @@ -115,7 +115,7 @@ public struct OrderBuilder: Sendable {
guard
(try? filesDirectory.resourceValues(forKeys: [.isDirectoryKey]).isDirectory) ?? false
else {
throw OrdersError.noSourceFiles
throw WalletOrdersError.noSourceFiles
}

let tempDir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions Sources/WalletOrders/WalletOrders.docc/WalletOrders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ``WalletOrders``

Create orders for the Apple Wallet app.

## Overview

This package provides tools to create orders for the Apple Wallet app.

## Topics

### Essentials

- ``OrderBuilder``
- ``OrderJSON``

### Errors

- ``WalletOrdersError``
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Errors that can be thrown by Apple Wallet orders.
public struct OrdersError: Error, Sendable, Equatable {
public struct WalletOrdersError: Error, Sendable, Equatable {
/// The type of the errors that can be thrown by Apple Wallet orders.
public struct ErrorType: Sendable, Hashable, CustomStringConvertible, Equatable {
enum Base: String, Sendable, Equatable {
Expand Down Expand Up @@ -31,7 +31,7 @@ public struct OrdersError: Error, Sendable, Equatable {
self.errorType = errorType
}

static func == (lhs: OrdersError.Backing, rhs: OrdersError.Backing) -> Bool {
static func == (lhs: WalletOrdersError.Backing, rhs: WalletOrdersError.Backing) -> Bool {
lhs.errorType == rhs.errorType
}
}
Expand All @@ -51,14 +51,14 @@ public struct OrdersError: Error, Sendable, Equatable {
/// The `openssl` executable is missing.
public static let noOpenSSLExecutable = Self(errorType: .noOpenSSLExecutable)

public static func == (lhs: OrdersError, rhs: OrdersError) -> Bool {
public static func == (lhs: WalletOrdersError, rhs: WalletOrdersError) -> Bool {
lhs.backing == rhs.backing
}
}

extension OrdersError: CustomStringConvertible {
extension WalletOrdersError: CustomStringConvertible {
/// A textual representation of this error.
public var description: String {
"OrdersError(errorType: \(self.errorType))"
"WalletOrdersError(errorType: \(self.errorType))"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public struct PassBuilder: Sendable {
// Swift Crypto doesn't support encrypted PEM private keys, so we have to use OpenSSL for that.
if let pemPrivateKeyPassword {
guard FileManager.default.fileExists(atPath: self.openSSLURL.path) else {
throw PassesError.noOpenSSLExecutable
throw WalletPassesError.noOpenSSLExecutable
}

let dir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
Expand Down Expand Up @@ -122,7 +122,7 @@ public struct PassBuilder: Sendable {
guard
(try? filesDirectory.resourceValues(forKeys: [.isDirectoryKey]).isDirectory) ?? false
else {
throw PassesError.noSourceFiles
throw WalletPassesError.noSourceFiles
}

let tempDir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions Sources/WalletPasses/WalletPasses.docc/WalletPasses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ``WalletPasses``

Create passes for the Apple Wallet app.

## Overview

This package provides tools to create passes for the Apple Wallet app.

## Topics

### Essentials

- ``PassBuilder``
- ``PassJSON``

### Personalized Passes

- ``PersonalizationJSON``

### Errors

- ``WalletPassesError``
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Errors that can be thrown by Apple Wallet passes.
public struct PassesError: Error, Sendable, Equatable {
public struct WalletPassesError: Error, Sendable, Equatable {
/// The type of the errors that can be thrown by Apple Wallet passes.
public struct ErrorType: Sendable, Hashable, CustomStringConvertible, Equatable {
enum Base: String, Sendable, Equatable {
Expand Down Expand Up @@ -34,7 +34,7 @@ public struct PassesError: Error, Sendable, Equatable {
self.errorType = errorType
}

static func == (lhs: PassesError.Backing, rhs: PassesError.Backing) -> Bool {
static func == (lhs: WalletPassesError.Backing, rhs: WalletPassesError.Backing) -> Bool {
lhs.errorType == rhs.errorType
}
}
Expand All @@ -57,14 +57,14 @@ public struct PassesError: Error, Sendable, Equatable {
/// The number of passes to bundle is invalid.
public static let invalidNumberOfPasses = Self(errorType: .invalidNumberOfPasses)

public static func == (lhs: PassesError, rhs: PassesError) -> Bool {
public static func == (lhs: WalletPassesError, rhs: WalletPassesError) -> Bool {
lhs.backing == rhs.backing
}
}

extension PassesError: CustomStringConvertible {
extension WalletPassesError: CustomStringConvertible {
/// A textual representation of this error.
public var description: String {
"PassesError(errorType: \(self.errorType))"
"WalletPassesError(errorType: \(self.errorType))"
}
}
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import Orders
import WalletOrders

struct TestOrder: OrderJSON.Properties {
var schemaVersion = OrderJSON.SchemaVersion.v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Foundation
import Testing
import WalletOrders

@testable import Orders

@Suite("Orders Tests")
struct OrdersTests {
@Suite("WalletOrders Tests")
struct WalletOrdersTests {
@Test("Build Order")
func build() throws {
let builder = OrderBuilder(
Expand All @@ -15,7 +14,7 @@ struct OrdersTests {

let bundle = try builder.build(
order: TestOrder(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/OrdersTests/SourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletOrdersTests/SourceFiles"
)

#expect(bundle != nil)
Expand All @@ -32,7 +31,7 @@ struct OrdersTests {

let bundle = try builder.build(
order: TestOrder(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/OrdersTests/SourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletOrdersTests/SourceFiles"
)

#expect(bundle != nil)
Expand All @@ -46,10 +45,10 @@ struct OrdersTests {
pemPrivateKey: TestCertificate.pemPrivateKey
)

#expect(throws: OrdersError.noSourceFiles) {
#expect(throws: WalletOrdersError.noSourceFiles) {
try builder.build(
order: TestOrder(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/OrdersTests/NoSourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletOrdersTests/NoSourceFiles"
)
}
}
Expand All @@ -64,10 +63,10 @@ struct OrdersTests {
openSSLPath: "/usr/bin/no-openssl"
)

#expect(throws: OrdersError.noOpenSSLExecutable) {
#expect(throws: WalletOrdersError.noOpenSSLExecutable) {
try builder.build(
order: TestOrder(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/OrdersTests/SourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletOrdersTests/SourceFiles"
)
}
}
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import Passes
import WalletPasses

struct TestPass: PassJSON.Properties {
var description = "Test Pass"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Foundation
import Testing
import WalletPasses

@testable import Passes

@Suite("Passes Tests")
struct PassesTests {
@Suite("WalletPasses Tests")
struct WalletPassesTests {
@Test("Build Pass")
func build() throws {
let builder = PassBuilder(
Expand All @@ -15,7 +14,7 @@ struct PassesTests {

let bundle = try builder.build(
pass: TestPass(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/PassesTests/SourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletPassesTests/SourceFiles"
)

#expect(bundle != nil)
Expand All @@ -32,7 +31,7 @@ struct PassesTests {

let bundle = try builder.build(
pass: TestPass(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/PassesTests/SourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletPassesTests/SourceFiles"
)

#expect(bundle != nil)
Expand All @@ -56,7 +55,7 @@ struct PassesTests {

let bundle = try builder.build(
pass: TestPass(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/PassesTests/SourceFiles",
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletPassesTests/SourceFiles",
personalization: testPersonalization
)

Expand All @@ -71,10 +70,10 @@ struct PassesTests {
pemPrivateKey: TestCertificate.pemPrivateKey
)

#expect(throws: PassesError.noSourceFiles) {
#expect(throws: WalletPassesError.noSourceFiles) {
try builder.build(
pass: TestPass(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/PassesTests/NoSourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletPassesTests/NoSourceFiles"
)
}
}
Expand All @@ -89,10 +88,10 @@ struct PassesTests {
openSSLPath: "/usr/bin/no-openssl"
)

#expect(throws: PassesError.noOpenSSLExecutable) {
#expect(throws: WalletPassesError.noOpenSSLExecutable) {
try builder.build(
pass: TestPass(),
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/PassesTests/SourceFiles"
sourceFilesDirectoryPath: "\(FileManager.default.currentDirectoryPath)/Tests/WalletPassesTests/SourceFiles"
)
}
}
Expand Down

0 comments on commit d0b0b4d

Please sign in to comment.