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

👌 Check if Valet version is supported

This commit is contained in:
2023-01-07 13:24:52 +01:00
parent 27894e4884
commit d05f39efe7
6 changed files with 33 additions and 3 deletions

View File

@ -42,7 +42,7 @@ class ActivePhpInstallation {
do {
try determineVersion()
} catch {
#warning("In future versions of PHP Monitor, this should not crash")
// TODO: In future versions of PHP Monitor, this should not crash
fatalError("Could not determine or parse PHP version; aborting")
}

View File

@ -92,7 +92,7 @@ class PhpEnv {
var versionsOnly = await extractPhpVersions(
from: files.components(separatedBy: "\n"),
supported: Constants.ValetSupportedPhpVersionMatrix[Valet.shared.version.major]!
supported: Constants.ValetSupportedPhpVersionMatrix[Valet.shared.version.major] ?? []
)
// Make sure the aliased version is detected

View File

@ -250,6 +250,20 @@ class Startup {
titleText: "startup.errors.valet_version_unknown.title".localized,
subtitleText: "startup.errors.valet_version_unknown.subtitle".localized,
descriptionText: "startup.errors.valet_version_unknown.desc".localized
),
// =================================================================================
// Ensure the Valet version is supported.
// =================================================================================
EnvironmentCheck(
command: {
// We currently support Valet 2, 3 or 4. Any other version should get an alert.
return ![2, 3, 4].contains(Valet.shared.version.major)
},
name: "valet version is supported",
titleText: "startup.errors.valet_version_not_supported.title".localized,
subtitleText: "startup.errors.valet_version_not_supported.subtitle".localized(Valet.shared.version.text),
descriptionText: "startup.errors.valet_version_not_supported.desc".localized
)
]
}

View File

@ -149,7 +149,6 @@ class Valet {
Log.info("You are running Valet v\(version.major). Support for site isolation is available.")
self.features.append(.isolatedSites)
default:
#warning("An alert should be presented here")
Log.err("This version of Valet is not supported.")
}
}

View File

@ -501,6 +501,11 @@ You can do this by running `composer global update` in your terminal. After that
If you are seeing this message but are confused why this folder has gone missing, then you may want to investigate why it is gone—it shouldn't just disappear and it means your Valet installation is broken.";
// Valet version too new or old
"startup.errors.valet_version_not_supported.title" = "This version of Valet is not supported";
"startup.errors.valet_version_not_supported.subtitle" = "You are running a version of Valet that is currently not supported (%@). PHP Monitor currently works with Valet v2, v3 and v4. In order to avoid causing issues on your system, PHP Monitor cannot start.";
"startup.errors.valet_version_not_supported.desc" = "You must install a version of Valet that is compatible with PHP Monitor, or you may need to upgrade to a newer version of PHP Monitor which may include compatibility for this version of Valet (consult the latest release notes for more info).";
/// Brew & sudoers
"startup.errors.sudoers_brew.title" = "Brew has not been added to sudoers.d";
"startup.errors.sudoers_brew.subtitle" = "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.";

View File

@ -60,6 +60,18 @@ final class StartupTest: UITestCase {
click(app.buttons["generic.ok".localized])
}
final func test_get_warning_about_unsupported_valet_version() throws {
var configuration = TestableConfigurations.working
configuration.shellOutput["valet --version"] = .instant("Laravel Valet 5.0")
let app = XCPMApplication()
app.withConfiguration(configuration)
app.launch()
assertExists(app.staticTexts["startup.errors.valet_version_not_supported.title".localized], 3.0)
click(app.buttons["generic.ok".localized])
}
final func test_can_open_status_menu_item() throws {
let app = XCPMApplication()
app.withConfiguration(TestableConfigurations.working)