Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ jobs:
- name: Build DHModels
run: swift build --target DHModels

- name: Build DHKit
run: swift build --target DHKit

- name: Build validate-dhpack
run: swift build --target validate-dhpack

- name: Test DHModels
run: swift test --filter DHModelsTests

- name: Test DHKit
run: swift test --filter DHKitTests

swift-format:
name: swift-format lint
runs-on: ubuntu-latest
Expand Down
52 changes: 24 additions & 28 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@ let sharedSettings: [SwiftSetting] = [
.enableUpcomingFeature("MemberImportVisibility"),
]

var products: [Product] = [
let products: [Product] = [
.library(name: "DHModels", targets: ["DHModels"]),
.library(name: "DHKit", targets: ["DHKit"]),
.executable(name: "validate-dhpack", targets: ["validate-dhpack"]),
]

var targets: [Target] = [
let targets: [Target] = [
// Pure Codable value types — no Apple-only imports, compiles on Linux.
.target(
name: "DHModels",
swiftSettings: sharedSettings
),

// Observable stores + SRD bundle resources.
.target(
name: "DHKit",
dependencies: [
"DHModels",
.product(name: "Logging", package: "swift-log"),
],
resources: [
.copy("Resources/adversaries.json"),
.copy("Resources/environments.json"),
],
swiftSettings: sharedSettings + [.defaultIsolation(MainActor.self)]
),

// CLI tool for validating .dhpack files — depends only on DHModels.
.executableTarget(
name: "validate-dhpack",
Expand All @@ -36,33 +51,14 @@ var targets: [Target] = [
resources: [.copy("Fixtures")],
swiftSettings: sharedSettings
),
]

#if canImport(Darwin)
products.append(.library(name: "DHKit", targets: ["DHKit"]))
targets += [
// Observable stores + SRD bundle resources — Apple platforms only.
.target(
name: "DHKit",
dependencies: [
"DHModels",
.product(name: "Logging", package: "swift-log"),
],
resources: [
.copy("Resources/adversaries.json"),
.copy("Resources/environments.json"),
],
swiftSettings: sharedSettings + [.defaultIsolation(MainActor.self)]
),

// Tests for DHKit — Apple platforms only.
.testTarget(
name: "DHKitTests",
dependencies: ["DHKit"],
swiftSettings: sharedSettings + [.defaultIsolation(MainActor.self)]
),
]
#endif
// Tests for DHKit.
.testTarget(
name: "DHKitTests",
dependencies: ["DHKit"],
swiftSettings: sharedSettings + [.defaultIsolation(MainActor.self)]
),
]

let package = Package(
name: "DHModels",
Expand Down
6 changes: 3 additions & 3 deletions Sources/DHKit/Compendium.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ public final class Compendium {
}

/// Return all adversaries of a given role.
public func adversaries(ofType role: AdversaryType) -> [Adversary] {
public func adversaries(ofRole role: AdversaryType) -> [Adversary] {
adversaries.filter { $0.role == role }
}

/// Full-text search across adversary names and descriptions.
/// Uses `localizedStandardContains` for diacritic- and case-insensitive matching.
public func searchAdversaries(query: String) -> [Adversary] {
public func adversaries(matching query: String) -> [Adversary] {
guard !query.isEmpty else { return adversaries }
return adversaries.filter {
$0.name.localizedStandardContains(query) || $0.flavorText.localizedStandardContains(query)
Expand Down Expand Up @@ -336,7 +336,7 @@ public final class Compendium {

// MARK: - Private Helpers

nonisolated private static func decodeArray<T: Decodable>(
@concurrent nonisolated private static func decodeArray<T: Decodable>(
_ type: T.Type, fromResource name: String, bundle: Bundle
) async throws -> [T] {
guard let url = bundle.url(forResource: name, withExtension: "json") else {
Expand Down
Loading
Loading