diff --git a/phpmon/Domain/Integrations/Homebrew/Commands/BrewCommand.swift b/phpmon/Domain/Integrations/Homebrew/Commands/BrewCommand.swift index 2fb1d67..e8a6863 100644 --- a/phpmon/Domain/Integrations/Homebrew/Commands/BrewCommand.swift +++ b/phpmon/Domain/Integrations/Homebrew/Commands/BrewCommand.swift @@ -16,21 +16,65 @@ protocol BrewCommand { extension BrewCommand { internal func reportInstallationProgress(_ text: String) -> (Double, String)? { - if text.contains("Fetching") { + // Special cases: downloading a manifest is effectively fetching metadata + if text.contains("==> Downloading") && text.contains("/manifests/") { return (0.1, "phpman.steps.fetching".localized) } - if text.contains("Downloading") { - return (0.25, "phpman.steps.downloading".localized) - } - if text.contains("Installing") { - return (0.60, "phpman.steps.installing".localized) - } - if text.contains("Pouring") { - return (0.80, "phpman.steps.pouring".localized) - } - if text.contains("Summary") { + + // Logical progress evaluation (reverse order for accuracy) + if text.contains("==> Summary") { return (0.90, "phpman.steps.summary".localized) } + if text.contains("==> Pouring") { + if let subject = extractContext(from: text) { + return (0.80, "phpman.steps.pouring".localized + "\n(\(subject))") + } + return (0.80, "phpman.steps.pouring".localized) + } + if text.contains("==> Installing") { + if let subject = extractContext(from: text) { + return (0.60, "phpman.steps.installing".localized + "\n(\(subject))") + } + return (0.60, "phpman.steps.installing".localized) + } + if text.contains("==> Downloading") { + if let subject = extractContext(from: text) { + return (0.25, "phpman.steps.downloading".localized + "\n(\(subject))") + } + return (0.25, "phpman.steps.downloading".localized) + } + if text.contains("==> Fetching") { + return (0.1, "phpman.steps.fetching".localized) + } + return nil + } + + internal func extractContext(from text: String) -> String? { + var pattern = #""# + if text.contains("==> Fetching") { + pattern = #"==> Fetching (\S+)"# + } + if text.contains("==> Downloading") { + pattern = #"==> Downloading (\S+)"# + } + if text.contains("==> Installing") { + pattern = #"==> Installing (\S+)"# + } + if text.contains("==> Pouring") { + pattern = #"==> Pouring (\S+)"# + } + + guard let regex = try? NSRegularExpression(pattern: pattern) else { + return nil + } + + let range = NSRange(text.startIndex..: View { .bold() .foregroundColor(.primary) .padding(.top, 8) + .multilineTextAlignment(.center) Text(detailText) .font(.system(size: 11)) .foregroundColor(.primary) .padding(.top, -4) + .multilineTextAlignment(.center) }.padding(60) } } diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index d1265ad..cbca9cb 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -201,11 +201,11 @@ You may be asked for your password during the uninstallation process if file per "phpman.operations.updating" = "Installing updates..."; "phpman.operations.installing" = "Installing %@..."; -"phpman.steps.fetching" = "Fetching..."; +"phpman.steps.fetching" = "Fetching some package metadata..."; "phpman.steps.downloading" = "Downloading package data..."; "phpman.steps.installing" = "Installing some package data..."; "phpman.steps.pouring" = "Pouring... This can take a while..."; -"phpman.steps.summary" = "Some package has finished installing..."; +"phpman.steps.summary" = "Please wait a moment..."; "phpman.services.loading" = "Loading..."; "phpman.services.not_installed" = "A key service is not installed.";