mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
♻️ Rename PhpEnv to PhpEnvironments
This commit is contained in:
@ -72,8 +72,8 @@
|
||||
C40B24F427A310830018C7D2 /* StatusMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47331A1247093B7009A0597 /* StatusMenu.swift */; };
|
||||
C40C5C9C2846A40600E28255 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C5C9B2846A40600E28255 /* Preset.swift */; };
|
||||
C40C5C9D2846A40600E28255 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C5C9B2846A40600E28255 /* Preset.swift */; };
|
||||
C40C7F1E2772136000DDDCDC /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
||||
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
||||
C40C7F1E2772136000DDDCDC /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||
C40C7F1F2772136000DDDCDC /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||
C40C7F2827721FF600DDDCDC /* Valet+Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */; };
|
||||
C40C7F2927721FF600DDDCDC /* Valet+Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */; };
|
||||
C40C7F3027722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
|
||||
@ -288,10 +288,10 @@
|
||||
C471E7EF28F9BAC30021E251 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415D3B62770F294005EF286 /* Actions.swift */; };
|
||||
C471E7F028F9BAC30021E251 /* Paths.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5853B2770FE3900DA4FBE /* Paths.swift */; };
|
||||
C471E7F128F9BAC70021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||
C471E7F228F9BAC70021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
||||
C471E7F228F9BAC70021E251 /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||
C471E7F328F9BAC70021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
||||
C471E7F428F9BAC80021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
||||
C471E7F528F9BAC80021E251 /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||
C471E7F628F9BAC80021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
||||
C471E7F728F9BACB0021E251 /* PhpSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */; };
|
||||
C471E7F828F9BACB0021E251 /* InternalSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADC7277611A0007277F4 /* InternalSwitcher.swift */; };
|
||||
@ -876,7 +876,7 @@
|
||||
C40934A6298EEB8700D25014 /* phpmon-dev.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = "phpmon-dev.rb"; sourceTree = "<group>"; };
|
||||
C40934AA298EEDA900D25014 /* CaskFileParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaskFileParserTest.swift; sourceTree = "<group>"; };
|
||||
C40C5C9B2846A40600E28255 /* Preset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preset.swift; sourceTree = "<group>"; };
|
||||
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpEnv.swift; sourceTree = "<group>"; };
|
||||
C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpEnvironments.swift; sourceTree = "<group>"; };
|
||||
C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Valet+Alerts.swift"; sourceTree = "<group>"; };
|
||||
C40C7F2F27722E8D00DDDCDC /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||
C40D72592A018ACC0054A067 /* PhpFormulaeStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpFormulaeStatus.swift; sourceTree = "<group>"; };
|
||||
@ -1654,7 +1654,7 @@
|
||||
children = (
|
||||
C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */,
|
||||
C4CE7F9529683B43000102CF /* PhpVersionNumberCollection.swift */,
|
||||
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */,
|
||||
C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */,
|
||||
C4D936C827E3EB6100BD69FE /* PhpHelper.swift */,
|
||||
);
|
||||
path = "PHP Version";
|
||||
@ -2427,7 +2427,7 @@
|
||||
C4D3660B29113F20006BD146 /* System.swift in Sources */,
|
||||
C4D36601291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||
C4EED88927A48778006D7272 /* InterAppHandler.swift in Sources */,
|
||||
C40C7F1E2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
||||
C40C7F1E2772136000DDDCDC /* PhpEnvironments.swift in Sources */,
|
||||
C4B79EB629CA387F00A483EE /* BrewFormulaeHandler.swift in Sources */,
|
||||
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
|
||||
C474B00624C0E98C00066A22 /* LocalNotification.swift in Sources */,
|
||||
@ -2626,7 +2626,7 @@
|
||||
C490E3B929BCA368006D2DE6 /* App+BrewWatch.swift in Sources */,
|
||||
C471E7FF28F9BAD10021E251 /* Xdebug.swift in Sources */,
|
||||
C409349F298EE8E900D25014 /* AppUpdater.swift in Sources */,
|
||||
C471E7F228F9BAC70021E251 /* PhpEnv.swift in Sources */,
|
||||
C471E7F228F9BAC70021E251 /* PhpEnvironments.swift in Sources */,
|
||||
C471E7E628F9BAC20021E251 /* Process.swift in Sources */,
|
||||
C471E81928F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
|
||||
C45B914B295607F400F4EC78 /* Service.swift in Sources */,
|
||||
@ -2824,7 +2824,7 @@
|
||||
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */,
|
||||
C471E7D228F9BA630021E251 /* ActiveFileSystem.swift in Sources */,
|
||||
C471E80028F9BAD10021E251 /* Xdebug.swift in Sources */,
|
||||
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */,
|
||||
C471E7F528F9BAC80021E251 /* PhpEnvironments.swift in Sources */,
|
||||
C471E7ED28F9BAC30021E251 /* Process.swift in Sources */,
|
||||
C471E81128F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
|
||||
C471E7CC28F9BA5B0021E251 /* TestableShell.swift in Sources */,
|
||||
@ -3055,7 +3055,7 @@
|
||||
C43BCD4529FBEF40001547BC /* InstallAndUpgradeCommand.swift in Sources */,
|
||||
C4551657297AED18009B8466 /* ValetRcTest.swift in Sources */,
|
||||
C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
||||
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
||||
C40C7F1F2772136000DDDCDC /* PhpEnvironments.swift in Sources */,
|
||||
C464ADB0275A7A6A003FCD53 /* DomainListVC.swift in Sources */,
|
||||
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */,
|
||||
C46EBC4B28DB966A007ACC74 /* TestableShell.swift in Sources */,
|
||||
|
@ -47,8 +47,8 @@ class Actions {
|
||||
"chown -R \(Paths.whoami):admin \(Paths.cellarPath)/\(HomebrewFormulae.dnsmasq)"
|
||||
]
|
||||
|
||||
PhpEnv.shared.availablePhpVersions.forEach { version in
|
||||
let formula = version == PhpEnv.brewPhpAlias
|
||||
PhpEnvironments.shared.availablePhpVersions.forEach { version in
|
||||
let formula = version == PhpEnvironments.brewPhpAlias
|
||||
? "php"
|
||||
: "php@\(version)"
|
||||
servicesCommands.append("\(Paths.brew) services stop \(formula)")
|
||||
@ -125,7 +125,7 @@ class Actions {
|
||||
extensions and/or run `composer global update`.
|
||||
*/
|
||||
public static func fixMyValet() async {
|
||||
await InternalSwitcher().performSwitch(to: PhpEnv.brewPhpAlias)
|
||||
await InternalSwitcher().performSwitch(to: PhpEnvironments.brewPhpAlias)
|
||||
await brew("services restart \(HomebrewFormulae.dnsmasq)", sudo: HomebrewFormulae.dnsmasq.elevated)
|
||||
await brew("services restart \(HomebrewFormulae.php)", sudo: HomebrewFormulae.php.elevated)
|
||||
await brew("services restart \(HomebrewFormulae.nginx)", sudo: HomebrewFormulae.nginx.elevated)
|
||||
|
@ -10,11 +10,11 @@ import Foundation
|
||||
|
||||
struct HomebrewFormulae {
|
||||
static var php: HomebrewFormula {
|
||||
if PhpEnv.shared.homebrewPackage == nil {
|
||||
if PhpEnvironments.shared.homebrewPackage == nil {
|
||||
return HomebrewFormula("php", elevated: true)
|
||||
}
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
return HomebrewFormula("php", elevated: true)
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ActivePhpInstallation {
|
||||
// MARK: - Computed
|
||||
|
||||
var formula: String {
|
||||
return (version.short == PhpEnv.brewPhpAlias) ? "php" : "php@\(version.short)"
|
||||
return (version.short == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version.short)"
|
||||
}
|
||||
|
||||
// MARK: - Initializer
|
||||
|
@ -12,11 +12,11 @@ import Cocoa
|
||||
class Xdebug {
|
||||
|
||||
public static var enabled: Bool {
|
||||
return PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") != nil
|
||||
return PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") != nil
|
||||
}
|
||||
|
||||
public static var activeModes: [String] {
|
||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||
guard let file = PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||
return []
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// PhpSwitcher.swift
|
||||
// PhpEnvironments.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 21/12/2021.
|
||||
@ -8,18 +8,27 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class PhpEnv {
|
||||
class PhpEnvironments {
|
||||
|
||||
// MARK: - Initializer
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
init() {
|
||||
self.currentInstall = ActivePhpInstallation.load()
|
||||
}
|
||||
|
||||
/**
|
||||
Creates the shared instance. Called when starting the app.
|
||||
*/
|
||||
static func prepare() {
|
||||
_ = Self.shared
|
||||
}
|
||||
|
||||
/**
|
||||
Determine which PHP version the `php` formula is aliased to.
|
||||
*/
|
||||
func determinePhpAlias() async {
|
||||
let brewPhpAlias = await Shell.pipe("\(Paths.brew) info php --json").out
|
||||
|
||||
@ -36,8 +45,8 @@ class PhpEnv {
|
||||
/** The delegate that is informed of updates. */
|
||||
weak var delegate: PhpSwitcherDelegate?
|
||||
|
||||
/** The static app instance. Accessible at any time. */
|
||||
static let shared = PhpEnv()
|
||||
/** The static instance. Accessible at any time. */
|
||||
static let shared = PhpEnvironments()
|
||||
|
||||
/** Whether the switcher is busy performing any actions. */
|
||||
var isBusy: Bool = false {
|
||||
@ -71,9 +80,9 @@ class PhpEnv {
|
||||
As such, we take that information from Homebrew.
|
||||
*/
|
||||
static var brewPhpAlias: String {
|
||||
if PhpEnv.shared.homebrewPackage == nil { return "8.2" }
|
||||
if PhpEnvironments.shared.homebrewPackage == nil { return "8.2" }
|
||||
|
||||
return PhpEnv.shared.homebrewPackage.version
|
||||
return PhpEnvironments.shared.homebrewPackage.version
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,16 +99,30 @@ class PhpEnv {
|
||||
|
||||
// MARK: - Methods
|
||||
|
||||
/**
|
||||
The switcher that is currently in use.
|
||||
This was originally added so the Internal and Valet switcher could be swapped out,
|
||||
but currently this is no longer needed.
|
||||
*/
|
||||
public static var switcher: PhpSwitcher {
|
||||
return InternalSwitcher()
|
||||
}
|
||||
|
||||
/**
|
||||
Alias that detects which versions of PHP are installed.
|
||||
See also: `detectPhpVersions()`. Please note that this method
|
||||
does *not* return the set of PHP versions that are supported.
|
||||
*/
|
||||
public static func detectPhpVersions() async {
|
||||
_ = await Self.shared.detectPhpVersions()
|
||||
}
|
||||
|
||||
/**
|
||||
Detects which versions of PHP are installed.
|
||||
This step also detects which versions of PHP are incompatible with the current version of Valet.
|
||||
If a PHP installation is currently broken, that will also be reflected.
|
||||
|
||||
Returns a `Set<String>` of installations that are considered valid.
|
||||
*/
|
||||
public func detectPhpVersions() async -> Set<String> {
|
||||
let files = await Shell.pipe("ls \(Paths.optPath) | grep php@").out
|
||||
@ -184,6 +207,10 @@ class PhpEnv {
|
||||
return output
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a list of `VersionNumber` instances based on the available PHP versions
|
||||
that are valid to switch to for a given constraint.
|
||||
*/
|
||||
public func validVersions(for constraint: String) -> [VersionNumber] {
|
||||
constraint.split(separator: "|").flatMap {
|
||||
return PhpVersionNumberCollection
|
||||
@ -196,7 +223,7 @@ class PhpEnv {
|
||||
Validates whether the currently running version matches the provided version.
|
||||
*/
|
||||
public func validate(_ version: String) -> Bool {
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
Log.info("It appears as if no PHP installation is currently active.")
|
||||
return false
|
||||
}
|
||||
@ -217,7 +244,7 @@ class PhpEnv {
|
||||
You can then use the configuration file instance to change values.
|
||||
*/
|
||||
public func getConfigFile(forKey key: String) -> PhpConfigurationFile? {
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
return nil
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class InternalSwitcher: PhpSwitcher {
|
||||
let versions = getVersionsToBeHandled(version)
|
||||
|
||||
await withTaskGroup(of: String.self, body: { group in
|
||||
for available in PhpEnv.shared.availablePhpVersions {
|
||||
for available in PhpEnvironments.shared.availablePhpVersions {
|
||||
group.addTask {
|
||||
await self.unlinkAndStopPhpVersion(available)
|
||||
return available
|
||||
@ -76,7 +76,7 @@ class InternalSwitcher: PhpSwitcher {
|
||||
}
|
||||
|
||||
func unlinkAndStopPhpVersion(_ version: String) async {
|
||||
let formula = (version == PhpEnv.brewPhpAlias) ? "php" : "php@\(version)"
|
||||
let formula = (version == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version)"
|
||||
await brew("unlink \(formula)")
|
||||
|
||||
if Valet.installed {
|
||||
@ -88,7 +88,7 @@ class InternalSwitcher: PhpSwitcher {
|
||||
}
|
||||
|
||||
func linkAndStartPhpVersion(_ version: String, primary: Bool) async {
|
||||
let formula = (version == PhpEnv.brewPhpAlias) ? "php" : "php@\(version)"
|
||||
let formula = (version == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version)"
|
||||
|
||||
if primary {
|
||||
Log.info("\(formula) is the primary formula, linking...")
|
||||
|
@ -44,11 +44,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
let brew: Brew
|
||||
|
||||
/**
|
||||
The PhpEnv singleton that handles PHP version
|
||||
The PhpEnvironments singleton that handles PHP version
|
||||
detection, as well as switching. It is initialized
|
||||
when the app is ready and passed all checks.
|
||||
*/
|
||||
var phpEnvironment: PhpEnv! = nil
|
||||
var phpEnvironments: PhpEnvironments! = nil
|
||||
|
||||
/**
|
||||
The logger is responsible for different levels of logging.
|
||||
@ -98,7 +98,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
}
|
||||
|
||||
func initializeSwitcher() {
|
||||
self.phpEnvironment = PhpEnv.shared
|
||||
self.phpEnvironments = PhpEnvironments.shared
|
||||
}
|
||||
|
||||
static func initializeTestingProfile(_ path: String) {
|
||||
|
@ -59,11 +59,11 @@ class DomainListPhpCell: NSTableCellView, DomainListCellProtocol {
|
||||
return []
|
||||
}
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
return []
|
||||
}
|
||||
|
||||
return PhpEnv.shared.validVersions(for: site.preferredPhpVersion).filter({ version in
|
||||
return PhpEnvironments.shared.validVersions(for: site.preferredPhpVersion).filter({ version in
|
||||
version.short != install.version.short
|
||||
})
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ extension DomainListVC {
|
||||
private func addIsolate(to menu: NSMenu, with site: ValetSite) {
|
||||
var items: [NSMenuItem] = []
|
||||
|
||||
for version in PhpEnv.shared.availablePhpVersions.reversed() {
|
||||
for version in PhpEnvironments.shared.availablePhpVersions.reversed() {
|
||||
let item = PhpMenuItem(
|
||||
title: "domain_list.always_use_php".localized(version),
|
||||
action: #selector(self.isolateSite),
|
||||
|
@ -27,7 +27,7 @@ import Foundation
|
||||
return
|
||||
}
|
||||
|
||||
PhpEnv.shared.isBusy = true
|
||||
PhpEnvironments.shared.isBusy = true
|
||||
MainMenu.shared.setBusyImage()
|
||||
MainMenu.shared.rebuild()
|
||||
|
||||
@ -105,7 +105,7 @@ import Foundation
|
||||
// MARK: Main Menu Update
|
||||
|
||||
private func removeBusyStatus() {
|
||||
PhpEnv.shared.isBusy = false
|
||||
PhpEnvironments.shared.isBusy = false
|
||||
Task { @MainActor in
|
||||
MainMenu.shared.updatePhpVersionInStatusBar()
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ class BrewPermissionFixer {
|
||||
whether the Homebrew binary directory for the given PHP version is owned by root.
|
||||
*/
|
||||
private func determineBrokenFormulae() async {
|
||||
let formulae = PhpEnv.shared.cachedPhpInstallations.keys
|
||||
let formulae = PhpEnvironments.shared.cachedPhpInstallations.keys
|
||||
|
||||
for formula in formulae {
|
||||
let realFormula = formula == PhpEnv.brewPhpAlias
|
||||
let realFormula = formula == PhpEnvironments.brewPhpAlias
|
||||
? "php"
|
||||
: "php@\(formula)"
|
||||
|
||||
|
@ -66,7 +66,7 @@ class BrewDiagnostics {
|
||||
public static func checkForValetMisconfiguration() async {
|
||||
Log.info("Checking for PHP-FPM issues with Valet...")
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
Log.info("Will skip check for issues if no PHP version is linked.")
|
||||
return
|
||||
}
|
||||
@ -103,13 +103,13 @@ class BrewDiagnostics {
|
||||
from: tapAlias.data(using: .utf8)!
|
||||
).first!
|
||||
|
||||
if tapPhp.version != PhpEnv.brewPhpAlias {
|
||||
if tapPhp.version != PhpEnvironments.brewPhpAlias {
|
||||
Log.warn("The `php` formula alias seems to be the different between the tap and core. "
|
||||
+ "This could be a problem!")
|
||||
Log.info("Determining whether both of these versions are installed...")
|
||||
|
||||
let bothInstalled = PhpEnv.shared.availablePhpVersions.contains(tapPhp.version)
|
||||
&& PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpAlias)
|
||||
let bothInstalled = PhpEnvironments.shared.availablePhpVersions.contains(tapPhp.version)
|
||||
&& PhpEnvironments.shared.availablePhpVersions.contains(PhpEnvironments.brewPhpAlias)
|
||||
|
||||
if bothInstalled {
|
||||
Log.warn("Both conflicting aliases seem to be installed, warning the user!")
|
||||
|
@ -35,7 +35,7 @@ struct BrewFormula {
|
||||
var homebrewFolder: String {
|
||||
let resolved = name
|
||||
.replacingOccurrences(of: "shivammathur/php/", with: "")
|
||||
.replacingOccurrences(of: "php@" + PhpEnv.brewPhpAlias, with: "php")
|
||||
.replacingOccurrences(of: "php@" + PhpEnvironments.brewPhpAlias, with: "php")
|
||||
|
||||
return "\(Paths.optPath)/\(resolved)/bin"
|
||||
}
|
||||
@ -64,6 +64,6 @@ struct BrewFormula {
|
||||
return nil
|
||||
}
|
||||
|
||||
return PhpEnv.shared.cachedPhpInstallations[shortVersion]?.isHealthy ?? nil
|
||||
return PhpEnvironments.shared.cachedPhpInstallations[shortVersion]?.isHealthy ?? nil
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class BrewFormulaeHandler: HandlesBrewFormulae {
|
||||
}
|
||||
|
||||
return Brew.phpVersionFormulae.map { (version, formula) in
|
||||
let fullVersion = PhpEnv.shared.cachedPhpInstallations[version]?.versionNumber.text
|
||||
let fullVersion = PhpEnvironments.shared.cachedPhpInstallations[version]?.versionNumber.text
|
||||
var upgradeVersion: String?
|
||||
|
||||
if let version = fullVersion {
|
||||
|
@ -38,7 +38,7 @@ class InstallAndUpgradeCommand: BrewCommand {
|
||||
try await self.installPackages(onProgress)
|
||||
|
||||
// Re-check the installed versions
|
||||
await PhpEnv.detectPhpVersions()
|
||||
await PhpEnvironments.detectPhpVersions()
|
||||
|
||||
// After performing operations, attempt to run repairs if needed
|
||||
try await self.repairBrokenPackages(onProgress)
|
||||
@ -80,13 +80,13 @@ class InstallAndUpgradeCommand: BrewCommand {
|
||||
private func repairBrokenPackages(_ onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
||||
// Determine which PHP installations are considered unhealthy
|
||||
// Build a list of formulae to reinstall
|
||||
let requiringRepair = PhpEnv.shared
|
||||
let requiringRepair = PhpEnvironments.shared
|
||||
.cachedPhpInstallations.values
|
||||
.filter({ !$0.isHealthy })
|
||||
.map { installation in
|
||||
let formula = "php@\(installation.versionNumber.short)"
|
||||
|
||||
if installation.versionNumber.short == PhpEnv.brewPhpAlias {
|
||||
if installation.versionNumber.short == PhpEnvironments.brewPhpAlias {
|
||||
return "php"
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class InstallAndUpgradeCommand: BrewCommand {
|
||||
onProgress(.create(value: 0.95, title: self.title, description: "Reloading PHP versions..."))
|
||||
|
||||
// Check which version of PHP are now installed
|
||||
await PhpEnv.detectPhpVersions()
|
||||
await PhpEnvironments.detectPhpVersions()
|
||||
|
||||
// Keep track of the currently installed version
|
||||
await MainMenu.shared.refreshActiveInstallation()
|
||||
|
@ -55,7 +55,7 @@ class RemovePhpVersionCommand: BrewCommand {
|
||||
|
||||
if process.terminationStatus <= 0 {
|
||||
onProgress(.create(value: 0.95, title: progressTitle, description: "Reloading PHP versions..."))
|
||||
await PhpEnv.detectPhpVersions()
|
||||
await PhpEnvironments.detectPhpVersions()
|
||||
await MainMenu.shared.refreshActiveInstallation()
|
||||
onProgress(.create(value: 1, title: progressTitle, description: "The operation has succeeded."))
|
||||
} else {
|
||||
|
@ -75,7 +75,7 @@ class FakeValetInteractor: ValetInteractor {
|
||||
override func isolate(site: ValetSite, version: String) async throws {
|
||||
await delay(seconds: delayTime)
|
||||
|
||||
site.isolatedPhpVersion = PhpEnv.shared.cachedPhpInstallations[version]
|
||||
site.isolatedPhpVersion = PhpEnvironments.shared.cachedPhpInstallations[version]
|
||||
site.evaluateCompatibility()
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class FakeValetSite: ValetSite {
|
||||
self.isolatedPhpVersion = PhpInstallation(isolated)
|
||||
}
|
||||
|
||||
if PhpEnv.shared.currentInstall != nil {
|
||||
if PhpEnvironments.shared.currentInstall != nil {
|
||||
self.evaluateCompatibility()
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class ValetSite: ValetListable {
|
||||
/// Which version of PHP is actually used to serve this site.
|
||||
var servingPhpVersion: String {
|
||||
return self.isolatedPhpVersion?.versionNumber.short
|
||||
?? PhpEnv.phpInstall?.version.short
|
||||
?? PhpEnvironments.phpInstall?.version.short
|
||||
?? "???"
|
||||
}
|
||||
|
||||
@ -98,12 +98,12 @@ class ValetSite: ValetListable {
|
||||
*/
|
||||
public func determineIsolated() {
|
||||
if let version = ValetSite.isolatedVersion("~/.config/valet/Nginx/\(self.name).\(self.tld)") {
|
||||
if !PhpEnv.shared.cachedPhpInstallations.keys.contains(version) {
|
||||
if !PhpEnvironments.shared.cachedPhpInstallations.keys.contains(version) {
|
||||
Log.err("The PHP version \(version) is isolated for the site \(self.name) "
|
||||
+ "but that PHP version is unavailable.")
|
||||
return
|
||||
}
|
||||
self.isolatedPhpVersion = PhpEnv.shared.cachedPhpInstallations[version]
|
||||
self.isolatedPhpVersion = PhpEnvironments.shared.cachedPhpInstallations[version]
|
||||
} else {
|
||||
self.isolatedPhpVersion = nil
|
||||
}
|
||||
@ -238,7 +238,7 @@ class ValetSite: ValetListable {
|
||||
return
|
||||
}
|
||||
|
||||
guard let linked = PhpEnv.phpInstall else {
|
||||
guard let linked = PhpEnvironments.phpInstall else {
|
||||
self.isCompatibleWithPreferredPhpVersion = false
|
||||
return
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class Valet {
|
||||
return
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall == nil {
|
||||
if PhpEnvironments.phpInstall == nil {
|
||||
Log.info("Cannot validate Valet version if no PHP version is linked.")
|
||||
return
|
||||
}
|
||||
@ -192,7 +192,7 @@ class Valet {
|
||||
that means that Valet won't work properly.
|
||||
*/
|
||||
func phpFpmConfigurationValid() async -> Bool {
|
||||
guard let version = PhpEnv.shared.currentInstall?.version else {
|
||||
guard let version = PhpEnvironments.shared.currentInstall?.version else {
|
||||
Log.info("Cannot check PHP-FPM status: no version of PHP is active")
|
||||
return true
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ extension MainMenu {
|
||||
}
|
||||
|
||||
@objc func disableAllXdebugModes() {
|
||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||
guard let file = PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||
Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
||||
return
|
||||
}
|
||||
@ -124,7 +124,7 @@ extension MainMenu {
|
||||
@objc func toggleXdebugMode(sender: XdebugMenuItem) {
|
||||
Log.info("Switching Xdebug to mode: \(sender.mode)")
|
||||
|
||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||
guard let file = PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||
return Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ extension MainMenu {
|
||||
}
|
||||
|
||||
@objc func openActiveConfigFolder() {
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
// TODO: Can't open the config if no PHP version is active
|
||||
return
|
||||
}
|
||||
@ -259,7 +259,7 @@ extension MainMenu {
|
||||
if silently {
|
||||
MainMenu.shared.shouldSwitchSilently = true
|
||||
}
|
||||
if PhpEnv.shared.availablePhpVersions.contains(version) {
|
||||
if PhpEnvironments.shared.availablePhpVersions.contains(version) {
|
||||
Task { MainMenu.shared.switchToPhpVersion(version) }
|
||||
} else {
|
||||
Task {
|
||||
@ -275,18 +275,18 @@ extension MainMenu {
|
||||
|
||||
@objc func switchToPhpVersion(_ version: String) {
|
||||
setBusyImage()
|
||||
PhpEnv.shared.isBusy = true
|
||||
PhpEnv.shared.delegate = self
|
||||
PhpEnv.shared.delegate?.switcherDidStartSwitching(to: version)
|
||||
PhpEnvironments.shared.isBusy = true
|
||||
PhpEnvironments.shared.delegate = self
|
||||
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
|
||||
|
||||
Task(priority: .userInitiated) { [unowned self] in
|
||||
updatePhpVersionInStatusBar()
|
||||
rebuild()
|
||||
await PhpEnv.switcher.performSwitch(to: version)
|
||||
await PhpEnvironments.switcher.performSwitch(to: version)
|
||||
|
||||
PhpEnv.shared.currentInstall = ActivePhpInstallation()
|
||||
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
|
||||
App.shared.handlePhpConfigWatcher()
|
||||
PhpEnv.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
||||
PhpEnvironments.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,18 +302,18 @@ extension MainMenu {
|
||||
func switchToPhp(_ version: String) async {
|
||||
Task { @MainActor [self] in
|
||||
setBusyImage()
|
||||
PhpEnv.shared.isBusy = true
|
||||
PhpEnv.shared.delegate = self
|
||||
PhpEnv.shared.delegate?.switcherDidStartSwitching(to: version)
|
||||
PhpEnvironments.shared.isBusy = true
|
||||
PhpEnvironments.shared.delegate = self
|
||||
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
|
||||
}
|
||||
|
||||
updatePhpVersionInStatusBar()
|
||||
rebuild()
|
||||
await PhpEnv.switcher.performSwitch(to: version)
|
||||
await PhpEnvironments.switcher.performSwitch(to: version)
|
||||
|
||||
PhpEnv.shared.currentInstall = ActivePhpInstallation()
|
||||
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
|
||||
App.shared.handlePhpConfigWatcher()
|
||||
PhpEnv.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
||||
PhpEnvironments.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ extension MainMenu {
|
||||
]
|
||||
) {
|
||||
if behaviours.contains(.reloadsPhpInstallation) {
|
||||
PhpEnv.shared.isBusy = true
|
||||
PhpEnvironments.shared.isBusy = true
|
||||
}
|
||||
|
||||
if behaviours.contains(.setsBusyUI) {
|
||||
@ -59,12 +59,12 @@ extension MainMenu {
|
||||
do { try execute() } catch let e { error = e }
|
||||
|
||||
if behaviours.contains(.setsBusyUI) {
|
||||
PhpEnv.shared.isBusy = false
|
||||
PhpEnvironments.shared.isBusy = false
|
||||
}
|
||||
|
||||
Task { @MainActor [self, error] in
|
||||
if behaviours.contains(.reloadsPhpInstallation) {
|
||||
PhpEnv.shared.currentInstall = ActivePhpInstallation()
|
||||
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
|
||||
}
|
||||
|
||||
if behaviours.contains(.updatesMenuBarContents) {
|
||||
|
@ -12,9 +12,9 @@ import AppKit
|
||||
extension MainMenu {
|
||||
|
||||
@MainActor @objc func fixMyValet() {
|
||||
let previousVersion = PhpEnv.phpInstall?.version.short
|
||||
let previousVersion = PhpEnvironments.phpInstall?.version.short
|
||||
|
||||
if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpAlias) {
|
||||
if !PhpEnvironments.shared.availablePhpVersions.contains(PhpEnvironments.brewPhpAlias) {
|
||||
presentAlertForMissingFormula()
|
||||
return
|
||||
}
|
||||
@ -22,7 +22,7 @@ extension MainMenu {
|
||||
if !BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.fix_my_valet.title".localized,
|
||||
subtitle: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpAlias)
|
||||
subtitle: "alert.fix_my_valet.info".localized(PhpEnvironments.brewPhpAlias)
|
||||
)
|
||||
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
||||
.withSecondary(text: "alert.fix_my_valet.cancel".localized)
|
||||
@ -34,7 +34,7 @@ extension MainMenu {
|
||||
Task { @MainActor in
|
||||
await Actions.fixMyValet()
|
||||
|
||||
if previousVersion == PhpEnv.brewPhpAlias || previousVersion == nil {
|
||||
if previousVersion == PhpEnvironments.brewPhpAlias || previousVersion == nil {
|
||||
self.presentAlertForSameVersion()
|
||||
} else {
|
||||
self.presentAlertForDifferentVersion(version: previousVersion!)
|
||||
@ -74,7 +74,7 @@ extension MainMenu {
|
||||
alert.close(with: .alertSecondButtonReturn)
|
||||
MainMenu.shared.switchToPhpVersion(version)
|
||||
})
|
||||
.withSecondary(text: "alert.fix_my_valet_done.stay".localized(PhpEnv.brewPhpAlias))
|
||||
.withSecondary(text: "alert.fix_my_valet_done.stay".localized(PhpEnvironments.brewPhpAlias))
|
||||
.withTertiary(text: "", action: { _ in
|
||||
NSWorkspace.shared.open(Constants.Urls.FrequentlyAskedQuestions)
|
||||
})
|
||||
|
@ -32,7 +32,7 @@ extension MainMenu {
|
||||
*/
|
||||
private func onEnvironmentPass() async {
|
||||
// Determine what the `php` formula is aliased to
|
||||
await PhpEnv.shared.determinePhpAlias()
|
||||
await PhpEnvironments.shared.determinePhpAlias()
|
||||
|
||||
// Initialize preferences
|
||||
_ = Preferences.shared
|
||||
@ -60,7 +60,7 @@ extension MainMenu {
|
||||
await Brew.shared.determineVersion()
|
||||
|
||||
// Actually detect the PHP versions
|
||||
await PhpEnv.detectPhpVersions()
|
||||
await PhpEnvironments.detectPhpVersions()
|
||||
|
||||
// Check for an alias conflict
|
||||
await BrewDiagnostics.checkForCaskConflict()
|
||||
@ -69,7 +69,7 @@ extension MainMenu {
|
||||
updatePhpVersionInStatusBar()
|
||||
|
||||
// Attempt to find out if PHP-FPM is broken
|
||||
PhpEnv.prepare()
|
||||
PhpEnvironments.prepare()
|
||||
|
||||
// Set up the filesystem watcher for the Homebrew binaries
|
||||
App.shared.prepareHomebrewWatchers()
|
||||
|
@ -16,7 +16,7 @@ extension MainMenu {
|
||||
|
||||
nonisolated func switcherDidCompleteSwitch(to version: String) {
|
||||
// Mark as no longer busy
|
||||
PhpEnv.shared.isBusy = false
|
||||
PhpEnvironments.shared.isBusy = false
|
||||
|
||||
Task { // Things to do after reloading domain list data
|
||||
if Valet.installed {
|
||||
@ -28,7 +28,7 @@ extension MainMenu {
|
||||
updatePhpVersionInStatusBar()
|
||||
rebuild()
|
||||
|
||||
if !PhpEnv.shared.validate(version) {
|
||||
if !PhpEnvironments.shared.validate(version) {
|
||||
self.suggestFixMyValet(failed: version)
|
||||
return
|
||||
}
|
||||
@ -125,7 +125,7 @@ extension MainMenu {
|
||||
preference: .notifyAboutVersionChange
|
||||
)
|
||||
|
||||
guard PhpEnv.phpInstall != nil else {
|
||||
guard PhpEnvironments.phpInstall != nil else {
|
||||
Log.err("Cannot notify about version change if PHP is unlinked")
|
||||
return
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
|
||||
/** Reloads which PHP versions is currently active. */
|
||||
@objc func refreshActiveInstallation() {
|
||||
if !PhpEnv.shared.isBusy {
|
||||
PhpEnv.shared.currentInstall = ActivePhpInstallation.load()
|
||||
if !PhpEnvironments.shared.isBusy {
|
||||
PhpEnvironments.shared.currentInstall = ActivePhpInstallation.load()
|
||||
updatePhpVersionInStatusBar()
|
||||
} else {
|
||||
Log.perf("Skipping version refresh due to busy status!")
|
||||
@ -122,7 +122,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
BetterAlert().withInformation(
|
||||
title: "startup.unsupported_versions_explanation.title".localized,
|
||||
subtitle: "startup.unsupported_versions_explanation.subtitle".localized(
|
||||
PhpEnv.shared.incompatiblePhpVersions
|
||||
PhpEnvironments.shared.incompatiblePhpVersions
|
||||
.map({ version in
|
||||
return "• PHP \(version)"
|
||||
})
|
||||
@ -151,7 +151,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
/** Refreshes the icon with the PHP version. */
|
||||
@objc func refreshIcon() {
|
||||
Task { @MainActor [self] in
|
||||
if PhpEnv.shared.isBusy {
|
||||
if PhpEnvironments.shared.isBusy {
|
||||
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||
} else {
|
||||
if Preferences.preferences[.shouldDisplayDynamicIcon] as! Bool == false {
|
||||
@ -161,7 +161,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
// The dynamic icon has been requested
|
||||
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
setStatusBarImage(version: "???")
|
||||
return
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import Cocoa
|
||||
extension StatusMenu {
|
||||
|
||||
func addPhpVersionMenuItems() {
|
||||
if PhpEnv.phpInstall == nil {
|
||||
if PhpEnvironments.phpInstall == nil {
|
||||
addItem(HeaderView.asMenuItem(text: "⚠️ " + "mi_no_php_linked".localized, minimumWidth: 280))
|
||||
addItems([
|
||||
NSMenuItem.separator(),
|
||||
@ -23,28 +23,29 @@ extension StatusMenu {
|
||||
return
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall!.hasErrorState {
|
||||
if PhpEnvironments.phpInstall!.hasErrorState {
|
||||
let brokenMenuItems = ["mi_php_broken_1", "mi_php_broken_2", "mi_php_broken_3", "mi_php_broken_4"]
|
||||
return addItems(brokenMenuItems.map { NSMenuItem(title: $0.localized) })
|
||||
}
|
||||
|
||||
addItem(HeaderView.asMenuItem(
|
||||
text: "\("mi_php_version".localized) \(PhpEnv.phpInstall!.version.long)",
|
||||
text: "\("mi_php_version".localized) \(PhpEnvironments.phpInstall!.version.long)",
|
||||
minimumWidth: 280 // this ensures the menu is at least wide enough not to cause clipping
|
||||
))
|
||||
}
|
||||
|
||||
func addPhpActionMenuItems() {
|
||||
if PhpEnv.shared.isBusy {
|
||||
if PhpEnvironments.shared.isBusy {
|
||||
addItem(NSMenuItem(title: "mi_busy".localized))
|
||||
return
|
||||
}
|
||||
|
||||
if PhpEnv.shared.availablePhpVersions.isEmpty && PhpEnv.shared.incompatiblePhpVersions.isEmpty {
|
||||
if PhpEnvironments.shared.availablePhpVersions.isEmpty
|
||||
&& PhpEnvironments.shared.incompatiblePhpVersions.isEmpty {
|
||||
return
|
||||
}
|
||||
|
||||
if PhpEnv.shared.currentInstall == nil {
|
||||
if PhpEnvironments.shared.currentInstall == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -54,7 +55,7 @@ extension StatusMenu {
|
||||
}
|
||||
|
||||
func addServicesManagerMenuItem() {
|
||||
if PhpEnv.shared.isBusy {
|
||||
if PhpEnvironments.shared.isBusy {
|
||||
return
|
||||
}
|
||||
|
||||
@ -66,20 +67,20 @@ extension StatusMenu {
|
||||
|
||||
func addSwitchToPhpMenuItems() {
|
||||
var shortcutKey = 1
|
||||
for index in (0..<PhpEnv.shared.availablePhpVersions.count) {
|
||||
for index in (0..<PhpEnvironments.shared.availablePhpVersions.count) {
|
||||
// Get the short and long version
|
||||
let shortVersion = PhpEnv.shared.availablePhpVersions[index]
|
||||
let longVersion = PhpEnv.shared.cachedPhpInstallations[shortVersion]!.versionNumber
|
||||
let shortVersion = PhpEnvironments.shared.availablePhpVersions[index]
|
||||
let longVersion = PhpEnvironments.shared.cachedPhpInstallations[shortVersion]!.versionNumber
|
||||
|
||||
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
||||
let versionString = long ? longVersion.text : shortVersion
|
||||
|
||||
let action = #selector(MainMenu.switchToPhpVersion(sender:))
|
||||
let brew = (shortVersion == PhpEnv.brewPhpAlias) ? "php" : "php@\(shortVersion)"
|
||||
let brew = (shortVersion == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(shortVersion)"
|
||||
|
||||
let menuItem = PhpMenuItem(
|
||||
title: "\("mi_php_switch".localized) \(versionString) (\(brew))",
|
||||
action: (shortVersion == PhpEnv.phpInstall?.version.short)
|
||||
action: (shortVersion == PhpEnvironments.phpInstall?.version.short)
|
||||
? nil
|
||||
: action, keyEquivalent: "\(shortcutKey)"
|
||||
)
|
||||
@ -90,11 +91,11 @@ extension StatusMenu {
|
||||
addItem(menuItem)
|
||||
}
|
||||
|
||||
if !PhpEnv.shared.incompatiblePhpVersions.isEmpty {
|
||||
if !PhpEnvironments.shared.incompatiblePhpVersions.isEmpty {
|
||||
addItem(NSMenuItem.separator())
|
||||
addItem(NSMenuItem(
|
||||
title: "⚠️ " + "mi_php_unsupported".localized(
|
||||
"\(PhpEnv.shared.incompatiblePhpVersions.count)"
|
||||
"\(PhpEnvironments.shared.incompatiblePhpVersions.count)"
|
||||
),
|
||||
action: #selector(MainMenu.showIncompatiblePhpVersionsAlert)
|
||||
))
|
||||
@ -175,7 +176,7 @@ extension StatusMenu {
|
||||
),
|
||||
NSMenuItem(
|
||||
title: "mi_update_global_composer".localized,
|
||||
action: PhpEnv.shared.isBusy
|
||||
action: PhpEnvironments.shared.isBusy
|
||||
? nil
|
||||
: #selector(MainMenu.updateGlobalComposerDependencies),
|
||||
keyEquivalent: "g",
|
||||
@ -187,7 +188,7 @@ extension StatusMenu {
|
||||
// MARK: - Stats
|
||||
|
||||
func addStatsMenuItem() {
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
Log.info("Not showing stats menu item if no PHP version is linked.")
|
||||
return
|
||||
}
|
||||
@ -204,7 +205,7 @@ extension StatusMenu {
|
||||
// MARK: - Extensions
|
||||
|
||||
func addExtensionsMenuItems() {
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
Log.info("Not showing extensions menu items if no PHP version is linked.")
|
||||
return
|
||||
}
|
||||
@ -311,7 +312,7 @@ extension StatusMenu {
|
||||
if Valet.installed {
|
||||
items.append(contentsOf: [
|
||||
NSMenuItem.separator(),
|
||||
NSMenuItem(title: "mi_fix_my_valet".localized(PhpEnv.brewPhpAlias),
|
||||
NSMenuItem(title: "mi_fix_my_valet".localized(PhpEnvironments.brewPhpAlias),
|
||||
action: #selector(MainMenu.fixMyValet),
|
||||
toolTip: "mi_fix_my_valet_tooltip".localized),
|
||||
NSMenuItem(title: "mi_fix_brew_permissions".localized(),
|
||||
|
@ -13,12 +13,12 @@ class StatusMenu: NSMenu {
|
||||
addPhpVersionMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayGlobalVersionSwitcher) {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayGlobalVersionSwitcher) {
|
||||
addPhpActionMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall != nil && Valet.installed && Preferences.isEnabled(.displayServicesManager) {
|
||||
if PhpEnvironments.phpInstall != nil && Valet.installed && Preferences.isEnabled(.displayServicesManager) {
|
||||
addServicesManagerMenuItem()
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
@ -28,23 +28,23 @@ class StatusMenu: NSMenu {
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayPhpConfigFinder) {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayPhpConfigFinder) {
|
||||
addConfigurationMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayComposerToolkit) {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayComposerToolkit) {
|
||||
addComposerMenuItems()
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
if !PhpEnv.shared.isBusy {
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayLimitsWidget) {
|
||||
if !PhpEnvironments.shared.isBusy {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayLimitsWidget) {
|
||||
addStatsMenuItem()
|
||||
addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayExtensions) {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayExtensions) {
|
||||
addExtensionsMenuItems()
|
||||
NSMenuItem.separator()
|
||||
|
||||
@ -53,11 +53,11 @@ class StatusMenu: NSMenu {
|
||||
|
||||
addPhpDoctorMenuItem()
|
||||
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayPresets) {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayPresets) {
|
||||
addPresetsMenuItem()
|
||||
}
|
||||
|
||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayMisc) {
|
||||
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayMisc) {
|
||||
addFirstAidAndServicesMenuItems()
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class PhpGuard {
|
||||
var currentVersion: String?
|
||||
|
||||
init() {
|
||||
guard let linked = PhpEnv.phpInstall else {
|
||||
guard let linked = PhpEnvironments.phpInstall else {
|
||||
Log.warn("PHP Guard is unable to determine the current PHP version!")
|
||||
return
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ struct Preset: Codable, Equatable {
|
||||
applyConfigurationValue(key: conf.key, value: conf.value ?? "")
|
||||
}
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
Log.info("Cannot toggle extensions if no PHP version is linked.")
|
||||
return
|
||||
}
|
||||
@ -129,12 +129,12 @@ struct Preset: Codable, Equatable {
|
||||
// MARK: - Apply Functionality
|
||||
|
||||
private func switchToPhpVersionIfValid() async -> Bool {
|
||||
if PhpEnv.shared.currentInstall?.version.short == self.version! {
|
||||
if PhpEnvironments.shared.currentInstall?.version.short == self.version! {
|
||||
Log.info("The version we are supposed to switch to is already active.")
|
||||
return true
|
||||
}
|
||||
|
||||
if PhpEnv.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
||||
if PhpEnvironments.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
||||
await MainMenu.shared.switchToPhp(self.version!)
|
||||
return true
|
||||
} else {
|
||||
@ -144,7 +144,7 @@ struct Preset: Codable, Equatable {
|
||||
subtitle: "alert.php_switch_unavailable.subtitle".localized(version!),
|
||||
description: "alert.php_switch_unavailable.info".localized(
|
||||
version!,
|
||||
PhpEnv.shared.availablePhpVersions.joined(separator: ", ")
|
||||
PhpEnvironments.shared.availablePhpVersions.joined(separator: ", ")
|
||||
)
|
||||
).withPrimary(
|
||||
text: "alert.php_switch_unavailable.ok".localized
|
||||
@ -155,7 +155,7 @@ struct Preset: Codable, Equatable {
|
||||
}
|
||||
|
||||
private func applyConfigurationValue(key: String, value: String) {
|
||||
guard let file = PhpEnv.shared.getConfigFile(forKey: key) else {
|
||||
guard let file = PhpEnvironments.shared.getConfigFile(forKey: key) else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ struct Preset: Codable, Equatable {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ struct Preset: Codable, Equatable {
|
||||
private func diffExtensions() -> [String: Bool] {
|
||||
var items: [String: Bool] = [:]
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
fatalError("If no PHP version is linked, diffing extensions is not possible.")
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ struct Preset: Codable, Equatable {
|
||||
var items: [String: String?] = [:]
|
||||
|
||||
for (key, _) in self.configuration {
|
||||
guard let file = PhpEnv.shared.getConfigFile(forKey: key) else {
|
||||
guard let file = PhpEnvironments.shared.getConfigFile(forKey: key) else {
|
||||
break
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ struct VersionPopoverView: View {
|
||||
if site.isolatedPhpVersion != nil {
|
||||
information += "alert.composer_php_isolated.desc".localized(
|
||||
site.isolatedPhpVersion!.versionNumber.short,
|
||||
PhpEnv.phpInstall?.version.short ?? "???"
|
||||
PhpEnvironments.phpInstall?.version.short ?? "???"
|
||||
)
|
||||
information += "\n\n"
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ struct PhpFormulaeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
await PhpEnv.detectPhpVersions()
|
||||
await PhpEnvironments.detectPhpVersions()
|
||||
await self.handler.refreshPhpVersions(loadOutdated: false)
|
||||
await self.handler.refreshPhpVersions(loadOutdated: true)
|
||||
self.status.busy = false
|
||||
@ -244,7 +244,7 @@ struct PhpFormulaeView: View {
|
||||
|
||||
public func confirmUninstall(_ formula: BrewFormula) async {
|
||||
// Disallow removal of the currently active versipn
|
||||
if formula.installedVersion == PhpEnv.shared.currentInstall?.version.text {
|
||||
if formula.installedVersion == PhpEnvironments.shared.currentInstall?.version.text {
|
||||
self.presentErrorAlert(
|
||||
title: "phpman.uninstall_prevented.title".localized,
|
||||
description: "phpman.uninstall_prevented.desc".localized,
|
||||
@ -297,7 +297,7 @@ struct PhpFormulaeView: View {
|
||||
}
|
||||
|
||||
public func setBusyStatus(_ busy: Bool) {
|
||||
PhpEnv.shared.isBusy = busy
|
||||
PhpEnvironments.shared.isBusy = busy
|
||||
if busy {
|
||||
Task { @MainActor in
|
||||
MainMenu.shared.setBusyImage()
|
||||
|
@ -28,7 +28,7 @@ class PhpConfigChecker {
|
||||
FileExistenceCheck(condition: { Valet.installed }, path: "php-fpm.d/valet-fpm.conf")
|
||||
]
|
||||
|
||||
for version in PhpEnv.shared.availablePhpVersions {
|
||||
for version in PhpEnvironments.shared.availablePhpVersions {
|
||||
for file in shouldExist {
|
||||
// Early exit in case our condition is not met
|
||||
if file.condition != nil && file.condition!() == false {
|
||||
|
@ -27,11 +27,11 @@ extension App {
|
||||
}
|
||||
|
||||
public func onHomebrewPhpModification() async {
|
||||
// let previous = PhpEnv.shared.currentInstall?.version.text
|
||||
// let previous = PhpEnvironments.shared.currentInstall?.version.text
|
||||
Log.info("Something changed in the Homebrew binary directory...")
|
||||
await PhpEnv.detectPhpVersions()
|
||||
await PhpEnvironments.detectPhpVersions()
|
||||
await MainMenu.shared.refreshActiveInstallation()
|
||||
// let new = PhpEnv.shared.currentInstall?.version.text
|
||||
// let new = PhpEnvironments.shared.currentInstall?.version.text
|
||||
|
||||
// TODO:
|
||||
// Check if the new and previous version are different
|
||||
|
@ -33,7 +33,7 @@ extension App {
|
||||
return
|
||||
}
|
||||
|
||||
guard let install = PhpEnv.phpInstall else {
|
||||
guard let install = PhpEnvironments.phpInstall else {
|
||||
Log.info("It appears as if no PHP installation is currently active.")
|
||||
Log.info("The FS watcher will be disabled until a PHP install is active.")
|
||||
return
|
||||
|
Reference in New Issue
Block a user