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

🏗 WIP: Cleanup

This commit is contained in:
2023-05-11 22:08:42 +02:00
parent 104f3a7d8c
commit 67ec63212c
4 changed files with 19 additions and 29 deletions

View File

@ -145,6 +145,9 @@ class InstallAndUpgradeCommand: BrewCommand {
await MainMenu.shared.switchToAnyPhpVersion(version, silently: true)
}
// Also rebuild the content of the main menu
await MainMenu.shared.rebuild()
// Let the UI know that the installation has been completed
onProgress(.create(
value: 1,

View File

@ -62,7 +62,8 @@ class Valet {
}
lazy var installed: Bool = {
return FileSystem.fileExists(Paths.binPath.appending("/valet")) && FileSystem.anyExists("~/.config/valet")
return FileSystem.fileExists(Paths.binPath.appending("/valet"))
&& FileSystem.anyExists("~/.config/valet")
}()
/**

View File

@ -8,6 +8,7 @@
import Cocoa
class StatusMenu: NSMenu {
// swiftlint:disable cyclomatic_complexity
func addMenuItems() {
addPhpVersionMenuItems()
addItem(NSMenuItem.separator())

View File

@ -14,42 +14,27 @@ extension App {
let notifier = FSNotifier(
for: URL(fileURLWithPath: Paths.binPath),
eventMask: .all,
onChange: {
Task { await self.onHomebrewPhpModification() }
// Removing requires termination and then removing reference
// self.watchers[.homebrewBinaries]?.terminate()
// self.watchers[.homebrewBinaries] = nil
}
onChange: { Task { await self.onHomebrewPhpModification() } }
)
App.shared.watchers[.homebrewBinaries] = notifier
}
public func destroyHomebrewWatchers() {
// Removing requires termination and then removing reference
self.watchers[.homebrewBinaries]?.terminate()
self.watchers[.homebrewBinaries] = nil
}
public func onHomebrewPhpModification() async {
let previous = PhpEnv.shared.currentInstall?.version.text
// let previous = PhpEnv.shared.currentInstall?.version.text
Log.info("Something changed in the Homebrew binary directory...")
await PhpEnv.detectPhpVersions()
await MainMenu.shared.refreshActiveInstallation()
let new = PhpEnv.shared.currentInstall?.version.text
if previous != new {
#warning("Notifications should be opt-in and are currently disabled")
Log.info("The PHP version has changed, new version is now: \(new ?? "unlinked")")
/*
// These notifications will cause duplicate notifications if using the switcher
if new != nil {
LocalNotification.send(
title: "Globally linked PHP version has changed!",
subtitle: "PHP \(new!) is now active.",
preference: nil
)
} else {
LocalNotification.send(
title: "Globally linked PHP version has changed!",
subtitle: "PHP is now unlinked.",
preference: nil
)
}
*/
}
// let new = PhpEnv.shared.currentInstall?.version.text
// TODO:
// Check if the new and previous version are different
// if so, we can show a notification if needed
}
}