1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
6fc613ac4c 🐛 Own /bin and /sbin folders specifically 2023-05-24 19:29:38 +02:00
8240b676c1 🐛 Own the entire Homebrew formula directory 2023-05-24 19:19:13 +02:00
cbebf75b48 🐛 Fix error message, check sbin folder ownership 2023-05-24 19:17:41 +02:00
40c24793f5 🐛 Show "Please wait" text when running command 2023-05-24 19:08:41 +02:00
6a921d8e3e 🐛 Use PHP Guard when removing a PHP version 2023-05-24 19:05:58 +02:00
a3368effec 🐛 Fix async issue when PHP Guard reset kicks in
Whenever PHP Guard is used to reset the PHP version when a different PHP
version is installed using the PHP Version Manager, it would previously
kick its version switching process off asynchronously as a separate task
which meant that the app would go into "ready" state too soon. Now this
is considered a blocking task that the app will wait for (async) before
turning the app back into its "ready" state again.
2023-05-24 18:59:49 +02:00
7f4c6878e4 📝 Update README 2023-05-22 20:12:49 +02:00
7 changed files with 72 additions and 19 deletions

View File

@ -3352,7 +3352,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1240;
CURRENT_PROJECT_VERSION = 1245;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -3382,7 +3382,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1240;
CURRENT_PROJECT_VERSION = 1245;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -3620,7 +3620,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1240;
CURRENT_PROJECT_VERSION = 1245;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -3734,7 +3734,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1240;
CURRENT_PROJECT_VERSION = 1245;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -3848,7 +3848,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1240;
CURRENT_PROJECT_VERSION = 1245;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -4027,7 +4027,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1240;
CURRENT_PROJECT_VERSION = 1245;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;

View File

@ -584,9 +584,9 @@ Thank you very much for your contributions, kind words and support.
### Loading info about PHP in the background
This utility runs `php-config --version` in the background periodically. It also checks your `.ini` files for extensions and loads more information about your limits (memory limit, POST limit, upload limit).
This app runs `php-config --version` in the background periodically, usually whenever your Homebrew configuration is modified. A filesystem watcher is used to determine if anything changes in your Homebrew's `bin` directory.
In order to save power, this only happens once every 60 seconds.
PHP Monitor also checks your `.ini` files for extensions and loads more information about your limits (memory limit, POST limit, upload limit). See also the section on *Config change detection* below.
### Switching PHP versions

View File

@ -61,17 +61,25 @@ class BrewPermissionFixer {
? "php"
: "php@\(formula)"
let binaryPath = "\(Paths.optPath)/\(realFormula)/bin"
if isOwnedByRoot(path: binaryPath) {
let borked = DueOwnershipFormula(
formula: realFormula,
path: binaryPath
)
let binFolderOwned = isOwnedByRoot(path: "\(Paths.optPath)/\(realFormula)/bin")
let sbinFolderOwned = isOwnedByRoot(path: "\(Paths.optPath)/\(realFormula)/sbin")
if binFolderOwned || sbinFolderOwned {
Log.warn("\(formula) is owned by root")
broken.append(borked)
if binFolderOwned {
broken.append(DueOwnershipFormula(
formula: realFormula,
path: "\(Paths.optPath)/\(realFormula)/bin"
))
}
if sbinFolderOwned {
broken.append(DueOwnershipFormula(
formula: realFormula,
path: "\(Paths.optPath)/\(realFormula)/sbin"
))
}
}
}
}

View File

@ -33,6 +33,14 @@ class InstallAndUpgradeCommand: BrewCommand {
}
func execute(onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
let progressTitle = "Please wait..."
onProgress(.create(
value: 0.2,
title: progressTitle,
description: "PHP Monitor is preparing Homebrew..."
))
// Try to run all upgrade and installation operations
try await self.upgradePackages(onProgress)
try await self.installPackages(onProgress)
@ -147,7 +155,7 @@ class InstallAndUpgradeCommand: BrewCommand {
// If a PHP version was active prior to running the operations, attempt to restore it
if let version = phpGuard.currentVersion {
await MainMenu.shared.switchToAnyPhpVersion(version, silently: true)
await MainMenu.shared.switchToPhpVersionAndWait(version, silently: true)
}
// Also rebuild the content of the main menu

View File

@ -11,12 +11,14 @@ import Foundation
class RemovePhpVersionCommand: BrewCommand {
let formula: String
let version: String
let phpGuard: PhpGuard
init(formula: String) {
self.version = formula
.replacingOccurrences(of: "php@", with: "")
.replacingOccurrences(of: "shivammathur/php/", with: "")
self.formula = formula
self.phpGuard = PhpGuard()
}
func execute(onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
@ -55,8 +57,15 @@ class RemovePhpVersionCommand: BrewCommand {
if process.terminationStatus <= 0 {
onProgress(.create(value: 0.95, title: progressTitle, description: "Reloading PHP versions..."))
await PhpEnvironments.detectPhpVersions()
await MainMenu.shared.refreshActiveInstallation()
if let version = phpGuard.currentVersion {
await MainMenu.shared.switchToPhpVersionAndWait(version, silently: true)
}
onProgress(.create(value: 1, title: progressTitle, description: "The operation has succeeded."))
} else {
throw BrewCommandError(error: "The command failed to run correctly.", log: loggedMessages)

View File

@ -273,6 +273,30 @@ extension MainMenu {
}
}
func switchToPhpVersionAndWait(_ version: String, silently: Bool = false) async {
if silently {
MainMenu.shared.shouldSwitchSilently = true
}
if !PhpEnvironments.shared.availablePhpVersions.contains(version) {
Log.warn("This PHP version is currently unavailable, not switching!")
return
}
setBusyImage()
PhpEnvironments.shared.isBusy = true
PhpEnvironments.shared.delegate = self
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
updatePhpVersionInStatusBar()
rebuild()
await PhpEnvironments.switcher.performSwitch(to: version)
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
App.shared.handlePhpConfigWatcher()
PhpEnvironments.shared.delegate?.switcherDidCompleteSwitch(to: version)
}
@objc func switchToPhpVersion(_ version: String) {
setBusyImage()
PhpEnvironments.shared.isBusy = true

View File

@ -197,12 +197,16 @@ struct PhpFormulaeView: View {
self.status.description = progress.description
self.status.busy = progress.value != 1
// Whenever a key step is finished, refresh the PHP versions
if progress.value == 1 {
self.setBusyStatus(false)
await self.handler.refreshPhpVersions(loadOutdated: false)
}
}
}
// Finally, after completing the command, also refresh PHP versions
await self.handler.refreshPhpVersions(loadOutdated: false)
// and mark the app as no longer busy
self.setBusyStatus(false)
} catch let error {
let error = error as! BrewCommandError
let messages = error.log.suffix(2).joined(separator: "\n")
@ -289,7 +293,7 @@ struct PhpFormulaeView: View {
self.presentErrorAlert(
title: "phpman.failures.uninstall.title".localized,
description: "phpman.failures.uninstall.desc".localized(
"brew uninstall \(formula) --force"
"brew uninstall \(formula.name) --force"
),
button: "generic.ok".localized
)