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

👌 Updated menu

This commit is contained in:
2022-06-14 23:13:41 +02:00
parent 1fe086d53e
commit 721bb32087
5 changed files with 23 additions and 1 deletions

View File

@ -111,6 +111,12 @@ class Actions {
NSWorkspace.shared.activateFileViewerSelecting([file] as [URL])
}
public static func openPhpMonitorConfigFile() {
let file = FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent(".config/phpmon")
NSWorkspace.shared.activateFileViewerSelecting([file] as [URL])
}
// MARK: - Other Actions
public static func createTempPhpInfoFile() -> URL {

View File

@ -220,6 +220,10 @@ extension MainMenu {
Actions.openPhpConfigFolder(version: PhpEnv.phpInstall.version.short)
}
@objc func openPhpMonitorConfigurationFile() {
Actions.openPhpMonitorConfigFile()
}
@objc func openGlobalComposerFolder() {
Actions.openGlobalComposerFolder()
}

View File

@ -21,6 +21,10 @@ extension StatusMenu {
self.addItem(
NSMenuItem(title: "mi_phpinfo".localized, action: #selector(MainMenu.openPhpInfo), keyEquivalent: "i")
)
self.addItem(
NSMenuItem(title: "mi_phpmon_config".localized,
action: #selector(MainMenu.openPhpMonitorConfigurationFile), keyEquivalent: "y")
)
}
func addComposerMenuItems() {
@ -194,6 +198,7 @@ extension StatusMenu {
let services = NSMenuItem(title: "mi_other".localized, action: nil, keyEquivalent: "")
let servicesMenu = NSMenu()
servicesMenu.addItem(HeaderView.asMenuItem(text: "mi_first_aid".localized))
let fixMyValetMenuItem = NSMenuItem(
title: "mi_fix_my_valet".localized(PhpEnv.brewPhpVersion),
action: #selector(MainMenu.fixMyValet), keyEquivalent: ""

View File

@ -211,9 +211,16 @@ class Preferences {
// MARK: - Custom Preferences
private func loadCustomPreferences() {
// Ensure the configuration directory is created if missing
Shell.run("mkdir -p ~/.config/phpmon")
// Move the legacy file
moveOutdatedConfigurationFile()
// Attempt to load the file if it exists
let url = URL(fileURLWithPath: "/Users/\(Paths.whoami)/.config/phpmon/config.json")
if Filesystem.fileExists(url.path) {
Log.info("A custom ~/.config/phpmon/config.json file was found. Attempting to parse...")
loadCustomPreferencesFile(url)
} else {
@ -224,7 +231,6 @@ class Preferences {
private func moveOutdatedConfigurationFile() {
if Filesystem.fileExists("~/.phpmon.conf.json") && !Filesystem.fileExists("~/.config/phpmon/config.json") {
Log.info("An outdated configuration file was found. Moving it...")
Shell.run("mkdir -p ~/.config/phpmon")
Shell.run("mv ~/.phpmon.conf.json ~/.config/phpmon/config.json")
Log.info("The configuration file was moved successfully!")
}

View File

@ -48,6 +48,7 @@
"mi_composer" = "Composer";
"mi_valet_config" = "Locate Valet Folder (.config/valet)";
"mi_php_config" = "Locate PHP Configuration File (php.ini)";
"mi_phpmon_config" = "Locate PHP Monitor Folder (.config/phpmon)";
"mi_global_composer" = "Locate Global Composer File (.composer)";
"mi_phpinfo" = "Show Current Configuration (phpinfo)";
"mi_update_global_composer" = "Update Global Composer Dependencies...";