mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
♻️ Alter how PHP version support is handled
This commit is contained in:
@ -229,10 +229,10 @@
|
|||||||
C471E7EE28F9BAC30021E251 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EE188322D3386B00E126E5 /* Constants.swift */; };
|
C471E7EE28F9BAC30021E251 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EE188322D3386B00E126E5 /* Constants.swift */; };
|
||||||
C471E7EF28F9BAC30021E251 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415D3B62770F294005EF286 /* Actions.swift */; };
|
C471E7EF28F9BAC30021E251 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415D3B62770F294005EF286 /* Actions.swift */; };
|
||||||
C471E7F028F9BAC30021E251 /* Paths.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5853B2770FE3900DA4FBE /* Paths.swift */; };
|
C471E7F028F9BAC30021E251 /* Paths.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5853B2770FE3900DA4FBE /* Paths.swift */; };
|
||||||
C471E7F128F9BAC70021E251 /* PhpVersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* PhpVersionNumber.swift */; };
|
C471E7F128F9BAC70021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||||
C471E7F228F9BAC70021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
C471E7F228F9BAC70021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
||||||
C471E7F328F9BAC70021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
C471E7F328F9BAC70021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
||||||
C471E7F428F9BAC80021E251 /* PhpVersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* PhpVersionNumber.swift */; };
|
C471E7F428F9BAC80021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||||
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
||||||
C471E7F628F9BAC80021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
C471E7F628F9BAC80021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
||||||
C471E7F728F9BACB0021E251 /* PhpSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */; };
|
C471E7F728F9BACB0021E251 /* PhpSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */; };
|
||||||
@ -497,8 +497,8 @@
|
|||||||
C485707C28BF459500539B36 /* NoWarningsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C708C28AA7F7900E8D498 /* NoWarningsView.swift */; };
|
C485707C28BF459500539B36 /* NoWarningsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C708C28AA7F7900E8D498 /* NoWarningsView.swift */; };
|
||||||
C485707D28BF45A200539B36 /* WarningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4297F7928970D59004C4630 /* WarningView.swift */; };
|
C485707D28BF45A200539B36 /* WarningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4297F7928970D59004C4630 /* WarningView.swift */; };
|
||||||
C48D0C9325CC804200CC7490 /* XibLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D0C9225CC804200CC7490 /* XibLoadable.swift */; };
|
C48D0C9325CC804200CC7490 /* XibLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D0C9225CC804200CC7490 /* XibLoadable.swift */; };
|
||||||
C48D6C70279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* PhpVersionNumber.swift */; };
|
C48D6C70279CD2AC00F26D7E /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||||
C48D6C71279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* PhpVersionNumber.swift */; };
|
C48D6C71279CD2AC00F26D7E /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||||
C48D6C75279CD3E400F26D7E /* PhpVersionNumberTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C73279CD3E400F26D7E /* PhpVersionNumberTest.swift */; };
|
C48D6C75279CD3E400F26D7E /* PhpVersionNumberTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C73279CD3E400F26D7E /* PhpVersionNumberTest.swift */; };
|
||||||
C4927F0B27B2DFC200C55AFD /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4927F0A27B2DFC200C55AFD /* Errors.swift */; };
|
C4927F0B27B2DFC200C55AFD /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4927F0A27B2DFC200C55AFD /* Errors.swift */; };
|
||||||
C4927F0C27B2DFC200C55AFD /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4927F0A27B2DFC200C55AFD /* Errors.swift */; };
|
C4927F0C27B2DFC200C55AFD /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4927F0A27B2DFC200C55AFD /* Errors.swift */; };
|
||||||
@ -832,7 +832,7 @@
|
|||||||
C4811D2322D70A4700B5F6B3 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
|
C4811D2322D70A4700B5F6B3 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
|
||||||
C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
|
C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
|
||||||
C48D0C9225CC804200CC7490 /* XibLoadable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XibLoadable.swift; sourceTree = "<group>"; };
|
C48D0C9225CC804200CC7490 /* XibLoadable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XibLoadable.swift; sourceTree = "<group>"; };
|
||||||
C48D6C6F279CD2AC00F26D7E /* PhpVersionNumber.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpVersionNumber.swift; sourceTree = "<group>"; };
|
C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionNumber.swift; sourceTree = "<group>"; };
|
||||||
C48D6C73279CD3E400F26D7E /* PhpVersionNumberTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhpVersionNumberTest.swift; sourceTree = "<group>"; };
|
C48D6C73279CD3E400F26D7E /* PhpVersionNumberTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhpVersionNumberTest.swift; sourceTree = "<group>"; };
|
||||||
C4927F0A27B2DFC200C55AFD /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
|
C4927F0A27B2DFC200C55AFD /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
|
||||||
C4930849279F331F009C240B /* AddSiteVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSiteVC.swift; sourceTree = "<group>"; };
|
C4930849279F331F009C240B /* AddSiteVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSiteVC.swift; sourceTree = "<group>"; };
|
||||||
@ -1401,7 +1401,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */,
|
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */,
|
||||||
C48D6C6F279CD2AC00F26D7E /* PhpVersionNumber.swift */,
|
C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */,
|
||||||
C4D936C827E3EB6100BD69FE /* PhpHelper.swift */,
|
C4D936C827E3EB6100BD69FE /* PhpHelper.swift */,
|
||||||
);
|
);
|
||||||
path = "PHP Version";
|
path = "PHP Version";
|
||||||
@ -1963,7 +1963,7 @@
|
|||||||
C4C8900728F0E3EF00CE5E97 /* ActiveFileSystem.swift in Sources */,
|
C4C8900728F0E3EF00CE5E97 /* ActiveFileSystem.swift in Sources */,
|
||||||
C4D8016622B1584700C6DA1B /* Startup.swift in Sources */,
|
C4D8016622B1584700C6DA1B /* Startup.swift in Sources */,
|
||||||
C42C49DB27C2806F0074ABAC /* MainMenu+FixMyValet.swift in Sources */,
|
C42C49DB27C2806F0074ABAC /* MainMenu+FixMyValet.swift in Sources */,
|
||||||
C48D6C70279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */,
|
C48D6C70279CD2AC00F26D7E /* VersionNumber.swift in Sources */,
|
||||||
C4998F0A2617633900B2526E /* PreferencesWindowController.swift in Sources */,
|
C4998F0A2617633900B2526E /* PreferencesWindowController.swift in Sources */,
|
||||||
C46FA9882822EFDC00D78807 /* PhpConfigurationFile.swift in Sources */,
|
C46FA9882822EFDC00D78807 /* PhpConfigurationFile.swift in Sources */,
|
||||||
C4F8C0A422D4F12C002EFE61 /* DateExtension.swift in Sources */,
|
C4F8C0A422D4F12C002EFE61 /* DateExtension.swift in Sources */,
|
||||||
@ -2271,7 +2271,7 @@
|
|||||||
C471E81728F9BAE80021E251 /* NSMenuExtension.swift in Sources */,
|
C471E81728F9BAE80021E251 /* NSMenuExtension.swift in Sources */,
|
||||||
C471E81328F9BAE80021E251 /* XibLoadable.swift in Sources */,
|
C471E81328F9BAE80021E251 /* XibLoadable.swift in Sources */,
|
||||||
C4D3661C291173EA006BD146 /* DictionaryExtension.swift in Sources */,
|
C4D3661C291173EA006BD146 /* DictionaryExtension.swift in Sources */,
|
||||||
C471E7F128F9BAC70021E251 /* PhpVersionNumber.swift in Sources */,
|
C471E7F128F9BAC70021E251 /* VersionNumber.swift in Sources */,
|
||||||
C471E7DC28F9BA8F0021E251 /* ShellProtocol.swift in Sources */,
|
C471E7DC28F9BA8F0021E251 /* ShellProtocol.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -2436,7 +2436,7 @@
|
|||||||
C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */,
|
C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */,
|
||||||
C471E80F28F9BAE80021E251 /* NSMenuExtension.swift in Sources */,
|
C471E80F28F9BAE80021E251 /* NSMenuExtension.swift in Sources */,
|
||||||
C471E80B28F9BAE80021E251 /* XibLoadable.swift in Sources */,
|
C471E80B28F9BAE80021E251 /* XibLoadable.swift in Sources */,
|
||||||
C471E7F428F9BAC80021E251 /* PhpVersionNumber.swift in Sources */,
|
C471E7F428F9BAC80021E251 /* VersionNumber.swift in Sources */,
|
||||||
C471E7CB28F9BA5B0021E251 /* TestableCommand.swift in Sources */,
|
C471E7CB28F9BA5B0021E251 /* TestableCommand.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -2595,7 +2595,7 @@
|
|||||||
C4E4404727C56F4700D225E1 /* ValetSite.swift in Sources */,
|
C4E4404727C56F4700D225E1 /* ValetSite.swift in Sources */,
|
||||||
C44CCD4A27AFF3BC00CE40E5 /* MainMenu+Async.swift in Sources */,
|
C44CCD4A27AFF3BC00CE40E5 /* MainMenu+Async.swift in Sources */,
|
||||||
C449B4F327EE7FC600C47E8A /* DomainListTypeCell.swift in Sources */,
|
C449B4F327EE7FC600C47E8A /* DomainListTypeCell.swift in Sources */,
|
||||||
C48D6C71279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */,
|
C48D6C71279CD2AC00F26D7E /* VersionNumber.swift in Sources */,
|
||||||
C485706F28BF452300539B36 /* WarningsWindowController.swift in Sources */,
|
C485706F28BF452300539B36 /* WarningsWindowController.swift in Sources */,
|
||||||
C46FA9892822EFDC00D78807 /* PhpConfigurationFile.swift in Sources */,
|
C46FA9892822EFDC00D78807 /* PhpConfigurationFile.swift in Sources */,
|
||||||
C41C02AB27E61CB3009F26CB /* FakeValetSite.swift in Sources */,
|
C41C02AB27E61CB3009F26CB /* FakeValetSite.swift in Sources */,
|
||||||
|
@ -20,29 +20,25 @@ struct Constants {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The PHP versions supported by this application.
|
* The PHP versions supported by this application.
|
||||||
* Versions that do not appear in this array are omitted from the list.
|
* Depends on what version of Valet is installed.
|
||||||
*/
|
*/
|
||||||
static let SupportedPhpVersions = [
|
static let ValetSupportedPhpVersionMatrix = [
|
||||||
// ====================
|
2: // Valet v2 has the broadest legacy support
|
||||||
// STABLE RELEASES
|
[
|
||||||
// ====================
|
"5.6",
|
||||||
// Versions of PHP that are stable and are supported.
|
"7.0", "7.1", "7.2", "7.3", "7.4",
|
||||||
"5.6", // only supported when Valet 2.x is active
|
"8.0", "8.1", "8.2"
|
||||||
"7.0",
|
],
|
||||||
"7.1",
|
3: // Valet v3 dropped support for v5.6
|
||||||
"7.2",
|
[
|
||||||
"7.3",
|
"7.0", "7.1", "7.2", "7.3", "7.4",
|
||||||
|
"8.0", "8.1", "8.2", "8.3"
|
||||||
|
],
|
||||||
|
4: // Valet v4 dropped support for <v7.4
|
||||||
|
[
|
||||||
"7.4",
|
"7.4",
|
||||||
"8.0",
|
"8.0", "8.1", "8.2", "8.3"
|
||||||
"8.1",
|
]
|
||||||
"8.2",
|
|
||||||
|
|
||||||
// ====================
|
|
||||||
// EXPERIMENTAL SUPPORT
|
|
||||||
// ====================
|
|
||||||
// Every release that supports the next release will always support the next
|
|
||||||
// dev release. In this case, that means that the version below is detected.
|
|
||||||
"8.3"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
struct Urls {
|
struct Urls {
|
||||||
|
@ -17,7 +17,7 @@ import Foundation
|
|||||||
Using `version.short` is advisable if you want to interact with Homebrew.
|
Using `version.short` is advisable if you want to interact with Homebrew.
|
||||||
*/
|
*/
|
||||||
class ActivePhpInstallation {
|
class ActivePhpInstallation {
|
||||||
var version: PhpVersionNumber!
|
var version: VersionNumber!
|
||||||
var limits: Limits!
|
var limits: Limits!
|
||||||
var iniFiles: [PhpConfigurationFile] = []
|
var iniFiles: [PhpConfigurationFile] = []
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class ActivePhpInstallation {
|
|||||||
|
|
||||||
self.hasErrorState = (output == "" || output.contains("Warning") || output.contains("Error"))
|
self.hasErrorState = (output == "" || output.contains("Warning") || output.contains("Error"))
|
||||||
|
|
||||||
self.version = try? PhpVersionNumber.parse(output)
|
self.version = try? VersionNumber.parse(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,11 +131,10 @@ class PhpEnv {
|
|||||||
) async -> [String] {
|
) async -> [String] {
|
||||||
var output: [String] = []
|
var output: [String] = []
|
||||||
|
|
||||||
var supported = Constants.SupportedPhpVersions
|
let valetMajor = Valet.shared.version.major
|
||||||
|
let supported = Constants.ValetSupportedPhpVersionMatrix[valetMajor] ?? []
|
||||||
|
|
||||||
if !Valet.enabled(feature: .supportForPhp56) {
|
print(supported)
|
||||||
supported.removeAll { $0 == "5.6" }
|
|
||||||
}
|
|
||||||
|
|
||||||
versions.filter { (version) -> Bool in
|
versions.filter { (version) -> Bool in
|
||||||
// Omit everything that doesn't start with php@
|
// Omit everything that doesn't start with php@
|
||||||
@ -161,7 +160,7 @@ class PhpEnv {
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
public func validVersions(for constraint: String) -> [PhpVersionNumber] {
|
public func validVersions(for constraint: String) -> [VersionNumber] {
|
||||||
constraint.split(separator: "|").flatMap {
|
constraint.split(separator: "|").flatMap {
|
||||||
return PhpVersionNumberCollection
|
return PhpVersionNumberCollection
|
||||||
.make(from: self.availablePhpVersions)
|
.make(from: self.availablePhpVersions)
|
||||||
|
@ -9,19 +9,19 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct PhpVersionNumberCollection: Equatable {
|
public struct PhpVersionNumberCollection: Equatable {
|
||||||
let versions: [PhpVersionNumber]
|
let versions: [VersionNumber]
|
||||||
|
|
||||||
public static func make(from versions: [String]) -> Self {
|
public static func make(from versions: [String]) -> Self {
|
||||||
return PhpVersionNumberCollection(
|
return PhpVersionNumberCollection(
|
||||||
versions: versions.map { try! PhpVersionNumber.parse($0) }
|
versions: versions.map { try! VersionNumber.parse($0) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var first: PhpVersionNumber? {
|
public var first: VersionNumber? {
|
||||||
return self.versions.first
|
return self.versions.first
|
||||||
}
|
}
|
||||||
|
|
||||||
public var all: [PhpVersionNumber] {
|
public var all: [VersionNumber] {
|
||||||
return self.versions
|
return self.versions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,19 +56,19 @@ public struct PhpVersionNumberCollection: Equatable {
|
|||||||
If checking compatibility with general Homebrew versions of PHP, do NOT use strict mode, since
|
If checking compatibility with general Homebrew versions of PHP, do NOT use strict mode, since
|
||||||
the patch version there is not used. (The formula php@8.0 suffices for ^8.0.1.)
|
the patch version there is not used. (The formula php@8.0 suffices for ^8.0.1.)
|
||||||
*/
|
*/
|
||||||
public func matching(constraint: String, strict: Bool = false) -> [PhpVersionNumber] {
|
public func matching(constraint: String, strict: Bool = false) -> [VersionNumber] {
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .versionOnly) {
|
if let version = VersionNumber.make(from: constraint, type: .versionOnly) {
|
||||||
// Strict constraint (e.g. "7.0") -> returns specific version
|
// Strict constraint (e.g. "7.0") -> returns specific version
|
||||||
return self.versions.filter { $0.isSameAs(version, strict) }
|
return self.versions.filter { $0.isSameAs(version, strict) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .caretVersionRange) {
|
if let version = VersionNumber.make(from: constraint, type: .caretVersionRange) {
|
||||||
// Caret range means that the major version is never higher but minor version can be higher
|
// Caret range means that the major version is never higher but minor version can be higher
|
||||||
// ^7.2 will be compatible with all versions between 7.2 and 8.0
|
// ^7.2 will be compatible with all versions between 7.2 and 8.0
|
||||||
return self.versions.filter { $0.hasNewerMinorVersionOrPatch(version, strict) }
|
return self.versions.filter { $0.hasNewerMinorVersionOrPatch(version, strict) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .tildeVersionRange) {
|
if let version = VersionNumber.make(from: constraint, type: .tildeVersionRange) {
|
||||||
// Tilde range means that most specific digit is used as the basis.
|
// Tilde range means that most specific digit is used as the basis.
|
||||||
return self.versions.filter {
|
return self.versions.filter {
|
||||||
version.patch != nil
|
version.patch != nil
|
||||||
@ -79,19 +79,19 @@ public struct PhpVersionNumberCollection: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .greaterThanOrEqual) {
|
if let version = VersionNumber.make(from: constraint, type: .greaterThanOrEqual) {
|
||||||
return self.versions.filter { $0.isSameAs(version, strict) || $0.isNewerThan(version, strict) }
|
return self.versions.filter { $0.isSameAs(version, strict) || $0.isNewerThan(version, strict) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .greaterThan) {
|
if let version = VersionNumber.make(from: constraint, type: .greaterThan) {
|
||||||
return self.versions.filter { $0.isNewerThan(version, strict) }
|
return self.versions.filter { $0.isNewerThan(version, strict) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .smallerThanOrEqual) {
|
if let version = VersionNumber.make(from: constraint, type: .smallerThanOrEqual) {
|
||||||
return self.versions.filter { $0.isSameAs(version, strict) || $0.isOlderThan(version, strict)}
|
return self.versions.filter { $0.isSameAs(version, strict) || $0.isOlderThan(version, strict)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let version = PhpVersionNumber.make(from: constraint, type: .smallerThan) {
|
if let version = VersionNumber.make(from: constraint, type: .smallerThan) {
|
||||||
return self.versions.filter { $0.isOlderThan(version, strict)}
|
return self.versions.filter { $0.isOlderThan(version, strict)}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,18 +99,18 @@ public struct PhpVersionNumberCollection: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct PhpVersionNumber: Equatable, Hashable {
|
public struct VersionNumber: Equatable, Hashable {
|
||||||
let major: Int
|
let major: Int
|
||||||
let minor: Int
|
let minor: Int
|
||||||
let patch: Int?
|
let patch: Int?
|
||||||
|
|
||||||
public func toString() -> String {
|
var text: String {
|
||||||
return self.patch == nil
|
return self.patch == nil
|
||||||
? "\(major).\(minor)"
|
? "\(major).\(minor)"
|
||||||
: "\(major).\(minor).\(patch!)"
|
: "\(major).\(minor).\(patch!)"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func patch(_ strictFallback: Bool = true, _ constraint: PhpVersionNumber? = nil) -> Int {
|
public func patch(_ strictFallback: Bool = true, _ constraint: VersionNumber? = nil) -> Int {
|
||||||
return patch ?? (strictFallback ? 0 : constraint?.patch ?? 999)
|
return patch ?? (strictFallback ? 0 : constraint?.patch ?? 999)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,13 +168,17 @@ public struct PhpVersionNumber: Equatable, Hashable {
|
|||||||
|
|
||||||
// MARK: Comparison Logic
|
// MARK: Comparison Logic
|
||||||
|
|
||||||
internal func isSameAs(_ version: PhpVersionNumber, _ strict: Bool) -> Bool {
|
internal func isSameMajorVersionAs(_ version: VersionNumber) -> Bool {
|
||||||
|
return self.major == version.major
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func isSameAs(_ version: VersionNumber, _ strict: Bool) -> Bool {
|
||||||
return self.major == version.major
|
return self.major == version.major
|
||||||
&& self.minor == version.minor
|
&& self.minor == version.minor
|
||||||
&& (strict ? self.patch(strict, version) == version.patch(strict) : true)
|
&& (strict ? self.patch(strict, version) == version.patch(strict) : true)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func isNewerThan(_ version: PhpVersionNumber, _ strict: Bool) -> Bool {
|
internal func isNewerThan(_ version: VersionNumber, _ strict: Bool) -> Bool {
|
||||||
return (
|
return (
|
||||||
self.major > version.major ||
|
self.major > version.major ||
|
||||||
self.major == version.major && self.minor > version.minor ||
|
self.major == version.major && self.minor > version.minor ||
|
||||||
@ -183,7 +187,7 @@ public struct PhpVersionNumber: Equatable, Hashable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func isOlderThan(_ version: PhpVersionNumber, _ strict: Bool) -> Bool {
|
internal func isOlderThan(_ version: VersionNumber, _ strict: Bool) -> Bool {
|
||||||
return (
|
return (
|
||||||
self.major < version.major ||
|
self.major < version.major ||
|
||||||
self.major == version.major && self.minor < version.minor ||
|
self.major == version.major && self.minor < version.minor ||
|
||||||
@ -192,7 +196,7 @@ public struct PhpVersionNumber: Equatable, Hashable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func hasNewerMinorVersionOrPatch(_ version: PhpVersionNumber, _ strict: Bool) -> Bool {
|
internal func hasNewerMinorVersionOrPatch(_ version: VersionNumber, _ strict: Bool) -> Bool {
|
||||||
return self.major == version.major &&
|
return self.major == version.major &&
|
||||||
(
|
(
|
||||||
(self.minor == version.minor && self.patch(strict) >= version.patch(strict, self))
|
(self.minor == version.minor && self.patch(strict) >= version.patch(strict, self))
|
||||||
@ -200,12 +204,12 @@ public struct PhpVersionNumber: Equatable, Hashable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func hasSameMajorAndMinorButNewerOrSamePatch(_ version: PhpVersionNumber, _ strict: Bool) -> Bool {
|
internal func hasSameMajorAndMinorButNewerOrSamePatch(_ version: VersionNumber, _ strict: Bool) -> Bool {
|
||||||
return self.major == version.major && self.minor == version.minor
|
return self.major == version.major && self.minor == version.minor
|
||||||
&& self.patch(strict, version) >= version.patch(strict)
|
&& self.patch(strict, version) >= version.patch(strict)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func hasSameMajorButNewerOrSameMinor(_ version: PhpVersionNumber, _ strict: Bool) -> Bool {
|
internal func hasSameMajorButNewerOrSameMinor(_ version: VersionNumber, _ strict: Bool) -> Bool {
|
||||||
return self.major == version.major
|
return self.major == version.major
|
||||||
&& self.minor >= version.minor
|
&& self.minor >= version.minor
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
class PhpInstallation {
|
class PhpInstallation {
|
||||||
|
|
||||||
var versionNumber: PhpVersionNumber
|
var versionNumber: VersionNumber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
In order to determine details about a PHP installation, we’ll simply run `php-config --version`
|
In order to determine details about a PHP installation, we’ll simply run `php-config --version`
|
||||||
@ -19,7 +19,7 @@ class PhpInstallation {
|
|||||||
init(_ version: String) {
|
init(_ version: String) {
|
||||||
|
|
||||||
let phpConfigExecutablePath = "\(Paths.optPath)/php@\(version)/bin/php-config"
|
let phpConfigExecutablePath = "\(Paths.optPath)/php@\(version)/bin/php-config"
|
||||||
self.versionNumber = PhpVersionNumber.make(from: version)!
|
self.versionNumber = VersionNumber.make(from: version)!
|
||||||
|
|
||||||
if FileSystem.fileExists(phpConfigExecutablePath) {
|
if FileSystem.fileExists(phpConfigExecutablePath) {
|
||||||
let longVersionString = Command.execute(
|
let longVersionString = Command.execute(
|
||||||
@ -30,7 +30,7 @@ class PhpInstallation {
|
|||||||
|
|
||||||
// The parser should always work, or the string has to be very unusual.
|
// The parser should always work, or the string has to be very unusual.
|
||||||
// If so, the app SHOULD crash, so that the users report what's up.
|
// If so, the app SHOULD crash, so that the users report what's up.
|
||||||
self.versionNumber = try! PhpVersionNumber.parse(longVersionString)
|
self.versionNumber = try! VersionNumber.parse(longVersionString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class EnvironmentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract the version number
|
// Extract the version number
|
||||||
Valet.shared.version = VersionExtractor.from(output)
|
Valet.shared.version = try! VersionNumber.parse(VersionExtractor.from(output)!)
|
||||||
|
|
||||||
// Get the actual version
|
// Get the actual version
|
||||||
return Valet.shared.version == nil
|
return Valet.shared.version == nil
|
||||||
|
@ -242,7 +242,7 @@ class Startup {
|
|||||||
.components(separatedBy: "Laravel Valet")[1]
|
.components(separatedBy: "Laravel Valet")[1]
|
||||||
.trimmingCharacters(in: .whitespaces)
|
.trimmingCharacters(in: .whitespaces)
|
||||||
// Extract the version number
|
// Extract the version number
|
||||||
Valet.shared.version = VersionExtractor.from(output)
|
Valet.shared.version = try! VersionNumber.parse(VersionExtractor.from(output)!)
|
||||||
// Get the actual version
|
// Get the actual version
|
||||||
return Valet.shared.version == nil
|
return Valet.shared.version == nil
|
||||||
},
|
},
|
||||||
|
@ -53,7 +53,7 @@ class DomainListPhpCell: NSTableCellView, DomainListCellProtocol {
|
|||||||
@IBAction func pressedPhpVersion(_ sender: Any) {
|
@IBAction func pressedPhpVersion(_ sender: Any) {
|
||||||
guard let site = self.site else { return }
|
guard let site = self.site else { return }
|
||||||
|
|
||||||
var validPhpSuggestions: [PhpVersionNumber] {
|
var validPhpSuggestions: [VersionNumber] {
|
||||||
if site.isolatedPhpVersion != nil {
|
if site.isolatedPhpVersion != nil {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,13 @@ import Foundation
|
|||||||
class Valet {
|
class Valet {
|
||||||
|
|
||||||
enum FeatureFlag {
|
enum FeatureFlag {
|
||||||
case isolatedSites,
|
case isolatedSites
|
||||||
supportForPhp56
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static let shared = Valet()
|
static let shared = Valet()
|
||||||
|
|
||||||
/// The version of Valet that was detected.
|
/// The version of Valet that was detected.
|
||||||
var version: String! = nil
|
var version: VersionNumber! = nil
|
||||||
|
|
||||||
/// The Valet configuration file.
|
/// The Valet configuration file.
|
||||||
var config: Valet.Configuration!
|
var config: Valet.Configuration!
|
||||||
@ -138,13 +137,18 @@ class Valet {
|
|||||||
in use. This allows PHP Monitor to do different things when Valet 3.0 is enabled.
|
in use. This allows PHP Monitor to do different things when Valet 3.0 is enabled.
|
||||||
*/
|
*/
|
||||||
public func evaluateFeatureSupport() {
|
public func evaluateFeatureSupport() {
|
||||||
let isOlderThanVersionThree = version.versionCompare("3.0") == .orderedAscending
|
let isVersion2 = version.isSameMajorVersionAs(try! VersionNumber.parse("2.0"))
|
||||||
|
let isVersion3 = version.isSameMajorVersionAs(try! VersionNumber.parse("3.0"))
|
||||||
|
let isVersion4 = version.isSameMajorVersionAs(try! VersionNumber.parse("4.0"))
|
||||||
|
|
||||||
if isOlderThanVersionThree {
|
if isVersion2 {
|
||||||
self.features.append(.supportForPhp56)
|
Log.info("You are running Valet v2. Support for site isolation is disabled.")
|
||||||
} else {
|
} else if isVersion3 || isVersion4 {
|
||||||
Log.info("This version of Valet supports isolation.")
|
Log.info("You are running Valet v3 or v4. Support for site isolation is available.")
|
||||||
self.features.append(.isolatedSites)
|
self.features.append(.isolatedSites)
|
||||||
|
} else {
|
||||||
|
// TODO: Show an alert and notify that some features might not work
|
||||||
|
Log.err("This version of Valet is not supported.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,15 +162,16 @@ class Valet {
|
|||||||
Valet.shared.evaluateFeatureSupport()
|
Valet.shared.evaluateFeatureSupport()
|
||||||
|
|
||||||
// 2. Notify user if the version is too old
|
// 2. Notify user if the version is too old
|
||||||
if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {
|
if version.text.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {
|
||||||
let version = version
|
let version = version!
|
||||||
Log.warn("Valet version \(version!) is too old! (recommended: \(Constants.MinimumRecommendedValetVersion))")
|
let recommended = Constants.MinimumRecommendedValetVersion
|
||||||
|
Log.warn("Valet version \(version.text) is too old! (recommended: \(recommended))")
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
BetterAlert()
|
BetterAlert()
|
||||||
.withInformation(
|
.withInformation(
|
||||||
title: "alert.min_valet_version.title".localized,
|
title: "alert.min_valet_version.title".localized,
|
||||||
subtitle: "alert.min_valet_version.info".localized(
|
subtitle: "alert.min_valet_version.info".localized(
|
||||||
version!,
|
version.text,
|
||||||
Constants.MinimumRecommendedValetVersion
|
Constants.MinimumRecommendedValetVersion
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -174,9 +179,14 @@ class Valet {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.info("Valet version \(version!) is recent enough, OK " +
|
Log.info("Valet version \(version.text) is recent enough, OK " +
|
||||||
"(recommended: \(Constants.MinimumRecommendedValetVersion))")
|
"(recommended: \(Constants.MinimumRecommendedValetVersion))")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Notify user if the version is too high
|
||||||
|
if version.major > 4 {
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hasPlatformIssues() async -> Bool {
|
public func hasPlatformIssues() async -> Bool {
|
||||||
|
@ -50,7 +50,7 @@ extension MainMenu {
|
|||||||
|
|
||||||
// Attempt to find out more info about Valet
|
// Attempt to find out more info about Valet
|
||||||
if Valet.shared.version != nil {
|
if Valet.shared.version != nil {
|
||||||
Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!)")
|
Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!.text)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the version (this will enforce which versions of PHP are supported)
|
// Validate the version (this will enforce which versions of PHP are supported)
|
||||||
|
@ -56,7 +56,7 @@ extension StatusMenu {
|
|||||||
let longVersion = PhpEnv.shared.cachedPhpInstallations[shortVersion]!.versionNumber
|
let longVersion = PhpEnv.shared.cachedPhpInstallations[shortVersion]!.versionNumber
|
||||||
|
|
||||||
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
||||||
let versionString = long ? longVersion.toString() : shortVersion
|
let versionString = long ? longVersion.text : shortVersion
|
||||||
|
|
||||||
let action = #selector(MainMenu.switchToPhpVersion(sender:))
|
let action = #selector(MainMenu.switchToPhpVersion(sender:))
|
||||||
let brew = (shortVersion == PhpEnv.brewPhpAlias) ? "php" : "php@\(shortVersion)"
|
let brew = (shortVersion == PhpEnv.brewPhpAlias) ? "php" : "php@\(shortVersion)"
|
||||||
|
@ -12,7 +12,7 @@ struct VersionPopoverView: View {
|
|||||||
|
|
||||||
@State var site: ValetSite
|
@State var site: ValetSite
|
||||||
|
|
||||||
@State var validPhpVersions: [PhpVersionNumber]
|
@State var validPhpVersions: [VersionNumber]
|
||||||
|
|
||||||
@State var parent: NSPopover!
|
@State var parent: NSPopover!
|
||||||
|
|
||||||
@ -185,8 +185,8 @@ struct VersionPopoverView_Previews: PreviewProvider {
|
|||||||
constraint: "^8.0"
|
constraint: "^8.0"
|
||||||
),
|
),
|
||||||
validPhpVersions: [
|
validPhpVersions: [
|
||||||
PhpVersionNumber(major: 8, minor: 0, patch: 0),
|
VersionNumber(major: 8, minor: 0, patch: 0),
|
||||||
PhpVersionNumber(major: 8, minor: 1, patch: 0)
|
VersionNumber(major: 8, minor: 1, patch: 0)
|
||||||
],
|
],
|
||||||
parent: nil
|
parent: nil
|
||||||
)
|
)
|
||||||
|
@ -427,12 +427,12 @@ problem manually, using your own Terminal app (this just shows you the output)."
|
|||||||
"alert.php_alias_conflict.title" = "Homebrew `php` formula alias conflict detected";
|
"alert.php_alias_conflict.title" = "Homebrew `php` formula alias conflict detected";
|
||||||
"alert.php_alias_conflict.info" = "PHP Monitor has detected conflicting `php` aliases in your Homebrew setup, both of which have been detected as installed.\n\nThis will likely result in failed linking when switching PHP versions, and will break PHP Monitor functionality.\n\nFor more information, please visit: https://github.com/nicoverbruggen/phpmon/issues/54";
|
"alert.php_alias_conflict.info" = "PHP Monitor has detected conflicting `php` aliases in your Homebrew setup, both of which have been detected as installed.\n\nThis will likely result in failed linking when switching PHP versions, and will break PHP Monitor functionality.\n\nFor more information, please visit: https://github.com/nicoverbruggen/phpmon/issues/54";
|
||||||
|
|
||||||
"alert.min_valet_version.title" = "Your version of Valet is outdated, please upgrade!";
|
"alert.min_valet_version.title" = "The installed version of Valet does not meet the minimum version requirement. PHP Monitor may not function as expected!";
|
||||||
"alert.min_valet_version.info" = "You are currently running Valet %@.
|
"alert.min_valet_version.info" = "You are currently running Valet %@.
|
||||||
|
|
||||||
For optimal support of the latest versions of PHP and proper version switching, it is recommended that you update to version %@.
|
For optimal support of the latest versions of PHP and proper version switching, it is recommended that you update to version %@, which is the minimum requirement for this version of PHP Monitor.
|
||||||
|
|
||||||
You can do this by running `composer global update` in your terminal. After that, run `valet install` again. For best results, restart PHP Monitor after that.";
|
You can do this by running `composer global update` in your terminal. After that, run `valet install` again. For best results, restart PHP Monitor after that. Until this is resolved, PHP Monitor may not behave as expected.";
|
||||||
|
|
||||||
// Preset text description
|
// Preset text description
|
||||||
"alert.preset_description.switcher_version" = "Switches to PHP %@.\n\n";
|
"alert.preset_description.switcher_version" = "Switches to PHP %@.\n\n";
|
||||||
|
Reference in New Issue
Block a user