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

Fix tests, new shell in various places

This commit is contained in:
2022-10-05 01:06:52 +02:00
parent 3267dc8add
commit fb1ca60240
7 changed files with 268 additions and 326 deletions

View File

@ -25,9 +25,9 @@ class HomebrewPackageTest: XCTestCase {
XCTAssertEqual(package.name, "php")
XCTAssertEqual(package.full_name, "php")
XCTAssertEqual(package.aliases.first!, "php@8.0")
XCTAssertEqual(package.aliases.first!, "php@8.1")
XCTAssertEqual(package.installed.contains(where: { installed in
installed.version.starts(with: "8.0")
installed.version.starts(with: "8.1")
}), true)
}

View File

@ -1,70 +1,83 @@
[
{
"name":"php",
"full_name":"php",
"tap":"homebrew/core",
"oldname":null,
"aliases":[
"php@8.0"
"name": "php",
"full_name": "php",
"tap": "homebrew/core",
"oldname": null,
"aliases": [
"php@8.1"
],
"versioned_formulae":[
"versioned_formulae": [
"php@8.0",
"php@7.4",
"php@7.3",
"php@7.2"
],
"desc":"General-purpose scripting language",
"license":"PHP-3.01",
"homepage":"https://www.php.net/",
"versions":{
"stable":"8.0.2",
"head":"HEAD",
"bottle":true
"desc": "General-purpose scripting language",
"license": "PHP-3.01",
"homepage": "https://www.php.net/",
"versions": {
"stable": "8.1.10",
"head": "HEAD",
"bottle": true
},
"urls":{
"stable":{
"url":"https://www.php.net/distributions/php-8.0.2.tar.xz",
"tag":null,
"revision":null
"urls": {
"stable": {
"url": "https://www.php.net/distributions/php-8.1.10.tar.xz",
"tag": null,
"revision": null
}
},
"revision":0,
"version_scheme":0,
"bottle":{
"stable":{
"rebuild":0,
"cellar":"/opt/homebrew/Cellar",
"prefix":"/opt/homebrew",
"root_url":"https://homebrew.bintray.com/bottles",
"files":{
"arm64_big_sur":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.arm64_big_sur.bottle.tar.gz",
"sha256":"cbefa1db73d08b9af4593a44512b8d727e43033ee8517736bae5f16315501b12"
"revision": 1,
"version_scheme": 0,
"bottle": {
"stable": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_monterey": {
"cellar": "/opt/homebrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:dcee33c9f445db3026a7e867805eb8f6d82e9e5599599b8c6cd8645475f7961c",
"sha256": "dcee33c9f445db3026a7e867805eb8f6d82e9e5599599b8c6cd8645475f7961c"
},
"big_sur":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.big_sur.bottle.tar.gz",
"sha256":"6857142e12254b15da4e74c2986dd24faca57dac8d467b04621db349e277dd63"
"arm64_big_sur": {
"cellar": "/opt/homebrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:e0590064cd32f2baa4102fa49c80056f3886a0a89aec0589d0134ecbf0e7923e",
"sha256": "e0590064cd32f2baa4102fa49c80056f3886a0a89aec0589d0134ecbf0e7923e"
},
"catalina":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.catalina.bottle.tar.gz",
"sha256":"b651611134c18f93fdf121a4277b51b197a896a19ccb8020289b4e19e0638349"
"monterey": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:62481320613b19c6ff310bf6ed50c7d2a2253cdbf403af12ec97bccd8a97a84c",
"sha256": "62481320613b19c6ff310bf6ed50c7d2a2253cdbf403af12ec97bccd8a97a84c"
},
"mojave":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.mojave.bottle.tar.gz",
"sha256":"9583a51fcc6f804aadbb14e18f770d4fb4973deaed6ddc4770342e62974ffbca"
"big_sur": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:b34d96f7aad3c580a7cbdaadb8054fb9b6872111a5eec8e1bcb4a529970c8e03",
"sha256": "b34d96f7aad3c580a7cbdaadb8054fb9b6872111a5eec8e1bcb4a529970c8e03"
},
"catalina": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:cc0b85dcfdd60e1d8d7fa74c9f53be5d249d068835dbc7a81edacb7a076b6c76",
"sha256": "cc0b85dcfdd60e1d8d7fa74c9f53be5d249d068835dbc7a81edacb7a076b6c76"
},
"x86_64_linux": {
"cellar": "/home/linuxbrew/.linuxbrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/php/blobs/sha256:b934a5a4ad2d29b629f83962b57f638a654801d1ba21ba659a42da2e5afe3fae",
"sha256": "b934a5a4ad2d29b629f83962b57f638a654801d1ba21ba659a42da2e5afe3fae"
}
}
}
},
"keg_only":false,
"bottle_disabled":false,
"options":[
"keg_only": false,
"keg_only_reason": null,
"options": [
],
"build_dependencies":[
"build_dependencies": [
"httpd",
"pkg-config"
],
"dependencies":[
"dependencies": [
"apr",
"apr-util",
"argon2",
@ -74,11 +87,9 @@
"freetds",
"gd",
"gettext",
"glib",
"gmp",
"icu4c",
"krb5",
"libffi",
"libpq",
"libsodium",
"libzip",
@ -90,243 +101,295 @@
"tidy-html5",
"unixodbc"
],
"recommended_dependencies":[
"test_dependencies": [
"httpd"
],
"optional_dependencies":[
"recommended_dependencies": [
],
"uses_from_macos":[
"optional_dependencies": [
],
"uses_from_macos": [
{
"xz":"build"
"xz": "build"
},
"bzip2",
"libedit",
"libffi",
"libxml2",
"libxslt",
"zlib"
],
"requirements":[
"requirements": [
],
"conflicts_with":[
"conflicts_with": [
],
"caveats":"To enable PHP in Apache add the following to httpd.conf and restart Apache:\n LoadModule php_module $(brew --prefix)/opt/php/lib/httpd/modules/libphp.so\n\n <FilesMatch \\.php$>\n SetHandler application/x-httpd-php\n </FilesMatch>\n\nFinally, check DirectoryIndex includes index.php\n DirectoryIndex index.php index.html\n\nThe php.ini and php-fpm.ini file can be found in:\n $(brew --prefix)/etc/php/8.0/\n",
"installed":[
"caveats": "To enable PHP in Apache add the following to httpd.conf and restart Apache:\n LoadModule php_module $(brew --prefix)/opt/php/lib/httpd/modules/libphp.so\n\n <FilesMatch \\.php$>\n SetHandler application/x-httpd-php\n </FilesMatch>\n\nFinally, check DirectoryIndex includes index.php\n DirectoryIndex index.php index.html\n\nThe php.ini and php-fpm.ini file can be found in:\n $(brew --prefix)/etc/php/8.1/\n",
"installed": [
{
"version":"8.0.2",
"used_options":[
"version": "8.1.10_1",
"used_options": [
],
"built_as_bottle":true,
"poured_from_bottle":true,
"runtime_dependencies":[
"built_as_bottle": true,
"poured_from_bottle": true,
"runtime_dependencies": [
{
"full_name":"apr",
"version":"1.7.0"
"full_name": "apr",
"version": "1.7.0",
"declared_directly": true
},
{
"full_name":"openssl@1.1",
"version":"1.1.1i"
"full_name": "ca-certificates",
"version": "2022-07-19",
"declared_directly": false
},
{
"full_name":"apr-util",
"version":"1.6.1"
"full_name": "openssl@1.1",
"version": "1.1.1q",
"declared_directly": true
},
{
"full_name":"argon2",
"version":"20190702"
"full_name": "apr-util",
"version": "1.6.1",
"declared_directly": true
},
{
"full_name":"aspell",
"version":"0.60.8"
"full_name": "argon2",
"version": "20190702",
"declared_directly": true
},
{
"full_name":"autoconf",
"version":"2.69"
"full_name": "aspell",
"version": "0.60.8",
"declared_directly": true
},
{
"full_name":"brotli",
"version":"1.0.9"
"full_name": "m4",
"version": "1.4.19",
"declared_directly": false
},
{
"full_name":"gettext",
"version":"0.21"
"full_name": "autoconf",
"version": "2.71",
"declared_directly": true
},
{
"full_name":"libunistring",
"version":"0.9.10"
"full_name": "brotli",
"version": "1.0.9",
"declared_directly": false
},
{
"full_name":"libidn2",
"version":"2.3.0"
"full_name": "gettext",
"version": "0.21",
"declared_directly": true
},
{
"full_name":"libmetalink",
"version":"0.1.3"
"full_name": "libunistring",
"version": "1.0",
"declared_directly": false
},
{
"full_name":"libssh2",
"version":"1.9.0"
"full_name": "libidn2",
"version": "2.3.3",
"declared_directly": false
},
{
"full_name":"c-ares",
"version":"1.17.1"
"full_name": "libnghttp2",
"version": "1.49.0",
"declared_directly": false
},
{
"full_name":"jemalloc",
"version":"5.2.1"
"full_name": "libssh2",
"version": "1.10.0",
"declared_directly": false
},
{
"full_name":"libev",
"version":"4.33"
"full_name": "openldap",
"version": "2.6.3",
"declared_directly": true
},
{
"full_name":"nghttp2",
"version":"1.43.0"
"full_name": "rtmpdump",
"version": "2.4+20151223",
"declared_directly": false
},
{
"full_name":"openldap",
"version":"2.4.57"
"full_name": "lz4",
"version": "1.9.4",
"declared_directly": false
},
{
"full_name":"rtmpdump",
"version":"2.4+20151223"
"full_name": "xz",
"version": "5.2.6",
"declared_directly": false
},
{
"full_name":"zstd",
"version":"1.4.8"
"full_name": "zstd",
"version": "1.5.2",
"declared_directly": false
},
{
"full_name":"curl",
"version":"7.75.0"
"full_name": "curl",
"version": "7.85.0",
"declared_directly": true
},
{
"full_name":"libtool",
"version":"2.4.6"
"full_name": "libtool",
"version": "2.4.7",
"declared_directly": false
},
{
"full_name":"unixodbc",
"version":"2.3.9"
"full_name": "unixodbc",
"version": "2.3.11",
"declared_directly": true
},
{
"full_name":"freetds",
"version":"1.2.18"
"full_name": "freetds",
"version": "1.3.13",
"declared_directly": true
},
{
"full_name":"libpng",
"version":"1.6.37"
"full_name": "libpng",
"version": "1.6.37",
"declared_directly": false
},
{
"full_name":"freetype",
"version":"2.10.4"
"full_name": "freetype",
"version": "2.12.1",
"declared_directly": false
},
{
"full_name":"fontconfig",
"version":"2.13.1"
"full_name": "fontconfig",
"version": "2.14.0",
"declared_directly": false
},
{
"full_name":"jpeg",
"version":"9d"
"full_name": "jpeg-turbo",
"version": "2.1.4",
"declared_directly": false
},
{
"full_name":"libtiff",
"version":"4.2.0"
"full_name": "giflib",
"version": "5.2.1",
"declared_directly": false
},
{
"full_name":"webp",
"version":"1.2.0"
"full_name": "imath",
"version": "3.1.5",
"declared_directly": false
},
{
"full_name":"gd",
"version":"2.3.1"
"full_name": "openexr",
"version": "3.1.5",
"declared_directly": false
},
{
"full_name":"libffi",
"version":"3.3"
"full_name": "libtiff",
"version": "4.4.0",
"declared_directly": false
},
{
"full_name":"pcre",
"version":"8.44"
"full_name": "webp",
"version": "1.2.4",
"declared_directly": false
},
{
"full_name":"gdbm",
"version":"1.18.1"
"full_name": "jpeg-xl",
"version": "0.6.1",
"declared_directly": false
},
{
"full_name":"readline",
"version":"8.1"
"full_name": "libvmaf",
"version": "2.3.1",
"declared_directly": false
},
{
"full_name":"sqlite",
"version":"3.34.0"
"full_name": "aom",
"version": "3.4.0",
"declared_directly": false
},
{
"full_name":"tcl-tk",
"version":"8.6.11"
"full_name": "libavif",
"version": "0.10.1",
"declared_directly": false
},
{
"full_name":"xz",
"version":"5.2.5"
"full_name": "gd",
"version": "2.3.3",
"declared_directly": true
},
{
"full_name":"python@3.9",
"version":"3.9.1"
"full_name": "gmp",
"version": "6.2.1",
"declared_directly": true
},
{
"full_name":"glib",
"version":"2.66.6"
"full_name": "icu4c",
"version": "71.1",
"declared_directly": true
},
{
"full_name":"gmp",
"version":"6.2.1"
"full_name": "krb5",
"version": "1.20",
"declared_directly": true
},
{
"full_name":"icu4c",
"version":"67.1"
"full_name": "libpq",
"version": "14.5",
"declared_directly": true
},
{
"full_name":"krb5",
"version":"1.19"
"full_name": "libsodium",
"version": "1.0.18",
"declared_directly": true
},
{
"full_name":"libpq",
"version":"13.1"
"full_name": "libzip",
"version": "1.9.2",
"declared_directly": true
},
{
"full_name":"libsodium",
"version":"1.0.18"
"full_name": "oniguruma",
"version": "6.9.8",
"declared_directly": true
},
{
"full_name":"libzip",
"version":"1.7.3"
"full_name": "pcre2",
"version": "10.40",
"declared_directly": true
},
{
"full_name":"oniguruma",
"version":"6.9.6"
"full_name": "readline",
"version": "8.1.2",
"declared_directly": false
},
{
"full_name":"pcre2",
"version":"10.36"
"full_name": "sqlite",
"version": "3.39.2",
"declared_directly": true
},
{
"full_name":"tidy-html5",
"version":"5.6.0"
"full_name": "tidy-html5",
"version": "5.8.0",
"declared_directly": true
}
],
"installed_as_dependency":false,
"installed_on_request":true
"installed_as_dependency": false,
"installed_on_request": true
}
],
"linked_keg":"8.0.2",
"pinned":false,
"outdated":false,
"deprecated":false,
"deprecation_date":null,
"deprecation_reason":null,
"disabled":false,
"disable_date":null,
"disable_reason":null
"linked_keg": "8.1.10_1",
"pinned": false,
"outdated": false,
"deprecated": false,
"deprecation_date": null,
"deprecation_reason": null,
"disabled": false,
"disable_date": null,
"disable_reason": null
}
]
]

View File

@ -14,7 +14,9 @@ class PhpEnv {
init() {
self.currentInstall = ActivePhpInstallation()
}
func determinePhpAlias() {
Task {
let brewPhpAlias = await Shell.pipe("\(Paths.brew) info php --json").out
@ -23,7 +25,7 @@ class PhpEnv {
from: brewPhpAlias.data(using: .utf8)!
).first!
Log.info("When on your system, the `php` formula means version \(homebrewPackage.version)!")
Log.info("[BREW] On your system, the `php` formula means version \(homebrewPackage.version)!")
}
}
@ -79,14 +81,14 @@ class PhpEnv {
}
public static func detectPhpVersions() {
_ = Self.shared.detectPhpVersions()
Task { await Self.shared.detectPhpVersions() }
}
/**
Detects which versions of PHP are installed.
*/
public func detectPhpVersions() -> [String] {
let files = LegacyShell.pipe("ls \(Paths.optPath) | grep php@")
public func detectPhpVersions() async -> [String] {
let files = await Shell.pipe("ls \(Paths.optPath) | grep php@").out
var versionsOnly = extractPhpVersions(from: files.components(separatedBy: "\n"))

View File

@ -115,7 +115,9 @@ class Startup {
// Make sure we can detect one or more PHP installations.
// =================================================================================
EnvironmentCheck(
command: { return await !Shell.pipe("ls \(Paths.optPath) | grep php").out.contains("php") },
command: {
return await !Shell.pipe("ls \(Paths.optPath) | grep php").out.contains("php")
},
name: "`ls \(Paths.optPath) | grep php` returned php result",
titleText: "startup.errors.php_opt.title".localized,
subtitleText: "startup.errors.php_opt.subtitle".localized(

View File

@ -42,8 +42,10 @@ class HomebrewDiagnostics {
This check only needs to be performed if the `shivammathur/php` tap is active.
*/
public static func checkForCaskConflict() {
if hasAliasConflict() {
presentAlertAboutConflict()
Task {
if await hasAliasConflict() {
presentAlertAboutConflict()
}
}
}
@ -79,8 +81,8 @@ class HomebrewDiagnostics {
/**
Check if the alias conflict as documented in `checkForCaskConflict` actually occurred.
*/
private static func hasAliasConflict() -> Bool {
let tapAlias = LegacyShell.pipe("\(Paths.brew) info shivammathur/php/php --json")
private static func hasAliasConflict() async -> Bool {
let tapAlias = await Shell.pipe("brew info shivammathur/php/php --json").out
if tapAlias.contains("brew tap shivammathur/php") || tapAlias.contains("Error") {
Log.info("The user does not appear to have tapped: shivammathur/php")

View File

@ -31,6 +31,9 @@ extension MainMenu {
When the environment is all clear and the app can run, let's go.
*/
private func onEnvironmentPass() {
// Determine what the `php` formula is aliased to
PhpEnv.shared.determinePhpAlias()
// Determine install method
Log.info(HomebrewDiagnostics.customCaskInstalled
? "The app has probably been installed via Homebrew Cask."

View File

@ -53,6 +53,8 @@ class Testables {
: .instant(ShellStrings.phpVersion),
"ls /opt/homebrew/opt | grep php"
: .instant("php"),
"ls /opt/homebrew/opt | grep php@"
: .instant("php@8.1"),
"sudo /opt/homebrew/bin/brew services info nginx --json"
: .delayed(0.2, ShellStrings.nginxJson),
"cat /private/etc/sudoers.d/brew"
@ -76,7 +78,9 @@ class Testables {
shivammathur/php
"""),
"/opt/homebrew/bin/brew info php --json"
: .instant(ShellStrings.brewJson)
: .instant(ShellStrings.brewJson),
"brew info shivammathur/php/php --json"
: .instant("Error: No available formula with the name \"shivammathur/php/php\".")
]
)
}
@ -115,144 +119,10 @@ struct ShellStrings {
]
"""
static let brewJson = """
[
{
"name":"php",
"full_name":"php",
"tap":"homebrew/core",
"oldname":null,
"aliases":[
"php@8.0"
],
"versioned_formulae":[
"php@7.4",
"php@7.3",
"php@7.2"
],
"desc":"General-purpose scripting language",
"license":"PHP-3.01",
"homepage":"https://www.php.net/",
"versions":{
"stable":"8.0.2",
"head":"HEAD",
"bottle":true
},
"urls":{
"stable":{
"url":"https://www.php.net/distributions/php-8.0.2.tar.xz",
"tag":null,
"revision":null
}
},
"revision":0,
"version_scheme":0,
"bottle":{
"stable":{
"rebuild":0,
"cellar":"/opt/homebrew/Cellar",
"prefix":"/opt/homebrew",
"root_url":"https://homebrew.bintray.com/bottles",
"files":{
"arm64_big_sur":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.arm64_big_sur.bottle.tar.gz",
"sha256":"cbefa1db73d08b9af4593a44512b8d727e43033ee8517736bae5f16315501b12"
},
"big_sur":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.big_sur.bottle.tar.gz",
"sha256":"6857142e12254b15da4e74c2986dd24faca57dac8d467b04621db349e277dd63"
},
"catalina":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.catalina.bottle.tar.gz",
"sha256":"b651611134c18f93fdf121a4277b51b197a896a19ccb8020289b4e19e0638349"
},
"mojave":{
"url":"https://homebrew.bintray.com/bottles/php-8.0.2.mojave.bottle.tar.gz",
"sha256":"9583a51fcc6f804aadbb14e18f770d4fb4973deaed6ddc4770342e62974ffbca"
}
}
}
},
"keg_only":false,
"bottle_disabled":false,
"options":[
],
"build_dependencies":[
"httpd",
"pkg-config"
],
"dependencies":[
"apr",
"apr-util",
"argon2",
"aspell",
"autoconf",
"curl",
"freetds",
"gd",
"gettext",
"glib",
"gmp",
"icu4c",
"krb5",
"libffi",
"libpq",
"libsodium",
"libzip",
"oniguruma",
"openldap",
"openssl@1.1",
"pcre2",
"sqlite",
"tidy-html5",
"unixodbc"
],
"recommended_dependencies":[
],
"optional_dependencies":[
],
"uses_from_macos":[
{
"xz":"build"
},
"bzip2",
"libedit",
"libxml2",
"libxslt",
"zlib"
],
"requirements":[
],
"conflicts_with":[
],
"installed":[
{
"version": "8.1.10_1",
"used_options": [
],
"built_as_bottle": true,
"poured_from_bottle": true,
"runtime_dependencies": [],
"installed_as_dependency": false,
"installed_on_request": true
}
],
"linked_keg":"8.0.2",
"pinned":false,
"outdated":false,
"deprecated":false,
"deprecation_date":null,
"deprecation_reason":null,
"disabled":false,
"disable_date":null,
"disable_reason":null
}
]
"""
static let brewJson: String = {
return try! String(contentsOf: Bundle.main.url(
forResource: "brew-formula",
withExtension: "json"
)!, encoding: .utf8)
}()
}