1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-06 21:00:07 +01:00

🏗 WIP: Upgrade command dry-run check

This commit is contained in:
2023-04-03 20:15:13 +02:00
parent 4bca47a6d9
commit 9f608439fc
2 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
//
// InstallPhpVersionCommand.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 21/03/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import Foundation
public typealias BrewDependent = String
class UpgradePhpVersionCommand: BrewCommand {
let formula: String
let version: String
init(formula: String) {
self.version = formula
.replacingOccurrences(of: "php@", with: "")
.replacingOccurrences(of: "shivammathur/php/", with: "")
self.formula = formula
}
func execute() async throws -> [BrewDependent] {
let command = """
export HOMEBREW_NO_INSTALL_UPGRADE=true; \
export HOMEBREW_NO_INSTALL_CLEANUP=true; \
\(Paths.brew) upgrade \(formula) -n
"""
// Use this command to do a dry-run of the upgrade
// This will let us figure out the impact or failure modes
let (process, _) = try! await Shell.attach(
command,
didReceiveOutput: { text, _ in
if !text.isEmpty {
Log.perf(text)
}
},
withTimeout: .minutes(5)
)
return []
}
func execute(onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
//
}
}