Skip to content

Commit

Permalink
Fix some paths
Browse files Browse the repository at this point in the history
  • Loading branch information
milanvarady committed Jan 11, 2025
1 parent cd4e157 commit 6cbead2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: "")
Expand Down
2 changes: 1 addition & 1 deletion Applite/Model/Cask Models/Cask/Cask+LaunchApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
11 changes: 6 additions & 5 deletions Applite/Utilities/Other/BrewPaths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Applite/Views/Content View/ContentView+LoadCasks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"""
)
Expand Down
2 changes: 1 addition & 1 deletion Applite/Views/Setup/SetupView+BrewPathDetectedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
35 changes: 0 additions & 35 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down

0 comments on commit 6cbead2

Please sign in to comment.