diff --git a/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor DEV.xcscheme b/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor DEV.xcscheme
index 0f36fe6..0b2dcd1 100644
--- a/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor DEV.xcscheme
+++ b/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor DEV.xcscheme
@@ -79,11 +79,11 @@
isEnabled = "NO">
diff --git a/phpmon/Common/Shell/RealShell.swift b/phpmon/Common/Shell/RealShell.swift
index 77ab643..7f10d21 100644
--- a/phpmon/Common/Shell/RealShell.swift
+++ b/phpmon/Common/Shell/RealShell.swift
@@ -8,6 +8,9 @@
import Foundation
+extension Process: @unchecked Sendable {}
+extension Timer: @unchecked Sendable {}
+
class RealShell: ShellProtocol {
/**
The launch path of the terminal in question that is used.
@@ -123,7 +126,8 @@ class RealShell: ShellProtocol {
withTimeout timeout: TimeInterval = 5.0
) async throws -> (Process, ShellOutput) {
let task = getShellProcess(for: command)
- var output = ShellOutput(out: "", err: "")
+ // TODO: Make ShellOutput a struct again and add a class type for this use case only
+ let output = ShellOutput(out: "", err: "")
task.listen { incoming in
output.out += incoming; didReceiveOutput(incoming, .stdOut)
@@ -134,7 +138,7 @@ class RealShell: ShellProtocol {
return try await withCheckedThrowingContinuation({ continuation in
var timer: Timer?
- task.terminationHandler = { process in
+ task.terminationHandler = { [timer, output] process in
process.haltListening()
timer?.invalidate()
diff --git a/phpmon/Common/Shell/ShellProtocol.swift b/phpmon/Common/Shell/ShellProtocol.swift
index a6e2fed..eea59d4 100644
--- a/phpmon/Common/Shell/ShellProtocol.swift
+++ b/phpmon/Common/Shell/ShellProtocol.swift
@@ -52,7 +52,7 @@ enum ShellStream: Codable {
case stdOut, stdErr, stdIn
}
-struct ShellOutput {
+class ShellOutput {
var out: String
var err: String
@@ -60,6 +60,11 @@ struct ShellOutput {
return err.lengthOfBytes(using: .utf8) > 0
}
+ init(out: String, err: String) {
+ self.out = out
+ self.err = err
+ }
+
static func out(_ out: String?, _ err: String? = nil) -> ShellOutput {
return ShellOutput(out: out ?? "", err: err ?? "")
}
diff --git a/phpmon/Common/Testables/TestableConfiguration.swift b/phpmon/Common/Testables/TestableConfiguration.swift
index b27ac18..80ed1cd 100644
--- a/phpmon/Common/Testables/TestableConfiguration.swift
+++ b/phpmon/Common/Testables/TestableConfiguration.swift
@@ -31,10 +31,11 @@ public struct TestableConfiguration: Codable {
}
static func loadFrom(path: String) -> TestableConfiguration {
+ let url = URL(fileURLWithPath: path.replacingTildeWithHomeDirectory)
+
return try! JSONDecoder().decode(
TestableConfiguration.self,
- from: try! String(contentsOf: URL(fileURLWithPath: path), encoding: .utf8)
- .data(using: .utf8)!
+ from: try! String(contentsOf: url, encoding: .utf8).data(using: .utf8)!
)
}
}
diff --git a/phpmon/Domain/DomainList/AddSiteVC.swift b/phpmon/Domain/DomainList/AddSiteVC.swift
index 9ae5fde..a427613 100644
--- a/phpmon/Domain/DomainList/AddSiteVC.swift
+++ b/phpmon/Domain/DomainList/AddSiteVC.swift
@@ -51,7 +51,7 @@ class AddSiteVC: NSViewController, NSTextFieldDelegate {
// MARK: - Outlet Interactions
- @IBAction func pressedCreateLink(_ sender: Any) async {
+ func createLink() async {
let path = pathControl.url!.path
let name = inputDomainName.stringValue
@@ -89,6 +89,10 @@ class AddSiteVC: NSViewController, NSTextFieldDelegate {
)
}
+ @IBAction func pressedCreateLink(_ sender: Any) {
+ Task { await createLink() }
+ }
+
@IBAction func pressedCancel(_ sender: Any) {
dismissView(outcome: .cancel)
}
diff --git a/phpmon/Domain/DomainList/DomainListVC.swift b/phpmon/Domain/DomainList/DomainListVC.swift
index df410a1..24c47be 100644
--- a/phpmon/Domain/DomainList/DomainListVC.swift
+++ b/phpmon/Domain/DomainList/DomainListVC.swift
@@ -110,7 +110,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
@MainActor public func setUIBusy() {
// If it takes more than 0.5s to set the UI to not busy, show a spinner
timer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: { _ in
- self.progressIndicator.startAnimation(true)
+ DispatchQueue.main.async { self.progressIndicator.startAnimation(true) }
})
tableView.alphaValue = 0.3
diff --git a/tests/unit/Testables/TestableConfigurationTest.swift b/tests/unit/Testables/TestableConfigurationTest.swift
index 9398783..97ec216 100644
--- a/tests/unit/Testables/TestableConfigurationTest.swift
+++ b/tests/unit/Testables/TestableConfigurationTest.swift
@@ -11,10 +11,20 @@ import XCTest
class TestableConfigurationTest: XCTestCase {
func test_configuration_can_be_saved_as_json() async {
var configuration = TestableConfigurations.working
- try! configuration.toJson().write(toFile: "/tmp/pmc_working.json", atomically: true, encoding: .utf8)
+
+ try! configuration.toJson().write(
+ toFile: NSHomeDirectory() + "/.phpmon_fconf_working.json",
+ atomically: true,
+ encoding: .utf8
+ )
configuration.filesystem["/opt/homebrew/bin/php"] = nil
- try! configuration.toJson().write(toFile: "/tmp/pmc_broken.json", atomically: true, encoding: .utf8)
+
+ try! configuration.toJson().write(
+ toFile: NSHomeDirectory() + "/.phpmon_fconf_broken.json",
+ atomically: true,
+ encoding: .utf8
+ )
}
}