diff --git a/phpmon/Domain/Integrations/Valet/Valet.swift b/phpmon/Domain/Integrations/Valet/Valet.swift index 7de8420..5690c66 100644 --- a/phpmon/Domain/Integrations/Valet/Valet.swift +++ b/phpmon/Domain/Integrations/Valet/Valet.swift @@ -16,7 +16,7 @@ class Valet { var version: String /// The Valet configuration file. - var config: Valet.Configuration + var config: Valet.Configuration! /// A cached list of sites that were detected after analyzing the paths set up for Valet. var sites: [Site] = [] @@ -25,9 +25,11 @@ class Valet { var isBusy: Bool = false init() { - version = VersionExtractor.from(valet("--version")) - ?? "UNKNOWN" - + version = VersionExtractor.from(valet("--version")) ?? "UNKNOWN" + self.sites = [] + } + + public func loadConfiguration() { let file = FileManager.default.homeDirectoryForCurrentUser .appendingPathComponent(".config/valet/config.json") @@ -35,8 +37,6 @@ class Valet { Valet.Configuration.self, from: try! String(contentsOf: file, encoding: .utf8).data(using: .utf8)! ) - - self.sites = [] } public func startPreloadingSites() { diff --git a/phpmon/Domain/Menu/MainMenu+Startup.swift b/phpmon/Domain/Menu/MainMenu+Startup.swift index d418d7e..35434ba 100644 --- a/phpmon/Domain/Menu/MainMenu+Startup.swift +++ b/phpmon/Domain/Menu/MainMenu+Startup.swift @@ -71,6 +71,7 @@ extension MainMenu { // Attempt to find out more info about Valet Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version)") + Valet.shared.loadConfiguration() Valet.shared.validateVersion() Valet.shared.startPreloadingSites() diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 6cc17aa..c0b0504 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -219,10 +219,14 @@ You can do this by running `composer global update` in your terminal. After that "startup.errors.php_opt.title" = "PHP is not correctly installed"; "startup.errors.php_opt.desc" = "PHP alias was not found in `/usr/local/opt` or `/opt/homebrew/opt`. The app will not work correctly until you resolve this issue. If you already have the `php` formula installed, you may need to run `brew install php` in order for PHP Monitor to detect this installation."; -/// 3. Valet not installed +/// 3a. Valet not installed "startup.errors.valet_executable.title" = "Laravel Valet is not correctly installed"; "startup.errors.valet_executable.desc" = "You must install Valet with composer. Try running `which valet` in Terminal, it should return `/usr/local/bin/valet` or `/opt/homebrew/bin/valet`. The app will not work correctly until you resolve this issue. (PHP Monitor checks for the existence of `valet` in either of these paths.)"; +/// 3b. Valet configuration file missing +"startup.errors.valet_config.title" = "Laravel Valet configuration file missing"; +"startup.errors.valet_config.desc" = "PHP Monitor needs to be able to read the configuration file in `~/.config/valet/config.json`."; + /// 4. Brew & sudoers "startup.errors.sudoers_brew.title" = "Brew has not been added to sudoers.d"; "startup.errors.sudoers_brew.desc" = "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.";