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

👌 Finalize PHP Guard functionality

This commit is contained in:
2023-01-10 17:53:55 +01:00
parent 3c946a53e8
commit 6eea08cd4f
7 changed files with 47 additions and 27 deletions

View File

@ -2799,7 +2799,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1000;
CURRENT_PROJECT_VERSION = 1020;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -2828,7 +2828,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1000;
CURRENT_PROJECT_VERSION = 1020;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -3056,7 +3056,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1000;
CURRENT_PROJECT_VERSION = 1020;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
@ -3166,7 +3166,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1000;
CURRENT_PROJECT_VERSION = 1020;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;

View File

@ -172,6 +172,9 @@ class PhpEnv {
public func validate(_ version: String) -> Bool {
if self.currentInstall.version.short == version {
Log.info("Switching to version \(version) seems to have succeeded. Validation passed.")
Log.info("Keeping track that this is the new version!")
Stats.persistCurrentGlobalPhpVersion(version: version)
return true
}

View File

@ -51,9 +51,6 @@ class InternalSwitcher: PhpSwitcher {
await brew("services restart nginx", sudo: true)
Log.info("The new version(s) have been linked!")
// Persist which formula is linked so we can check at launch
Stats.persistCurrentGlobalPhpVersion(version: PhpEnv.phpInstall.formula)
})
}

View File

@ -53,19 +53,7 @@ class InterApp {
Task { MainMenu.shared.openPhpInfo() }
}),
InterApp.Action(command: "switch/php/", action: { version in
if PhpEnv.shared.availablePhpVersions.contains(version) {
Task { MainMenu.shared.switchToPhpVersion(version) }
} else {
Task {
BetterAlert().withInformation(
title: "alert.php_switch_unavailable.title".localized,
subtitle: "alert.php_switch_unavailable.subtitle".localized(version)
).withPrimary(
text: "alert.php_switch_unavailable.ok".localized
).show()
}
}
Task { MainMenu.shared.switchToAnyPhpVersion(version) }
})
]}
}

View File

@ -231,6 +231,21 @@ extension MainMenu {
self.switchToPhpVersion(sender.version)
}
public func switchToAnyPhpVersion(_ version: String) {
if PhpEnv.shared.availablePhpVersions.contains(version) {
Task { MainMenu.shared.switchToPhpVersion(version) }
} else {
Task {
BetterAlert().withInformation(
title: "alert.php_switch_unavailable.title".localized,
subtitle: "alert.php_switch_unavailable.subtitle".localized(version)
).withPrimary(
text: "alert.php_switch_unavailable.ok".localized
).show()
}
}
}
@objc func switchToPhpVersion(_ version: String) {
setBusyImage()
PhpEnv.shared.isBusy = true

View File

@ -145,8 +145,6 @@ class Stats {
let currentVersion = PhpEnv.phpInstall.version.short
let previousVersion = Stats.lastGlobalPhpVersion
// TODO: Add a preference to disable this
// Save the PHP version that is currently in use (only if unknown)
if Stats.lastGlobalPhpVersion == "" {
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
@ -159,15 +157,27 @@ class Stats {
BetterAlert()
.withInformation(
title: "startup.version_mismatch.title".localized,
subtitle: "startup.version_mismatch.subtitle".localized,
description: "startup.version_mismatch.desc".localized
subtitle: "startup.version_mismatch.subtitle".localized(
currentVersion,
previousVersion
),
description: "startup.version_mismatch.desc".localized()
)
.withPrimary(text: "OK")
// TODO: Add secondary button to switch to that version (if possible)
.withPrimary(text: "startup.version_mismatch.button_switch_back".localized(
previousVersion
), action: { alert in
alert.close(with: .OK)
Task { MainMenu.shared.switchToAnyPhpVersion(previousVersion) }
})
.withTertiary(text: "startup.version_mismatch.button_stay".localized(
currentVersion
), action: { alert in
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
alert.close(with: .OK)
})
.show()
}
}
}
}
}

View File

@ -540,6 +540,13 @@ If you are seeing this message but are confused why this folder has gone missing
"startup.errors.which_alias_issue.subtitle" = "It appears that there's a file in `/usr/local/bin/which`. This is usually set up by NodeJS, but `node` isn't in the PATH in `/usr/local/bin`. To fix this, keep reading.";
"startup.errors.which_alias_issue.desc" = "You will need to symlink `node` into the `/usr/local/bin` directory to make sure PHP Monitor can start successfully. For more info, see: https://github.com/nicoverbruggen/phpmon/issues/174";
// Warning about a different PHP version linked than last time
"startup.version_mismatch.title" = "Your active PHP version has changed.";
"startup.version_mismatch.subtitle" = "Since PHP Monitor was last active, your linked PHP version has been changed to PHP %@. Would you like to switch back to PHP %@, or do you want to keep using the current version?";
"startup.version_mismatch.desc" = "PHP Monitor keeps track of which version of PHP is globally linked. The global version may have been changed due to some other program or Homebrew may have linked a different formula after upgrades.";
"startup.version_mismatch.button_switch_back" = "Switch back to PHP %@";
"startup.version_mismatch.button_stay" = "Keep using PHP %@";
// SPONSOR ENCOURAGEMENT
"startup.sponsor_encouragement.title" = "If PHP Monitor has been useful to you or your company, please consider leaving a tip.";