mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
♻️ Paths now uses static variables instead of methods
This commit is contained in:
@ -14,7 +14,7 @@ class Actions {
|
||||
|
||||
public static func detectPhpVersions() -> [String]
|
||||
{
|
||||
let files = Shell.pipe("ls \(Paths.optPath()) | grep php@")
|
||||
let files = Shell.pipe("ls \(Paths.optPath) | grep php@")
|
||||
var versions = files.components(separatedBy: "\n")
|
||||
|
||||
// Remove all empty strings
|
||||
@ -83,13 +83,13 @@ class Actions {
|
||||
|
||||
public static func openGenericPhpConfigFolder()
|
||||
{
|
||||
let files = [NSURL(fileURLWithPath: "\(Paths.etcPath())/php")];
|
||||
let files = [NSURL(fileURLWithPath: "\(Paths.etcPath)/php")];
|
||||
NSWorkspace.shared.activateFileViewerSelecting(files as [URL])
|
||||
}
|
||||
|
||||
public static func openPhpConfigFolder(version: String)
|
||||
{
|
||||
let files = [NSURL(fileURLWithPath: "\(Paths.etcPath())/php/\(version)/php.ini")];
|
||||
let files = [NSURL(fileURLWithPath: "\(Paths.etcPath)/php/\(version)/php.ini")];
|
||||
NSWorkspace.shared.activateFileViewerSelecting(files as [URL])
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ class Actions {
|
||||
public static func didFindXdebug(_ version: String) -> Bool
|
||||
{
|
||||
return grepContains(
|
||||
file: "\(Paths.etcPath())/php/\(version)/php.ini",
|
||||
file: "\(Paths.etcPath)/php/\(version)/php.ini",
|
||||
query: "zend_extension=\"xdebug.so\""
|
||||
)
|
||||
}
|
||||
@ -112,7 +112,7 @@ class Actions {
|
||||
public static func didEnableXdebug(_ version: String) -> Bool
|
||||
{
|
||||
return !grepContains(
|
||||
file: "\(Paths.etcPath())/php/\(version)/php.ini",
|
||||
file: "\(Paths.etcPath)/php/\(version)/php.ini",
|
||||
query: "; zend_extension=\"xdebug.so\""
|
||||
)
|
||||
}
|
||||
@ -123,12 +123,12 @@ class Actions {
|
||||
|
||||
self.didEnableXdebug(version)
|
||||
? sed(
|
||||
file: "\(Paths.etcPath())/php/\(version)/php.ini",
|
||||
file: "\(Paths.etcPath)/php/\(version)/php.ini",
|
||||
original: "zend_extension=\"xdebug.so\"",
|
||||
replacement: "; zend_extension=\"xdebug.so\""
|
||||
)
|
||||
: sed(
|
||||
file: "\(Paths.etcPath())/php/\(version)/php.ini",
|
||||
file: "\(Paths.etcPath)/php/\(version)/php.ini",
|
||||
original: "; zend_extension=\"xdebug.so\"",
|
||||
replacement: "zend_extension=\"xdebug.so\""
|
||||
)
|
||||
@ -167,7 +167,7 @@ class Actions {
|
||||
*/
|
||||
private static func brew(_ command: String, sudo: Bool = false)
|
||||
{
|
||||
Shell.run("\(sudo ? "sudo " : "")" + "\(Paths.brew()) \(command)")
|
||||
Shell.run("\(sudo ? "sudo " : "")" + "\(Paths.brew) \(command)")
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,14 +24,14 @@ class Startup {
|
||||
self.failureCallback = failure
|
||||
|
||||
self.performEnvironmentCheck(
|
||||
!Shell.fileExists("\(Paths.binPath())/php"),
|
||||
!Shell.fileExists("\(Paths.binPath)/php"),
|
||||
messageText: "startup.errors.php_binary.title".localized,
|
||||
informativeText: "startup.errors.php_binary_desc".localized,
|
||||
breaking: true
|
||||
)
|
||||
|
||||
self.performEnvironmentCheck(
|
||||
!Shell.pipe("ls \(Paths.optPath()) | grep php").contains("php"),
|
||||
!Shell.pipe("ls \(Paths.optPath) | grep php").contains("php"),
|
||||
messageText: "startup.errors.php_opt.title".localized,
|
||||
informativeText: "startup.errors.php_opt.desc".localized,
|
||||
breaking: true
|
||||
@ -45,7 +45,7 @@ class Startup {
|
||||
)
|
||||
|
||||
self.performEnvironmentCheck(
|
||||
!Shell.pipe("cat /private/etc/sudoers.d/brew").contains("\(Paths.binPath())/brew"),
|
||||
!Shell.pipe("cat /private/etc/sudoers.d/brew").contains("\(Paths.binPath)/brew"),
|
||||
messageText: "startup.errors.sudoers_brew.title".localized,
|
||||
informativeText: "startup.errors.sudoers_brew.desc".localized,
|
||||
breaking: true
|
||||
@ -58,7 +58,7 @@ class Startup {
|
||||
breaking: true
|
||||
)
|
||||
|
||||
let services = Shell.pipe("\(Paths.brew()) services list | grep php")
|
||||
let services = Shell.pipe("\(Paths.brew) services list | grep php")
|
||||
self.performEnvironmentCheck(
|
||||
(services.countInstances(of: "started") > 1),
|
||||
messageText: "startup.errors.services.title".localized,
|
||||
@ -81,7 +81,7 @@ class Startup {
|
||||
print("PHP Monitor has determined the application has successfully passed all checks.")
|
||||
print("Determining which version of PHP is aliased to `php` via Homebrew...")
|
||||
|
||||
let brewPhpAlias = Shell.pipe("\(Paths.brew()) info php --json");
|
||||
let brewPhpAlias = Shell.pipe("\(Paths.brew) info php --json");
|
||||
|
||||
App.shared.brewPhpPackage = try! JSONDecoder().decode(
|
||||
[HomebrewPackage].self,
|
||||
|
@ -21,7 +21,7 @@ class PhpInstall {
|
||||
// MARK: - Initializer
|
||||
|
||||
init() {
|
||||
let version = Command.execute(path: Paths.php(), arguments: ["-r", "print phpversion();"])
|
||||
let version = Command.execute(path: Paths.php, arguments: ["-r", "print phpversion();"])
|
||||
|
||||
if (version == "" || version.contains("Warning")) {
|
||||
self.version.short = "💩 BROKEN"
|
||||
|
@ -213,7 +213,7 @@ class MainMenu: NSObject, NSWindowDelegate {
|
||||
@objc public func openPhpInfo() {
|
||||
self.waitAndExecute({
|
||||
try! "<?php phpinfo();".write(toFile: "/tmp/phpmon_phpinfo.php", atomically: true, encoding: .utf8)
|
||||
Shell.run("\(Paths.binPath())/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
||||
Shell.run("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
||||
}, {
|
||||
NSWorkspace.shared.open(URL(string: "file:///private/tmp/phpmon_phpinfo.html")!)
|
||||
})
|
||||
|
@ -39,25 +39,25 @@ class Paths {
|
||||
|
||||
// - MARK: Binaries
|
||||
|
||||
public static func brew() -> String {
|
||||
return "\(self.binPath())/brew"
|
||||
public static var brew: String {
|
||||
return "\(self.binPath)/brew"
|
||||
}
|
||||
|
||||
public static func php() -> String {
|
||||
return "\(self.binPath())/php"
|
||||
public static var php: String {
|
||||
return "\(self.binPath)/php"
|
||||
}
|
||||
|
||||
// - MARK: Paths
|
||||
|
||||
public static func binPath() -> String {
|
||||
public static var binPath: String {
|
||||
return "\(self.shared.baseDir.rawValue)/bin"
|
||||
}
|
||||
|
||||
public static func optPath() -> String {
|
||||
public static var optPath: String {
|
||||
return "\(self.shared.baseDir.rawValue)/opt"
|
||||
}
|
||||
|
||||
public static func etcPath() -> String {
|
||||
public static var etcPath: String {
|
||||
return "\(self.shared.baseDir.rawValue)/etc"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user