diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a50989..8b50a49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,5 +7,5 @@ jobs: - uses: actions/checkout@v4 - name: Run tests env: - DEVELOPER_DIR: /Applications/Xcode_13.4.1.app + DEVELOPER_DIR: /Applications/Xcode_14.2.app run: swift test diff --git a/Package.resolved b/Package.resolved index 01d83c2..d45c26c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -40,8 +40,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mxcl/Path.swift.git", "state" : { - "revision" : "dac007e907a4f4c565cfdc55a9ce148a761a11d5", - "version" : "0.16.3" + "revision" : "8e355c28e9393c42e58b18c54cace2c42c98a616", + "version" : "1.4.1" } }, { diff --git a/Package.swift b/Package.swift index 0f6c442..1734c72 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.6 +// swift-tools-version:5.7 import PackageDescription let package = Package( @@ -13,7 +13,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.1.4")), - .package(url: "https://github.com/mxcl/Path.swift.git", .upToNextMinor(from: "0.16.0")), + .package(url: "https://github.com/mxcl/Path.swift.git", .upToNextMinor(from: "1.4.1")), .package(url: "https://github.com/mxcl/Version.git", .upToNextMinor(from: "1.0.3")), .package(url: "https://github.com/mxcl/PromiseKit.git", .upToNextMinor(from: "6.22.1")), .package(url: "https://github.com/PromiseKit/Foundation.git", .upToNextMinor(from: "3.4.0")), diff --git a/Sources/XcodesKit/Entry+.swift b/Sources/XcodesKit/Entry+.swift index bdf85f7..ee7c256 100644 --- a/Sources/XcodesKit/Entry+.swift +++ b/Sources/XcodesKit/Entry+.swift @@ -1,15 +1,15 @@ import Foundation import Path -extension Entry { +extension Path { var isAppBundle: Bool { - kind == .directory && - path.extension == "app" && - !path.isSymlink + type == .directory && + `extension` == "app" && + !isSymlink } var infoPlist: InfoPlist? { - let infoPlistPath = path.join("Contents").join("Info.plist") + let infoPlistPath = join("Contents").join("Info.plist") guard let infoPlistData = try? Data(contentsOf: infoPlistPath.url), let infoPlist = try? PropertyListDecoder().decode(InfoPlist.self, from: infoPlistData) diff --git a/Sources/XcodesKit/Environment.swift b/Sources/XcodesKit/Environment.swift index cec674c..61dcfeb 100644 --- a/Sources/XcodesKit/Environment.swift +++ b/Sources/XcodesKit/Environment.swift @@ -277,9 +277,8 @@ public struct Files { public var contentsOfDirectory: (URL) throws -> [URL] = { try FileManager.default.contentsOfDirectory(at: $0, includingPropertiesForKeys: nil, options: []) } public var installedXcodes: (Path) -> [InstalledXcode] = { directory in - return ((try? directory.ls()) ?? []) + return directory.ls() .filter { $0.isAppBundle && $0.infoPlist?.bundleID == "com.apple.dt.Xcode" } - .map { $0.path } .compactMap(InstalledXcode.init) } } diff --git a/Sources/XcodesKit/Path+.swift b/Sources/XcodesKit/Path+.swift index eba6dd7..5766f2c 100644 --- a/Sources/XcodesKit/Path+.swift +++ b/Sources/XcodesKit/Path+.swift @@ -3,7 +3,7 @@ import Foundation extension Path { // Get Home even if we are running as root - static let environmentHome = ProcessInfo.processInfo.environment["HOME"].flatMap(Path.init) ?? .home + static let environmentHome = ProcessInfo.processInfo.environment["HOME"].flatMap(Path.init) ?? Path(Path.home) static let environmentApplicationSupport = environmentHome/"Library/Application Support" static let environmentCaches = environmentHome/"Library/Caches" public static let environmentDownloads = environmentHome/"Downloads" diff --git a/Sources/XcodesKit/Process.swift b/Sources/XcodesKit/Process.swift index dd79217..e5b6eb4 100644 --- a/Sources/XcodesKit/Process.swift +++ b/Sources/XcodesKit/Process.swift @@ -7,7 +7,7 @@ public typealias ProcessOutput = (status: Int32, out: String, err: String) extension Process { @discardableResult - static func sudo(password: String? = nil, _ executable: Path, workingDirectory: URL? = nil, _ arguments: String...) -> Promise { + static func sudo(password: String? = nil, _ executable: some Pathish, workingDirectory: URL? = nil, _ arguments: String...) -> Promise { var arguments = [executable.string] + arguments if password != nil { arguments.insert("-S", at: 0) @@ -16,7 +16,7 @@ extension Process { } @discardableResult - static func run(_ executable: Path, workingDirectory: URL? = nil, input: String? = nil, _ arguments: String...) -> Promise { + static func run(_ executable: some Pathish, workingDirectory: URL? = nil, input: String? = nil, _ arguments: String...) -> Promise { return run(executable.url, workingDirectory: workingDirectory, input: input, arguments) } diff --git a/Sources/XcodesKit/RuntimeInstaller.swift b/Sources/XcodesKit/RuntimeInstaller.swift index cf0821c..8513666 100644 --- a/Sources/XcodesKit/RuntimeInstaller.swift +++ b/Sources/XcodesKit/RuntimeInstaller.swift @@ -137,7 +137,7 @@ public class RuntimeInstaller { // 1-Mount DMG and get the mounted path let mountedUrl = try await mountDMG(dmgUrl: dmgUrl) // 2-Get the first path under the mounted path, should be a .pkg - let pkgPath = try! Path(url: mountedUrl)!.ls().first!.path + let pkgPath = Path(url: mountedUrl)!.ls().first! // 3-Create a caches directory (if it doesn't exist), and // 4-Set its ownership to the current user (important because under sudo it would be owned by root) try Path.xcodesCaches.mkdir().setCurrentUserAsOwner() diff --git a/Sources/XcodesKit/Version+Xcode.swift b/Sources/XcodesKit/Version+Xcode.swift index b8d1e55..33b0656 100644 --- a/Sources/XcodesKit/Version+Xcode.swift +++ b/Sources/XcodesKit/Version+Xcode.swift @@ -59,7 +59,7 @@ public extension Version { } /// Attempt to instatiate a `Version` using the `.xcode-version` file in the provided directory - static func fromXcodeVersionFile(inDirectory: Path = Path.cwd) -> Version? { + static func fromXcodeVersionFile(inDirectory: some Pathish = Path.cwd) -> Version? { let xcodeVersionFilePath = inDirectory.join(".xcode-version") guard Current.files.fileExists(atPath: xcodeVersionFilePath.string),