mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-08 05:30:05 +01:00
🐛 Check for platform issue after switch (#178)
This commit is contained in:
@@ -201,23 +201,26 @@ class Startup {
|
|||||||
// =================================================================================
|
// =================================================================================
|
||||||
// Determine that Valet works correctly (no issues in platform detected)
|
// Determine that Valet works correctly (no issues in platform detected)
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
|
/*
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: {
|
command: {
|
||||||
let output = valet("--version", sudo: false)
|
return valet("--version", sudo: false)
|
||||||
return output.contains("Composer detected issues in your platform")
|
.contains("Composer detected issues in your platform")
|
||||||
},
|
},
|
||||||
name: "`no global composer issues",
|
name: "`no global composer issues",
|
||||||
titleText: "startup.errors.global_composer_platform_issues.title".localized,
|
titleText: "startup.errors.global_composer_platform_issues.title".localized,
|
||||||
subtitleText: "startup.errors.global_composer_platform_issues.subtitle".localized,
|
subtitleText: "startup.errors.global_composer_platform_issues.subtitle".localized,
|
||||||
descriptionText: "startup.errors.global_composer_platform_issues.desc".localized
|
descriptionText: "startup.errors.global_composer_platform_issues.desc".localized
|
||||||
),
|
),
|
||||||
|
*/
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
// Determine the Valet version and ensure it isn't unknown.
|
// Determine the Valet version and ensure it isn't unknown.
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
EnvironmentCheck(
|
EnvironmentCheck(
|
||||||
command: {
|
command: {
|
||||||
Valet.shared.version = VersionExtractor.from(valet("--version", sudo: false))
|
let output = valet("--version", sudo: false)
|
||||||
return Valet.shared.version == nil
|
Valet.shared.version = VersionExtractor.from(output)
|
||||||
|
return Valet.shared.version == nil && output.contains("Laravel Valet")
|
||||||
},
|
},
|
||||||
name: "`valet --version` was loaded",
|
name: "`valet --version` was loaded",
|
||||||
titleText: "startup.errors.valet_version_unknown.title".localized,
|
titleText: "startup.errors.valet_version_unknown.title".localized,
|
||||||
|
|||||||
@@ -183,6 +183,11 @@ class Valet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func hasPlatformIssues() -> Bool {
|
||||||
|
return valet("--version", sudo: false)
|
||||||
|
.contains("Composer detected issues in your platform")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a count of how many sites are linked and parked.
|
Returns a count of how many sites are linked and parked.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -39,11 +39,16 @@ extension MainMenu {
|
|||||||
self.notifyAboutVersionChange(to: version)
|
self.notifyAboutVersionChange(to: version)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
self.notifyAboutVersionChange(to: version)
|
self.notifyAboutVersionChange(to: version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if Valet still works correctly
|
||||||
|
if Valet.shared.hasPlatformIssues() {
|
||||||
|
Log.info("Composer platform issue(s) detected.")
|
||||||
|
self.suggestFixMyComposer()
|
||||||
|
}
|
||||||
|
|
||||||
// Update stats
|
// Update stats
|
||||||
Stats.incrementSuccessfulSwitchCount()
|
Stats.incrementSuccessfulSwitchCount()
|
||||||
Stats.evaluateSponsorMessageShouldBeDisplayed()
|
Stats.evaluateSponsorMessageShouldBeDisplayed()
|
||||||
@@ -65,6 +70,24 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func suggestFixMyComposer() {
|
||||||
|
BetterAlert().withInformation(
|
||||||
|
title: "alert.global_composer_platform_issues.title".localized,
|
||||||
|
subtitle: "alert.global_composer_platform_issues.subtitle".localized,
|
||||||
|
description: "alert.global_composer_platform_issues.desc".localized
|
||||||
|
)
|
||||||
|
.withPrimary(text: "alert.global_composer_platform_issues.buttons.update".localized, action: { alert in
|
||||||
|
alert.close(with: .OK)
|
||||||
|
self.updateGlobalComposerDependencies()
|
||||||
|
})
|
||||||
|
.withSecondary(text: "", action: nil)
|
||||||
|
.withTertiary(text: "alert.global_composer_platform_issues.buttons.quit".localized, action: { alert in
|
||||||
|
alert.close(with: .OK)
|
||||||
|
self.terminateApp()
|
||||||
|
})
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
private func reloadDomainListData() {
|
private func reloadDomainListData() {
|
||||||
if let window = App.shared.domainListWindowController {
|
if let window = App.shared.domainListWindowController {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|||||||
@@ -388,6 +388,13 @@ You can do this by running `composer global update` in your terminal. After that
|
|||||||
"alert.php_switch_unavailable.info" = "Please make sure PHP %@ is installed and you can switch to it in the dropdown. Currently supported versions include PHP: %@.";
|
"alert.php_switch_unavailable.info" = "Please make sure PHP %@ is installed and you can switch to it in the dropdown. Currently supported versions include PHP: %@.";
|
||||||
"alert.php_switch_unavailable.ok" = "OK";
|
"alert.php_switch_unavailable.ok" = "OK";
|
||||||
|
|
||||||
|
// Composer issues
|
||||||
|
"alert.global_composer_platform_issues.title" = "Composer detected issues in your platform";
|
||||||
|
"alert.global_composer_platform_issues.subtitle" = "The version of PHP you switched to is too old for the global Composer dependencies you have installed. These dependencies will need to be updated.";
|
||||||
|
"alert.global_composer_platform_issues.desc" = "The easiest way to prevent this issue from occurring in the future is to switch to the oldest PHP version you have installed and to run `composer global update` again. \n\nAlternatively, you can choose the 'Automatically update global dependencies' option in Preferences to avoid this issue as well.";
|
||||||
|
"alert.global_composer_platform_issues.buttons.update" = "Update Global Dependencies";
|
||||||
|
"alert.global_composer_platform_issues.buttons.quit" = "Quit PHP Monitor";
|
||||||
|
|
||||||
// Revert
|
// Revert
|
||||||
"alert.revert_description.title" = "Revert Configuration?";
|
"alert.revert_description.title" = "Revert Configuration?";
|
||||||
"alert.revert_description.subtitle" = "PHP Monitor can revert to the previous configuration that was active. Here's what will be applied: \n\n%@";
|
"alert.revert_description.subtitle" = "PHP Monitor can revert to the previous configuration that was active. Here's what will be applied: \n\n%@";
|
||||||
|
|||||||
Reference in New Issue
Block a user