mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
🏗 WIP: Change the way Homebrew operations run
This commit is contained in:
@ -144,6 +144,10 @@
|
|||||||
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; };
|
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; };
|
||||||
C43A8A2025D9D1D700591B77 /* brew-formula.json in Resources */ = {isa = PBXBuildFile; fileRef = C43A8A1F25D9D1D700591B77 /* brew-formula.json */; };
|
C43A8A2025D9D1D700591B77 /* brew-formula.json in Resources */ = {isa = PBXBuildFile; fileRef = C43A8A1F25D9D1D700591B77 /* brew-formula.json */; };
|
||||||
C43A8A2425D9D20D00591B77 /* HomebrewPackageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */; };
|
C43A8A2425D9D20D00591B77 /* HomebrewPackageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */; };
|
||||||
|
C43BCD4429FBEF40001547BC /* HomebrewOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43BCD4329FBEF40001547BC /* HomebrewOperation.swift */; };
|
||||||
|
C43BCD4529FBEF40001547BC /* HomebrewOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43BCD4329FBEF40001547BC /* HomebrewOperation.swift */; };
|
||||||
|
C43BCD4629FBEF40001547BC /* HomebrewOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43BCD4329FBEF40001547BC /* HomebrewOperation.swift */; };
|
||||||
|
C43BCD4729FBEF40001547BC /* HomebrewOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43BCD4329FBEF40001547BC /* HomebrewOperation.swift */; };
|
||||||
C43FDBE929A932B0003D85EC /* PhpConfigChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */; };
|
C43FDBE929A932B0003D85EC /* PhpConfigChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */; };
|
||||||
C44067F527E2582B0045BD4E /* DomainListNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F427E2582B0045BD4E /* DomainListNameCell.swift */; };
|
C44067F527E2582B0045BD4E /* DomainListNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F427E2582B0045BD4E /* DomainListNameCell.swift */; };
|
||||||
C44067F727E258410045BD4E /* DomainListPhpCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F627E258410045BD4E /* DomainListPhpCell.swift */; };
|
C44067F727E258410045BD4E /* DomainListPhpCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F627E258410045BD4E /* DomainListPhpCell.swift */; };
|
||||||
@ -917,6 +921,7 @@
|
|||||||
C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = "<group>"; };
|
C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = "<group>"; };
|
||||||
C43A8A1F25D9D1D700591B77 /* brew-formula.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "brew-formula.json"; sourceTree = "<group>"; };
|
C43A8A1F25D9D1D700591B77 /* brew-formula.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "brew-formula.json"; sourceTree = "<group>"; };
|
||||||
C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewPackageTest.swift; sourceTree = "<group>"; };
|
C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewPackageTest.swift; sourceTree = "<group>"; };
|
||||||
|
C43BCD4329FBEF40001547BC /* HomebrewOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewOperation.swift; sourceTree = "<group>"; };
|
||||||
C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpConfigChecker.swift; sourceTree = "<group>"; };
|
C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpConfigChecker.swift; sourceTree = "<group>"; };
|
||||||
C44067F427E2582B0045BD4E /* DomainListNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListNameCell.swift; sourceTree = "<group>"; };
|
C44067F427E2582B0045BD4E /* DomainListNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListNameCell.swift; sourceTree = "<group>"; };
|
||||||
C44067F627E258410045BD4E /* DomainListPhpCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListPhpCell.swift; sourceTree = "<group>"; };
|
C44067F627E258410045BD4E /* DomainListPhpCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListPhpCell.swift; sourceTree = "<group>"; };
|
||||||
@ -1771,6 +1776,7 @@
|
|||||||
C4B79EBB29CA38DB00A483EE /* BrewCommand.swift */,
|
C4B79EBB29CA38DB00A483EE /* BrewCommand.swift */,
|
||||||
C4B79EC029CA473000A483EE /* InstallPhpVersionCommand.swift */,
|
C4B79EC029CA473000A483EE /* InstallPhpVersionCommand.swift */,
|
||||||
C4B79ECA29CA475900A483EE /* RemovePhpVersionCommand.swift */,
|
C4B79ECA29CA475900A483EE /* RemovePhpVersionCommand.swift */,
|
||||||
|
C43BCD4329FBEF40001547BC /* HomebrewOperation.swift */,
|
||||||
);
|
);
|
||||||
path = Commands;
|
path = Commands;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -2442,6 +2448,7 @@
|
|||||||
C40508AF28ADA23D008FAC1F /* NoDomainResultsView.swift in Sources */,
|
C40508AF28ADA23D008FAC1F /* NoDomainResultsView.swift in Sources */,
|
||||||
C4B79ECB29CA475900A483EE /* RemovePhpVersionCommand.swift in Sources */,
|
C4B79ECB29CA475900A483EE /* RemovePhpVersionCommand.swift in Sources */,
|
||||||
C4D89BC62783C99400A02B68 /* ComposerJson.swift in Sources */,
|
C4D89BC62783C99400A02B68 /* ComposerJson.swift in Sources */,
|
||||||
|
C43BCD4429FBEF40001547BC /* HomebrewOperation.swift in Sources */,
|
||||||
C4E2E84A28FC1E70003B070C /* DataExtension.swift in Sources */,
|
C4E2E84A28FC1E70003B070C /* DataExtension.swift in Sources */,
|
||||||
C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */,
|
C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */,
|
||||||
C42337A3281F19F000459A48 /* Xdebug.swift in Sources */,
|
C42337A3281F19F000459A48 /* Xdebug.swift in Sources */,
|
||||||
@ -2618,6 +2625,7 @@
|
|||||||
C45B914B295607F400F4EC78 /* Service.swift in Sources */,
|
C45B914B295607F400F4EC78 /* Service.swift in Sources */,
|
||||||
C471E7D928F9BA8F0021E251 /* TestableShell.swift in Sources */,
|
C471E7D928F9BA8F0021E251 /* TestableShell.swift in Sources */,
|
||||||
C471E81428F9BAE80021E251 /* NSWindowExtension.swift in Sources */,
|
C471E81428F9BAE80021E251 /* NSWindowExtension.swift in Sources */,
|
||||||
|
C43BCD4629FBEF40001547BC /* HomebrewOperation.swift in Sources */,
|
||||||
C471E7D328F9BA8F0021E251 /* ActiveShell.swift in Sources */,
|
C471E7D328F9BA8F0021E251 /* ActiveShell.swift in Sources */,
|
||||||
C4B79EC829CA474200A483EE /* FakeCommand.swift in Sources */,
|
C4B79EC829CA474200A483EE /* FakeCommand.swift in Sources */,
|
||||||
C471E7DE28F9BAA30021E251 /* CommandProtocol.swift in Sources */,
|
C471E7DE28F9BAA30021E251 /* CommandProtocol.swift in Sources */,
|
||||||
@ -2802,6 +2810,7 @@
|
|||||||
C471E82C28F9BB340021E251 /* ValetListable.swift in Sources */,
|
C471E82C28F9BB340021E251 /* ValetListable.swift in Sources */,
|
||||||
C471E82828F9BB310021E251 /* BrewDiagnostics.swift in Sources */,
|
C471E82828F9BB310021E251 /* BrewDiagnostics.swift in Sources */,
|
||||||
C471E81E28F9BB260021E251 /* BetterAlert.swift in Sources */,
|
C471E81E28F9BB260021E251 /* BetterAlert.swift in Sources */,
|
||||||
|
C43BCD4729FBEF40001547BC /* HomebrewOperation.swift in Sources */,
|
||||||
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */,
|
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */,
|
||||||
C471E7D228F9BA630021E251 /* ActiveFileSystem.swift in Sources */,
|
C471E7D228F9BA630021E251 /* ActiveFileSystem.swift in Sources */,
|
||||||
C471E80028F9BAD10021E251 /* Xdebug.swift in Sources */,
|
C471E80028F9BAD10021E251 /* Xdebug.swift in Sources */,
|
||||||
@ -3033,6 +3042,7 @@
|
|||||||
C4D36602291132B7006BD146 /* ValetScanners.swift in Sources */,
|
C4D36602291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||||
C40934AB298EEDA900D25014 /* CaskFileParserTest.swift in Sources */,
|
C40934AB298EEDA900D25014 /* CaskFileParserTest.swift in Sources */,
|
||||||
C436B39E29F3C42500B6A64E /* PreferencesTabs.swift in Sources */,
|
C436B39E29F3C42500B6A64E /* PreferencesTabs.swift in Sources */,
|
||||||
|
C43BCD4529FBEF40001547BC /* HomebrewOperation.swift in Sources */,
|
||||||
C4551657297AED18009B8466 /* ValetRcTest.swift in Sources */,
|
C4551657297AED18009B8466 /* ValetRcTest.swift in Sources */,
|
||||||
C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
||||||
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct BrewFormula {
|
class BrewFormula {
|
||||||
/// Name of the formula.
|
/// Name of the formula.
|
||||||
let name: String
|
let name: String
|
||||||
|
|
||||||
@ -30,4 +30,12 @@ struct BrewFormula {
|
|||||||
var hasUpgrade: Bool {
|
var hasUpgrade: Bool {
|
||||||
return upgradeVersion != nil
|
return upgradeVersion != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func getHomebrewFolder() -> String {
|
||||||
|
#error("This must return the path to the Homebrew folder")
|
||||||
|
}
|
||||||
|
|
||||||
|
public func isHealthy() -> Bool {
|
||||||
|
#error("This must check if the PHP version works")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,24 @@ protocol BrewCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension BrewCommand {
|
extension BrewCommand {
|
||||||
|
internal func reportInstallationProgress(_ text: String) -> (Double, String)? {
|
||||||
|
if text.contains("Fetching") {
|
||||||
|
return (0.1, "phpman.steps.fetching".localized)
|
||||||
|
}
|
||||||
|
if text.contains("Downloading") {
|
||||||
|
return (0.25, "phpman.steps.downloading".localized)
|
||||||
|
}
|
||||||
|
if text.contains("Installing") {
|
||||||
|
return (0.60, "phpman.steps.installing".localized)
|
||||||
|
}
|
||||||
|
if text.contains("Pouring") {
|
||||||
|
return (0.80, "phpman.steps.pouring".localized)
|
||||||
|
}
|
||||||
|
if text.contains("Summary") {
|
||||||
|
return (0.90, "phpman.steps.summary".localized)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BrewCommandProgress {
|
struct BrewCommandProgress {
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
//
|
||||||
|
// HomebrewOperationManager.swift
|
||||||
|
// PHP Monitor
|
||||||
|
//
|
||||||
|
// Created by Nico Verbruggen on 28/04/2023.
|
||||||
|
// Copyright © 2023 Nico Verbruggen. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class HomebrewOperation {
|
||||||
|
|
||||||
|
let installing: [String]
|
||||||
|
let upgrading: [String]
|
||||||
|
|
||||||
|
/**
|
||||||
|
You can pass in which PHP versions need to be upgraded and which ones need to be installed.
|
||||||
|
The process will be executed in two steps: first upgrades, then installations.
|
||||||
|
Upgrades come first because... well, otherwise installations may very well break.
|
||||||
|
Each version that is installed will need to be checked afterwards (if it is OK).
|
||||||
|
*/
|
||||||
|
public init(
|
||||||
|
upgrading: [String],
|
||||||
|
installing: [String]
|
||||||
|
) {
|
||||||
|
self.installing = installing
|
||||||
|
self.upgrading = upgrading
|
||||||
|
}
|
||||||
|
|
||||||
|
func execute(onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
||||||
|
try await self.upgradePackages()
|
||||||
|
try await self.installPackages()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func upgradePackages() async throws {
|
||||||
|
let command = """
|
||||||
|
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
|
||||||
|
\(Paths.brew) upgrade \(self.upgrading.joined(separator: " "))
|
||||||
|
"""
|
||||||
|
|
||||||
|
print(command)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func installPackages() async throws {
|
||||||
|
let command = """
|
||||||
|
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
|
||||||
|
\(Paths.brew) install \(self.upgrading.joined(separator: " ")) --force
|
||||||
|
"""
|
||||||
|
|
||||||
|
print(command)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func determineHealth(formula: String) -> Bool {
|
||||||
|
#warning("Should return proper health")
|
||||||
|
return false
|
||||||
|
|
||||||
|
// If the health comes back as negative, attempt to reinstall
|
||||||
|
let command = """
|
||||||
|
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
|
||||||
|
\(Paths.brew) reinstall \(formula) --force
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,7 @@ class InstallPhpVersionCommand: BrewCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func execute(onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
func execute(onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
||||||
let progressTitle = "Installing PHP \(version)..."
|
let progressTitle = "Running Homebrew operations..."
|
||||||
|
|
||||||
onProgress(.create(
|
onProgress(.create(
|
||||||
value: 0.2,
|
value: 0.2,
|
||||||
@ -83,26 +83,4 @@ class InstallPhpVersionCommand: BrewCommand {
|
|||||||
throw BrewCommandError(error: "The command failed to run correctly.")
|
throw BrewCommandError(error: "The command failed to run correctly.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reportInstallationProgress(_ text: String) -> (Double, String)? {
|
|
||||||
if text.contains("Fetching") {
|
|
||||||
return (0.1, "Fetching...")
|
|
||||||
}
|
|
||||||
if text.contains("Downloading") {
|
|
||||||
return (0.25, "Downloading package data...")
|
|
||||||
}
|
|
||||||
if text.contains("Already downloaded") || text.contains("Downloaded") {
|
|
||||||
return (0.50, "Downloaded!")
|
|
||||||
}
|
|
||||||
if text.contains("Installing") {
|
|
||||||
return (0.60, "Installing...")
|
|
||||||
}
|
|
||||||
if text.contains("Pouring") {
|
|
||||||
return (0.80, "Pouring...")
|
|
||||||
}
|
|
||||||
if text.contains("Summary") {
|
|
||||||
return (0.90, "The installation is done!")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ struct BlockingOverlayView<Content: View>: View {
|
|||||||
.font(.system(size: 11))
|
.font(.system(size: 11))
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
.padding(.top, -4)
|
.padding(.top, -4)
|
||||||
}
|
}.padding(60)
|
||||||
}
|
}
|
||||||
}.background(Color.white)
|
}.background(Color.white)
|
||||||
.disabled(isBlocking)
|
.disabled(isBlocking)
|
||||||
|
@ -149,10 +149,9 @@ struct PhpFormulaeView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
// TODO: Remove this and add a "upgrade all" button instead?
|
|
||||||
if formula.hasUpgrade {
|
if formula.hasUpgrade {
|
||||||
Button("phpman.buttons.update".localizedForSwiftUI) {
|
Button("phpman.buttons.update".localizedForSwiftUI) {
|
||||||
Task { await self.install(formula) }
|
Task { await self.install(formula, upgrade: true) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -97,11 +97,11 @@
|
|||||||
"phpman.version.available_for_installation" = "This version can be installed.";
|
"phpman.version.available_for_installation" = "This version can be installed.";
|
||||||
"phpman.buttons.uninstall" = "Uninstall";
|
"phpman.buttons.uninstall" = "Uninstall";
|
||||||
"phpman.buttons.install" = "Install";
|
"phpman.buttons.install" = "Install";
|
||||||
"phpman.buttons.update_all" = "Update All";
|
"phpman.buttons.update" = "Update";
|
||||||
|
|
||||||
"phpman.title" = "PHP Version Manager";
|
"phpman.title" = "PHP Version Manager";
|
||||||
"phpman.description" = "**PHP Version Manager** lets you install different PHP versions via Homebrew.";
|
"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. For more information, please consult the FAQ.";
|
"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.refresh.button" = "Search for Updates";
|
"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.";
|
"phpman.refresh.button.description" = "You can press the refresh button to check if any updates are available to installed PHP versions.";
|
||||||
|
|
||||||
@ -129,6 +129,12 @@ You may be asked for your password during the uninstallation process if file per
|
|||||||
"phpman.unlinked.desc" = "You likely still have some version of PHP that is currently installed, but currently no version of PHP is linked.";
|
"phpman.unlinked.desc" = "You likely still have some version of PHP that is currently installed, but currently no version of PHP is linked.";
|
||||||
"phpman.unlinked.detail" = "Without any PHP version linked, the `php` binary is not accessible on your system and you cannot run any PHP scripts without explicitly being part of the PATH. You can have PHP Monitor automatically resolve this problem (choose Fix Automatically in the main menu), or fix it yourself by running `brew link php --force`.";
|
"phpman.unlinked.detail" = "Without any PHP version linked, the `php` binary is not accessible on your system and you cannot run any PHP scripts without explicitly being part of the PATH. You can have PHP Monitor automatically resolve this problem (choose Fix Automatically in the main menu), or fix it yourself by running `brew link php --force`.";
|
||||||
|
|
||||||
|
"phpman.steps.fetching" = "Fetching...";
|
||||||
|
"phpman.steps.downloading" = "Downloading package data...";
|
||||||
|
"phpman.steps.installing" = "Installing some package data...";
|
||||||
|
"phpman.steps.pouring" = "Pouring... This can take a while...";
|
||||||
|
"phpman.steps.summary" = "Some package has finished installing...";
|
||||||
|
|
||||||
// LITE MODE
|
// LITE MODE
|
||||||
|
|
||||||
"lite_mode_explanation.title" = "You are currently running PHP Monitor in Standalone Mode.";
|
"lite_mode_explanation.title" = "You are currently running PHP Monitor in Standalone Mode.";
|
||||||
|
Reference in New Issue
Block a user