Modern Apps git

← xtool.git

Default DeviceInfoProvider

Commit
f721741b2308a0bc972bee7e8a4b25cfadeb7dc4
Author
Kabir Oberai <[email protected]>
When
2024-12-30 19:33 UTC (1 year ago)
Parents
23e7b77

Diff

Sources/Supersign/GrandSlam/Anisette/DeviceInfo+Fetching.swift
diff --git a/Sources/Supersign/GrandSlam/Anisette/DeviceInfo+Fetching.swift b/Sources/Supersign/GrandSlam/Anisette/DeviceInfo+Fetching.swiftindex 5c0df5f..ae4288b 100644--- a/Sources/Supersign/GrandSlam/Anisette/DeviceInfo+Fetching.swift+++ b/Sources/Supersign/GrandSlam/Anisette/DeviceInfo+Fetching.swift@@ -83,7 +83,7 @@ extension DeviceInfo {     }  }-#elseif os(Linux) || os(Windows)+#else extension DeviceInfo {     public static func current() -> DeviceInfo? {         return DeviceInfo(@@ -97,5 +97,5 @@ extension DeviceInfo { } #endif -// FIXME: Figure out DeviceInfo.current() on Windows/Linux+// FIXME: Figure out DeviceInfo.current() outside macOS // (see above)
Sources/Supersign/GrandSlam/Anisette/DeviceInfo.swift
diff --git a/Sources/Supersign/GrandSlam/Anisette/DeviceInfo.swift b/Sources/Supersign/GrandSlam/Anisette/DeviceInfo.swiftindex 64a0fc9..f1d46b2 100644--- a/Sources/Supersign/GrandSlam/Anisette/DeviceInfo.swift+++ b/Sources/Supersign/GrandSlam/Anisette/DeviceInfo.swift@@ -92,14 +92,28 @@ public struct DeviceInfo: Codable, Sendable {  } -public struct DeviceInfoProvider: TestDependencyKey, Sendable {+extension DeviceInfo {+    public enum FetchError: Error {+        case couldNotFetch+    }++    fileprivate static func fetch() throws -> Self {+        guard let deviceInfo = DeviceInfo.current() else {+            throw FetchError.couldNotFetch+        }+        return deviceInfo+    }+}++public struct DeviceInfoProvider: DependencyKey, Sendable {     public var fetch: @Sendable () throws -> DeviceInfo      public init(fetch: @escaping @Sendable () throws -> DeviceInfo) {         self.fetch = fetch     } -    public static let testValue = DeviceInfoProvider(fetch: unimplemented())+    private static let current = Result { try DeviceInfo.fetch() }+    public static let liveValue = DeviceInfoProvider { try current.get() } }  extension DependencyValues {
Sources/SupersignCLISupport/AuthCommand.swift
diff --git a/Sources/SupersignCLISupport/AuthCommand.swift b/Sources/SupersignCLISupport/AuthCommand.swiftindex f8ce071..87ad635 100644--- a/Sources/SupersignCLISupport/AuthCommand.swift+++ b/Sources/SupersignCLISupport/AuthCommand.swift@@ -201,17 +201,3 @@ struct AuthCommand: AsyncParsableCommand {         defaultSubcommand: AuthLoginCommand.self     ) }--extension DeviceInfo {-    static func fetch() throws -> Self {-        guard let deviceInfo = DeviceInfo.current() else {-            throw Console.Error("Could not fetch client info.")-        }-        return deviceInfo-    }-}--extension DeviceInfoProvider: DependencyKey {-    private static let current = Result { try DeviceInfo.fetch() }-    public static let liveValue = DeviceInfoProvider { try current.get() }-}