mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
✅ Added linting
This commit is contained in:
@ -17,14 +17,14 @@ extension MainMenu {
|
||||
DispatchQueue.main.async {
|
||||
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||
}
|
||||
|
||||
|
||||
if await Startup().checkEnvironment() {
|
||||
self.onEnvironmentPass()
|
||||
} else {
|
||||
self.onEnvironmentFail()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
When the environment is all clear and the app can run, let's go.
|
||||
*/
|
||||
@ -33,72 +33,61 @@ extension MainMenu {
|
||||
if Valet.shared.version != nil {
|
||||
Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!)")
|
||||
}
|
||||
|
||||
|
||||
// Validate the version (this will enforce which versions of PHP are supported)
|
||||
Valet.shared.validateVersion()
|
||||
|
||||
|
||||
// Actually detect the PHP versions
|
||||
PhpEnv.detectPhpVersions()
|
||||
|
||||
|
||||
// Check for an alias conflict
|
||||
if HomebrewDiagnostics.hasAliasConflict() {
|
||||
DispatchQueue.main.async {
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.php_alias_conflict.title".localized,
|
||||
subtitle: "alert.php_alias_conflict.info".localized
|
||||
)
|
||||
.withPrimary(text: "OK")
|
||||
.show()
|
||||
}
|
||||
HomebrewDiagnostics.presentAlertAboutConflict()
|
||||
}
|
||||
|
||||
|
||||
updatePhpVersionInStatusBar()
|
||||
|
||||
|
||||
Log.info("Determining broken PHP-FPM...")
|
||||
// Attempt to find out if PHP-FPM is broken
|
||||
let installation = PhpEnv.phpInstall
|
||||
installation.notifyAboutBrokenPhpFpm()
|
||||
|
||||
// Set up the config watchers on launch (these are automatically updated via delegate methods if the user switches)
|
||||
|
||||
// Set up the config watchers on launch
|
||||
// (these are automatically updated via delegate methods if the user switches)
|
||||
Log.info("Setting up watchers...")
|
||||
App.shared.handlePhpConfigWatcher()
|
||||
|
||||
|
||||
// Detect applications (preset + custom)
|
||||
Log.info("Detecting applications...")
|
||||
App.shared.detectedApplications = Application.detectPresetApplications()
|
||||
|
||||
let customApps = Preferences.custom.scanApps.map { appName in
|
||||
return Application(appName, .user_supplied)
|
||||
}.filter { app in
|
||||
return app.isInstalled()
|
||||
}
|
||||
|
||||
App.shared.detectedApplications.append(contentsOf: customApps)
|
||||
|
||||
let appNames = App.shared.detectedApplications.map { app in
|
||||
return app.name
|
||||
}
|
||||
|
||||
Log.info("Detected applications: \(appNames)")
|
||||
|
||||
|
||||
// Load the global hotkey
|
||||
App.shared.loadGlobalHotkey()
|
||||
|
||||
|
||||
// Preload sites
|
||||
Valet.shared.startPreloadingSites()
|
||||
|
||||
|
||||
// A non-default TLD is not officially supported since Valet 3.2.x
|
||||
if (Valet.shared.config.tld != "test") {
|
||||
DispatchQueue.main.async {
|
||||
BetterAlert().withInformation(
|
||||
title: "alert.warnings.tld_issue.title".localized,
|
||||
subtitle: "alert.warnings.tld_issue.subtitle".localized,
|
||||
description: "alert.warnings.tld_issue.description".localized
|
||||
).withPrimary(text: "OK").show()
|
||||
}
|
||||
}
|
||||
|
||||
Valet.notifyAboutUnsupportedTLD()
|
||||
|
||||
NotificationCenter.default.post(name: Events.ServicesUpdated, object: nil)
|
||||
|
||||
|
||||
Log.info("PHP Monitor is ready to serve!")
|
||||
|
||||
|
||||
// Schedule a request to fetch the PHP version every 60 seconds
|
||||
DispatchQueue.main.async { [self] in
|
||||
App.shared.timer = Timer.scheduledTimer(
|
||||
@ -109,17 +98,17 @@ extension MainMenu {
|
||||
repeats: true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Stats.incrementSuccessfulLaunchCount()
|
||||
Stats.evaluateSponsorMessageShouldBeDisplayed()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
When the environment is not OK, present an alert to inform the user.
|
||||
*/
|
||||
private func onEnvironmentFail() {
|
||||
DispatchQueue.main.async { [self] in
|
||||
|
||||
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.cannot_start.title".localized,
|
||||
@ -132,7 +121,7 @@ extension MainMenu {
|
||||
exit(1)
|
||||
})
|
||||
.show()
|
||||
|
||||
|
||||
Task { await startup() }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user