mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
👌 Cleanup, ensure all tests pass
This commit is contained in:
@ -184,6 +184,7 @@
|
|||||||
C4F30B09278E1A0E00755FCE /* CustomPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */; };
|
C4F30B09278E1A0E00755FCE /* CustomPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */; };
|
||||||
C4F30B0A278E1A1A00755FCE /* ComposerJson.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D89BC52783C99400A02B68 /* ComposerJson.swift */; };
|
C4F30B0A278E1A1A00755FCE /* ComposerJson.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D89BC52783C99400A02B68 /* ComposerJson.swift */; };
|
||||||
C4F30B0B278E203C00755FCE /* MainMenu+Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED402783497000AB15D8 /* MainMenu+Startup.swift */; };
|
C4F30B0B278E203C00755FCE /* MainMenu+Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED402783497000AB15D8 /* MainMenu+Startup.swift */; };
|
||||||
|
C4F319C927B034A500AFF46F /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DEB7D327A5D60B00834718 /* Stats.swift */; };
|
||||||
C4F7809C25D80344000DBC97 /* CommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F7809B25D80344000DBC97 /* CommandTest.swift */; };
|
C4F7809C25D80344000DBC97 /* CommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F7809B25D80344000DBC97 /* CommandTest.swift */; };
|
||||||
C4F780A825D80AE8000DBC97 /* php.ini in Resources */ = {isa = PBXBuildFile; fileRef = C4F780A725D80AE8000DBC97 /* php.ini */; };
|
C4F780A825D80AE8000DBC97 /* php.ini in Resources */ = {isa = PBXBuildFile; fileRef = C4F780A725D80AE8000DBC97 /* php.ini */; };
|
||||||
C4F780AE25D80B37000DBC97 /* ExtensionParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F780AD25D80B37000DBC97 /* ExtensionParserTest.swift */; };
|
C4F780AE25D80B37000DBC97 /* ExtensionParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F780AD25D80B37000DBC97 /* ExtensionParserTest.swift */; };
|
||||||
@ -1011,6 +1012,7 @@
|
|||||||
C43A8A2425D9D20D00591B77 /* BrewJsonParserTest.swift in Sources */,
|
C43A8A2425D9D20D00591B77 /* BrewJsonParserTest.swift in Sources */,
|
||||||
C4F780CA25D80B75000DBC97 /* HomebrewPackage.swift in Sources */,
|
C4F780CA25D80B75000DBC97 /* HomebrewPackage.swift in Sources */,
|
||||||
C4C8E81C276F54E5003AC782 /* PhpConfigWatcher.swift in Sources */,
|
C4C8E81C276F54E5003AC782 /* PhpConfigWatcher.swift in Sources */,
|
||||||
|
C4F319C927B034A500AFF46F /* Stats.swift in Sources */,
|
||||||
C4F30B04278E16BA00755FCE /* HomebrewService.swift in Sources */,
|
C4F30B04278E16BA00755FCE /* HomebrewService.swift in Sources */,
|
||||||
C4AF9F7B2754499000D44ED0 /* Valet.swift in Sources */,
|
C4AF9F7B2754499000D44ED0 /* Valet.swift in Sources */,
|
||||||
C4F780C025D80B6E000DBC97 /* Startup.swift in Sources */,
|
C4F780C025D80B6E000DBC97 /* Startup.swift in Sources */,
|
||||||
@ -1250,7 +1252,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 = 590;
|
CURRENT_PROJECT_VERSION = 600;
|
||||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = phpmon/Info.plist;
|
INFOPLIST_FILE = phpmon/Info.plist;
|
||||||
@ -1275,7 +1277,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 = 590;
|
CURRENT_PROJECT_VERSION = 600;
|
||||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = phpmon/Info.plist;
|
INFOPLIST_FILE = phpmon/Info.plist;
|
||||||
|
@ -51,6 +51,9 @@ class Alert {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notify the user about something by showing an alert.
|
||||||
|
*/
|
||||||
public static func notify(message: String, info: String, style: NSAlert.Style = .informational) {
|
public static func notify(message: String, info: String, style: NSAlert.Style = .informational) {
|
||||||
_ = present(
|
_ = present(
|
||||||
messageText: message,
|
messageText: message,
|
||||||
@ -61,7 +64,11 @@ class Alert {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func notifyAbout(error: Error&AlertableError) {
|
/**
|
||||||
|
Notify the user about a particular error (which must be `Alertable`)
|
||||||
|
by showing an alert.
|
||||||
|
*/
|
||||||
|
public static func notify(about error: Error & AlertableError) {
|
||||||
let key = error.getErrorMessageKey()
|
let key = error.getErrorMessageKey()
|
||||||
_ = present(
|
_ = present(
|
||||||
messageText: "\(key).title".localized,
|
messageText: "\(key).title".localized,
|
||||||
|
@ -20,13 +20,19 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Attempts asynchronous execution of a callback that may throw an Error.
|
Attempts asynchronous execution of a callback that may throw an `Error`.
|
||||||
While the callback is being executed, the UI will be marked as busy.
|
While the callback is being executed, the UI will be marked as busy.
|
||||||
|
|
||||||
- Parameter execute: Callback of the work that needs to happen.
|
(Preferably, if an `Error` is thrown, it should also be an `AlertableError`,
|
||||||
- Parameter success: Callback that is fired when all was OK.
|
which will make presenting errors easier.)
|
||||||
- Parameter failure: Callback that is fired when an Error was thrown.
|
|
||||||
|
- Parameter execute: Required callback of the work that needs to happen.
|
||||||
|
|
||||||
|
- Parameter success: Optional callback that is fired when all was OK.
|
||||||
|
- Parameter failure: Optional callback that is fired when an `Error` was thrown.
|
||||||
- Parameter behaviours: Various behaviours that can be tweaked, but usually best left to the default.
|
- Parameter behaviours: Various behaviours that can be tweaked, but usually best left to the default.
|
||||||
|
The default will set the UI to busy, reload PHP info, update the menu bar,
|
||||||
|
and broadcast to the services view that the list has been updated.
|
||||||
*/
|
*/
|
||||||
func asyncExecution(
|
func asyncExecution(
|
||||||
_ execute: @escaping () throws -> Void,
|
_ execute: @escaping () throws -> Void,
|
||||||
@ -42,9 +48,11 @@ extension MainMenu {
|
|||||||
if behaviours.contains(.reloadsPhpInstallation) {
|
if behaviours.contains(.reloadsPhpInstallation) {
|
||||||
PhpEnv.shared.isBusy = true
|
PhpEnv.shared.isBusy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if behaviours.contains(.setsBusyUI) {
|
if behaviours.contains(.setsBusyUI) {
|
||||||
setBusyImage()
|
setBusyImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||||
var error: Error? = nil
|
var error: Error? = nil
|
||||||
|
|
||||||
@ -60,14 +68,10 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if behaviours.contains(.updatesMenuBarContents) {
|
if behaviours.contains(.updatesMenuBarContents) {
|
||||||
// Refresh the entire menu bar menu's contents
|
|
||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
} else {
|
} else if behaviours.contains(.setsBusyUI) {
|
||||||
// We do still need to refresh the icon based on the busy state
|
|
||||||
if behaviours.contains(.setsBusyUI) {
|
|
||||||
refreshIcon()
|
refreshIcon()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if behaviours.contains(.broadcastServicesUpdate) {
|
if behaviours.contains(.broadcastServicesUpdate) {
|
||||||
NotificationCenter.default.post(name: Events.ServicesUpdated, object: nil)
|
NotificationCenter.default.post(name: Events.ServicesUpdated, object: nil)
|
||||||
|
@ -160,9 +160,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
|||||||
style: .warning
|
style: .warning
|
||||||
)
|
)
|
||||||
} failure: { error in
|
} failure: { error in
|
||||||
let error = error as! HomebrewPermissionError
|
Alert.notify(about: error as! HomebrewPermissionError)
|
||||||
Alert.notifyAbout(error: error)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user