mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗️ WIP: Various fixes and improvements
- Fixed `brewPhpAlias` (must be configurable later) - Added TODOs for where the filesystem abstraction is required - Set `Homebrew.fake` early on when applying testable configuration - Evaluate `FakeValetSite` compatibility again - Never display sponsor alert when running tests - Upgrade TestableConfiguration.working to use PHP 8.2
This commit is contained in:
@ -1320,7 +1320,6 @@
|
|||||||
C471E6D928F9AFC20021E251 /* Testables */ = {
|
C471E6D928F9AFC20021E251 /* Testables */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
C471E6DB28F9AFD10021E251 /* Command */,
|
|
||||||
C471E6DA28F9AFCB0021E251 /* Filesystem */,
|
C471E6DA28F9AFCB0021E251 /* Filesystem */,
|
||||||
C413E43328DA3E8F00AE33C7 /* Shell */,
|
C413E43328DA3E8F00AE33C7 /* Shell */,
|
||||||
C4E2E84628FC1D8C003B070C /* TestableConfigurationTest.swift */,
|
C4E2E84628FC1D8C003B070C /* TestableConfigurationTest.swift */,
|
||||||
@ -1337,13 +1336,6 @@
|
|||||||
path = Filesystem;
|
path = Filesystem;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
C471E6DB28F9AFD10021E251 /* Command */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
);
|
|
||||||
path = Command;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
C471E79628F9B4260021E251 /* tests */ = {
|
C471E79628F9B4260021E251 /* tests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -57,6 +57,8 @@ class PhpEnv {
|
|||||||
As such, we take that information from Homebrew.
|
As such, we take that information from Homebrew.
|
||||||
*/
|
*/
|
||||||
static var brewPhpAlias: String {
|
static var brewPhpAlias: String {
|
||||||
|
if Homebrew.fake { return "8.2" }
|
||||||
|
|
||||||
return Self.shared.homebrewPackage.version
|
return Self.shared.homebrewPackage.version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class PhpConfigurationFile: CreatedFromFile {
|
|||||||
let path = filePath.replacingOccurrences(of: "~", with: Paths.homePath)
|
let path = filePath.replacingOccurrences(of: "~", with: Paths.homePath)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
// TODO: Use FileSystem abstraction
|
||||||
let fileContents = try String(contentsOfFile: path)
|
let fileContents = try String(contentsOfFile: path)
|
||||||
return Self.init(path: path, contents: fileContents)
|
return Self.init(path: path, contents: fileContents)
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -17,6 +17,7 @@ public struct TestableConfiguration: Codable {
|
|||||||
func apply() {
|
func apply() {
|
||||||
Log.separator()
|
Log.separator()
|
||||||
Log.info("USING TESTABLE CONFIGURATION...")
|
Log.info("USING TESTABLE CONFIGURATION...")
|
||||||
|
Homebrew.fake = true
|
||||||
Log.separator()
|
Log.separator()
|
||||||
Log.info("Applying fake shell...")
|
Log.info("Applying fake shell...")
|
||||||
ActiveShell.useTestable(shellOutput)
|
ActiveShell.useTestable(shellOutput)
|
||||||
@ -27,7 +28,6 @@ public struct TestableConfiguration: Codable {
|
|||||||
Log.info("Applying fake scanner...")
|
Log.info("Applying fake scanner...")
|
||||||
ValetScanner.useFake()
|
ValetScanner.useFake()
|
||||||
Log.info("Applying fake services manager...")
|
Log.info("Applying fake services manager...")
|
||||||
Homebrew.fake = true
|
|
||||||
ServicesManager.useFake()
|
ServicesManager.useFake()
|
||||||
Log.info("Applying fake Valet domain interactor...")
|
Log.info("Applying fake Valet domain interactor...")
|
||||||
ValetInteractor.useFake()
|
ValetInteractor.useFake()
|
||||||
@ -46,6 +46,19 @@ public struct TestableConfiguration: Codable {
|
|||||||
static func loadFrom(path: String) -> TestableConfiguration {
|
static func loadFrom(path: String) -> TestableConfiguration {
|
||||||
let url = URL(fileURLWithPath: path.replacingTildeWithHomeDirectory)
|
let url = URL(fileURLWithPath: path.replacingTildeWithHomeDirectory)
|
||||||
|
|
||||||
|
if !FileManager.default.fileExists(atPath: url.path) {
|
||||||
|
/*
|
||||||
|
You will need to run the `TestableConfigurationTest` test,
|
||||||
|
which will generate two configuration files you can use.
|
||||||
|
*/
|
||||||
|
fatalError("Error: the expected configuration file at \(url.path) is missing!")
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If the decoder below fails to decode the configuration file,
|
||||||
|
the configuration may have been updated.
|
||||||
|
In that case, you will need to run the test (see above) again.
|
||||||
|
*/
|
||||||
return try! JSONDecoder().decode(
|
return try! JSONDecoder().decode(
|
||||||
TestableConfiguration.self,
|
TestableConfiguration.self,
|
||||||
from: try! String(contentsOf: url, encoding: .utf8).data(using: .utf8)!
|
from: try! String(contentsOf: url, encoding: .utf8).data(using: .utf8)!
|
||||||
|
@ -35,15 +35,6 @@ class FakeValetSite: ValetSite {
|
|||||||
self.isolatedPhpVersion = PhpInstallation(isolated)
|
self.isolatedPhpVersion = PhpInstallation(isolated)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Resolve this at a later time
|
self.evaluateCompatibility()
|
||||||
/*
|
|
||||||
self.composerPhpCompatibleWithLinked = self.composerPhp.split(separator: "|")
|
|
||||||
.map { string in
|
|
||||||
let origin = self.isolatedPhpVersion?.versionNumber.short ?? PhpEnv.phpInstall.version.long
|
|
||||||
return !PhpVersionNumberCollection.make(from: [origin])
|
|
||||||
.matching(constraint: string.trimmingCharacters(in: .whitespacesAndNewlines))
|
|
||||||
.isEmpty
|
|
||||||
}.contains(true)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,10 @@ class Stats {
|
|||||||
*/
|
*/
|
||||||
public static func evaluateSponsorMessageShouldBeDisplayed() {
|
public static func evaluateSponsorMessageShouldBeDisplayed() {
|
||||||
|
|
||||||
|
if Homebrew.fake {
|
||||||
|
return Log.info("A fake environment is in use, skipping sponsor alert.")
|
||||||
|
}
|
||||||
|
|
||||||
if Bundle.main.bundleIdentifier?.contains("beta") ?? false {
|
if Bundle.main.bundleIdentifier?.contains("beta") ?? false {
|
||||||
return Log.info("Sponsor messages never apply to beta builds.")
|
return Log.info("Sponsor messages never apply to beta builds.")
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,11 @@ struct ServicesView_Previews: PreviewProvider {
|
|||||||
.previewDisplayName("Loading")
|
.previewDisplayName("Loading")
|
||||||
|
|
||||||
ServicesView(manager: FakeServicesManager(
|
ServicesView(manager: FakeServicesManager(
|
||||||
formulae: ["php", "nginx", "dnsmasq", "thing1", "thing2", "thing3", "thing4", "thing5", "thing6", "thing7", "thing8"],
|
formulae: [
|
||||||
|
"php", "nginx", "dnsmasq", "thing1",
|
||||||
|
"thing2", "thing3", "thing4", "thing5",
|
||||||
|
"thing6", "thing7", "thing8"
|
||||||
|
],
|
||||||
status: .active
|
status: .active
|
||||||
), perRow: 4)
|
), perRow: 4)
|
||||||
.frame(width: 330.0)
|
.frame(width: 330.0)
|
||||||
|
@ -25,14 +25,14 @@ class TestableConfigurations {
|
|||||||
"/opt/homebrew/bin/valet"
|
"/opt/homebrew/bin/valet"
|
||||||
: .fake(.binary),
|
: .fake(.binary),
|
||||||
"/opt/homebrew/opt/php"
|
"/opt/homebrew/opt/php"
|
||||||
: .fake(.symlink, "/opt/homebrew/Cellar/php/8.1.10_1"),
|
: .fake(.symlink, "/opt/homebrew/Cellar/php/8.2.0"),
|
||||||
"/opt/homebrew/opt/php@8.1/bin/php"
|
"/opt/homebrew/opt/php@8.2/bin/php"
|
||||||
: .fake(.symlink, "/opt/homebrew/Cellar/php/8.1.10_1/bin/php"),
|
: .fake(.symlink, "/opt/homebrew/Cellar/php/8.2.0/bin/php"),
|
||||||
"/opt/homebrew/Cellar/php/8.1.10_1/bin/php"
|
"/opt/homebrew/Cellar/php/8.2.0/bin/php"
|
||||||
: .fake(.binary),
|
: .fake(.binary),
|
||||||
"/opt/homebrew/Cellar/php/8.1.10_1/bin/php-config"
|
"/opt/homebrew/Cellar/php/8.2.0/bin/php-config"
|
||||||
: .fake(.binary),
|
: .fake(.binary),
|
||||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf"
|
"/opt/homebrew/etc/php/8.2/php-fpm.d/www.conf"
|
||||||
: .fake(.text),
|
: .fake(.text),
|
||||||
"~/.config/valet/config.json"
|
"~/.config/valet/config.json"
|
||||||
: .fake(.text, """
|
: .fake(.text, """
|
||||||
@ -45,7 +45,7 @@ class TestableConfigurations {
|
|||||||
"loopback": "127.0.0.1"
|
"loopback": "127.0.0.1"
|
||||||
}
|
}
|
||||||
"""),
|
"""),
|
||||||
"/opt/homebrew/etc/php/8.1/php-fpm.d/valet-fpm.conf"
|
"/opt/homebrew/etc/php/8.2/php-fpm.d/valet-fpm.conf"
|
||||||
: .fake(.text),
|
: .fake(.text),
|
||||||
],
|
],
|
||||||
shellOutput: [
|
shellOutput: [
|
||||||
@ -57,15 +57,15 @@ class TestableConfigurations {
|
|||||||
: .instant("/opt/homebrew/bin/node"),
|
: .instant("/opt/homebrew/bin/node"),
|
||||||
"php -v"
|
"php -v"
|
||||||
: .instant("""
|
: .instant("""
|
||||||
PHP 8.1.10 (cli) (built: Sep 3 2022 12:09:27) (NTS)
|
PHP 8.2.0 (cli) (built: Dec XX 20XX XX:XX:XX) (NTS)
|
||||||
Copyright (c) The PHP Group
|
Copyright (c) The PHP Group
|
||||||
Zend Engine v4.1.10, Copyright (c) Zend Technologies
|
Zend Engine vX.X, Copyright (c) Zend Technologies
|
||||||
with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
|
with Zend OPcache vX.X, Copyright (c), by Zend Technologies
|
||||||
"""),
|
"""),
|
||||||
"ls /opt/homebrew/opt | grep php"
|
"ls /opt/homebrew/opt | grep php"
|
||||||
: .instant("php"),
|
: .instant("php"),
|
||||||
"ls /opt/homebrew/opt | grep php@"
|
"ls /opt/homebrew/opt | grep php@"
|
||||||
: .instant("php@8.1"),
|
: .instant("php@8.2"),
|
||||||
"sudo /opt/homebrew/bin/brew services info dnsmasq --json"
|
"sudo /opt/homebrew/bin/brew services info dnsmasq --json"
|
||||||
: .delayed(0.2, """
|
: .delayed(0.2, """
|
||||||
[
|
[
|
||||||
@ -110,7 +110,7 @@ class TestableConfigurations {
|
|||||||
nicoverbruggen/cask
|
nicoverbruggen/cask
|
||||||
shivammathur/php
|
shivammathur/php
|
||||||
"""),
|
"""),
|
||||||
"chmod +x /Users/nicoverbruggen/.config/phpmon/bin/pm81"
|
"chmod +x /Users/nicoverbruggen/.config/phpmon/bin/pm82"
|
||||||
: .instant(""),
|
: .instant(""),
|
||||||
"mkdir -p ~/.config/phpmon"
|
"mkdir -p ~/.config/phpmon"
|
||||||
: .instant(""),
|
: .instant(""),
|
||||||
@ -138,6 +138,8 @@ class TestableConfigurations {
|
|||||||
: .instant("version '5.6.2_976'"),
|
: .instant("version '5.6.2_976'"),
|
||||||
"/opt/homebrew/bin/brew unlink php"
|
"/opt/homebrew/bin/brew unlink php"
|
||||||
: .delayed(0.2, "OK"),
|
: .delayed(0.2, "OK"),
|
||||||
|
"/opt/homebrew/bin/brew unlink php@8.2"
|
||||||
|
: .delayed(0.2, "OK"),
|
||||||
"/opt/homebrew/bin/brew link php --overwrite --force"
|
"/opt/homebrew/bin/brew link php --overwrite --force"
|
||||||
: .delayed(0.2, "OK"),
|
: .delayed(0.2, "OK"),
|
||||||
"sudo /opt/homebrew/bin/brew services stop php"
|
"sudo /opt/homebrew/bin/brew services stop php"
|
||||||
@ -152,20 +154,20 @@ class TestableConfigurations {
|
|||||||
: .delayed(0.2, "OK"),
|
: .delayed(0.2, "OK"),
|
||||||
"sudo /opt/homebrew/bin/brew services start dnsmasq"
|
"sudo /opt/homebrew/bin/brew services start dnsmasq"
|
||||||
: .delayed(0.2, "OK"),
|
: .delayed(0.2, "OK"),
|
||||||
"ln -sF ~/.config/valet/valet81.sock ~/.config/valet/valet.sock"
|
"ln -sF ~/.config/valet/valet82.sock ~/.config/valet/valet.sock"
|
||||||
: .instant("OK"),
|
: .instant("OK"),
|
||||||
],
|
],
|
||||||
commandOutput: [
|
commandOutput: [
|
||||||
"/opt/homebrew/bin/php-config --version": "8.1.10",
|
"/opt/homebrew/bin/php-config --version": "8.2.0",
|
||||||
"/opt/homebrew/bin/php -r echo ini_get('memory_limit');": "512M",
|
"/opt/homebrew/bin/php -r echo ini_get('memory_limit');": "512M",
|
||||||
"/opt/homebrew/bin/php -r echo ini_get('upload_max_filesize');": "512M",
|
"/opt/homebrew/bin/php -r echo ini_get('upload_max_filesize');": "512M",
|
||||||
"/opt/homebrew/bin/php -r echo ini_get('post_max_size');": "512M",
|
"/opt/homebrew/bin/php -r echo ini_get('post_max_size');": "512M",
|
||||||
"/opt/homebrew/bin/php -r echo php_ini_scanned_files();"
|
"/opt/homebrew/bin/php -r echo php_ini_scanned_files();"
|
||||||
: """
|
: """
|
||||||
/opt/homebrew/etc/php/8.1/conf.d/error_log.ini,
|
/opt/homebrew/etc/php/8.2/conf.d/error_log.ini,
|
||||||
/opt/homebrew/etc/php/8.1/conf.d/ext-opcache.ini,
|
/opt/homebrew/etc/php/8.2/conf.d/ext-opcache.ini,
|
||||||
/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini,
|
/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini,
|
||||||
/opt/homebrew/etc/php/8.1/conf.d/xdebug.ini
|
/opt/homebrew/etc/php/8.2/conf.d/xdebug.ini
|
||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user