From 185695b396f4e54ee19daac863d2a8d4824ed6d0 Mon Sep 17 00:00:00 2001 From: James Barnard Date: Fri, 27 Sep 2019 10:21:06 +0100 Subject: [PATCH 1/6] Fix #708. Use stopRunning instead of stop to only stop running php services --- cli/valet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/valet.php b/cli/valet.php index 8d9ce4f..e512f0a 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -241,7 +241,7 @@ * Stop the daemon services. */ $app->command('stop', function () { - PhpFpm::stop(); + PhpFpm::stopRunning(); Nginx::stop(); From e5dceb2bc5d6c240ae0c100472a505367f6740cf Mon Sep 17 00:00:00 2001 From: James Barnard Date: Wed, 2 Oct 2019 13:56:51 +0100 Subject: [PATCH 2/6] Check for tld on end of certificate file name to support multi segment tld's --- cli/Valet/Site.php | 14 ++++++++++++-- tests/SiteTest.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index 88c82ab..0d9cdf6 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -120,11 +120,21 @@ function links() */ function getCertificates($path) { + $config = $this->config->read(); + return collect($this->files->scandir($path))->filter(function ($value, $key) { return ends_with($value, '.crt'); - })->map(function ($cert) { + })->map(function ($cert) use ($config) { $certWithoutSuffix = substr($cert, 0, -4); - return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, '.')); + $trimToString = '.'; + + // If we have the cert ending in our tld stripe that tld specifically + // if not then just strip the last segment for backwards compatibility. + if (ends_with($certWithoutSuffix, $config['tld'])) { + $trimToString .= $config['tld']; + } + + return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, $trimToString)); })->flip(); } diff --git a/tests/SiteTest.php b/tests/SiteTest.php index 71362ec..08cf139 100644 --- a/tests/SiteTest.php +++ b/tests/SiteTest.php @@ -28,6 +28,28 @@ public function tearDown() } + public function test_get_certificates_will_return_without_multi_segment_tld() + { + $files = Mockery::mock(Filesystem::class); + $files->shouldReceive('scandir') + ->once() + ->with($certPath = '/Users/testuser/.config/valet/Certificates') + ->andReturn(['helloworld.multi.segment.tld.com.crt']); + $config = Mockery::mock(Configuration::class); + $config->shouldReceive('read') + ->once() + ->andReturn(['tld' => 'multi.segment.tld.com']); + + swap(Filesystem::class, $files); + swap(Configuration::class, $config); + + /** @var Site $site */ + $site = resolve(Site::class); + $certs = $site->getCertificates($certPath); + $this->assertSame(['helloworld' => 0], $certs->all()); + } + + public function test_symlink_creates_symlink_to_given_path() { $files = Mockery::mock(Filesystem::class); @@ -77,6 +99,12 @@ public function test_certificates_trim_tld_for_custom_tlds() 'fiveletters.local.crt', ]); + $config = Mockery::mock(Configuration::class); + $config->shouldReceive('read') + ->once() + ->andReturn(['tld' => 'other']); + + swap(Configuration::class, $config); swap(Filesystem::class, $files); $site = resolve(Site::class); From c89f64f3e60681379b3d8961e1806c4036b81abc Mon Sep 17 00:00:00 2001 From: James Barnard Date: Wed, 2 Oct 2019 13:58:47 +0100 Subject: [PATCH 3/6] Fix incorrect new test name --- tests/SiteTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SiteTest.php b/tests/SiteTest.php index 08cf139..8e58543 100644 --- a/tests/SiteTest.php +++ b/tests/SiteTest.php @@ -28,7 +28,7 @@ public function tearDown() } - public function test_get_certificates_will_return_without_multi_segment_tld() + public function test_get_certificates_will_return_with_multi_segment_tld() { $files = Mockery::mock(Filesystem::class); $files->shouldReceive('scandir') From b3ef3b1367cd9c9e7ad885180f223db1e3f63891 Mon Sep 17 00:00:00 2001 From: James Barnard Date: Wed, 2 Oct 2019 15:10:46 +0100 Subject: [PATCH 4/6] Fix stripe -> strip typo --- cli/Valet/Site.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index 0d9cdf6..c69aac2 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -128,7 +128,7 @@ function getCertificates($path) $certWithoutSuffix = substr($cert, 0, -4); $trimToString = '.'; - // If we have the cert ending in our tld stripe that tld specifically + // If we have the cert ending in our tld strip that tld specifically // if not then just strip the last segment for backwards compatibility. if (ends_with($certWithoutSuffix, $config['tld'])) { $trimToString .= $config['tld']; From b7867e97cef55c7a5a4c87089544c19610c72d49 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Thu, 3 Oct 2019 13:22:03 -0400 Subject: [PATCH 5/6] Bump version --- cli/valet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/valet.php b/cli/valet.php index e512f0a..56589ee 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -31,7 +31,7 @@ */ Container::setInstance(new Container); -$version = '2.4.2'; +$version = '2.4.3'; $app = new Application('Laravel Valet', $version); From beda122db0abdf1b24eb703ac472babef96ed352 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Thu, 3 Oct 2019 13:37:43 -0400 Subject: [PATCH 6/6] Bump again --- cli/valet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/valet.php b/cli/valet.php index 56589ee..1154cdb 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -31,7 +31,7 @@ */ Container::setInstance(new Container); -$version = '2.4.3'; +$version = '2.5.0'; $app = new Application('Laravel Valet', $version);