diff --git a/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift b/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift index 7930005..2236a33 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift @@ -21,8 +21,6 @@ struct BrewPhpFormula: Equatable { /// The upgrade that is currently available, if it exists. let upgradeVersion: String? - // TODO: A rebuild attribute could be checked, to check if a Tap update exists for a pre-release version - /// Whether this formula is a stable version of PHP. let prerelease: Bool @@ -49,6 +47,16 @@ struct BrewPhpFormula: Equatable { var hasUpgrade: Bool { return upgradeVersion != nil } + + var hasFormulaFile: Bool { + guard let version = shortVersion else { + return false + } + + return FileSystem.fileExists( + "\(Paths.tapPath)/shivammathur/homebrew-php/Formula/php@\(version).rb" + ) + } /// Whether this formula alias is different. var hasUpgradedFormulaAlias: Bool { diff --git a/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift b/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift index 6b9e191..23b4256 100644 --- a/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift +++ b/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift @@ -238,7 +238,7 @@ struct PhpVersionManagerView: View { } else { Button("phpman.buttons.install".localizedForSwiftUI) { Task { await self.install(formula) } - }.disabled(formula.hasUpgradedFormulaAlias) + }.disabled(formula.hasUpgradedFormulaAlias || !formula.hasFormulaFile) } } } @@ -268,6 +268,17 @@ struct PhpVersionManagerView: View { Text("phpman.version.installed".localized(formula.installedVersion!)) .font(.system(size: 11)) .foregroundColor(.gray) + } else if !formula.hasFormulaFile { + HStack(spacing: 5) { + Text("phpman.version.unavailable".localizedForSwiftUI) + .font(.system(size: 11)) + .foregroundColor(.gray) + HelpButton(action: { + // Show an alert that displays information about the missing formula + // and what can be done to fix this particular issue. + // Running `brew tap shivammathur/php` generally works, I think. + }) + } } else { Text("phpman.version.available_for_installation".localizedForSwiftUI) .font(.system(size: 11)) diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index b27ce4e..ba633e0 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -138,6 +138,7 @@ and restart PHP Monitor for extensions to become visible. If the problem persist "phpman.version.has_update" = "Version %@ installed, %@ available."; "phpman.version.installed" = "Version %@ is currently installed."; "phpman.version.available_for_installation" = "This version can be installed."; +"phpman.version.unavailable" = "This version is temporarily unavailable."; "phpman.version.automatic_upgrade" = "This version will be automatically installed by upgrading an older version."; "phpman.buttons.uninstall" = "Uninstall"; "phpman.buttons.install" = "Install";