mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 WIP: Use BrewFormula
struct for operations
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class BrewFormula {
|
||||
struct BrewFormula {
|
||||
/// Name of the formula.
|
||||
let name: String
|
||||
|
||||
@ -31,11 +31,16 @@ class BrewFormula {
|
||||
return upgradeVersion != nil
|
||||
}
|
||||
|
||||
public func getHomebrewFolder() -> String {
|
||||
#error("This must return the path to the Homebrew folder")
|
||||
var homebrewFolder: String {
|
||||
let resolved = name
|
||||
.replacingOccurrences(of: "shivammathur/php/", with: "")
|
||||
.replacingOccurrences(of: "php@" + PhpEnv.brewPhpAlias, with: "php")
|
||||
|
||||
return "\(Paths.optPath)/\(resolved)/bin"
|
||||
}
|
||||
|
||||
public func isHealthy() -> Bool {
|
||||
#error("This must check if the PHP version works")
|
||||
return true
|
||||
// #error("This must check if the PHP version works")
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import Foundation
|
||||
|
||||
class HomebrewOperation {
|
||||
|
||||
let installing: [String]
|
||||
let upgrading: [String]
|
||||
let installing: [BrewFormula]
|
||||
let upgrading: [BrewFormula]
|
||||
|
||||
/**
|
||||
You can pass in which PHP versions need to be upgraded and which ones need to be installed.
|
||||
@ -20,8 +20,8 @@ class HomebrewOperation {
|
||||
Each version that is installed will need to be checked afterwards (if it is OK).
|
||||
*/
|
||||
public init(
|
||||
upgrading: [String],
|
||||
installing: [String]
|
||||
upgrading: [BrewFormula],
|
||||
installing: [BrewFormula]
|
||||
) {
|
||||
self.installing = installing
|
||||
self.upgrading = upgrading
|
||||
@ -36,7 +36,7 @@ class HomebrewOperation {
|
||||
let command = """
|
||||
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
|
||||
\(Paths.brew) upgrade \(self.upgrading.joined(separator: " "))
|
||||
\(Paths.brew) upgrade \(self.upgrading.map { $0.name }.joined(separator: " "))
|
||||
"""
|
||||
|
||||
print(command)
|
||||
@ -46,13 +46,13 @@ class HomebrewOperation {
|
||||
let command = """
|
||||
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
|
||||
\(Paths.brew) install \(self.upgrading.joined(separator: " ")) --force
|
||||
\(Paths.brew) install \(self.upgrading.map { $0.name }.joined(separator: " ")) --force
|
||||
"""
|
||||
|
||||
print(command)
|
||||
}
|
||||
|
||||
private func determineHealth(formula: String) -> Bool {
|
||||
private func determineHealth(formula: BrewFormula) -> Bool {
|
||||
#warning("Should return proper health")
|
||||
return false
|
||||
|
||||
|
@ -124,6 +124,7 @@ struct PhpFormulaeView: View {
|
||||
.padding(.horizontal, 5)
|
||||
VStack(alignment: .leading) {
|
||||
Text(formula.displayName).bold()
|
||||
Text(formula.homebrewFolder)
|
||||
|
||||
if formula.isInstalled && formula.hasUpgrade {
|
||||
Text("\(formula.installedVersion!) installed, \(formula.upgradeVersion!) available.")
|
||||
@ -139,6 +140,8 @@ struct PhpFormulaeView: View {
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
/*
|
||||
if formula.isInstalled {
|
||||
Button("phpman.buttons.uninstall".localizedForSwiftUI, role: .destructive) {
|
||||
Task { await self.confirmUninstall(formula) }
|
||||
@ -148,7 +151,6 @@ struct PhpFormulaeView: View {
|
||||
Task { await self.install(formula) }
|
||||
}
|
||||
}
|
||||
/*
|
||||
if formula.hasUpgrade {
|
||||
Button("phpman.buttons.update".localizedForSwiftUI) {
|
||||
Task { await self.install(formula, upgrade: true) }
|
||||
|
@ -101,7 +101,7 @@
|
||||
|
||||
"phpman.title" = "PHP Version Manager";
|
||||
"phpman.description" = "**PHP Version Manager** lets you install different PHP versions via Homebrew.";
|
||||
"phpman.disclaimer" = "Please note that installing or upgrading PHP versions may cause other Homebrew packages to be upgraded as well. If you haven't updated Homebrew in a bit, operations here may take a couple of minutes to complete as it is likely multiple dependencies and other (unrelated) packages will also be upgraded. (Partial upgrades aren't done to avoid breaking packages in general.)";
|
||||
"phpman.disclaimer" = "Please note that installing or upgrading PHP versions may cause other Homebrew packages to be upgraded as well. Installing or updating PHP versions may take some time, so please be patient.";
|
||||
"phpman.refresh.button" = "Search for Updates";
|
||||
"phpman.refresh.button.description" = "You can press the refresh button to check if any updates are available to installed PHP versions.";
|
||||
|
||||
|
Reference in New Issue
Block a user