From 6cbead2d5c920d108d85dd7ace7a070991c68d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1rady=20Mil=C3=A1n?= <61704770+MilanVarady@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:06:53 +0100 Subject: [PATCH] Fix some paths --- .../CaskManager+BrewFunctions.swift | 2 +- .../Cask Models/Cask/Cask+LaunchApp.swift | 2 +- Applite/Utilities/Other/BrewPaths.swift | 11 +++--- .../BrewPathSelectorView+PathOption.swift | 36 ++++++++++--------- .../Content View/ContentView+LoadCasks.swift | 2 +- .../SetupView+BrewPathDetectedView.swift | 2 +- Localizable.xcstrings | 35 ------------------ 7 files changed, 30 insertions(+), 60 deletions(-) diff --git a/Applite/Model/Cask Models/Cask Manager/CaskManager+BrewFunctions.swift b/Applite/Model/Cask Models/Cask Manager/CaskManager+BrewFunctions.swift index 72e7f87..097ab90 100644 --- a/Applite/Model/Cask Models/Cask Manager/CaskManager+BrewFunctions.swift +++ b/Applite/Model/Cask Models/Cask Manager/CaskManager+BrewFunctions.swift @@ -31,7 +31,7 @@ extension CaskManager { let noQuarantine = UserDefaults.standard.bool(forKey: Preferences.noQuarantine.rawValue) if noQuarantine { arguments.append("--no-quarantine") } - let command = "\(BrewPaths.currentBrewExecutable) install --cask \(arguments.joined(separator: " "))" + let command = "\(BrewPaths.currentBrewExecutable.quotedPath()) install --cask \(arguments.joined(separator: " "))" // Setup progress cask.progressState = .busy(withTask: "") diff --git a/Applite/Model/Cask Models/Cask/Cask+LaunchApp.swift b/Applite/Model/Cask Models/Cask/Cask+LaunchApp.swift index 084b85f..146589d 100644 --- a/Applite/Model/Cask Models/Cask/Cask+LaunchApp.swift +++ b/Applite/Model/Cask Models/Cask/Cask+LaunchApp.swift @@ -28,7 +28,7 @@ extension Cask { appPath = "\"\(applicationsDirectory)/\(self.info.name).app\"" } else { // Open normal app - let brewDirectory = BrewPaths.currentBrewDirectory + let brewDirectory = BrewPaths.currentBrewDirectory.path(percentEncoded: false) appPath = "\(brewDirectory.replacingOccurrences(of: " ", with: "\\ ") )/Caskroom/\(self.id)/*/*.app" } diff --git a/Applite/Utilities/Other/BrewPaths.swift b/Applite/Utilities/Other/BrewPaths.swift index c32ba12..bb3afb3 100755 --- a/Applite/Utilities/Other/BrewPaths.swift +++ b/Applite/Utilities/Other/BrewPaths.swift @@ -71,19 +71,20 @@ struct BrewPaths { .appendingPathComponent("brew") /// Dynamically returns the current brew directory in use - static var currentBrewDirectory: String { + static var currentBrewDirectory: URL { switch Self.selectedBrewOption { case .appPath: - return appBrewDirectory.path + return appBrewDirectory case .defaultAppleSilicon: - return "/opt/homebrew" + return URL(fileURLWithPath: "/opt/homebrew") case .defaultIntel: - return "/usr/local" + return URL(fileURLWithPath: "/usr/local") case .custom: - return UserDefaults.standard.string(forKey: "customUserBrewPath")?.replacing("/bin/brew", with: "") ?? "" + let path = UserDefaults.standard.string(forKey: "customUserBrewPath")?.replacing("/bin/brew", with: "") ?? "" + return URL(fileURLWithPath: path) } } diff --git a/Applite/Views/Components/Brew Path Selector/BrewPathSelectorView+PathOption.swift b/Applite/Views/Components/Brew Path Selector/BrewPathSelectorView+PathOption.swift index 52d2744..f421737 100644 --- a/Applite/Views/Components/Brew Path Selector/BrewPathSelectorView+PathOption.swift +++ b/Applite/Views/Components/Brew Path Selector/BrewPathSelectorView+PathOption.swift @@ -9,26 +9,30 @@ import SwiftUI extension BrewPathSelectorView { func pathOption(_ option: BrewPaths.PathOption, showPath: Bool = true) -> some View { - HStack { - Text(getPathDescription(for: option)) + VStack(alignment: .leading) { + HStack { + Text(getPathDescription(for: option)) + + if option.rawValue == brewPathOption { + if isSelectedPathValid { + Image(systemName: "checkmark.circle") + .font(.system(size: 16)) + .foregroundColor(.green) + } else { + Image(systemName: "xmark.circle") + .font(.system(size: 16)) + .foregroundColor(.red) + } + } + } if showPath { - Text("(\(BrewPaths.getBrewExectuablePath(for: option)))") + Text(BrewPaths.getBrewExectuablePath(for: option).path(percentEncoded: false)) .truncationMode(.middle) .lineLimit(1) - .foregroundColor(.gray) - } - - if option.rawValue == brewPathOption { - if isSelectedPathValid { - Image(systemName: "checkmark.circle") - .font(.system(size: 16)) - .foregroundColor(.green) - } else { - Image(systemName: "xmark.circle") - .font(.system(size: 16)) - .foregroundColor(.red) - } + .foregroundStyle(.secondary) + .fontWeight(.thin) + .fontDesign(.monospaced) } } } diff --git a/Applite/Views/Content View/ContentView+LoadCasks.swift b/Applite/Views/Content View/ContentView+LoadCasks.swift index ab3ad72..519bc81 100644 --- a/Applite/Views/Content View/ContentView+LoadCasks.swift +++ b/Applite/Views/Content View/ContentView+LoadCasks.swift @@ -18,7 +18,7 @@ extension ContentView { logger.error( """ Initial cask load failure. Reason: selected brew path seems invalid. - Brew executable path path: \(BrewPaths.currentBrewExecutable) + Brew executable path path: \(BrewPaths.currentBrewExecutable.path(percentEncoded: false)) brew --version output: \(output) """ ) diff --git a/Applite/Views/Setup/SetupView+BrewPathDetectedView.swift b/Applite/Views/Setup/SetupView+BrewPathDetectedView.swift index fd8d927..a6c27d4 100644 --- a/Applite/Views/Setup/SetupView+BrewPathDetectedView.swift +++ b/Applite/Views/Setup/SetupView+BrewPathDetectedView.swift @@ -24,7 +24,7 @@ extension SetupView { Card { HStack { Image(systemName: "mug") - Text(BrewPaths.currentBrewDirectory) + Text(BrewPaths.currentBrewDirectory.path(percentEncoded: false)) .font(.system(size: 12, design: .monospaced)) } } diff --git a/Localizable.xcstrings b/Localizable.xcstrings index deb6e40..df68f24 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -135,41 +135,6 @@ } } }, - "(%@)" : { - "localizations" : { - "fr" : { - "stringUnit" : { - "state" : "translated", - "value" : "(%@)" - } - }, - "hu" : { - "stringUnit" : { - "state" : "translated", - "value" : "(%@)" - } - }, - "ja" : { - "stringUnit" : { - "state" : "translated", - "value" : "(%@)" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "(%@)" - } - }, - "zh-HK" : { - "stringUnit" : { - "state" : "translated", - "value" : "(%@)" - } - } - }, - "shouldTranslate" : false - }, "[Homebrew](https://brew.sh) is a free and open source package manager tool that makes installing third-party applications really easy. Applite uses Homebrew under the hood to download and manage applications." : { "comment" : "Manage Homebrew view description", "localizations" : {