1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-06 19:40:08 +02:00

Allow pre-release builds to be installed

This commit is contained in:
2023-08-31 19:05:40 +02:00
parent 528f213f17
commit eb566bb523
7 changed files with 55 additions and 5 deletions

View File

@ -18,6 +18,13 @@ struct Constants {
*/
static let MinimumRecommendedValetVersion = "2.16.2"
/**
* The PHP versions that are considered pre-release versions.
*/
static let ExperimentalPhpVersions: Set = [
"8.3", "8.4"
]
/**
* The PHP versions supported by this application.
* Any other PHP versions are considered invalid.
@ -25,7 +32,9 @@ struct Constants {
static let DetectedPhpVersions: Set = [
"5.6",
"7.0", "7.1", "7.2", "7.3", "7.4",
"8.0", "8.1", "8.2", "8.3"
"8.0", "8.1", "8.2",
"8.3",
"8.4"
]
/**
@ -42,13 +51,13 @@ struct Constants {
[
"7.0", "7.1", "7.2", "7.3", "7.4",
"8.0", "8.1", "8.2",
"8.3" // dev
"8.3", "8.4" // dev
],
4: // Valet v4 dropped support for v7.0
[
"7.1", "7.2", "7.3", "7.4",
"8.0", "8.1", "8.2",
"8.3" // dev
"8.3", "8.4" // dev
]
]

View File

@ -45,6 +45,7 @@ class Brew {
/// Each formula for each PHP version that can be installed.
public static let phpVersionFormulae = [
"8.3": "shivammathur/php/php@8.3",
"8.2": "php@8.2",
"8.1": "php@8.1",
"8.0": "php@8.0",

View File

@ -21,11 +21,28 @@ struct BrewFormula {
/// The upgrade that is currently available, if it exists.
let upgradeVersion: String?
/// Whether this formula is a stable version of PHP.
let prerelease: Bool
/// Whether the formula is currently installed.
var isInstalled: Bool {
return installedVersion != nil
}
init(
name: String,
displayName: String,
installedVersion: String?,
upgradeVersion: String?,
prerelease: Bool = false
) {
self.name = name
self.displayName = displayName
self.installedVersion = installedVersion
self.upgradeVersion = upgradeVersion
self.prerelease = prerelease
}
/// Whether the formula can be upgraded.
var hasUpgrade: Bool {
return upgradeVersion != nil

View File

@ -56,7 +56,8 @@ class BrewFormulaeHandler: HandlesBrewFormulae {
name: formula,
displayName: "PHP \(version)",
installedVersion: fullVersion,
upgradeVersion: upgradeVersion
upgradeVersion: upgradeVersion,
prerelease: Constants.ExperimentalPhpVersions.contains(version)
)
}.sorted { $0.displayName > $1.displayName }
}

View File

@ -11,6 +11,13 @@ import Foundation
class FakeBrewFormulaeHandler: HandlesBrewFormulae {
public func loadPhpVersions(loadOutdated: Bool) async -> [BrewFormula] {
return [
BrewFormula(
name: "php",
displayName: "PHP 8.3",
installedVersion: nil,
upgradeVersion: "8.3.0",
prerelease: true
),
BrewFormula(
name: "php",
displayName: "PHP 8.2",

View File

@ -135,7 +135,21 @@ struct PhpVersionManagerView: View {
.foregroundColor(formula.iconColor)
.padding(.horizontal, 5)
VStack(alignment: .leading, spacing: 2) {
Text(formula.displayName).bold()
HStack {
Text(formula.displayName).bold()
if formula.prerelease {
Text("phpman.version.prerelease".localized.uppercased())
.font(.system(size: 9))
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(Color.appPrimary)
.foregroundColor(Color.white)
.clipShape(Capsule())
.fixedSize(horizontal: true, vertical: true)
.frame(maxHeight: 7)
}
}
if formula.isInstalled && formula.hasUpgrade {
Text("phpman.version.has_update".localized(

View File

@ -108,6 +108,7 @@
"phpman.buttons.install" = "Install";
"phpman.buttons.update" = "Update";
"phpman.buttons.repair" = "Repair";
"phpman.version.prerelease" = "Pre-release";
"phpman.title" = "PHP Version Manager";
"phpman.description" = "**PHP Version Manager** lets you install, upgrade and delete different PHP versions via Homebrew without needing to run the commands in the terminal yourself.";