mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
6fc613ac4c | |||
8240b676c1 | |||
cbebf75b48 | |||
40c24793f5 | |||
6a921d8e3e | |||
a3368effec | |||
7f4c6878e4 |
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
)
|
||||
|
Reference in New Issue
Block a user