1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +02:00

♻️ Refactoring, version bump for M1 support (#20)

This commit is contained in:
2021-01-01 22:58:16 +01:00
parent 94f086881a
commit 4ea11c5f59
3 changed files with 25 additions and 20 deletions

View File

@ -423,7 +423,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = phpmon/Info.plist;
@ -431,7 +431,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -447,7 +447,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = phpmon/Info.plist;
@ -455,7 +455,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -8,7 +8,7 @@
import Foundation
enum HomebrewDirectory: String {
enum HomebrewDir: String {
case opt = "/opt/homebrew/bin"
case usr = "/usr/local/bin"
}
@ -16,24 +16,26 @@ enum HomebrewDirectory: String {
class Paths {
static let shared = Paths()
var baseDirectory : HomebrewDirectory
var baseDir : HomebrewDir
init() {
let optBrewFound = Shell.fileExists("\(HomebrewDirectory.opt.rawValue)/brew")
let usrBrewFound = Shell.fileExists("\(HomebrewDirectory.usr.rawValue)/brew")
let optBrewFound = Shell.fileExists("\(HomebrewDir.opt.rawValue)/brew")
let usrBrewFound = Shell.fileExists("\(HomebrewDir.usr.rawValue)/brew")
if (optBrewFound) {
self.baseDirectory = .opt
// This is usually the case with Homebrew installed on Apple Silicon
self.baseDir = .opt
} else if (usrBrewFound) {
self.baseDirectory = .usr
// This is usually the case with Homebrew installed on Intel (or Rosetta 2)
self.baseDir = .usr
} else {
// Falling back to Intel
print("Seems like we couldn't determine the architecture.")
// Falling back to default "legacy" Homebrew location (for Intel)
print("Seems like we couldn't determine the Homebrew directory.")
print("This usually means we're in trouble... (no Homebrew?)")
self.baseDirectory = .usr
self.baseDir = .usr
}
print("Homebrew directory: \(self.baseDirectory)")
print("Homebrew directory: \(self.baseDir)")
}
public static func brew() -> String {
@ -45,11 +47,11 @@ class Paths {
}
public static func binPath() -> String {
return self.shared.baseDirectory.rawValue
return self.shared.baseDir.rawValue
}
public static func optPath() -> String {
switch self.shared.baseDirectory {
switch self.shared.baseDir {
case .opt:
return "/opt/homebrew/opt"
case .usr:
@ -58,7 +60,7 @@ class Paths {
}
public static func etcPath() -> String {
switch self.shared.baseDirectory {
switch self.shared.baseDir {
case .opt:
return "/opt/homebrew/etc"
case .usr:

View File

@ -47,9 +47,12 @@ class Shell {
)!
}
public static func fileExists(_ filePath: String) -> Bool {
/**
Checks if a file exists at the provided path.
*/
public static func fileExists(_ path: String) -> Bool {
return Shell.user.pipe(
"if [ -f \(filePath) ]; then echo \"Y\"; fi"
).contains("Y")
"if [ -f \(path) ]; then echo \"PHP_Y_FE\"; fi"
).contains("PHP_Y_FE")
}
}