Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

KeyValueStorage tweaks

Kabir Oberai23e7b770802b
diff --git a/Sources/Supersign/Utilities/KeyValueStorage.swift b/Sources/Supersign/Utilities/KeyValueStorage.swift
index 6d20fa5..b268088 100644
--- a/Sources/Supersign/Utilities/KeyValueStorage.swift
+++ b/Sources/Supersign/Utilities/KeyValueStorage.swift
@@ -22,8 +22,8 @@ public protocol KeyValueStorage: Sendable {
func setString(_ string: String?, forKey key: String) throws
}
-public enum KeyValueStorageDependencyKey: TestDependencyKey {
- public static let testValue: KeyValueStorage = UnimplementedKeyValueStorage()
+public enum KeyValueStorageDependencyKey: DependencyKey {
+ public static let liveValue: KeyValueStorage = DirectoryStorage()
}
extension DependencyValues {
@@ -56,16 +56,6 @@ extension KeyValueStorage {
}
}
-private struct UnimplementedKeyValueStorage: KeyValueStorage {
- func data(forKey key: String) throws -> Data? {
- unimplemented(placeholder: nil)
- }
-
- func setData(_ data: Data?, forKey key: String) throws {
- unimplemented()
- }
-}
-
public final class MemoryKeyValueStorage: KeyValueStorage {
private let dict = LockIsolated<[String: Data]>([:])
diff --git a/Sources/SupersignCLI/SupersignCLI.swift b/Sources/SupersignCLI/SupersignCLI.swift
index 3475bf0..df3234f 100644
--- a/Sources/SupersignCLI/SupersignCLI.swift
+++ b/Sources/SupersignCLI/SupersignCLI.swift
@@ -5,22 +5,16 @@ import Dependencies
@main enum SupersignCLIMain {
static func main() async throws {
+ prepareDependencies { dependencies in
+ #warning("Improve persistence mechanism")
+ // for macOS, we can use KeychainStorage but we need to sign with entitlements.
+ // for Windows, we could use dpapi.h or wincred.h.
+ // for Linux, maybe use libsecret?
+ // see https://github.com/atom/node-keytar
+// #if os(macOS)
+// dependencies.keyValueStorage = KeychainStorage(service: "com.kabiroberai.Supercharge-Keychain.credentials")
+// #endif
+ }
try await SupersignCLI.run()
}
}
-
-#warning("Improve persistence mechanism")
-
-// for macOS, we can use KeychainStorage but we need to sign with entitlements.
-// for Windows, we could use dpapi.h or wincred.h.
-// for Linux, maybe use libsecret?
-// see https://github.com/atom/node-keytar
-extension KeyValueStorageDependencyKey: DependencyKey {
- public static let liveValue: KeyValueStorage = {
-// #if os(macOS)
-// KeychainStorage(service: "com.kabiroberai.Supercharge-Keychain.credentials")
-// #else
- DirectoryStorage()
-// #endif
- }()
-}