diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index f109bcc..199090e 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -804,6 +804,7 @@ C4F30B0B278E203C00755FCE /* MainMenu+Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED402783497000AB15D8 /* MainMenu+Startup.swift */; }; C4F319C927B034A500AFF46F /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DEB7D327A5D60B00834718 /* Stats.swift */; }; C4F361612836BFD9003598CC /* MainMenu+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F361602836BFD9003598CC /* MainMenu+Actions.swift */; }; + C4F520672AF03791006787F2 /* ExtensionEnumeratorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F520662AF03791006787F2 /* ExtensionEnumeratorTest.swift */; }; C4F5FBCD28218CB8001065C5 /* Xdebug.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42337A2281F19F000459A48 /* Xdebug.swift */; }; C4F7809C25D80344000DBC97 /* CommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F7809B25D80344000DBC97 /* CommandTest.swift */; }; C4F780A825D80AE8000DBC97 /* php.ini in Resources */ = {isa = PBXBuildFile; fileRef = C4F780A725D80AE8000DBC97 /* php.ini */; }; @@ -1118,6 +1119,7 @@ C4F30B02278E16BA00755FCE /* HomebrewService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewService.swift; sourceTree = ""; }; C4F30B06278E195800755FCE /* brew-services.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "brew-services.json"; sourceTree = ""; }; C4F361602836BFD9003598CC /* MainMenu+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MainMenu+Actions.swift"; sourceTree = ""; }; + C4F520662AF03791006787F2 /* ExtensionEnumeratorTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionEnumeratorTest.swift; sourceTree = ""; }; C4F5FBCC28218C93001065C5 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; C4F7807925D7F84B000DBC97 /* Unit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Unit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; C4F7809B25D80344000DBC97 /* CommandTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandTest.swift; sourceTree = ""; }; @@ -1940,6 +1942,7 @@ C4551656297AED18009B8466 /* ValetRcTest.swift */, C40934AA298EEDA900D25014 /* CaskFileParserTest.swift */, C4AFC4B229C4F43300BF4E0D /* HomebrewUpgradableTest.swift */, + C4F520662AF03791006787F2 /* ExtensionEnumeratorTest.swift */, ); path = Parsers; sourceTree = ""; @@ -3059,6 +3062,7 @@ C4B5635F276AB09000F12CCB /* VersionExtractor.swift in Sources */, C463E381284930EE00422731 /* PresetHelper.swift in Sources */, C441CC572AE8249400DDFACD /* ConfigFSNotifier.swift in Sources */, + C4F520672AF03791006787F2 /* ExtensionEnumeratorTest.swift in Sources */, C46FA98C2822F08F00D78807 /* PhpConfigurationFileTest.swift in Sources */, C4D5576529C77CC5001A44CD /* PhpVersionManagerWindowController.swift in Sources */, C4BF90C127C57C220054E78C /* MainMenu+FixMyValet.swift in Sources */, diff --git a/README.md b/README.md index 8ca756e..ad1a26a 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ All stable and supported PHP versions are also supported by PHP Monitor. However Backports that are installable via PHP Monitor's **PHP Version Manager** functionality are subject to availability via [this tap](https://github.com/shivammathur/homebrew-php). +PHP extensions that are installable via PHP Monitor's **PHP Version Manager** functionality are subject to availability via [this tap](https://github.com/shivammathur/homebrew-extensions). + For maximum compatibility with older PHP versions, you may wish to keep using Valet 2 or 3. For more information, please see [SECURITY.md](./SECURITY.md) to find out which versions of PHP are supported with different versions of Valet. diff --git a/phpmon/Common/Core/Paths.swift b/phpmon/Common/Core/Paths.swift index 1ea5579..7255b20 100644 --- a/phpmon/Common/Core/Paths.swift +++ b/phpmon/Common/Core/Paths.swift @@ -102,6 +102,10 @@ public class Paths { return "\(shared.baseDir.rawValue)/etc" } + public static var tapPath: String { + return "\(shared.baseDir.rawValue)/Library/Taps" + } + public static var caskroomPath: String { return "\(shared.baseDir.rawValue)/Caskroom/" + (App.identifier.contains(".dev") ? "phpmon-dev" : "phpmon") diff --git a/tests/unit/Parsers/ExtensionEnumeratorTest.swift b/tests/unit/Parsers/ExtensionEnumeratorTest.swift new file mode 100644 index 0000000..338c558 --- /dev/null +++ b/tests/unit/Parsers/ExtensionEnumeratorTest.swift @@ -0,0 +1,38 @@ +// +// ExtensionEnumeratorTest.swift +// Unit Tests +// +// Created by Nico Verbruggen on 30/10/2023. +// Copyright © 2023 Nico Verbruggen. All rights reserved. +// + +import XCTest + +final class ExtensionEnumeratorTest: XCTestCase { + + override func setUp() async throws { + ActiveFileSystem.useTestable([ + "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.1.rb": .fake(.text, ""), + "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.2.rb": .fake(.text, ""), + "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.3.rb": .fake(.text, ""), + "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula/xdebug@8.4.rb": .fake(.text, ""), + ]) + } + + func testCanReadFormulae() throws { + let directory = "\(Paths.tapPath)/shivammathur/homebrew-extensions/Formula" + let files = try FileSystem.getShallowContentsOfDirectory(directory) + + XCTAssertEqual( + Set(["xdebug@8.1.rb", "xdebug@8.2.rb", "xdebug@8.3.rb", "xdebug@8.4.rb"]), + Set(files) + ) + } + + func testCanParseFormulaeBasedOnSyntax() throws { + // TODO: Write a class that can figure out which PHP version can get which extensions + // A regular expression can be used (format: @.rb ) + // Perhaps it is also needed to write a whitelist to figure out which extensions are allowed? + } + +}