diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e451d2..2b30971 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} \ No newline at end of file diff --git a/.spi.yml b/.spi.yml index 7fcbd54..6c990d0 100644 --- a/.spi.yml +++ b/.spi.yml @@ -1,4 +1,4 @@ version: 1 builder: configs: - - documentation_targets: [Passes, Orders] \ No newline at end of file + - documentation_targets: [WalletPasses, WalletOrders] \ No newline at end of file diff --git a/Package.swift b/Package.swift index f93316a..189a496 100644 --- a/Package.swift +++ b/Package.swift @@ -7,17 +7,16 @@ 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"), @@ -25,9 +24,9 @@ let package = Package( swiftSettings: swiftSettings ), .testTarget( - name: "PassesTests", + name: "WalletPassesTests", dependencies: [ - .target(name: "Passes") + .target(name: "WalletPasses") ], resources: [ .copy("SourceFiles") @@ -35,7 +34,7 @@ let package = Package( swiftSettings: swiftSettings ), .target( - name: "Orders", + name: "WalletOrders", dependencies: [ .product(name: "X509", package: "swift-certificates"), .product(name: "Zip", package: "zip"), @@ -43,9 +42,9 @@ let package = Package( swiftSettings: swiftSettings ), .testTarget( - name: "OrdersTests", + name: "WalletOrdersTests", dependencies: [ - .target(name: "Orders") + .target(name: "WalletOrders") ], resources: [ .copy("SourceFiles") diff --git a/README.md b/README.md index 9676ea4..e87a469 100644 --- a/README.md +++ b/README.md @@ -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") ``` diff --git a/Sources/Orders/OrderBuilder.swift b/Sources/WalletOrders/OrderBuilder.swift similarity index 98% rename from Sources/Orders/OrderBuilder.swift rename to Sources/WalletOrders/OrderBuilder.swift index 0ce10bc..28ec859 100644 --- a/Sources/Orders/OrderBuilder.swift +++ b/Sources/WalletOrders/OrderBuilder.swift @@ -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) @@ -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) diff --git a/Sources/Orders/OrderJSON.swift b/Sources/WalletOrders/OrderJSON.swift similarity index 100% rename from Sources/Orders/OrderJSON.swift rename to Sources/WalletOrders/OrderJSON.swift diff --git a/Sources/WalletOrders/WalletOrders.docc/WalletOrders.md b/Sources/WalletOrders/WalletOrders.docc/WalletOrders.md new file mode 100644 index 0000000..72c54d0 --- /dev/null +++ b/Sources/WalletOrders/WalletOrders.docc/WalletOrders.md @@ -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`` diff --git a/Sources/Orders/OrdersError.swift b/Sources/WalletOrders/WalletOrdersError.swift similarity index 82% rename from Sources/Orders/OrdersError.swift rename to Sources/WalletOrders/WalletOrdersError.swift index 2d9639c..a0b3691 100644 --- a/Sources/Orders/OrdersError.swift +++ b/Sources/WalletOrders/WalletOrdersError.swift @@ -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 { @@ -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 } } @@ -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))" } } diff --git a/Sources/Passes/PassBuilder.swift b/Sources/WalletPasses/PassBuilder.swift similarity index 98% rename from Sources/Passes/PassBuilder.swift rename to Sources/WalletPasses/PassBuilder.swift index d02dc54..06bc768 100644 --- a/Sources/Passes/PassBuilder.swift +++ b/Sources/WalletPasses/PassBuilder.swift @@ -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) @@ -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) diff --git a/Sources/Passes/PassJSON.swift b/Sources/WalletPasses/PassJSON.swift similarity index 100% rename from Sources/Passes/PassJSON.swift rename to Sources/WalletPasses/PassJSON.swift diff --git a/Sources/Passes/PersonalizationJSON.swift b/Sources/WalletPasses/PersonalizationJSON.swift similarity index 100% rename from Sources/Passes/PersonalizationJSON.swift rename to Sources/WalletPasses/PersonalizationJSON.swift diff --git a/Sources/WalletPasses/WalletPasses.docc/WalletPasses.md b/Sources/WalletPasses/WalletPasses.docc/WalletPasses.md new file mode 100644 index 0000000..ced06b8 --- /dev/null +++ b/Sources/WalletPasses/WalletPasses.docc/WalletPasses.md @@ -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`` diff --git a/Sources/Passes/PassesError.swift b/Sources/WalletPasses/WalletPassesError.swift similarity index 84% rename from Sources/Passes/PassesError.swift rename to Sources/WalletPasses/WalletPassesError.swift index e1e0f8f..24bed96 100644 --- a/Sources/Passes/PassesError.swift +++ b/Sources/WalletPasses/WalletPassesError.swift @@ -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 { @@ -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 } } @@ -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))" } } diff --git a/Tests/OrdersTests/SourceFiles/EmptyDir/.gitkeep b/Tests/WalletOrdersTests/SourceFiles/EmptyDir/.gitkeep similarity index 100% rename from Tests/OrdersTests/SourceFiles/EmptyDir/.gitkeep rename to Tests/WalletOrdersTests/SourceFiles/EmptyDir/.gitkeep diff --git a/Tests/OrdersTests/SourceFiles/icon.png b/Tests/WalletOrdersTests/SourceFiles/icon.png similarity index 100% rename from Tests/OrdersTests/SourceFiles/icon.png rename to Tests/WalletOrdersTests/SourceFiles/icon.png diff --git a/Tests/OrdersTests/SourceFiles/it-IT.lproj/pet_store_logo.png b/Tests/WalletOrdersTests/SourceFiles/it-IT.lproj/pet_store_logo.png similarity index 100% rename from Tests/OrdersTests/SourceFiles/it-IT.lproj/pet_store_logo.png rename to Tests/WalletOrdersTests/SourceFiles/it-IT.lproj/pet_store_logo.png diff --git a/Tests/OrdersTests/SourceFiles/pet_store_logo.png b/Tests/WalletOrdersTests/SourceFiles/pet_store_logo.png similarity index 100% rename from Tests/OrdersTests/SourceFiles/pet_store_logo.png rename to Tests/WalletOrdersTests/SourceFiles/pet_store_logo.png diff --git a/Tests/OrdersTests/TestCertificate.swift b/Tests/WalletOrdersTests/TestCertificate.swift similarity index 100% rename from Tests/OrdersTests/TestCertificate.swift rename to Tests/WalletOrdersTests/TestCertificate.swift diff --git a/Tests/OrdersTests/TestOrder.swift b/Tests/WalletOrdersTests/TestOrder.swift similarity index 97% rename from Tests/OrdersTests/TestOrder.swift rename to Tests/WalletOrdersTests/TestOrder.swift index 107be17..54e2478 100644 --- a/Tests/OrdersTests/TestOrder.swift +++ b/Tests/WalletOrdersTests/TestOrder.swift @@ -1,5 +1,5 @@ import Foundation -import Orders +import WalletOrders struct TestOrder: OrderJSON.Properties { var schemaVersion = OrderJSON.SchemaVersion.v1 diff --git a/Tests/OrdersTests/OrdersTests.swift b/Tests/WalletOrdersTests/WalletOrdersTests.swift similarity index 83% rename from Tests/OrdersTests/OrdersTests.swift rename to Tests/WalletOrdersTests/WalletOrdersTests.swift index 604f919..8ac43e2 100644 --- a/Tests/OrdersTests/OrdersTests.swift +++ b/Tests/WalletOrdersTests/WalletOrdersTests.swift @@ -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( @@ -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) @@ -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) @@ -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" ) } } @@ -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" ) } } diff --git a/Tests/PassesTests/SourceFiles/EmptyDir/.gitkeep b/Tests/WalletPassesTests/SourceFiles/EmptyDir/.gitkeep similarity index 100% rename from Tests/PassesTests/SourceFiles/EmptyDir/.gitkeep rename to Tests/WalletPassesTests/SourceFiles/EmptyDir/.gitkeep diff --git a/Tests/PassesTests/SourceFiles/icon.png b/Tests/WalletPassesTests/SourceFiles/icon.png similarity index 100% rename from Tests/PassesTests/SourceFiles/icon.png rename to Tests/WalletPassesTests/SourceFiles/icon.png diff --git a/Tests/PassesTests/SourceFiles/it-IT.lproj/logo.png b/Tests/WalletPassesTests/SourceFiles/it-IT.lproj/logo.png similarity index 100% rename from Tests/PassesTests/SourceFiles/it-IT.lproj/logo.png rename to Tests/WalletPassesTests/SourceFiles/it-IT.lproj/logo.png diff --git a/Tests/PassesTests/SourceFiles/it-IT.lproj/personalizationLogo.png b/Tests/WalletPassesTests/SourceFiles/it-IT.lproj/personalizationLogo.png similarity index 100% rename from Tests/PassesTests/SourceFiles/it-IT.lproj/personalizationLogo.png rename to Tests/WalletPassesTests/SourceFiles/it-IT.lproj/personalizationLogo.png diff --git a/Tests/PassesTests/SourceFiles/logo.png b/Tests/WalletPassesTests/SourceFiles/logo.png similarity index 100% rename from Tests/PassesTests/SourceFiles/logo.png rename to Tests/WalletPassesTests/SourceFiles/logo.png diff --git a/Tests/PassesTests/SourceFiles/personalizationLogo.png b/Tests/WalletPassesTests/SourceFiles/personalizationLogo.png similarity index 100% rename from Tests/PassesTests/SourceFiles/personalizationLogo.png rename to Tests/WalletPassesTests/SourceFiles/personalizationLogo.png diff --git a/Tests/PassesTests/TestCertificate.swift b/Tests/WalletPassesTests/TestCertificate.swift similarity index 100% rename from Tests/PassesTests/TestCertificate.swift rename to Tests/WalletPassesTests/TestCertificate.swift diff --git a/Tests/PassesTests/TestPass.swift b/Tests/WalletPassesTests/TestPass.swift similarity index 98% rename from Tests/PassesTests/TestPass.swift rename to Tests/WalletPassesTests/TestPass.swift index fe241c0..19c179b 100644 --- a/Tests/PassesTests/TestPass.swift +++ b/Tests/WalletPassesTests/TestPass.swift @@ -1,5 +1,5 @@ import Foundation -import Passes +import WalletPasses struct TestPass: PassJSON.Properties { var description = "Test Pass" diff --git a/Tests/PassesTests/PassesTests.swift b/Tests/WalletPassesTests/WalletPassesTests.swift similarity index 85% rename from Tests/PassesTests/PassesTests.swift rename to Tests/WalletPassesTests/WalletPassesTests.swift index 6876c4a..0fab8b6 100644 --- a/Tests/PassesTests/PassesTests.swift +++ b/Tests/WalletPassesTests/WalletPassesTests.swift @@ -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( @@ -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) @@ -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) @@ -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 ) @@ -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" ) } } @@ -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" ) } }