mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-07 02:07:22 +01:00
Use separate socket for debug builds (#766)
This commit is contained in:
@@ -22,6 +22,9 @@ let package = Package(
|
||||
.library(
|
||||
name: "SecretAgentKit",
|
||||
targets: ["SecretAgentKit", "XPCWrappers"]),
|
||||
.library(
|
||||
name: "Common",
|
||||
targets: ["Common"]),
|
||||
.library(
|
||||
name: "Brief",
|
||||
targets: ["Brief"]),
|
||||
@@ -65,6 +68,12 @@ let package = Package(
|
||||
name: "SecretAgentKitTests",
|
||||
dependencies: ["SecretAgentKit"],
|
||||
),
|
||||
.target(
|
||||
name: "Common",
|
||||
dependencies: [],
|
||||
resources: [localization],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.target(
|
||||
name: "Brief",
|
||||
dependencies: ["XPCWrappers"],
|
||||
|
||||
11
Sources/Packages/Sources/Common/BundleIDs.swift
Normal file
11
Sources/Packages/Sources/Common/BundleIDs.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
import Foundation
|
||||
|
||||
extension Bundle {
|
||||
public static var agentBundleID: String {
|
||||
Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent")
|
||||
}
|
||||
|
||||
public static var hostBundleID: String {
|
||||
Bundle.main.bundleIdentifier!.replacingOccurrences(of: "SecretAgent", with: "Host")
|
||||
}
|
||||
}
|
||||
29
Sources/Packages/Sources/Common/URLs.swift
Normal file
29
Sources/Packages/Sources/Common/URLs.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
import Foundation
|
||||
|
||||
extension URL {
|
||||
|
||||
public static var agentHomeURL: URL {
|
||||
URL(fileURLWithPath: URL.homeDirectory.path().replacingOccurrences(of: Bundle.hostBundleID, with: Bundle.agentBundleID))
|
||||
}
|
||||
|
||||
public static var socketPath: String {
|
||||
#if DEBUG
|
||||
URL.agentHomeURL.appendingPathComponent("socket-debug.ssh").path()
|
||||
#else
|
||||
URL.agentHomeURL.appendingPathComponent("socket.ssh").path()
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension String {
|
||||
|
||||
public var normalizedPathAndFolder: (String, String) {
|
||||
// All foundation-based normalization methods replace this with the container directly.
|
||||
let processedPath = replacingOccurrences(of: "~", with: "/Users/\(NSUserName())")
|
||||
let url = URL(filePath: processedPath)
|
||||
let folder = url.deletingLastPathComponent().path()
|
||||
return (processedPath, folder)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user