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

👌 Delayed loading of config.json

This commit is contained in:
2022-01-26 19:47:00 +01:00
parent c4772db808
commit a2b25e31ca
3 changed files with 12 additions and 7 deletions

View File

@ -16,7 +16,7 @@ class Valet {
var version: String var version: String
/// The Valet configuration file. /// 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. /// A cached list of sites that were detected after analyzing the paths set up for Valet.
var sites: [Site] = [] var sites: [Site] = []
@ -25,9 +25,11 @@ class Valet {
var isBusy: Bool = false var isBusy: Bool = false
init() { init() {
version = VersionExtractor.from(valet("--version")) version = VersionExtractor.from(valet("--version")) ?? "UNKNOWN"
?? "UNKNOWN" self.sites = []
}
public func loadConfiguration() {
let file = FileManager.default.homeDirectoryForCurrentUser let file = FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent(".config/valet/config.json") .appendingPathComponent(".config/valet/config.json")
@ -35,8 +37,6 @@ class Valet {
Valet.Configuration.self, Valet.Configuration.self,
from: try! String(contentsOf: file, encoding: .utf8).data(using: .utf8)! from: try! String(contentsOf: file, encoding: .utf8).data(using: .utf8)!
) )
self.sites = []
} }
public func startPreloadingSites() { public func startPreloadingSites() {

View File

@ -71,6 +71,7 @@ extension MainMenu {
// Attempt to find out more info about Valet // Attempt to find out more info about Valet
Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version)") Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version)")
Valet.shared.loadConfiguration()
Valet.shared.validateVersion() Valet.shared.validateVersion()
Valet.shared.startPreloadingSites() Valet.shared.startPreloadingSites()

View File

@ -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.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."; "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.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.)"; "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 /// 4. Brew & sudoers
"startup.errors.sudoers_brew.title" = "Brew has not been added to sudoers.d"; "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."; "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.";