mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 Health check in UI
This commit is contained in:
@ -45,7 +45,9 @@ class PhpInstallation {
|
|||||||
withStandardError: true
|
withStandardError: true
|
||||||
).trimmingCharacters(in: .whitespacesAndNewlines)
|
).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
|
||||||
if testCommand.contains("Library not loaded") {
|
// If the "dyld: Library not loaded" issue pops up, we have an unhealthy PHP installation
|
||||||
|
// and we will need to reinstall this version of PHP via Homebrew.
|
||||||
|
if testCommand.contains("Library not loaded") && testCommand.contains("dyld") {
|
||||||
self.isHealthy = false
|
self.isHealthy = false
|
||||||
Log.err("The PHP installation of \(self.versionNumber.short) is not healthy!")
|
Log.err("The PHP installation of \(self.versionNumber.short) is not healthy!")
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,19 @@ struct BrewFormula {
|
|||||||
return "\(Paths.optPath)/\(resolved)/bin"
|
return "\(Paths.optPath)/\(resolved)/bin"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isHealthy() -> Bool {
|
var shortVersion: String? {
|
||||||
return true
|
guard let version = self.installedVersion else {
|
||||||
// #error("This must check if the PHP version works")
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return VersionNumber.make(from: version)?.short ?? nil
|
||||||
|
}
|
||||||
|
|
||||||
|
public func isHealthy() -> Bool? {
|
||||||
|
guard let shortVersion = self.shortVersion else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhpEnv.shared.cachedPhpInstallations[shortVersion]?.isHealthy ?? nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,14 @@ struct PhpFormulaeView: View {
|
|||||||
.padding(.horizontal, 5)
|
.padding(.horizontal, 5)
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text(formula.displayName).bold()
|
Text(formula.displayName).bold()
|
||||||
// Text(formula.homebrewFolder)
|
|
||||||
|
if formula.isHealthy() == nil {
|
||||||
|
Text("Unknown health")
|
||||||
|
} else {
|
||||||
|
Text(formula.isHealthy()! ? "Health OK" : "Broken!")
|
||||||
|
}
|
||||||
|
|
||||||
|
Text(formula.homebrewFolder)
|
||||||
|
|
||||||
if formula.isInstalled && formula.hasUpgrade {
|
if formula.isInstalled && formula.hasUpgrade {
|
||||||
Text("\(formula.installedVersion!) installed, \(formula.upgradeVersion!) available.")
|
Text("\(formula.installedVersion!) installed, \(formula.upgradeVersion!) available.")
|
||||||
|
Reference in New Issue
Block a user