From f3b1172d0ed186f27cda35e29d1a5a7c664d44f1 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 31 Mar 2022 13:35:23 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=80=20Version=205.2.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a bugfix release that fixes the isolation command (#158). --- PHP Monitor.xcodeproj/project.pbxproj | 8 ++++---- phpmon/Domain/SiteList/SiteListVC+Actions.swift | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index e6e7e4a..058c20d 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1324,7 +1324,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 756; + CURRENT_PROJECT_VERSION = 757; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -1334,7 +1334,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 5.2; + MARKETING_VERSION = 5.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1350,7 +1350,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 756; + CURRENT_PROJECT_VERSION = 757; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -1360,7 +1360,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 5.2; + MARKETING_VERSION = 5.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/phpmon/Domain/SiteList/SiteListVC+Actions.swift b/phpmon/Domain/SiteList/SiteListVC+Actions.swift index 2cdf79e..8f8f84a 100644 --- a/phpmon/Domain/SiteList/SiteListVC+Actions.swift +++ b/phpmon/Domain/SiteList/SiteListVC+Actions.swift @@ -78,7 +78,7 @@ extension SiteListVC { } @objc func isolateSite(sender: PhpMenuItem) { - let command = "cd '\(selectedSite!.absolutePath)' && sudo \(Paths.valet) isolate php@\(sender.version) && exit;" + let command = "sudo \(Paths.valet) isolate php@\(sender.version) --site '\(self.selectedSite!.name)' && exit;" self.performAction(command: command) { self.selectedSite!.determineIsolated() @@ -97,7 +97,7 @@ extension SiteListVC { } @objc func removeIsolatedSite() { - self.performAction(command: "cd '\(selectedSite!.absolutePath)' && sudo \(Paths.valet) unisolate && exit;") { + self.performAction(command: "sudo \(Paths.valet) unisolate --site '\(self.selectedSite!.name)' && exit;") { self.selectedSite!.isolatedPhpVersion = nil } } From df506e412844f9e92e0cfb95a3cb8965b7fc3d68 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Wed, 20 Apr 2022 12:19:02 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20Fix=20various=20minor=20issu?= =?UTF-8?q?es=20(discovered=20via=20#162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Renaming the configuration files from `www.conf` to the backup (`disabled-by-phpmon`) will now succeed if the `disabled-by-phpmon` file already exists. This would fail if the `disabled-by-phpmon` file already existed in previous builds. - The PHP-FPM alert when there's an issue with a missing socket configuration file has been tweaked and now contains a workaround if you want to run a newer version of PHP (e.g. PHP 8.2) that is not officially supported by Valet yet. - When attempting to list the PHP version numbers, the `parse()` method is now used, as opposed to `PhpVersionNumber.make()`, which couldn't correctly handle pre-release versions of PHP. - Updated tests to reflect these changes to `PhpVersionNumber`. --- PHP Monitor.xcodeproj/project.pbxproj | 8 ++++---- phpmon-tests/Versions/PhpVersionNumberTest.swift | 10 +++++++--- phpmon/Common/Helpers/VersionExtractor.swift | 2 +- phpmon/Common/PHP/PHP Version/PhpVersionNumber.swift | 2 +- phpmon/Common/PHP/Switcher/InternalSwitcher.swift | 4 ++++ phpmon/Domain/PHP/ActivePhpInstallation+Checks.swift | 3 ++- phpmon/Localizable.strings | 5 +++-- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 058c20d..88303ef 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1324,7 +1324,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 757; + CURRENT_PROJECT_VERSION = 760; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -1334,7 +1334,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 5.2.1; + MARKETING_VERSION = 5.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1350,7 +1350,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 757; + CURRENT_PROJECT_VERSION = 760; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -1360,7 +1360,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 5.2.1; + MARKETING_VERSION = 5.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/phpmon-tests/Versions/PhpVersionNumberTest.swift b/phpmon-tests/Versions/PhpVersionNumberTest.swift index 8ef2ac4..11b96e3 100644 --- a/phpmon-tests/Versions/PhpVersionNumberTest.swift +++ b/phpmon-tests/Versions/PhpVersionNumberTest.swift @@ -11,20 +11,24 @@ import XCTest class PhpVersionNumberTest: XCTestCase { func testCanDeconstructPhpVersion() throws { + XCTAssertEqual( + try! PhpVersionNumber.parse("PHP 8.2.0-dev"), + PhpVersionNumber(major: 8, minor: 2, patch: 0) + ) XCTAssertEqual( try! PhpVersionNumber.parse("PHP 8.1.0RC5-dev"), PhpVersionNumber(major: 8, minor: 1, patch: 0) ) XCTAssertEqual( - PhpVersionNumber.make(from: "8.0.11"), + try! PhpVersionNumber.parse("8.0.11"), PhpVersionNumber(major: 8, minor: 0, patch: 11) ) XCTAssertEqual( - PhpVersionNumber.make(from: "7.4.2"), + try! PhpVersionNumber.parse("7.4.2"), PhpVersionNumber(major: 7, minor: 4, patch: 2) ) XCTAssertEqual( - PhpVersionNumber.make(from: "7.4"), + try! PhpVersionNumber.parse("7.4"), PhpVersionNumber(major: 7, minor: 4, patch: nil) ) XCTAssertEqual( diff --git a/phpmon/Common/Helpers/VersionExtractor.swift b/phpmon/Common/Helpers/VersionExtractor.swift index 7ac49de..42e43b2 100644 --- a/phpmon/Common/Helpers/VersionExtractor.swift +++ b/phpmon/Common/Helpers/VersionExtractor.swift @@ -11,7 +11,7 @@ import Foundation class VersionExtractor { /** - This attempts to extract the version number from the command line output of Valet. + This attempts to extract the version number from any given string. */ public static func from(_ string: String) -> String? { do { diff --git a/phpmon/Common/PHP/PHP Version/PhpVersionNumber.swift b/phpmon/Common/PHP/PHP Version/PhpVersionNumber.swift index 1461df6..a938452 100644 --- a/phpmon/Common/PHP/PHP Version/PhpVersionNumber.swift +++ b/phpmon/Common/PHP/PHP Version/PhpVersionNumber.swift @@ -13,7 +13,7 @@ public struct PhpVersionNumberCollection: Equatable { public static func make(from versions: [String]) -> Self { return PhpVersionNumberCollection( - versions: versions.map { PhpVersionNumber.make(from: $0)! } + versions: versions.map { try! PhpVersionNumber.parse($0) } ) } diff --git a/phpmon/Common/PHP/Switcher/InternalSwitcher.swift b/phpmon/Common/PHP/Switcher/InternalSwitcher.swift index e690cf9..417da35 100644 --- a/phpmon/Common/PHP/Switcher/InternalSwitcher.swift +++ b/phpmon/Common/PHP/Switcher/InternalSwitcher.swift @@ -71,6 +71,10 @@ class InternalSwitcher: PhpSwitcher { let existing = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf")! let new = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf.disabled-by-phpmon")! do { + if (FileManager.default.fileExists(atPath: new.path)) { + Log.info("A moved `www.conf.disabled-by-phpmon` file was found for PHP \(version), cleaning up so the newer `www.conf` can be moved again.") + try FileManager.default.removeItem(at: new) + } try FileManager.default.moveItem(at: existing, to: new) Log.info("Success: A default `www.conf` file was disabled for PHP \(version).") } catch { diff --git a/phpmon/Domain/PHP/ActivePhpInstallation+Checks.swift b/phpmon/Domain/PHP/ActivePhpInstallation+Checks.swift index 50dc957..437e656 100644 --- a/phpmon/Domain/PHP/ActivePhpInstallation+Checks.swift +++ b/phpmon/Domain/PHP/ActivePhpInstallation+Checks.swift @@ -24,7 +24,8 @@ extension ActivePhpInstallation { BetterAlert() .withInformation( title: "alert.php_fpm_broken.title".localized, - subtitle: "alert.php_fpm_broken.info".localized + subtitle: "alert.php_fpm_broken.info".localized, + description: "alert.php_fpm_broken.description".localized ) .withPrimary(text: "OK") .show() diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 75f36ee..b1558b3 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -262,8 +262,9 @@ problem manually, using your own Terminal app (this just shows you the output)." "alert.fix_homebrew_permissions_done.desc" = "When you are done with Homebrew (after running `brew upgrade`, for example) you should restart PHP Monitor and select \"Restart All Services\" if you want Valet to work again. It is always recommended to restart PHP Monitor whenever you upgrade PHP versions with `brew upgrade`, or things might break."; // PHP FPM Broken -"alert.php_fpm_broken.title" = "PHP-FPM configuration is incorrect"; -"alert.php_fpm_broken.info" = "PHP Monitor has determined that there are issues with your PHP-FPM config: it's not pointing to the Valet socket. This will result in 502 Bad Gateway if you visit websites linked via Valet.\n\nYou can usually fix this by running\n`valet install`, which updates your\n PHP-FPM configuration."; +"alert.php_fpm_broken.title" = "Your PHP-FPM configuration is not pointing at the Valet socket!"; +"alert.php_fpm_broken.info" = "PHP Monitor has determined that there are issues with your PHP-FPM config. This will result in '502 Bad Gateway' responses if you visit websites linked via Valet."; +"alert.php_fpm_broken.description" = "If it's been a while, you can usually fix this by running `valet install`, which updates your PHP-FPM configuration.\n\nIf you are seeing this message and you are trying to run a pre-release version of PHP, it is possible that Valet does not support this pre-release version of PHP yet.\n\nIf that is the case, you can try the following workaround: edit the file at `~/.composer/vendor/laravel/valet/cli/Valet/Brew.php` and add e.g. `php@8.2` to the `SUPPORTED_PHP_VERSIONS` array. After editing the file, try running `valet install`. (This will, if all goes well, set up all the required Valet configuration files.)"; // PHP Monitor Cannot Start "alert.cannot_start.title" = "PHP Monitor cannot start due to a configuration problem"; From 3cff2d6469fd592ad493db4b5b59d1f1ca2a7125 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Wed, 20 Apr 2022 22:31:20 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20Fix=20issue=20w/=20flag=20ev?= =?UTF-8?q?aluation=20order=20(#165)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 4 ++-- phpmon/Domain/Menu/MainMenu+Startup.swift | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 88303ef..f426176 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1324,7 +1324,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 760; + CURRENT_PROJECT_VERSION = 761; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -1350,7 +1350,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 760; + CURRENT_PROJECT_VERSION = 761; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; diff --git a/phpmon/Domain/Menu/MainMenu+Startup.swift b/phpmon/Domain/Menu/MainMenu+Startup.swift index b0bf4da..8849dee 100644 --- a/phpmon/Domain/Menu/MainMenu+Startup.swift +++ b/phpmon/Domain/Menu/MainMenu+Startup.swift @@ -29,8 +29,18 @@ extension MainMenu { When the environment is all clear and the app can run, let's go. */ private func onEnvironmentPass() { + // Attempt to find out more info about Valet + if Valet.shared.version != nil { + Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!)") + } + + // Validate the version (this will enforce which versions of PHP are supported) + Valet.shared.validateVersion() + + // Actually detect the PHP versions PhpEnv.detectPhpVersions() + // Check for an alias conflict if HomebrewDiagnostics.hasAliasConflict() { DispatchQueue.main.async { BetterAlert() @@ -71,12 +81,7 @@ extension MainMenu { // Load the global hotkey App.shared.loadGlobalHotkey() - // Attempt to find out more info about Valet - if Valet.shared.version != nil { - Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!)") - } - - Valet.shared.validateVersion() + // Preload sites Valet.shared.startPreloadingSites() if (Valet.shared.config.tld != "test") {