diff --git a/phpmon/Domain/Integrations/Homebrew/BrewDiagnostics.swift b/phpmon/Domain/Integrations/Homebrew/BrewDiagnostics.swift index 8457bc3..7c695e7 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewDiagnostics.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewDiagnostics.swift @@ -138,27 +138,12 @@ class BrewDiagnostics { } } - public static func verifyAndInstallThirdPartyTaps() async { + public static func verifyThirdPartyTaps() async { let requiredTaps = [ "shivammathur/php", "shivammathur/extensions" ] - var requiredInstall = false - - // Install required taps if missing (if possible) - for tap in requiredTaps where !installedTaps.contains(tap) { - Log.info("Required tap `\(tap)` is missing... will install!") - await Shell.quiet("brew tap \(tap)") - Log.info("Completed command. Will verify installation later...") - requiredInstall = true - } - - // Reload the list of taps after installing - if requiredInstall { - await loadInstalledTaps() - } - // Check the status of the installed taps for tap in requiredTaps { if installedTaps.contains(tap) { diff --git a/phpmon/Domain/Menu/MainMenu+Startup.swift b/phpmon/Domain/Menu/MainMenu+Startup.swift index 6408901..2b1425e 100644 --- a/phpmon/Domain/Menu/MainMenu+Startup.swift +++ b/phpmon/Domain/Menu/MainMenu+Startup.swift @@ -56,10 +56,9 @@ extension MainMenu { // Actually detect the PHP versions await PhpEnvironments.detectPhpVersions() - // Verify and install third party taps (if missing) - // This may fail if the user has no internet, at which point - // the missing tap(s) will be actionable as a warning - await BrewDiagnostics.verifyAndInstallThirdPartyTaps() + // Verify third party taps + // The missing tap(s) will be actionable later + await BrewDiagnostics.verifyThirdPartyTaps() // Check for an alias conflict await BrewDiagnostics.checkForCaskConflict() diff --git a/phpmon/Modules/PHP Doctor/Data/WarningManager.swift b/phpmon/Modules/PHP Doctor/Data/WarningManager.swift index 8d52c49..ee51e29 100644 --- a/phpmon/Modules/PHP Doctor/Data/WarningManager.swift +++ b/phpmon/Modules/PHP Doctor/Data/WarningManager.swift @@ -100,7 +100,9 @@ class WarningManager: ObservableObject { ] }, url: "https://github.com/shivammathur/homebrew-php", fix: { + await delay(seconds: 10) await Shell.quiet("brew tap shivammathur/php") + await BrewDiagnostics.loadInstalledTaps() await WarningManager.shared.checkEnvironment() } ), @@ -116,6 +118,7 @@ class WarningManager: ObservableObject { url: "https://github.com/shivammathur/homebrew-extensions", fix: { await Shell.quiet("brew tap shivammathur/extensions") + await BrewDiagnostics.loadInstalledTaps() await WarningManager.shared.checkEnvironment() } ), diff --git a/phpmon/Modules/PHP Doctor/UI/WarningView.swift b/phpmon/Modules/PHP Doctor/UI/WarningView.swift index 2907e49..196c822 100644 --- a/phpmon/Modules/PHP Doctor/UI/WarningView.swift +++ b/phpmon/Modules/PHP Doctor/UI/WarningView.swift @@ -13,6 +13,7 @@ struct WarningView: View { @State var paragraphs: [String] @State var documentationUrl: String? @State var automaticFix: (() async -> Void)? + @State var busyFixing: Bool = false var body: some View { VStack(alignment: .leading) { @@ -40,12 +41,25 @@ struct WarningView: View { HStack { if let automaticFix { - Button("Fix Automatically") { - Task { - await automaticFix() + Button( + action: { + Task { + busyFixing = true + await automaticFix() + busyFixing = false + } + }, + label: { + if busyFixing { + ProgressView() + .progressViewStyle(CircularProgressViewStyle()) + .scaleEffect(0.6) + } + + Text("Fix Automatically") } - } - } + ) + .disabled(busyFixing) } if let documentationUrl { Button("Learn More") {