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

♻️ Reworked "Fix My Valet" to use built-in switcher

This commit is contained in:
2022-03-18 18:36:49 +01:00
parent 9a6975e3d9
commit d5d9b38ed6
3 changed files with 16 additions and 28 deletions

View File

@ -1302,7 +1302,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 720; CURRENT_PROJECT_VERSION = 730;
DEBUG = YES; DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787; DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -1328,7 +1328,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 720; CURRENT_PROJECT_VERSION = 730;
DEBUG = NO; DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787; DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;

View File

@ -124,25 +124,13 @@ class Actions {
If this does not solve the issue, the user may need to install additional If this does not solve the issue, the user may need to install additional
extensions and/or run `composer global update`. extensions and/or run `composer global update`.
*/ */
public static func fixMyValet() public static func fixMyValet(completed: @escaping () -> Void)
{ {
brew("services restart dnsmasq", sudo: true) InternalSwitcher().performSwitch(to: PhpEnv.brewPhpVersion, completion: {
PhpEnv.shared.detectPhpVersions().forEach { (version) in
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
brew("unlink php@\(version)")
brew("services stop \(formula)")
brew("services stop \(formula)", sudo: true)
}
brew("services stop dnsmasq")
brew("services stop php")
brew("services stop nginx")
brew("link php --overwrite --force")
brew("services restart dnsmasq", sudo: true) brew("services restart dnsmasq", sudo: true)
brew("services restart php", sudo: true) brew("services restart php", sudo: true)
brew("services restart nginx", sudo: true) brew("services restart nginx", sudo: true)
completed()
})
} }
} }

View File

@ -32,9 +32,8 @@ extension MainMenu {
return return
} }
asyncExecution { Actions.fixMyValet {
Actions.fixMyValet() DispatchQueue.main.async {
} success: {
if previousVersion == PhpEnv.brewPhpVersion { if previousVersion == PhpEnv.brewPhpVersion {
self.presentAlertForSameVersion() self.presentAlertForSameVersion()
} else { } else {
@ -42,6 +41,7 @@ extension MainMenu {
} }
} }
} }
}
private func presentAlertForMissingFormula() { private func presentAlertForMissingFormula() {
BetterAlert() BetterAlert()