diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index c54e306..bb1c865 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -3299,7 +3299,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1200; + CURRENT_PROJECT_VERSION = 1205; DEAD_CODE_STRIPPING = YES; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; @@ -3329,7 +3329,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1200; + CURRENT_PROJECT_VERSION = 1205; DEAD_CODE_STRIPPING = YES; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; @@ -3558,7 +3558,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1200; + CURRENT_PROJECT_VERSION = 1205; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3669,7 +3669,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1200; + CURRENT_PROJECT_VERSION = 1205; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3780,7 +3780,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1200; + CURRENT_PROJECT_VERSION = 1205; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3953,7 +3953,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1200; + CURRENT_PROJECT_VERSION = 1205; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; diff --git a/phpmon/Common/PHP/PHP Version/PhpHelper.swift b/phpmon/Common/PHP/PHP Version/PhpHelper.swift index b248bb1..be41b47 100644 --- a/phpmon/Common/PHP/PHP Version/PhpHelper.swift +++ b/phpmon/Common/PHP/PHP Version/PhpHelper.swift @@ -50,16 +50,7 @@ class PhpHelper { .resolvingSymlinksInPath().path // The contents of the script! - let script = """ - #!/bin/zsh - # \(keyPhrase) - # It reflects the location of PHP \(version)'s binaries on your system. - # Usage: . pm\(dotless) - [[ $ZSH_EVAL_CONTEXT =~ :file$ ]] \\ - && echo "PHP Monitor has enabled this terminal to use PHP \(version)." \\ - || echo "You must run '. pm\(dotless)' (or 'source pm\(dotless)') instead!"; - export PATH=\(path):$PATH - """ + let script = script(path, keyPhrase, version, dotless) Task { @MainActor in try FileSystem.writeAtomicallyToFile(destination, content: script) @@ -87,6 +78,24 @@ class PhpHelper { } } + private static func script( + _ path: String, + _ keyPhrase: String, + _ version: String, + _ dotless: String + ) -> String { + return """ + #!/bin/zsh + # \(keyPhrase) + # It reflects the location of PHP \(version)'s binaries on your system. + # Usage: . pm\(dotless) + [[ $ZSH_EVAL_CONTEXT =~ :file$ ]] \\ + && echo "PHP Monitor has enabled this terminal to use PHP \(version)." \\ + || echo "You must run '. pm\(dotless)' (or 'source pm\(dotless)') instead!"; + export PATH=\(path):$PATH + """ + } + private static func createSymlink(_ dotless: String) async { let source = "\(Paths.homePath)/.config/phpmon/bin/pm\(dotless)" let destination = "/usr/local/bin/pm\(dotless)" diff --git a/phpmon/Domain/Menu/MainMenu+Actions.swift b/phpmon/Domain/Menu/MainMenu+Actions.swift index b94f5df..2cbcdef 100644 --- a/phpmon/Domain/Menu/MainMenu+Actions.swift +++ b/phpmon/Domain/Menu/MainMenu+Actions.swift @@ -18,6 +18,19 @@ extension MainMenu { } } + @MainActor @objc func displayUnlinkedInfo() { + Task { @MainActor in + BetterAlert() + .withInformation( + title: "phpman.unlinked.title".localized, + subtitle: "phpman.unlinked.desc".localized, + description: "phpman.unlinked.detail".localized + ) + .withPrimary(text: "generic.ok".localized) + .show() + } + } + @MainActor @objc func fixHomebrewPermissions() { if !BetterAlert() .withInformation( diff --git a/phpmon/Domain/Menu/StatusMenu+Items.swift b/phpmon/Domain/Menu/StatusMenu+Items.swift index b8bc49b..59e8dd3 100644 --- a/phpmon/Domain/Menu/StatusMenu+Items.swift +++ b/phpmon/Domain/Menu/StatusMenu+Items.swift @@ -16,10 +16,9 @@ extension StatusMenu { if PhpEnv.phpInstall == nil { addItem(HeaderView.asMenuItem(text: "⚠️ " + "mi_no_php_linked".localized, minimumWidth: 280)) addItems([ - // TODO: Make sure these buttons do something NSMenuItem.separator(), NSMenuItem(title: "mi_fix_php_link".localized, action: #selector(MainMenu.linkPhpBinary)), - NSMenuItem(title: "mi_no_php_linked_explain".localized) + NSMenuItem(title: "mi_no_php_linked_explain".localized, action: #selector(MainMenu.displayUnlinkedInfo)) ]) return } diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index a6857f4..8e9ee6a 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -90,8 +90,8 @@ // PHPMAN -"phpman.title" = "PHP Manager"; -"phpman.description" = "**PHP Manager** lets you install different PHP versions via Homebrew."; +"phpman.title" = "PHP Version Manager"; +"phpman.description" = "**PHP Version Manager** lets you install different PHP versions via Homebrew."; "phpman.disclaimer" = "Please note that installing or upgrading PHP versions may cause other Homebrew packages to be upgraded as well, but only if Homebrew would otherwise have broken those other packages via a shared dependency. (More in the FAQ!)"; "phpman.refresh.button" = "Search for Updates"; "phpman.refresh.button.description" = "You can press this button to check (again) if any updates are available to installed PHP versions. When you first open this window, PHP Monitor already does this check."; @@ -105,6 +105,10 @@ "phpman.failures.uninstall.title" = "Uninstall failed!"; "phpman.failures.uninstall.desc" = "Unfortunately, the automatic uninstallation failed. You can manually try to run this command: `%@` and find out what goes wrong. Remember to restart PHP Monitor (or press the refresh button) when this is done."; +"phpman.unlinked.title" = "None of the versions of PHP installed on your system are currently linked."; +"phpman.unlinked.desc" = "You likely still have some version of PHP that is currently installed, but currently no version of PHP is linked."; +"phpman.unlinked.detail" = "Without any PHP version linked, the `php` binary is not accessible on your system and you cannot run any PHP scripts without explicitly being part of the PATH. You can have PHP Monitor automatically resolve this problem (choose Fix Automatically in the main menu), or fix it yourself by running `brew link php --force`."; + // GENERIC "generic.ok" = "OK";