diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 8a492db..90a9ad7 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -21,6 +21,14 @@ 033D45A02B0D513900070080 /* RemovePhpExtensionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033D459D2B0D513900070080 /* RemovePhpExtensionCommand.swift */; }; 033D45A12B0D513900070080 /* RemovePhpExtensionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033D459D2B0D513900070080 /* RemovePhpExtensionCommand.swift */; }; 033D45A32B0D531D00070080 /* PhpExtensionManagerView+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033D45A22B0D531D00070080 /* PhpExtensionManagerView+Actions.swift */; }; + 03BFF5272E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; }; + 03BFF5282E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; }; + 03BFF5292E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; }; + 03BFF52A2E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; }; + 03BFF52C2E313244007F96FA /* StatusMenu+Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF52B2E313240007F96FA /* StatusMenu+Driver.swift */; }; + 03BFF52D2E313244007F96FA /* StatusMenu+Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF52B2E313240007F96FA /* StatusMenu+Driver.swift */; }; + 03BFF52E2E313244007F96FA /* StatusMenu+Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF52B2E313240007F96FA /* StatusMenu+Driver.swift */; }; + 03BFF52F2E313244007F96FA /* StatusMenu+Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF52B2E313240007F96FA /* StatusMenu+Driver.swift */; }; 03E36FE728D9219000636F7F /* ActiveShell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E36FE628D9219000636F7F /* ActiveShell.swift */; }; 03E36FE828D9219000636F7F /* ActiveShell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E36FE628D9219000636F7F /* ActiveShell.swift */; }; 5420395926135DC100FB00FA /* PreferencesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PreferencesVC.swift */; }; @@ -920,6 +928,8 @@ 033D45972B0D4EC600070080 /* InstallPhpExtensionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallPhpExtensionCommand.swift; sourceTree = ""; }; 033D459D2B0D513900070080 /* RemovePhpExtensionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemovePhpExtensionCommand.swift; sourceTree = ""; }; 033D45A22B0D531D00070080 /* PhpExtensionManagerView+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PhpExtensionManagerView+Actions.swift"; sourceTree = ""; }; + 03BFF5262E312C39007F96FA /* Startup+Timers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Startup+Timers.swift"; sourceTree = ""; }; + 03BFF52B2E313240007F96FA /* StatusMenu+Driver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StatusMenu+Driver.swift"; sourceTree = ""; }; 03E36FE628D9219000636F7F /* ActiveShell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveShell.swift; sourceTree = ""; }; 5420395826135DC100FB00FA /* PreferencesVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesVC.swift; sourceTree = ""; }; 5420395E2613607600FB00FA /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = ""; }; @@ -1850,6 +1860,7 @@ C4F361602836BFD9003598CC /* MainMenu+Actions.swift */, C47331A1247093B7009A0597 /* StatusMenu.swift */, C4C3643828AE4FCE00C0770E /* StatusMenu+Items.swift */, + 03BFF52B2E313240007F96FA /* StatusMenu+Driver.swift */, C4821C592C2DEDE200357A68 /* AppMenu.swift */, ); path = Menu; @@ -1938,6 +1949,7 @@ C4B97B7A275CF20A003F3378 /* App+GlobalHotkey.swift */, C4EED88827A48778006D7272 /* InterAppHandler.swift */, C4D8016522B1584700C6DA1B /* Startup.swift */, + 03BFF5262E312C39007F96FA /* Startup+Timers.swift */, C495F5AE28A42E080087F70A /* EnvironmentCheck.swift */, C40FE736282ABA4F00A302C2 /* AppVersion.swift */, C409349C298EE8E900D25014 /* AppUpdater.swift */, @@ -2589,6 +2601,7 @@ C4EB53E528551F9B006F9937 /* HeaderView.swift in Sources */, C4EA3C472BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */, C40FE737282ABA4F00A302C2 /* AppVersion.swift in Sources */, + 03BFF5282E312C3D007F96FA /* Startup+Timers.swift in Sources */, C44A874828905BB000498BC4 /* ProgressVC.swift in Sources */, C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */, C456A0C62AA614BD0080144F /* PhpPreference.swift in Sources */, @@ -2641,6 +2654,7 @@ C40C7F3027722E8D00DDDCDC /* Logger.swift in Sources */, C41CA5ED2774F8EE00A2C80E /* DomainListVC+Actions.swift in Sources */, C412E5FC25700D5300A1FB67 /* HomebrewDecodable.swift in Sources */, + 03BFF52E2E313244007F96FA /* StatusMenu+Driver.swift in Sources */, 03E36FE728D9219000636F7F /* ActiveShell.swift in Sources */, C4D9ADBF277610E1007277F4 /* PhpSwitcher.swift in Sources */, C45E76142854A65300B4FE0C /* ServicesManager.swift in Sources */, @@ -2862,6 +2876,7 @@ C471E7FE28F9BACE0021E251 /* HomebrewDecodable.swift in Sources */, C4415E8F2B0287E90035F520 /* BrewFormulaeObservable.swift in Sources */, C471E7D828F9BA8F0021E251 /* FileSystemProtocol.swift in Sources */, + 03BFF52F2E313244007F96FA /* StatusMenu+Driver.swift in Sources */, C471E7F328F9BAC70021E251 /* PhpHelper.swift in Sources */, C46DC7A62C7B5BC900F19D17 /* Favorites.swift in Sources */, C471E7E728F9BAC20021E251 /* Constants.swift in Sources */, @@ -2892,6 +2907,7 @@ C490E3B929BCA368006D2DE6 /* App+BrewWatch.swift in Sources */, C471E7FF28F9BAD10021E251 /* Xdebug.swift in Sources */, C409349F298EE8E900D25014 /* AppUpdater.swift in Sources */, + 03BFF5292E312C3D007F96FA /* Startup+Timers.swift in Sources */, C471E7F228F9BAC70021E251 /* PhpEnvironments.swift in Sources */, C471E7E628F9BAC20021E251 /* Process.swift in Sources */, C471E81928F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */, @@ -3078,6 +3094,7 @@ C4611E5A2AEAD2E20010BE24 /* ConfigManagerWindowController.swift in Sources */, C471E80E28F9BAE80021E251 /* DateExtension.swift in Sources */, C490E3BA29BCA368006D2DE6 /* App+BrewWatch.swift in Sources */, + 03BFF5272E312C3D007F96FA /* Startup+Timers.swift in Sources */, C471E7D028F9BA630021E251 /* FileSystemProtocol.swift in Sources */, C471E81228F9BAE80021E251 /* TimeIntervalExtension.swift in Sources */, C471E7DF28F9BAAB0021E251 /* RealCommand.swift in Sources */, @@ -3089,6 +3106,7 @@ C471E80228F9BAD40021E251 /* PhpInstallation.swift in Sources */, C471E81028F9BAE80021E251 /* StringExtension.swift in Sources */, C48DDD1029C75C9E00D032D9 /* BlockingOverlayView.swift in Sources */, + 03BFF52C2E313244007F96FA /* StatusMenu+Driver.swift in Sources */, C471E7F828F9BACB0021E251 /* InternalSwitcher.swift in Sources */, C471E82328F9BB2E0021E251 /* ComposerJson.swift in Sources */, C471E82128F9BB2E0021E251 /* ProjectTypeDetection.swift in Sources */, @@ -3237,6 +3255,7 @@ C43603A1275E67610028EFC6 /* AppDelegate+Notifications.swift in Sources */, C4C3643A28AE4FCE00C0770E /* StatusMenu+Items.swift in Sources */, C42759682627662800093CAE /* NSMenuExtension.swift in Sources */, + 03BFF52D2E313244007F96FA /* StatusMenu+Driver.swift in Sources */, C4AFC4B429C4F43300BF4E0D /* HomebrewUpgradableTest.swift in Sources */, C4E2E84828FC1D93003B070C /* TestableConfigurationTest.swift in Sources */, C4D936CB27E3EE4A00BD69FE /* DomainListCellProtocol.swift in Sources */, @@ -3248,6 +3267,7 @@ C485706D28BF450900539B36 /* NSMenuItemExtension.swift in Sources */, C481F79726164A78004FBCFF /* PreferencesVC.swift in Sources */, C495F5B028A42E080087F70A /* EnvironmentCheck.swift in Sources */, + 03BFF52A2E312C3D007F96FA /* Startup+Timers.swift in Sources */, C41E871B2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */, C40C7F3127722E8D00DDDCDC /* Logger.swift in Sources */, C4068CAB27B0890D00544CD5 /* MenuBarIcons.swift in Sources */, @@ -3692,7 +3712,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1555; + CURRENT_PROJECT_VERSION = 1565; DEAD_CODE_STRIPPING = YES; DEBUG = YES; ENABLE_HARDENED_RUNTIME = YES; @@ -3704,7 +3724,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.5; - MARKETING_VERSION = 25.06; + MARKETING_VERSION = 25.07; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_MODULE_NAME = PHP_Monitor; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3722,7 +3742,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1555; + CURRENT_PROJECT_VERSION = 1565; DEAD_CODE_STRIPPING = YES; DEBUG = NO; ENABLE_HARDENED_RUNTIME = YES; @@ -3734,7 +3754,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.5; - MARKETING_VERSION = 25.06; + MARKETING_VERSION = 25.07; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_MODULE_NAME = PHP_Monitor; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3955,7 +3975,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1555; + CURRENT_PROJECT_VERSION = 1565; DEAD_CODE_STRIPPING = YES; DEBUG = NO; ENABLE_HARDENED_RUNTIME = YES; @@ -3967,7 +3987,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.5; - MARKETING_VERSION = 25.06; + MARKETING_VERSION = 25.07; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev; PRODUCT_MODULE_NAME = PHP_Monitor; PRODUCT_NAME = "$(TARGET_NAME) DEV"; @@ -4071,7 +4091,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1555; + CURRENT_PROJECT_VERSION = 1565; DEAD_CODE_STRIPPING = YES; DEBUG = YES; ENABLE_HARDENED_RUNTIME = YES; @@ -4083,7 +4103,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.5; - MARKETING_VERSION = 25.06; + MARKETING_VERSION = 25.07; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev; PRODUCT_MODULE_NAME = PHP_Monitor; PRODUCT_NAME = "$(TARGET_NAME) DEV"; @@ -4187,7 +4207,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1555; + CURRENT_PROJECT_VERSION = 1565; DEAD_CODE_STRIPPING = YES; DEBUG = YES; ENABLE_HARDENED_RUNTIME = YES; @@ -4199,7 +4219,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.5; - MARKETING_VERSION = 25.06; + MARKETING_VERSION = 25.07; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap; PRODUCT_MODULE_NAME = PHP_Monitor; PRODUCT_NAME = "$(TARGET_NAME) EAP"; @@ -4366,7 +4386,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1555; + CURRENT_PROJECT_VERSION = 1565; DEAD_CODE_STRIPPING = YES; DEBUG = NO; ENABLE_HARDENED_RUNTIME = YES; @@ -4378,7 +4398,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.5; - MARKETING_VERSION = 25.06; + MARKETING_VERSION = 25.07; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap; PRODUCT_MODULE_NAME = PHP_Monitor; PRODUCT_NAME = "$(TARGET_NAME) EAP"; diff --git a/phpmon/Assets.xcassets/ValetDriverIcon.imageset/Contents.json b/phpmon/Assets.xcassets/ValetDriverIcon.imageset/Contents.json new file mode 100644 index 0000000..39e31f6 --- /dev/null +++ b/phpmon/Assets.xcassets/ValetDriverIcon.imageset/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ValetDriverIcon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/phpmon/Assets.xcassets/ValetDriverIcon.imageset/ValetDriverIcon@2x.png b/phpmon/Assets.xcassets/ValetDriverIcon.imageset/ValetDriverIcon@2x.png new file mode 100644 index 0000000..e63a8ef Binary files /dev/null and b/phpmon/Assets.xcassets/ValetDriverIcon.imageset/ValetDriverIcon@2x.png differ diff --git a/phpmon/Common/Core/Constants.swift b/phpmon/Common/Core/Constants.swift index c6acd0c..af1b941 100644 --- a/phpmon/Common/Core/Constants.swift +++ b/phpmon/Common/Core/Constants.swift @@ -18,6 +18,16 @@ struct Constants { */ static let MinimumRecommendedValetVersion = "2.16.2" + /** + The amount of seconds that is considered the threshold for + PHP Monitor to mark any given launch as a "slow" launch. + + If the startup procedure was slow (or hangs), this message should + be displayed. This is based on an appropriate launch time on a + basic M1 Apple chip, with some margin for slower Intel chips. + */ + static let SlowBootThresholdInterval: TimeInterval = 30.0 + /** PHP Monitor supplies a hardcoded list of PHP packages in its own PHP Version Manager. diff --git a/phpmon/Domain/App/Startup+Timers.swift b/phpmon/Domain/App/Startup+Timers.swift new file mode 100644 index 0000000..3d3fcbc --- /dev/null +++ b/phpmon/Domain/App/Startup+Timers.swift @@ -0,0 +1,74 @@ +// +// Startup+Timers.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 23/07/2025. +// Copyright © 2025 Nico Verbruggen. All rights reserved. +// + +import Foundation +import AppKit +import NVAlert + +extension Startup { + @MainActor static var startupTimer: Timer? + @MainActor static var launchTime: Date? + + /** Returns a human-readable version to indicate how many seconds elapsed since boot. */ + @MainActor static var humanReadableSinceBootTime: String { + return String(format: "%.2f", Date().timeIntervalSince(Self.launchTime!)) + } + + /** Starts the timeout timer that keeps track of how long the app takes to boot. */ + @MainActor func startStartupTimer() { + Self.launchTime = Date() + Self.startupTimer = Timer.scheduledTimer( + timeInterval: Constants.SlowBootThresholdInterval, target: self, + selector: #selector(startupTimeout), userInfo: nil, repeats: false + ) + } + + /** + Invalidates and stops the startup timer. + This is only called if the slow boot threshold is not exceeded. + */ + @MainActor static func invalidateTimeoutTimer() { + if Self.startupTimer == nil { + return + } + + Log.info("PHP Monitor was quick; elapsed time: \(Self.humanReadableSinceBootTime) sec.") + Self.startupTimer?.invalidate() + Self.startupTimer = nil + } + + /** + Displays an alert for when the application startup process takes too long. + */ + @MainActor @objc func startupTimeout() { + Log.info("PHP Monitor was slow; elapsed time: \(Self.humanReadableSinceBootTime) sec.") + + // Invalidate the timer + Self.startupTimer?.invalidate() + Self.startupTimer = nil + + // Present an alert that lets the user know about the slow start + NVAlert() + .withInformation( + title: "startup.timeout.title".localized, + subtitle: "startup.timeout.subtitle".localized, + description: "startup.timeout.description".localized + ) + .withPrimary(text: "alert.cannot_start.close".localized, action: { vc in + vc.close(with: .alertFirstButtonReturn) + exit(1) + }) + .withSecondary(text: "startup.timeout.ignore".localized, action: { vc in + vc.close(with: .alertSecondButtonReturn) + }) + .withTertiary(text: "", action: { _ in + NSWorkspace.shared.open(URL(string: "https://github.com/nicoverbruggen/phpmon/issues/294")!) + }) + .show() + } +} diff --git a/phpmon/Domain/App/Startup.swift b/phpmon/Domain/App/Startup.swift index 4f486aa..ebc6c0c 100644 --- a/phpmon/Domain/App/Startup.swift +++ b/phpmon/Domain/App/Startup.swift @@ -10,21 +10,6 @@ import AppKit import NVAlert class Startup { - - @MainActor static var startupTimer: Timer? - - @MainActor func startTimeoutTimer() { - Self.startupTimer = Timer.scheduledTimer( - timeInterval: 30.0, target: self, selector: #selector(startupTimeout), - userInfo: nil, repeats: false - ) - } - - @MainActor static func invalidateTimeoutTimer() { - Self.startupTimer?.invalidate() - Self.startupTimer = nil - } - /** Checks the user's environment and checks if PHP Monitor can be used properly. This checks if PHP is installed, Valet is running, the appropriate permissions are set, and more. @@ -38,7 +23,7 @@ class Startup { // Set up a "background" timer on the main thread Task { @MainActor in - startTimeoutTimer() + startStartupTimer() } for group in self.groups { @@ -69,29 +54,6 @@ class Startup { return true } - /** - Displays an alert for when the application startup process takes too long. - */ - @MainActor @objc func startupTimeout() { - NVAlert() - .withInformation( - title: "startup.timeout.title".localized, - subtitle: "startup.timeout.subtitle".localized, - description: "startup.timeout.description".localized - ) - .withPrimary(text: "alert.cannot_start.close".localized, action: { vc in - vc.close(with: .alertFirstButtonReturn) - exit(1) - }) - .withSecondary(text: "startup.timeout.ignore".localized, action: { vc in - vc.close(with: .alertSecondButtonReturn) - }) - .withTertiary(text: "", action: { _ in - NSWorkspace.shared.open(URL(string: "https://github.com/nicoverbruggen/phpmon/issues/294")!) - }) - .show() - } - /** Displays an alert for a particular check. There are two types of alerts: - ones that require an app restart, which prompt the user to exit the app diff --git a/phpmon/Domain/Integrations/Composer/ProjectTypeDetection.swift b/phpmon/Domain/Integrations/Composer/ProjectTypeDetection.swift index 7cad37f..a9eb5ed 100644 --- a/phpmon/Domain/Integrations/Composer/ProjectTypeDetection.swift +++ b/phpmon/Domain/Integrations/Composer/ProjectTypeDetection.swift @@ -15,7 +15,8 @@ struct ProjectTypeDetection { public static let CommonDependencyList = [ "laravel/framework": "Laravel", "symfony/symfony": "Symfony", - "laravel/lumen": "Lumen" + "laravel/lumen": "Lumen", + "tempest/framework": "Tempest" ] /** diff --git a/phpmon/Domain/Integrations/Valet/Domains/ValetInteractor.swift b/phpmon/Domain/Integrations/Valet/Domains/ValetInteractor.swift index 7cc2c26..b51bc33 100644 --- a/phpmon/Domain/Integrations/Valet/Domains/ValetInteractor.swift +++ b/phpmon/Domain/Integrations/Valet/Domains/ValetInteractor.swift @@ -51,7 +51,15 @@ class ValetInteractor { // Keep track of the command we wish to run let action = site.secured ? "unsecure" : "secure" - let command = "cd '\(site.absolutePath)' && sudo \(Paths.valet) \(action) && exit;" + + // Use modernized version of command using domain name + // This will allow us to secure multiple domains that use the same path + var command = "sudo \(Paths.valet) \(action) '\(site.name)' && exit;" + + // For Valet 2, use the old syntax; this has a known issue so Valet 3+ is preferred + if !Valet.enabled(feature: .isolatedSites) { + command = "cd '\(site.absolutePath)' && sudo \(Paths.valet) \(action) && exit;" + } // Run the command await Shell.quiet(command) diff --git a/phpmon/Domain/Menu/MainMenu+Startup.swift b/phpmon/Domain/Menu/MainMenu+Startup.swift index 80ed97e..c7d5e69 100644 --- a/phpmon/Domain/Menu/MainMenu+Startup.swift +++ b/phpmon/Domain/Menu/MainMenu+Startup.swift @@ -103,12 +103,6 @@ extension MainMenu { // Find out which services are active Log.info("The services manager knows about \(ServicesManager.shared.services.count) services.") - // Post-launch stats and update check, but only if not running tests - await performPostLaunchActions() - - // Check if the linked version has changed between launches of phpmon - PhpGuard().compareToLastGlobalVersion() - // We are ready! PhpEnvironments.shared.isBusy = false @@ -120,6 +114,9 @@ extension MainMenu { // Check if we upgraded from a previous version AppUpdater.checkIfUpdateWasPerformed() + + // Post-launch stats and update check, but only if not running tests + await performPostLaunchActions() } /** @@ -127,18 +124,24 @@ extension MainMenu { (This code is skipped when running SwiftUI previews.) */ private func performPostLaunchActions() async { - if !isRunningSwiftUIPreview { - Stats.incrementSuccessfulLaunchCount() - Stats.evaluateSponsorMessageShouldBeDisplayed() + if isRunningSwiftUIPreview { + return + } - if Stats.successfulLaunchCount == 1 { - Log.info("Should present the first launch screen!") - Task { @MainActor in - OnboardingWindowController.show() - } - } else { - await AppUpdater().checkForUpdates(userInitiated: false) + Stats.incrementSuccessfulLaunchCount() + Stats.evaluateSponsorMessageShouldBeDisplayed() + + if Stats.successfulLaunchCount == 1 { + Log.info("Should present the first launch screen!") + Task { @MainActor in + OnboardingWindowController.show() } + } else { + // Check for updates + await AppUpdater().checkForUpdates(userInitiated: false) + + // Check if the linked version has changed between launches of phpmon + await PhpGuard().compareToLastGlobalVersion() } } diff --git a/phpmon/Domain/Menu/StatusMenu+Driver.swift b/phpmon/Domain/Menu/StatusMenu+Driver.swift new file mode 100644 index 0000000..d74e093 --- /dev/null +++ b/phpmon/Domain/Menu/StatusMenu+Driver.swift @@ -0,0 +1,28 @@ +// +// StatusMenu+Driver.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 23/07/2025. +// Copyright © 2025 Nico Verbruggen. All rights reserved. +// + +import Cocoa + +extension StatusMenu { + @MainActor func addLiteModeMenuItem() { + addItems([ + NSMenuItem.separator(), + NSMenuItem(title: "mi_lite_mode".localized, action: #selector(MainMenu.openLiteModeInfo)) + ]) + } + + @MainActor func addValetVersionItem() { + if let version = Valet.shared.version { + addItems([ + NSMenuItem.separator(), + NSMenuItem(title: "mi_driver".localized("Valet \(version.text)"), + action: nil, customImage: "ValetDriverIcon") + ]) + } + } +} diff --git a/phpmon/Domain/Menu/StatusMenu+Items.swift b/phpmon/Domain/Menu/StatusMenu+Items.swift index 008da2d..2205f0a 100644 --- a/phpmon/Domain/Menu/StatusMenu+Items.swift +++ b/phpmon/Domain/Menu/StatusMenu+Items.swift @@ -103,13 +103,6 @@ extension StatusMenu { } } - @MainActor func addLiteModeMenuItem() { - addItems([ - NSMenuItem.separator(), - NSMenuItem(title: "mi_lite_mode".localized, action: #selector(MainMenu.openLiteModeInfo)) - ]) - } - @MainActor func addPreferencesMenuItems() { addItems([ @@ -331,13 +324,14 @@ extension StatusMenu { if Valet.installed { items.append(contentsOf: [ NSMenuItem.separator(), + HeaderView.asMenuItem(text: "Laravel Valet"), NSMenuItem(title: "mi_fix_my_valet".localized(PhpEnvironments.brewPhpAlias), action: #selector(MainMenu.fixMyValet), toolTip: "mi_fix_my_valet_tooltip".localized), NSMenuItem(title: "mi_fix_brew_permissions".localized(), action: #selector(MainMenu.fixHomebrewPermissions), toolTip: "mi_fix_brew_permissions_tooltip".localized), - NSMenuItem.separator(), + NSMenuItem.separator(), // SERVICES HeaderView.asMenuItem(text: "mi_services".localized), diff --git a/phpmon/Domain/Menu/StatusMenu.swift b/phpmon/Domain/Menu/StatusMenu.swift index 85ffc6e..5dbe8c9 100644 --- a/phpmon/Domain/Menu/StatusMenu.swift +++ b/phpmon/Domain/Menu/StatusMenu.swift @@ -66,7 +66,11 @@ class StatusMenu: NSMenu { addPreferencesMenuItems() - if !Valet.installed { + if Valet.installed { + // Add the menu item displaying the driver information + addValetVersionItem() + } else { + // No driver, using Standalone Mode (internally: lite mode) addLiteModeMenuItem() } diff --git a/phpmon/Domain/PHP/PhpGuard.swift b/phpmon/Domain/PHP/PhpGuard.swift index 55af936..420e061 100644 --- a/phpmon/Domain/PHP/PhpGuard.swift +++ b/phpmon/Domain/PHP/PhpGuard.swift @@ -23,7 +23,7 @@ class PhpGuard { Log.info("The currently linked version of PHP is: \(linked.version.short).") } - public func compareToLastGlobalVersion() { + public func compareToLastGlobalVersion() async { guard let currentVersion else { return } @@ -34,6 +34,7 @@ class PhpGuard { Stats.persistCurrentGlobalPhpVersion(version: currentVersion) return Log.warn("PHP Guard is saving the currently linked PHP version (first time only).") } + Log.info("Previously, the globally linked PHP version was: \(previousVersion).") if previousVersion == currentVersion { diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index cbca9cb..5ebd9f1 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -68,6 +68,7 @@ "mi_donate" = "Donate..."; "mi_check_for_updates" = "Check for Updates..."; "mi_lite_mode" = "About Standalone Mode..."; +"mi_driver" = "App Driver: %@"; "mi_quit" = "Quit PHP Monitor"; "mi_about" = "About PHP Monitor";