From d52c9966bcf67d985c77752cbec8b4872f1b31cb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 15:50:10 +0100 Subject: [PATCH 0001/4023] [2.x] Set up HydePHP v2 --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 0624889cb02..1fd59536328 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -## [Unreleased] - YYYY-MM-DD +## [v2-dev] - YYYY-MM-DD ### About From cd0b22753dd991e1a6853355b1cfb682d8abdc25 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:01:53 +0100 Subject: [PATCH 0002/4023] Reset release notes --- RELEASE_NOTES.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1fd59536328..3f1a32d1613 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,10 +10,10 @@ This serves two purposes: 2. At release time, you can move the Unreleased section changes into a new release version section. ### Added -- Added info banners when dashboard content sections are empty in https://github.com/hydephp/develop/pull/1494 +- for new features. ### Changed -- Shortened the path printed to console when using the dashboard to create a page in https://github.com/hydephp/develop/pull/1492 +- for changes in existing functionality. ### Deprecated - for soon-to-be removed features. @@ -22,8 +22,7 @@ This serves two purposes: - for now removed features. ### Fixed -- Improved support for running HydePHP through the Phar archive in https://github.com/hydephp/develop/pull/1491 -- Fixed wrong section title in the dashboard page in https://github.com/hydephp/develop/pull/1493 +- for any bug fixes. ### Security - in case of vulnerabilities. From 4e3a0c2a1ea3924923b8e5c6b519647fee075130 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 15:57:53 +0100 Subject: [PATCH 0003/4023] Deprecate GenerateSearch.php --- RELEASE_NOTES.md | 2 +- .../src/Framework/Actions/PostBuildTasks/GenerateSearch.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3f1a32d1613..9e868506daa 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -16,7 +16,7 @@ This serves two purposes: - for changes in existing functionality. ### Deprecated -- for soon-to-be removed features. +- \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch ### Removed - for now removed features. diff --git a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php index 991190ff4b2..a2d115a6e96 100644 --- a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php +++ b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php @@ -9,6 +9,7 @@ use Hyde\Framework\Features\Documentation\DocumentationSearchPage; use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; +/** @deprecated */ class GenerateSearch extends PostBuildTask { use InteractsWithDirectories; From d9eec2881648aab1742a18689257daf20668d79c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:11:45 +0100 Subject: [PATCH 0004/4023] Add new internal `GeneratesDocumentationSearchIndex::generate` method --- .../Actions/GeneratesDocumentationSearchIndex.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index 1e0948e47cf..5e5882bf234 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -39,6 +39,17 @@ public static function handle(): string return $service->path; } + /** + * Generate the search index return it as a string. + */ + public static function generate(): string + { + $service = new static(); + $service->run(); + + return $service->index->toJson(); + } + protected function __construct() { $this->index = new Collection(); From feb99e9d681f802554e38a9235f856cdc651de63 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 15:59:24 +0100 Subject: [PATCH 0005/4023] Deprecate internal `GeneratesDocumentationSearchIndex::handle` method --- .../src/Framework/Actions/GeneratesDocumentationSearchIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index 5e5882bf234..85e17aa1448 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -26,7 +26,7 @@ class GeneratesDocumentationSearchIndex protected string $path; /** - * Generate the search index and save it to disk. + * @deprecated Generate the search index and save it to disk. * * @return string The path to the generated file. */ From 697e016fb300334e602576084775d28fd5b81d59 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:10:43 +0100 Subject: [PATCH 0006/4023] Add experimental `InMemoryPage::getOutputPath` overload support --- RELEASE_NOTES.md | 2 +- packages/framework/src/Pages/InMemoryPage.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9e868506daa..18fd270e216 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,7 +10,7 @@ This serves two purposes: 2. At release time, you can move the Unreleased section changes into a new release version section. ### Added -- for new features. +- Add experimental InMemoryPage::getOutputPath overload support ### Changed - for changes in existing functionality. diff --git a/packages/framework/src/Pages/InMemoryPage.php b/packages/framework/src/Pages/InMemoryPage.php index 541e9356ec9..56a429344e2 100644 --- a/packages/framework/src/Pages/InMemoryPage.php +++ b/packages/framework/src/Pages/InMemoryPage.php @@ -82,6 +82,16 @@ public function getBladeView(): string return $this->view; } + /** @experimental Get the path to the output file for the page. */ + public function getOutputPath(): string + { + if ($this->hasMacro('getOutputPath')) { + return $this->__call('getOutputPath', []); + } + + return parent::getOutputPath(); + } + /** * Get the contents that will be saved to disk for this page. * From d48918410f17c4ab6ede24d254d94fb58f228912 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:22:32 +0100 Subject: [PATCH 0007/4023] Add upgrade guide section --- RELEASE_NOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3f1a32d1613..f5a0bd794e1 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -26,3 +26,7 @@ This serves two purposes: ### Security - in case of vulnerabilities. + +### Upgrade Guide + +If there are any breaking changes, include an upgrade guide here. From 9bee9cd05ac3b1efb8eef8236b51804a5c6c5413 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:23:19 +0100 Subject: [PATCH 0008/4023] Update build task service to not call deprecated search generator --- .../framework/src/Framework/Services/BuildTaskService.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/framework/src/Framework/Services/BuildTaskService.php b/packages/framework/src/Framework/Services/BuildTaskService.php index a976526e214..d2eb432a015 100644 --- a/packages/framework/src/Framework/Services/BuildTaskService.php +++ b/packages/framework/src/Framework/Services/BuildTaskService.php @@ -11,7 +11,6 @@ use Hyde\Framework\Features\BuildTasks\PreBuildTask; use Hyde\Framework\Features\BuildTasks\PostBuildTask; use Hyde\Framework\Actions\PreBuildTasks\CleanSiteDirectory; -use Hyde\Framework\Actions\PostBuildTasks\GenerateSearch; use Hyde\Framework\Actions\PostBuildTasks\GenerateRssFeed; use Hyde\Framework\Actions\PostBuildTasks\GenerateSitemap; use Hyde\Framework\Actions\PostBuildTasks\GenerateBuildManifest; @@ -136,7 +135,6 @@ private function registerFrameworkTasks(): void $this->registerIf(GenerateBuildManifest::class, $this->canGenerateManifest()); $this->registerIf(GenerateSitemap::class, $this->canGenerateSitemap()); $this->registerIf(GenerateRssFeed::class, $this->canGenerateFeed()); - $this->registerIf(GenerateSearch::class, $this->canGenerateSearch()); } private function canCleanSiteDirectory(): bool @@ -158,9 +156,4 @@ private function canGenerateFeed(): bool { return Features::rss(); } - - private function canGenerateSearch(): bool - { - return Features::hasDocumentationSearch(); - } } From c8937ad292344fc3bbb68adb9793627dbf343918 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:38:24 +0100 Subject: [PATCH 0009/4023] Update core extension to add search index as an in memory page --- .../src/Foundation/HydeCoreExtension.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 6c48936a370..95f1963bfad 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -8,9 +8,12 @@ use Hyde\Pages\BladePage; use Hyde\Pages\MarkdownPage; use Hyde\Pages\MarkdownPost; +use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; +use Hyde\Foundation\Kernel\PageCollection; use Hyde\Foundation\Concerns\HydeExtension; use Hyde\Facades\Features; +use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; use function array_filter; use function array_keys; @@ -28,4 +31,18 @@ public static function getPageClasses(): array DocumentationPage::class => Features::hasDocumentationPages(), ], fn (bool $value): bool => $value)); } + + public function discoverPages(PageCollection $collection): void + { + if (Features::hasDocumentationSearch()) { + $collection->addPage(tap(new InMemoryPage('search.json'), function (InMemoryPage $page): void { + $page->macro('compile', function (): string { + return GeneratesDocumentationSearchIndex::generate(); + }); + $page->macro('getOutputPath', function (): string { + return DocumentationPage::outputDirectory().'/search.json'; + }); + })); + } + } } From 30f3ce6b809ede0b93b4007af67a6dc219eea681 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 17:00:56 +0100 Subject: [PATCH 0010/4023] Update core extension to inject search page during discovery --- packages/framework/src/Foundation/HydeCoreExtension.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 95f1963bfad..4f1784d1b8a 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -14,6 +14,7 @@ use Hyde\Foundation\Concerns\HydeExtension; use Hyde\Facades\Features; use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; +use Hyde\Framework\Features\Documentation\DocumentationSearchPage; use function array_filter; use function array_keys; @@ -43,6 +44,10 @@ public function discoverPages(PageCollection $collection): void return DocumentationPage::outputDirectory().'/search.json'; }); })); + + if (DocumentationSearchPage::enabled()) { + $collection->addPage(new DocumentationSearchPage()); + } } } } From 733b95f5995d43c5e01c5fda97019d29b6474df5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 17:06:34 +0100 Subject: [PATCH 0011/4023] Hide dynamic search pages from navigation --- packages/framework/src/Foundation/HydeCoreExtension.php | 2 +- .../Features/Documentation/DocumentationSearchPage.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 4f1784d1b8a..27c0706a93c 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -36,7 +36,7 @@ public static function getPageClasses(): array public function discoverPages(PageCollection $collection): void { if (Features::hasDocumentationSearch()) { - $collection->addPage(tap(new InMemoryPage('search.json'), function (InMemoryPage $page): void { + $collection->addPage(tap(new InMemoryPage('search.json', ['navigation' => ['hidden' => true]]), function (InMemoryPage $page): void { $page->macro('compile', function (): string { return GeneratesDocumentationSearchIndex::generate(); }); diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index 4563eb45337..f58ff0b83ca 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -36,6 +36,7 @@ public function __construct() { parent::__construct('search', [ 'title' => 'Search', + 'navigation' => ['hidden' => true], ]); } From 8bfe35ea59f0463ed0d585d77c0d74d13ac3a177 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 17:54:55 +0100 Subject: [PATCH 0012/4023] Run tests without documentation search feature --- .../tests/Feature/PageCollectionTest.php | 10 +++++++++ .../tests/Feature/RouteCollectionTest.php | 4 ++++ .../Unit/Pages/PageModelGetHelperTest.php | 4 ++++ packages/testing/src/ResetsApplication.php | 22 +++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/packages/framework/tests/Feature/PageCollectionTest.php b/packages/framework/tests/Feature/PageCollectionTest.php index 19a961b761d..f055ae3bf24 100644 --- a/packages/framework/tests/Feature/PageCollectionTest.php +++ b/packages/framework/tests/Feature/PageCollectionTest.php @@ -80,6 +80,7 @@ public function test_get_page_returns_parsed_page_object_for_given_source_path() public function test_get_pages_returns_collection_of_pages_of_given_class() { $this->withoutDefaultPages(); + $this->withoutDocumentationSearch(); $this->file('_pages/foo.blade.php'); $this->file('_pages/foo.md'); @@ -103,11 +104,13 @@ public function test_get_pages_returns_collection_of_pages_of_given_class() $this->assertEquals(new HtmlPage('foo'), Pages::getPages(HtmlPage::class)->first()); $this->restoreDefaultPages(); + $this->restoreDocumentationSearch(); } public function test_get_pages_returns_all_pages_when_not_supplied_with_class_string() { $this->withoutDefaultPages(); + $this->withoutDocumentationSearch(); $this->file('_pages/foo.blade.php'); $this->file('_pages/foo.md'); @@ -125,13 +128,16 @@ public function test_get_pages_returns_all_pages_when_not_supplied_with_class_st $this->assertEquals(new HtmlPage('foo'), $collection->get('_pages/foo.html')); $this->restoreDefaultPages(); + $this->restoreDocumentationSearch(); } public function test_get_pages_returns_empty_collection_when_no_pages_are_discovered() { $this->withoutDefaultPages(); + $this->withoutDocumentationSearch(); $this->assertEmpty(Pages::getPages()); $this->restoreDefaultPages(); + $this->restoreDocumentationSearch(); } public function test_pages_are_not_discovered_for_disabled_features() @@ -155,6 +161,8 @@ public function test_pages_are_not_discovered_for_disabled_features() public function test_pages_with_custom_source_directories_are_discovered_properly() { + $this->withoutDocumentationSearch(); + BladePage::setSourceDirectory('.source/pages'); MarkdownPage::setSourceDirectory('.source/pages'); MarkdownPost::setSourceDirectory('.source/posts'); @@ -177,6 +185,8 @@ public function test_pages_with_custom_source_directories_are_discovered_properl $this->assertEquals(new MarkdownPage('foo'), $collection->get('.source/pages/foo.md')); $this->assertEquals(new MarkdownPost('foo'), $collection->get('.source/posts/foo.md')); $this->assertEquals(new DocumentationPage('foo'), $collection->get('.source/docs/foo.md')); + + $this->restoreDocumentationSearch(); } public function test_get_file_throws_exception_when_file_is_not_found() diff --git a/packages/framework/tests/Feature/RouteCollectionTest.php b/packages/framework/tests/Feature/RouteCollectionTest.php index 383ef835a47..e1b8c74a0dd 100644 --- a/packages/framework/tests/Feature/RouteCollectionTest.php +++ b/packages/framework/tests/Feature/RouteCollectionTest.php @@ -40,6 +40,7 @@ public function test_boot_method_discovers_all_pages() public function test_boot_method_discovers_all_page_types() { $this->withoutDefaultPages(); + $this->withoutDocumentationSearch(); $this->file('_pages/blade.blade.php'); $this->file('_pages/markdown.md'); @@ -61,6 +62,7 @@ public function test_boot_method_discovers_all_page_types() ], $collection->all()); $this->restoreDefaultPages(); + $this->restoreDocumentationSearch(); } public function test_get_routes_returns_all_routes() @@ -77,6 +79,7 @@ public function test_get_routes_returns_all_routes() public function test_get_routes_for_model_returns_collection_of_routes_of_given_class() { $this->withoutDefaultPages(); + $this->withoutDocumentationSearch(); $this->file('_pages/blade.blade.php'); $this->file('_pages/markdown.md'); @@ -94,6 +97,7 @@ public function test_get_routes_for_model_returns_collection_of_routes_of_given_ $this->assertEquals(new Route(new HtmlPage('html')), Routes::getRoutes(HtmlPage::class)->first()); $this->restoreDefaultPages(); + $this->restoreDocumentationSearch(); } public function test_add_route_adds_new_route() diff --git a/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php b/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php index fea50135306..f8727b4caed 100644 --- a/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php +++ b/packages/framework/tests/Unit/Pages/PageModelGetHelperTest.php @@ -51,6 +51,8 @@ public function test_markdown_post_get_helper_returns_markdown_post_collection() public function test_documentation_page_get_helper_returns_documentation_page_collection() { + $this->withoutDocumentationSearch(); + Filesystem::touch('_docs/test-page.md'); $collection = DocumentationPage::all(); @@ -59,5 +61,7 @@ public function test_documentation_page_get_helper_returns_documentation_page_co $this->assertContainsOnlyInstancesOf(DocumentationPage::class, $collection); Filesystem::unlink('_docs/test-page.md'); + + $this->restoreDocumentationSearch(); } } diff --git a/packages/testing/src/ResetsApplication.php b/packages/testing/src/ResetsApplication.php index f5db985f41f..96729828402 100644 --- a/packages/testing/src/ResetsApplication.php +++ b/packages/testing/src/ResetsApplication.php @@ -50,6 +50,28 @@ protected function restoreDefaultPages(): void copy(Hyde::vendorPath('resources/views/pages/404.blade.php'), Hyde::path('_pages/404.blade.php')); } + /** @experimental We may want to make this a part of {@see static::withoutDefaultPages()} */ + protected function withoutDocumentationSearch(): void + { + $features = config('hyde.features'); + + $flipped = array_flip($features); + unset($flipped['documentation-search']); + $features = array_flip($flipped); + + config(['hyde.features' => $features]); + } + + /** @experimental We may want to make this a part of {@see static::restoreDefaultPages()} */ + protected function restoreDocumentationSearch(): void + { + $features = config('hyde.features'); + + $features[] = 'documentation-search'; + + config(['hyde.features' => $features]); + } + protected static function unlinkUnlessDefault(string $filepath): void { $protected = [ From f55ad51f56a502619e95a96996157ddf9dd590d1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 18:06:56 +0100 Subject: [PATCH 0013/4023] Hide the search page from sidebar generation Could cause issues if the user wants to document their search page, maybe we tie it into the create_search_page config option? Because if they have a custom search page, they would want to disable that feature, and then this should also be disabled. --- .../src/Framework/Actions/GeneratesDocumentationSearchIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index 85e17aa1448..368895b599d 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -59,7 +59,7 @@ protected function __construct() protected function run(): void { DocumentationPage::all()->each(function (DocumentationPage $page): void { - if (! in_array($page->identifier, Config::getArray('docs.exclude_from_search', []))) { + if (! in_array($page->identifier, array_merge(Config::getArray('docs.exclude_from_search', []), ['search']))) { $this->index->push($this->generatePageEntry($page)); } }); From ba44d871ba03516d4ea0c0a5b06ac58397f7bcb3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 20:12:16 +0100 Subject: [PATCH 0014/4023] Test documentation search sitemap integration --- .../Feature/Services/SitemapServiceTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/framework/tests/Feature/Services/SitemapServiceTest.php b/packages/framework/tests/Feature/Services/SitemapServiceTest.php index e82342eb974..0c735f08819 100644 --- a/packages/framework/tests/Feature/Services/SitemapServiceTest.php +++ b/packages/framework/tests/Feature/Services/SitemapServiceTest.php @@ -67,6 +67,7 @@ public function test_generate_adds_markdown_posts_to_xml() public function test_generate_adds_documentation_pages_to_xml() { + $this->withoutDocumentationSearch(); Filesystem::touch('_docs/foo.md'); $service = new SitemapGenerator(); @@ -74,6 +75,19 @@ public function test_generate_adds_documentation_pages_to_xml() $this->assertCount(3, $service->getXmlElement()->url); + Filesystem::unlink('_docs/foo.md'); + $this->restoreDocumentationSearch(); + } + + public function test_generate_adds_documentation_search_pages_to_xml() + { + Filesystem::touch('_docs/foo.md'); + + $service = new SitemapGenerator(); + $service->generate(); + + $this->assertCount(5, $service->getXmlElement()->url); + Filesystem::unlink('_docs/foo.md'); } @@ -131,6 +145,7 @@ public function test_all_route_types_are_discovered() { config(['hyde.url' => 'foo']); Filesystem::unlink(['_pages/index.blade.php', '_pages/404.blade.php']); + $this->withoutDocumentationSearch(); $files = [ '_pages/blade.blade.php', @@ -157,6 +172,8 @@ public function test_all_route_types_are_discovered() copy(Hyde::vendorPath('resources/views/homepages/welcome.blade.php'), Hyde::path('_pages/index.blade.php')); copy(Hyde::vendorPath('resources/views/pages/404.blade.php'), Hyde::path('_pages/404.blade.php')); + + $this->restoreDocumentationSearch(); } public function testLinksFallbackToRelativeLinksWhenASiteUrlIsNotSet() From c45a64e6aabd3a037b028da05e39593c0cf9a963 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 20:29:02 +0100 Subject: [PATCH 0015/4023] Remove blanket assertion Was probably added as a blanket to include build task output. Can't find any info in the Git log. Since it's unclear, and removing it makes the test pass, that's exactly what I'm going to do. --- packages/framework/tests/Feature/StaticSiteServiceTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/tests/Feature/StaticSiteServiceTest.php b/packages/framework/tests/Feature/StaticSiteServiceTest.php index c4bc8d35dbf..165a11ad07b 100644 --- a/packages/framework/tests/Feature/StaticSiteServiceTest.php +++ b/packages/framework/tests/Feature/StaticSiteServiceTest.php @@ -83,7 +83,6 @@ public function test_all_page_types_can_be_compiled() ->expectsOutput('Creating Markdown Pages...') ->expectsOutput('Creating Markdown Posts...') ->expectsOutput('Creating Documentation Pages...') - ->doesntExpectOutputToContain('Creating') ->assertExitCode(0); $this->assertFileExists(Hyde::path('_site/html.html')); From 49de93d20f9d1f3594b889fecf7b378b1b3d3e73 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 13 Dec 2023 16:58:36 +0100 Subject: [PATCH 0016/4023] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c5a5421e35c..afe7ac9692f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,7 +13,7 @@ This serves two purposes: - Add experimental InMemoryPage::getOutputPath overload support ### Changed -- for changes in existing functionality. +- Changed how the documentation search is generated, to be an InMemoryPage instead of a post-build task. ### Deprecated - \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch @@ -30,3 +30,11 @@ This serves two purposes: ### Upgrade Guide If there are any breaking changes, include an upgrade guide here. + +#### Documentation search changes + +The documentation search page and search index have been changed to be generated as InMemoryPages instead of a post-build task. + +In case you have customized the GenerateSearch post-build task, you will need to adapt your code to the new InMemoryPage, which is generated in the HydeCoreExtension class. + +For more information, see https://github.com/hydephp/develop/pull/1498. From 5728f7ad29a4295d3fb003cdb533feaf6f199f17 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 10:38:23 +0100 Subject: [PATCH 0017/4023] Extract helper method --- .../Actions/GeneratesDocumentationSearchIndex.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index 368895b599d..dfc7c4f95d8 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -59,7 +59,7 @@ protected function __construct() protected function run(): void { DocumentationPage::all()->each(function (DocumentationPage $page): void { - if (! in_array($page->identifier, array_merge(Config::getArray('docs.exclude_from_search', []), ['search']))) { + if (! in_array($page->identifier, $this->getPagesToExcludeFromSearch())) { $this->index->push($this->generatePageEntry($page)); } }); @@ -103,4 +103,9 @@ protected function getPath(): string { return Hyde::sitePath(DocumentationPage::outputDirectory().'/search.json'); } + + protected function getPagesToExcludeFromSearch(): array + { + return array_merge(Config::getArray('docs.exclude_from_search', []), ['search']); + } } From 3cb7f404f0b03f05b9ad6b02a14e959552741325 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 10:40:11 +0100 Subject: [PATCH 0018/4023] Make search index page exclusion dependent on config setting > Because if they have a custom search page, they would want to disable that feature, and then this should also be disabled. See https://github.com/hydephp/develop/pull/1498#discussion_r1425650912 --- .../src/Framework/Actions/GeneratesDocumentationSearchIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index dfc7c4f95d8..64bbb7d8e67 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -106,6 +106,6 @@ protected function getPath(): string protected function getPagesToExcludeFromSearch(): array { - return array_merge(Config::getArray('docs.exclude_from_search', []), ['search']); + return array_merge(Config::getArray('docs.exclude_from_search', []), Config::getBool('docs.create_search_page', true) ? ['search'] : []); } } From bd140499e0d7850ca3e333eaddb9c9d45ba79a59 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 12:22:23 +0100 Subject: [PATCH 0019/4023] Extract experimental helper method Decoupling it from the extension cleans up the code, and allows us to use it in the build search command, even if it's not injected due to the search feature being disabled (then we still allow the user to force it like before) --- .../src/Foundation/HydeCoreExtension.php | 10 +--------- .../Actions/GeneratesDocumentationSearchIndex.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 27c0706a93c..50d5d40a0ed 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -8,7 +8,6 @@ use Hyde\Pages\BladePage; use Hyde\Pages\MarkdownPage; use Hyde\Pages\MarkdownPost; -use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; use Hyde\Foundation\Kernel\PageCollection; use Hyde\Foundation\Concerns\HydeExtension; @@ -36,14 +35,7 @@ public static function getPageClasses(): array public function discoverPages(PageCollection $collection): void { if (Features::hasDocumentationSearch()) { - $collection->addPage(tap(new InMemoryPage('search.json', ['navigation' => ['hidden' => true]]), function (InMemoryPage $page): void { - $page->macro('compile', function (): string { - return GeneratesDocumentationSearchIndex::generate(); - }); - $page->macro('getOutputPath', function (): string { - return DocumentationPage::outputDirectory().'/search.json'; - }); - })); + $collection->addPage(GeneratesDocumentationSearchIndex::makePage()); if (DocumentationSearchPage::enabled()) { $collection->addPage(new DocumentationSearchPage()); diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index 64bbb7d8e67..125f6098316 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -7,10 +7,12 @@ use Hyde\Hyde; use Hyde\Facades\Config; use Hyde\Facades\Filesystem; +use Hyde\Pages\InMemoryPage; use Hyde\Framework\Concerns\InteractsWithDirectories; use Hyde\Pages\DocumentationPage; use Illuminate\Support\Collection; +use function tap; use function basename; use function in_array; use function trim; @@ -50,6 +52,19 @@ public static function generate(): string return $service->index->toJson(); } + /** @experimental May be moved to a DocumentationSearch class */ + public static function makePage(): InMemoryPage + { + return tap(new InMemoryPage('search.json', ['navigation' => ['hidden' => true]]), function (InMemoryPage $page): void { + $page->macro('compile', function (): string { + return GeneratesDocumentationSearchIndex::generate(); + }); + $page->macro('getOutputPath', function (): string { + return DocumentationPage::outputDirectory().'/search.json'; + }); + }); + } + protected function __construct() { $this->index = new Collection(); From 158c6f223d736ee2af2b26afb22614bd5fb30485 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 15:51:35 +0100 Subject: [PATCH 0020/4023] Update build search command to use new search page system --- .../src/Console/Commands/BuildSearchCommand.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index 03cf8f95934..594fc5c3917 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -4,8 +4,10 @@ namespace Hyde\Console\Commands; -use Hyde\Framework\Actions\PostBuildTasks\GenerateSearch; use LaravelZero\Framework\Commands\Command; +use Hyde\Framework\Actions\StaticPageBuilder; +use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; +use Hyde\Framework\Features\Documentation\DocumentationSearchPage; /** * Run the build process for the documentation search index. @@ -20,6 +22,12 @@ class BuildSearchCommand extends Command public function handle(): int { - return (new GenerateSearch())->run($this->output); + StaticPageBuilder::handle(GeneratesDocumentationSearchIndex::makePage()); + + if (DocumentationSearchPage::enabled()) { + DocumentationSearchPage::generate(); + } + + return Command::SUCCESS; } } From 873b928714cb3b123df794a40c2ee9300f264355 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 15:52:46 +0100 Subject: [PATCH 0021/4023] Support getting the search page from the kernel In case it's been modified or injected somehow, this is a nicety to have --- .../src/Console/Commands/BuildSearchCommand.php | 16 ++++++++++++++-- .../Feature/Commands/BuildSearchCommandTest.php | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index 594fc5c3917..225980b2689 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -4,8 +4,11 @@ namespace Hyde\Console\Commands; -use LaravelZero\Framework\Commands\Command; +use Hyde\Pages\Concerns\HydePage; +use Hyde\Foundation\Facades\Pages; use Hyde\Framework\Actions\StaticPageBuilder; +use Hyde\Framework\Exceptions\FileNotFoundException; +use LaravelZero\Framework\Commands\Command; use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; use Hyde\Framework\Features\Documentation\DocumentationSearchPage; @@ -22,7 +25,7 @@ class BuildSearchCommand extends Command public function handle(): int { - StaticPageBuilder::handle(GeneratesDocumentationSearchIndex::makePage()); + StaticPageBuilder::handle($this->getPageFromKernel() ?? GeneratesDocumentationSearchIndex::makePage()); if (DocumentationSearchPage::enabled()) { DocumentationSearchPage::generate(); @@ -30,4 +33,13 @@ public function handle(): int return Command::SUCCESS; } + + protected function getPageFromKernel(): ?HydePage + { + try { + return Pages::getPage('search.json'); + } catch (FileNotFoundException) { + return null; + } + } } diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index d8dc55a2826..bd25e01bd78 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -6,8 +6,10 @@ use Hyde\Facades\Filesystem; use Hyde\Hyde; +use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; use Hyde\Testing\TestCase; +use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; /** * @covers \Hyde\Console\Commands\BuildSearchCommand @@ -103,4 +105,18 @@ public function test_search_files_can_be_generated_for_custom_site_and_nested_do Filesystem::deleteDirectory('foo'); } + + public function test_command_uses_page_from_kernel_when_present() + { + Hyde::pages()->addPage(tap(GeneratesDocumentationSearchIndex::makePage(), function (InMemoryPage $page): void { + $page->macro('compile', fn () => '{"foo":"bar"}'); + })); + + $this->artisan('build:search')->assertExitCode(0); + $this->assertFileExists(Hyde::path('_site/docs/search.json')); + $this->assertSame('{"foo":"bar"}', Filesystem::getContents('_site/docs/search.json')); + + Filesystem::unlink('_site/docs/search.json'); + Filesystem::unlink('_site/docs/search.html'); + } } From 4f91f82c9a841889039ad2f5638610348ca2b644 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 17:11:10 +0100 Subject: [PATCH 0022/4023] Simplify logic to use nullable helper --- .../framework/src/Console/Commands/BuildSearchCommand.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index 225980b2689..21992b51668 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -7,7 +7,6 @@ use Hyde\Pages\Concerns\HydePage; use Hyde\Foundation\Facades\Pages; use Hyde\Framework\Actions\StaticPageBuilder; -use Hyde\Framework\Exceptions\FileNotFoundException; use LaravelZero\Framework\Commands\Command; use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; use Hyde\Framework\Features\Documentation\DocumentationSearchPage; @@ -36,10 +35,6 @@ public function handle(): int protected function getPageFromKernel(): ?HydePage { - try { - return Pages::getPage('search.json'); - } catch (FileNotFoundException) { - return null; - } + return Pages::get('search.json'); } } From e80cbb2f495dabf51435edfb3bf962b997c37a54 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 17:11:26 +0100 Subject: [PATCH 0023/4023] Inline simplified helper method --- .../framework/src/Console/Commands/BuildSearchCommand.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index 21992b51668..a0248172a17 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -4,7 +4,6 @@ namespace Hyde\Console\Commands; -use Hyde\Pages\Concerns\HydePage; use Hyde\Foundation\Facades\Pages; use Hyde\Framework\Actions\StaticPageBuilder; use LaravelZero\Framework\Commands\Command; @@ -24,7 +23,7 @@ class BuildSearchCommand extends Command public function handle(): int { - StaticPageBuilder::handle($this->getPageFromKernel() ?? GeneratesDocumentationSearchIndex::makePage()); + StaticPageBuilder::handle(Pages::get('search.json') ?? GeneratesDocumentationSearchIndex::makePage()); if (DocumentationSearchPage::enabled()) { DocumentationSearchPage::generate(); @@ -32,9 +31,4 @@ public function handle(): int return Command::SUCCESS; } - - protected function getPageFromKernel(): ?HydePage - { - return Pages::get('search.json'); - } } From 03f7fd897735c097bffb7b3cd27da505059c8680 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 17:15:54 +0100 Subject: [PATCH 0024/4023] Get the search page from the kernel as well --- .../framework/src/Console/Commands/BuildSearchCommand.php | 2 +- .../tests/Feature/Commands/BuildSearchCommandTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index a0248172a17..563778da0b1 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -26,7 +26,7 @@ public function handle(): int StaticPageBuilder::handle(Pages::get('search.json') ?? GeneratesDocumentationSearchIndex::makePage()); if (DocumentationSearchPage::enabled()) { - DocumentationSearchPage::generate(); + StaticPageBuilder::handle(Pages::get('docs/search') ?? new DocumentationSearchPage()); } return Command::SUCCESS; diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index bd25e01bd78..72a5f591930 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -106,15 +106,21 @@ public function test_search_files_can_be_generated_for_custom_site_and_nested_do Filesystem::deleteDirectory('foo'); } - public function test_command_uses_page_from_kernel_when_present() + public function test_command_uses_search_pages_from_kernel_when_present() { Hyde::pages()->addPage(tap(GeneratesDocumentationSearchIndex::makePage(), function (InMemoryPage $page): void { $page->macro('compile', fn () => '{"foo":"bar"}'); })); + Hyde::pages()->addPage(tap(new InMemoryPage('docs/search'), function (InMemoryPage $page): void { + $page->macro('compile', fn () => 'Foo'); + })); + $this->artisan('build:search')->assertExitCode(0); $this->assertFileExists(Hyde::path('_site/docs/search.json')); + $this->assertFileExists(Hyde::path('_site/docs/search.html')); $this->assertSame('{"foo":"bar"}', Filesystem::getContents('_site/docs/search.json')); + $this->assertSame('Foo', Filesystem::getContents('_site/docs/search.html')); Filesystem::unlink('_site/docs/search.json'); Filesystem::unlink('_site/docs/search.html'); From b021766d2f16be15a6c988e8b2b17e45384f2a22 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 17:17:42 +0100 Subject: [PATCH 0025/4023] Clean up test method --- .../framework/tests/Feature/Commands/BuildSearchCommandTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index 72a5f591930..2c289a5b4f9 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -117,8 +117,10 @@ public function test_command_uses_search_pages_from_kernel_when_present() })); $this->artisan('build:search')->assertExitCode(0); + $this->assertFileExists(Hyde::path('_site/docs/search.json')); $this->assertFileExists(Hyde::path('_site/docs/search.html')); + $this->assertSame('{"foo":"bar"}', Filesystem::getContents('_site/docs/search.json')); $this->assertSame('Foo', Filesystem::getContents('_site/docs/search.html')); From 799d51f4a9b164ff5f3bdd6d64559d7b2d6ae034 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 18:17:06 +0100 Subject: [PATCH 0026/4023] Extract a model class for the documentation search index --- .../GeneratesDocumentationSearchIndex.php | 11 +---- .../DocumentationSearchIndex.php | 46 +++++++++++++++++++ .../Commands/BuildSearchCommandTest.php | 4 +- 3 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index 125f6098316..e76c20496dd 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -11,8 +11,8 @@ use Hyde\Framework\Concerns\InteractsWithDirectories; use Hyde\Pages\DocumentationPage; use Illuminate\Support\Collection; +use Hyde\Framework\Features\Documentation\DocumentationSearchIndex; -use function tap; use function basename; use function in_array; use function trim; @@ -55,14 +55,7 @@ public static function generate(): string /** @experimental May be moved to a DocumentationSearch class */ public static function makePage(): InMemoryPage { - return tap(new InMemoryPage('search.json', ['navigation' => ['hidden' => true]]), function (InMemoryPage $page): void { - $page->macro('compile', function (): string { - return GeneratesDocumentationSearchIndex::generate(); - }); - $page->macro('getOutputPath', function (): string { - return DocumentationPage::outputDirectory().'/search.json'; - }); - }); + return DocumentationSearchIndex::make(); } protected function __construct() diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php new file mode 100644 index 00000000000..b5b650c722f --- /dev/null +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php @@ -0,0 +1,46 @@ + ['hidden' => true], + ]); + } + + public function compile(): string + { + return GeneratesDocumentationSearchIndex::generate(); + } + + public function getOutputPath(): string + { + return DocumentationPage::outputDirectory().'/search.json'; + } +} diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index 2c289a5b4f9..454b63196d3 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -9,7 +9,6 @@ use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; use Hyde\Testing\TestCase; -use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; /** * @covers \Hyde\Console\Commands\BuildSearchCommand @@ -108,8 +107,9 @@ public function test_search_files_can_be_generated_for_custom_site_and_nested_do public function test_command_uses_search_pages_from_kernel_when_present() { - Hyde::pages()->addPage(tap(GeneratesDocumentationSearchIndex::makePage(), function (InMemoryPage $page): void { + Hyde::pages()->addPage(tap(new InMemoryPage('search.json'), function (InMemoryPage $page): void { $page->macro('compile', fn () => '{"foo":"bar"}'); + $page->macro('getOutputPath', fn () => 'docs/search.json'); })); Hyde::pages()->addPage(tap(new InMemoryPage('docs/search'), function (InMemoryPage $page): void { From 76c1c3ef2911ae5959ceb6eb71021cb3cfdadbda Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 18:44:28 +0100 Subject: [PATCH 0027/4023] Remove unused method --- .../Documentation/DocumentationSearchIndex.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php index b5b650c722f..b33845960a5 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php @@ -6,7 +6,6 @@ use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; -use Hyde\Framework\Actions\StaticPageBuilder; use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; /** @@ -14,16 +13,6 @@ */ class DocumentationSearchIndex extends InMemoryPage { - /** - * Generate the search page and save it to disk. - * - * @return string The path to the generated file. - */ - public static function generate(): string - { - return StaticPageBuilder::handle(new static()); - } - /** * Create a new DocumentationSearchPage instance. */ From 44e97cd41508eccf6ce57142e2141fd14e0ee97b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 18:48:24 +0100 Subject: [PATCH 0028/4023] Merge in source directory prefix for search index identifier --- .../Features/Documentation/DocumentationSearchIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php index b33845960a5..f1dcaaa1acb 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php @@ -18,7 +18,7 @@ class DocumentationSearchIndex extends InMemoryPage */ public function __construct() { - parent::__construct('search.json', [ + parent::__construct(DocumentationPage::sourceDirectory().'/search.json', [ 'navigation' => ['hidden' => true], ]); } From 01cba90c8a9ac168e57f4f5001039bef0f3b9fd1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 19:46:01 +0100 Subject: [PATCH 0029/4023] Trim leading slashes from assembled paths --- .../Features/Documentation/DocumentationSearchIndex.php | 4 ++-- .../Features/Documentation/DocumentationSearchPage.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php index f1dcaaa1acb..4ad3e5deb30 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php @@ -18,7 +18,7 @@ class DocumentationSearchIndex extends InMemoryPage */ public function __construct() { - parent::__construct(DocumentationPage::sourceDirectory().'/search.json', [ + parent::__construct(ltrim(DocumentationPage::sourceDirectory().'/search.json', '/'), [ 'navigation' => ['hidden' => true], ]); } @@ -30,6 +30,6 @@ public function compile(): string public function getOutputPath(): string { - return DocumentationPage::outputDirectory().'/search.json'; + return ltrim(DocumentationPage::outputDirectory().'/search.json', '/'); } } diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index f58ff0b83ca..b582111b529 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -52,6 +52,6 @@ public static function enabled(): bool public static function routeKey(): string { - return parent::outputDirectory().'/search'; + return ltrim(parent::outputDirectory().'/search'); } } From 57bdecb2bc2c593c9cf5ed129953f559a3fe115d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 19:50:38 +0100 Subject: [PATCH 0030/4023] Inline added simplified experimental method --- .../framework/src/Console/Commands/BuildSearchCommand.php | 4 ++-- packages/framework/src/Foundation/HydeCoreExtension.php | 4 ++-- .../Actions/GeneratesDocumentationSearchIndex.php | 8 -------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index 563778da0b1..814f69ed751 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -7,8 +7,8 @@ use Hyde\Foundation\Facades\Pages; use Hyde\Framework\Actions\StaticPageBuilder; use LaravelZero\Framework\Commands\Command; -use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; use Hyde\Framework\Features\Documentation\DocumentationSearchPage; +use Hyde\Framework\Features\Documentation\DocumentationSearchIndex; /** * Run the build process for the documentation search index. @@ -23,7 +23,7 @@ class BuildSearchCommand extends Command public function handle(): int { - StaticPageBuilder::handle(Pages::get('search.json') ?? GeneratesDocumentationSearchIndex::makePage()); + StaticPageBuilder::handle(Pages::get('search.json') ?? DocumentationSearchIndex::make()); if (DocumentationSearchPage::enabled()) { StaticPageBuilder::handle(Pages::get('docs/search') ?? new DocumentationSearchPage()); diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 50d5d40a0ed..5ecf1e90ef2 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -12,8 +12,8 @@ use Hyde\Foundation\Kernel\PageCollection; use Hyde\Foundation\Concerns\HydeExtension; use Hyde\Facades\Features; -use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; use Hyde\Framework\Features\Documentation\DocumentationSearchPage; +use Hyde\Framework\Features\Documentation\DocumentationSearchIndex; use function array_filter; use function array_keys; @@ -35,7 +35,7 @@ public static function getPageClasses(): array public function discoverPages(PageCollection $collection): void { if (Features::hasDocumentationSearch()) { - $collection->addPage(GeneratesDocumentationSearchIndex::makePage()); + $collection->addPage(DocumentationSearchIndex::make()); if (DocumentationSearchPage::enabled()) { $collection->addPage(new DocumentationSearchPage()); diff --git a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php index e76c20496dd..64bbb7d8e67 100644 --- a/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Actions/GeneratesDocumentationSearchIndex.php @@ -7,11 +7,9 @@ use Hyde\Hyde; use Hyde\Facades\Config; use Hyde\Facades\Filesystem; -use Hyde\Pages\InMemoryPage; use Hyde\Framework\Concerns\InteractsWithDirectories; use Hyde\Pages\DocumentationPage; use Illuminate\Support\Collection; -use Hyde\Framework\Features\Documentation\DocumentationSearchIndex; use function basename; use function in_array; @@ -52,12 +50,6 @@ public static function generate(): string return $service->index->toJson(); } - /** @experimental May be moved to a DocumentationSearch class */ - public static function makePage(): InMemoryPage - { - return DocumentationSearchIndex::make(); - } - protected function __construct() { $this->index = new Collection(); From cca3610b786864df861a769c744a4d8db9793fc1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 19:52:21 +0100 Subject: [PATCH 0031/4023] Change constructor style Just makes it visually consistent --- packages/framework/src/Console/Commands/BuildSearchCommand.php | 2 +- packages/framework/src/Foundation/HydeCoreExtension.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index 814f69ed751..d73a9112500 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -23,7 +23,7 @@ class BuildSearchCommand extends Command public function handle(): int { - StaticPageBuilder::handle(Pages::get('search.json') ?? DocumentationSearchIndex::make()); + StaticPageBuilder::handle(Pages::get('search.json') ?? new DocumentationSearchIndex()); if (DocumentationSearchPage::enabled()) { StaticPageBuilder::handle(Pages::get('docs/search') ?? new DocumentationSearchPage()); diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 5ecf1e90ef2..38772c55871 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -35,7 +35,7 @@ public static function getPageClasses(): array public function discoverPages(PageCollection $collection): void { if (Features::hasDocumentationSearch()) { - $collection->addPage(DocumentationSearchIndex::make()); + $collection->addPage(new DocumentationSearchIndex()); if (DocumentationSearchPage::enabled()) { $collection->addPage(new DocumentationSearchPage()); From 37f7046251b8c0514b8d8ef821de4ef3d35bbac8 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 20:05:28 +0100 Subject: [PATCH 0032/4023] Refractor internal search page to extend in memory page I think this is more semantic --- .../Documentation/DocumentationSearchPage.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index b582111b529..0bf7f8ad8c6 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -5,10 +5,10 @@ namespace Hyde\Framework\Features\Documentation; use Hyde\Hyde; +use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; use Hyde\Framework\Actions\StaticPageBuilder; use Hyde\Facades\Config; -use Illuminate\Support\Facades\View; /** * @internal This page is used to render the search page for the documentation. @@ -17,7 +17,7 @@ * If you want to override this page, you can create a page with the route key "docs/search", * then this class will not be applied. For example, `_pages/docs/search.blade.php`. */ -class DocumentationSearchPage extends DocumentationPage +class DocumentationSearchPage extends InMemoryPage { /** * Generate the search page and save it to disk. @@ -34,15 +34,10 @@ public static function generate(): string */ public function __construct() { - parent::__construct('search', [ + parent::__construct(ltrim(DocumentationPage::outputDirectory().'/search', '/'), [ 'title' => 'Search', 'navigation' => ['hidden' => true], - ]); - } - - public function compile(): string - { - return View::make('hyde::pages.documentation-search')->render(); + ], view: 'hyde::pages.documentation-search'); } public static function enabled(): bool @@ -52,6 +47,6 @@ public static function enabled(): bool public static function routeKey(): string { - return ltrim(parent::outputDirectory().'/search'); + return ltrim(DocumentationPage::outputDirectory().'/search'); } } From 34ba8552a08210b82e597ede3472a534c62f1aeb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 11:12:57 +0100 Subject: [PATCH 0033/4023] Update documentation article component to support existing variables Allows for them to be passed from a model class, for example. --- RELEASE_NOTES.md | 1 + .../views/components/docs/documentation-article.blade.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index afe7ac9692f..d1ba26e97a6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -14,6 +14,7 @@ This serves two purposes: ### Changed - Changed how the documentation search is generated, to be an InMemoryPage instead of a post-build task. +- Updated the documentation article component to support existing $document instance. ### Deprecated - \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch diff --git a/packages/framework/resources/views/components/docs/documentation-article.blade.php b/packages/framework/resources/views/components/docs/documentation-article.blade.php index 1bacc9e5c42..4565069d6a0 100644 --- a/packages/framework/resources/views/components/docs/documentation-article.blade.php +++ b/packages/framework/resources/views/components/docs/documentation-article.blade.php @@ -1,5 +1,5 @@ @php - $document = \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page); + $document ??= \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page); @endphp
Date: Fri, 15 Dec 2023 11:13:37 +0100 Subject: [PATCH 0034/4023] Update search page to mock document See https://github.com/hydephp/develop/commit/37f7046251b8c0514b8d8ef821de4ef3d35bbac8#commitcomment-135026537 --- .../Features/Documentation/DocumentationSearchPage.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index 0bf7f8ad8c6..af1c39b5892 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -37,6 +37,7 @@ public function __construct() parent::__construct(ltrim(DocumentationPage::outputDirectory().'/search', '/'), [ 'title' => 'Search', 'navigation' => ['hidden' => true], + 'document' => $this->makeDocument(), ], view: 'hyde::pages.documentation-search'); } @@ -49,4 +50,10 @@ public static function routeKey(): string { return ltrim(DocumentationPage::outputDirectory().'/search'); } + + /** @experimental Fixes type issue {@see https://github.com/hydephp/develop/commit/37f7046251b8c0514b8d8ef821de4ef3d35bbac8#commitcomment-135026537} */ + protected function makeDocument(): SemanticDocumentationArticle + { + return SemanticDocumentationArticle::make(new DocumentationPage()); + } } From b6eca700b4bb96037e55f7fe12071306fad2e074 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 11:36:00 +0100 Subject: [PATCH 0035/4023] Fix added search index page should include docs prefix These in-memory page identifiers should include the route key prefix they would get if they were documentation pages --- packages/framework/src/Console/Commands/BuildSearchCommand.php | 2 +- .../framework/tests/Feature/Commands/BuildSearchCommandTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index d73a9112500..4388c64cb68 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -23,7 +23,7 @@ class BuildSearchCommand extends Command public function handle(): int { - StaticPageBuilder::handle(Pages::get('search.json') ?? new DocumentationSearchIndex()); + StaticPageBuilder::handle(Pages::get('docs/search.json') ?? new DocumentationSearchIndex()); if (DocumentationSearchPage::enabled()) { StaticPageBuilder::handle(Pages::get('docs/search') ?? new DocumentationSearchPage()); diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index 454b63196d3..9dcdc335552 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -107,7 +107,7 @@ public function test_search_files_can_be_generated_for_custom_site_and_nested_do public function test_command_uses_search_pages_from_kernel_when_present() { - Hyde::pages()->addPage(tap(new InMemoryPage('search.json'), function (InMemoryPage $page): void { + Hyde::pages()->addPage(tap(new InMemoryPage('docs/search.json'), function (InMemoryPage $page): void { $page->macro('compile', fn () => '{"foo":"bar"}'); $page->macro('getOutputPath', fn () => 'docs/search.json'); })); From 6c932a1bf49cce15e0214a063532c85ca50d7306 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 11:38:23 +0100 Subject: [PATCH 0036/4023] Deprecate internal logic to be removed within refactor --- .../Framework/Features/Documentation/DocumentationSearchPage.php | 1 + packages/realtime-compiler/src/Routing/PageRouter.php | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index af1c39b5892..06530bb84a9 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -46,6 +46,7 @@ public static function enabled(): bool return Config::getBool('docs.create_search_page', true) && ! Hyde::routes()->has(self::routeKey()); } + /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ public static function routeKey(): string { return ltrim(DocumentationPage::outputDirectory().'/search'); diff --git a/packages/realtime-compiler/src/Routing/PageRouter.php b/packages/realtime-compiler/src/Routing/PageRouter.php index 1e41b531bd4..3d29cc7d18c 100644 --- a/packages/realtime-compiler/src/Routing/PageRouter.php +++ b/packages/realtime-compiler/src/Routing/PageRouter.php @@ -90,6 +90,7 @@ public static function handle(Request $request): Response protected function getPageFromRoute(): HydePage { + /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ if (unslash($this->request->path) === DocumentationSearchPage::routeKey() && DocumentationSearchPage::enabled()) { // Since this page is not present within the search index (as it's normally generated by a build task) // we instantiate and return it here. From 4556eed47894c9d5e5bd85aa85559445b9300cec Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 12:56:30 +0100 Subject: [PATCH 0037/4023] Fix wrong method used to emulate route key --- .../Features/Documentation/DocumentationSearchIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php index 4ad3e5deb30..2cb5aab6298 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchIndex.php @@ -18,7 +18,7 @@ class DocumentationSearchIndex extends InMemoryPage */ public function __construct() { - parent::__construct(ltrim(DocumentationPage::sourceDirectory().'/search.json', '/'), [ + parent::__construct(ltrim(DocumentationPage::outputDirectory().'/search.json', '/'), [ 'navigation' => ['hidden' => true], ]); } From 790689e0bfa3960e0585319801c299c6f2fa4bf0 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 12:57:57 +0100 Subject: [PATCH 0038/4023] Create DocumentationSearchIndexTest.php --- .../Feature/DocumentationSearchIndexTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 packages/framework/tests/Feature/DocumentationSearchIndexTest.php diff --git a/packages/framework/tests/Feature/DocumentationSearchIndexTest.php b/packages/framework/tests/Feature/DocumentationSearchIndexTest.php new file mode 100644 index 00000000000..58de0d066dd --- /dev/null +++ b/packages/framework/tests/Feature/DocumentationSearchIndexTest.php @@ -0,0 +1,36 @@ +assertInstanceOf(DocumentationSearchIndex::class, new DocumentationSearchIndex()); + } + + public function testRouteKeyIsSetToDocumentationOutputDirectory() + { + $page = new DocumentationSearchIndex(); + $this->assertSame('docs/search.json', $page->routeKey); + } + + public function testRouteKeyIsSetToConfiguredDocumentationOutputDirectory() + { + DocumentationPage::setOutputDirectory('foo'); + + $page = new DocumentationSearchIndex(); + $this->assertSame('foo/search.json', $page->routeKey); + } +} From 37c2dde6b063579dbdb3ad4444c9ae27b3ef27bc Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 12:58:05 +0100 Subject: [PATCH 0039/4023] Add coverage annotation --- .../framework/tests/Feature/Commands/BuildSearchCommandTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index 9dcdc335552..faa5f89b75a 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -14,6 +14,7 @@ * @covers \Hyde\Console\Commands\BuildSearchCommand * @covers \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch * @covers \Hyde\Framework\Features\Documentation\DocumentationSearchPage + * @covers \Hyde\Framework\Features\Documentation\DocumentationSearchIndex */ class BuildSearchCommandTest extends TestCase { From 38608b81dde77497e6a1283f0f3b9e81432ed039 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 13:32:59 +0100 Subject: [PATCH 0040/4023] Remove hacky route injection in favour of new search page implementation Targets the realtime compiler v4 as it's a breaking change that requires Hyde v2. See https://github.com/hydephp/develop/pull/1498 --- packages/realtime-compiler/src/Routing/PageRouter.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/realtime-compiler/src/Routing/PageRouter.php b/packages/realtime-compiler/src/Routing/PageRouter.php index 3d29cc7d18c..a3a3876203a 100644 --- a/packages/realtime-compiler/src/Routing/PageRouter.php +++ b/packages/realtime-compiler/src/Routing/PageRouter.php @@ -8,7 +8,6 @@ use Hyde\Pages\Concerns\BaseMarkdownPage; use Hyde\Framework\Actions\StaticPageBuilder; use Hyde\RealtimeCompiler\Http\LiveEditController; -use Hyde\Framework\Features\Documentation\DocumentationSearchPage; use Hyde\Pages\Concerns\HydePage; use Hyde\RealtimeCompiler\Concerns\InteractsWithLaravel; use Hyde\RealtimeCompiler\Concerns\SendsErrorResponses; @@ -90,13 +89,6 @@ public static function handle(Request $request): Response protected function getPageFromRoute(): HydePage { - /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ - if (unslash($this->request->path) === DocumentationSearchPage::routeKey() && DocumentationSearchPage::enabled()) { - // Since this page is not present within the search index (as it's normally generated by a build task) - // we instantiate and return it here. - return new DocumentationSearchPage(); - } - return Routes::getOrFail($this->normalizePath($this->request->path))->getPage(); } } From 9c100594e1292ebee8ab2c2329199fc71398fad3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 13:42:25 +0100 Subject: [PATCH 0041/4023] Update test to use new search page implementation --- packages/realtime-compiler/tests/RealtimeCompilerTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/realtime-compiler/tests/RealtimeCompilerTest.php b/packages/realtime-compiler/tests/RealtimeCompilerTest.php index 9f48e9467a9..5c2cec606c3 100644 --- a/packages/realtime-compiler/tests/RealtimeCompilerTest.php +++ b/packages/realtime-compiler/tests/RealtimeCompilerTest.php @@ -164,6 +164,8 @@ }); test('docs/search renders search page', function () { + Filesystem::put('_docs/index.md', '# Hello World!'); + mockRoute('docs/search'); $kernel = new HttpKernel(); @@ -175,6 +177,7 @@ expect($response->body)->toContain('Search the documentation site'); + Filesystem::unlink('_docs/index.md'); Filesystem::unlink('_site/docs/search.html'); }); From 0838ab4f25f75299f28495dcb9191e03a1ea0f3a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 15:10:29 +0100 Subject: [PATCH 0042/4023] Remove internal `DocumentationSearchPage::routeKey()` method This is now no longer needed thanks to https://github.com/hydephp/develop/pull/1498, but is kept as protected so the `enabled` method can use it --- .../Documentation/DocumentationSearchPage.php | 3 +-- .../tests/Feature/DocumentationSearchPageTest.php | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index 06530bb84a9..a27408c92fd 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -46,8 +46,7 @@ public static function enabled(): bool return Config::getBool('docs.create_search_page', true) && ! Hyde::routes()->has(self::routeKey()); } - /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ - public static function routeKey(): string + protected static function routeKey(): string { return ltrim(DocumentationPage::outputDirectory().'/search'); } diff --git a/packages/framework/tests/Feature/DocumentationSearchPageTest.php b/packages/framework/tests/Feature/DocumentationSearchPageTest.php index 22a9b53ed1c..ec91f318044 100644 --- a/packages/framework/tests/Feature/DocumentationSearchPageTest.php +++ b/packages/framework/tests/Feature/DocumentationSearchPageTest.php @@ -59,15 +59,4 @@ public function testEnabledIsFalseWhenDisabledAndRouteExists() Hyde::routes()->put('docs/search', new InMemoryPage('docs/search')); $this->assertFalse(DocumentationSearchPage::enabled()); } - - public function testStaticRouteKeyHelper() - { - $this->assertSame('docs/search', DocumentationSearchPage::routeKey()); - } - - public function testStaticRouteKeyHelperWithCustomOutputDirectory() - { - DocumentationPage::setOutputDirectory('foo'); - $this->assertSame('foo/search', DocumentationSearchPage::routeKey()); - } } From 82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 15 Dec 2023 15:50:21 +0100 Subject: [PATCH 0043/4023] Add improved conditional to fix override priority As part of the v2 refactors, since routes aren't discovered yet, we need to check the pages directly. This also means that custom search pages are now not built by the build:search command. We could change it so that it is, but we don't know if the custom page is a custom search feature, or a page that documents a search feature. So we don't know if this is what the user would want/expect. Additionally, the kernel API changes to needing to put the overrides in the pages collection instead of the route collection. This is also a very very minor implementation change with minimal impact. --- .../Features/Documentation/DocumentationSearchPage.php | 9 ++++++++- .../tests/Feature/Commands/BuildSearchCommandTest.php | 6 +++--- .../tests/Feature/DocumentationSearchPageTest.php | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index a27408c92fd..a352a250358 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -7,6 +7,7 @@ use Hyde\Hyde; use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; +use Hyde\Pages\Concerns\HydePage; use Hyde\Framework\Actions\StaticPageBuilder; use Hyde\Facades\Config; @@ -43,7 +44,13 @@ public function __construct() public static function enabled(): bool { - return Config::getBool('docs.create_search_page', true) && ! Hyde::routes()->has(self::routeKey()); + return Config::getBool('docs.create_search_page', true) && ! static::anotherSearchPageExists(); + } + + protected static function anotherSearchPageExists(): bool + { + // Since routes aren't discovered yet, we need to check the pages directly + return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } protected static function routeKey(): string diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index faa5f89b75a..dfcf392d5bf 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -120,12 +120,12 @@ public function test_command_uses_search_pages_from_kernel_when_present() $this->artisan('build:search')->assertExitCode(0); $this->assertFileExists(Hyde::path('_site/docs/search.json')); - $this->assertFileExists(Hyde::path('_site/docs/search.html')); +// $this->assertFileExists(Hyde::path('_site/docs/search.html')); $this->assertSame('{"foo":"bar"}', Filesystem::getContents('_site/docs/search.json')); - $this->assertSame('Foo', Filesystem::getContents('_site/docs/search.html')); +// $this->assertSame('Foo', Filesystem::getContents('_site/docs/search.html')); Filesystem::unlink('_site/docs/search.json'); - Filesystem::unlink('_site/docs/search.html'); +// Filesystem::unlink('_site/docs/search.html'); } } diff --git a/packages/framework/tests/Feature/DocumentationSearchPageTest.php b/packages/framework/tests/Feature/DocumentationSearchPageTest.php index ec91f318044..9f1d2546bec 100644 --- a/packages/framework/tests/Feature/DocumentationSearchPageTest.php +++ b/packages/framework/tests/Feature/DocumentationSearchPageTest.php @@ -49,14 +49,14 @@ public function testEnabledIsFalseWhenDisabled() public function testEnabledIsFalseWhenRouteExists() { - Hyde::routes()->put('docs/search', new InMemoryPage('docs/search')); + Hyde::pages()->put('docs/search', new InMemoryPage('docs/search')); $this->assertFalse(DocumentationSearchPage::enabled()); } public function testEnabledIsFalseWhenDisabledAndRouteExists() { config(['docs.create_search_page' => false]); - Hyde::routes()->put('docs/search', new InMemoryPage('docs/search')); + Hyde::pages()->put('docs/search', new InMemoryPage('docs/search')); $this->assertFalse(DocumentationSearchPage::enabled()); } } From 53d41b81c8e916f0fcc4246b2fa05f51b9079d59 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 16 Dec 2023 16:40:15 +0100 Subject: [PATCH 0044/4023] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d1ba26e97a6..31f6df9770b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -39,3 +39,16 @@ The documentation search page and search index have been changed to be generated In case you have customized the GenerateSearch post-build task, you will need to adapt your code to the new InMemoryPage, which is generated in the HydeCoreExtension class. For more information, see https://github.com/hydephp/develop/pull/1498. + +### Breaking changes + +#### Low impact +- The `GenerateSearch` post-build task has been removed. If you have previously extended or customized this class, + you will need to adapt your code, as the search index files are now handled implicitly during the standard build process, + as the search pages are now added to the kernel page and route collection. (https://github.com/hydephp/develop/pull/1498) +- If your site has a custom documentation search page, for example `_docs/search.md` or `_pages/docs/search.blade.php`, + that page will no longer be build when using the specific `build:search` command. It will, of course, + be built using the standard `build` command. https://github.com/hydephp/develop/commit/82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced +- In the highly unlikely event your site customizes any of the search pages by replacing them in the kernel route collection, + you would now need to do that in the kernel page collection due to the search pages being generated earlier in the lifecycle. + https://github.com/hydephp/develop/commit/82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced From 3bad9138c1e785f3b2a28c7c0530e1fc93bcc14f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 17 Dec 2023 19:59:55 +0100 Subject: [PATCH 0045/4023] Breaking: Remove the GenerateSearch build task --- .../Actions/PostBuildTasks/GenerateSearch.php | 34 ------------------- .../Commands/BuildSearchCommandTest.php | 1 - .../Feature/Services/BuildTaskServiceTest.php | 1 - .../tests/Unit/BuildTaskServiceUnitTest.php | 6 ---- 4 files changed, 42 deletions(-) delete mode 100644 packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php diff --git a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php deleted file mode 100644 index a2d115a6e96..00000000000 --- a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSearch.php +++ /dev/null @@ -1,34 +0,0 @@ -path = GeneratesDocumentationSearchIndex::handle(); - - if (DocumentationSearchPage::enabled()) { - $this->createdSiteFile(DocumentationSearchPage::generate()); - } - } - - public function printFinishMessage(): void - { - $this->createdSiteFile($this->path)->withExecutionTime(); - } -} diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index dfcf392d5bf..9562ae12512 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -12,7 +12,6 @@ /** * @covers \Hyde\Console\Commands\BuildSearchCommand - * @covers \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch * @covers \Hyde\Framework\Features\Documentation\DocumentationSearchPage * @covers \Hyde\Framework\Features\Documentation\DocumentationSearchIndex */ diff --git a/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php b/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php index 0260d37a8f6..347f83530ca 100644 --- a/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php +++ b/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php @@ -19,7 +19,6 @@ * @covers \Hyde\Framework\Features\BuildTasks\PostBuildTask * @covers \Hyde\Framework\Actions\PostBuildTasks\GenerateSitemap * @covers \Hyde\Framework\Actions\PostBuildTasks\GenerateRssFeed - * @covers \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch * * @see \Hyde\Framework\Testing\Unit\BuildTaskServiceUnitTest */ diff --git a/packages/framework/tests/Unit/BuildTaskServiceUnitTest.php b/packages/framework/tests/Unit/BuildTaskServiceUnitTest.php index 1b08979d54f..bcf14ff42a2 100644 --- a/packages/framework/tests/Unit/BuildTaskServiceUnitTest.php +++ b/packages/framework/tests/Unit/BuildTaskServiceUnitTest.php @@ -8,7 +8,6 @@ use Hyde\Foundation\Kernel\Filesystem; use Hyde\Framework\Actions\PostBuildTasks\GenerateBuildManifest; use Hyde\Framework\Actions\PostBuildTasks\GenerateRssFeed; -use Hyde\Framework\Actions\PostBuildTasks\GenerateSearch; use Hyde\Framework\Actions\PostBuildTasks\GenerateSitemap as FrameworkGenerateSitemap; use Hyde\Framework\Features\BuildTasks\BuildTask; use Hyde\Framework\Features\BuildTasks\PostBuildTask; @@ -167,11 +166,6 @@ public function testGenerateRssFeedExtendsPostBuildTask() $this->assertInstanceOf(PostBuildTask::class, new GenerateRssFeed()); } - public function testGenerateSearchExtendsPostBuildTask() - { - $this->assertInstanceOf(PostBuildTask::class, new GenerateSearch()); - } - public function testGenerateSitemapExtendsPostBuildTask() { $this->assertInstanceOf(PostBuildTask::class, new FrameworkGenerateSitemap()); From aeeed9f4fab5edab6513ef1c5210e9a1a4e349e6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 17 Dec 2023 20:26:26 +0100 Subject: [PATCH 0046/4023] Cleanup and improve release notes --- RELEASE_NOTES.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 31f6df9770b..599dcd1e614 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,17 +10,17 @@ This serves two purposes: 2. At release time, you can move the Unreleased section changes into a new release version section. ### Added -- Add experimental InMemoryPage::getOutputPath overload support +- Add experimental `InMemoryPage::getOutputPath` overload support ### Changed -- Changed how the documentation search is generated, to be an InMemoryPage instead of a post-build task. -- Updated the documentation article component to support existing $document instance. +- Changed how the documentation search is generated, to be an `InMemoryPage` instead of a post-build task. +- Updated the documentation article component to support existing `$document` instance. ### Deprecated -- \Hyde\Framework\Actions\PostBuildTasks\GenerateSearch +- for soon-to-be removed features. ### Removed -- for now removed features. +- Breaking: Removed the build task `\Hyde\Framework\Actions\PostBuildTasks\GenerateSearch` (see upgrade guide below) ### Fixed - for any bug fixes. @@ -32,23 +32,29 @@ This serves two purposes: If there are any breaking changes, include an upgrade guide here. -#### Documentation search changes +#### Documentation search page changes -The documentation search page and search index have been changed to be generated as InMemoryPages instead of a post-build task. +The documentation search page and search index have been changed to be generated as `InMemoryPages` instead of a post-build task. -In case you have customized the GenerateSearch post-build task, you will need to adapt your code to the new InMemoryPage, which is generated in the HydeCoreExtension class. +The main impact noticeable to most users by this is the implicit changes, like the pages showing up in the dashboard and route list command. + +In case you have customized the `GenerateSearch` post-build task you may, depending on what you were trying to do, +want to adapt your code to interact with the new `InMemoryPage`, which is generated in the `HydeCoreExtension` class. For more information, see https://github.com/hydephp/develop/pull/1498. ### Breaking changes #### Low impact + - The `GenerateSearch` post-build task has been removed. If you have previously extended or customized this class, you will need to adapt your code, as the search index files are now handled implicitly during the standard build process, as the search pages are now added to the kernel page and route collection. (https://github.com/hydephp/develop/pull/1498) + - If your site has a custom documentation search page, for example `_docs/search.md` or `_pages/docs/search.blade.php`, - that page will no longer be build when using the specific `build:search` command. It will, of course, + that page will no longer be built when using the specific `build:search` command. It will, of course, be built using the standard `build` command. https://github.com/hydephp/develop/commit/82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced +- - In the highly unlikely event your site customizes any of the search pages by replacing them in the kernel route collection, you would now need to do that in the kernel page collection due to the search pages being generated earlier in the lifecycle. https://github.com/hydephp/develop/commit/82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced From e43d6e829ce914422cf927c21bbc0575b105b145 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 10:47:03 +0100 Subject: [PATCH 0047/4023] Improve code comment --- .../Features/Documentation/DocumentationSearchPage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index a352a250358..27150145f3d 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -49,7 +49,8 @@ public static function enabled(): bool protected static function anotherSearchPageExists(): bool { - // Since routes aren't discovered yet, we need to check the pages directly + // Since routes aren't discovered yet due to this page being added in the core extension, + // we need to check the page collection directly, instead of the route collection. return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } From 32a1ee5e085bf367d96a6546acfa2d05672c26f3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 10:46:00 +0100 Subject: [PATCH 0048/4023] Use helper method with same code --- .../Features/Documentation/DocumentationSearchPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index 27150145f3d..e3070f59897 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -35,7 +35,7 @@ public static function generate(): string */ public function __construct() { - parent::__construct(ltrim(DocumentationPage::outputDirectory().'/search', '/'), [ + parent::__construct(static::routeKey(), [ 'title' => 'Search', 'navigation' => ['hidden' => true], 'document' => $this->makeDocument(), From eb07152ae1cdece442145fd5f44808d74234e912 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:12:23 +0100 Subject: [PATCH 0049/4023] Revert "Remove internal `DocumentationSearchPage::routeKey()` method" This reverts commit 0838ab4f25f75299f28495dcb9191e03a1ea0f3a as the class is internal it doesn't bog up the public API, but we can still use it to reduce overlapping logic in our codebase. --- .../Documentation/DocumentationSearchPage.php | 3 ++- .../tests/Feature/DocumentationSearchPageTest.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index e3070f59897..d5d90690c25 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -54,7 +54,8 @@ protected static function anotherSearchPageExists(): bool return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } - protected static function routeKey(): string + /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ + public static function routeKey(): string { return ltrim(DocumentationPage::outputDirectory().'/search'); } diff --git a/packages/framework/tests/Feature/DocumentationSearchPageTest.php b/packages/framework/tests/Feature/DocumentationSearchPageTest.php index 9f1d2546bec..cfb45b76a0c 100644 --- a/packages/framework/tests/Feature/DocumentationSearchPageTest.php +++ b/packages/framework/tests/Feature/DocumentationSearchPageTest.php @@ -59,4 +59,15 @@ public function testEnabledIsFalseWhenDisabledAndRouteExists() Hyde::pages()->put('docs/search', new InMemoryPage('docs/search')); $this->assertFalse(DocumentationSearchPage::enabled()); } + + public function testStaticRouteKeyHelper() + { + $this->assertSame('docs/search', DocumentationSearchPage::routeKey()); + } + + public function testStaticRouteKeyHelperWithCustomOutputDirectory() + { + DocumentationPage::setOutputDirectory('foo'); + $this->assertSame('foo/search', DocumentationSearchPage::routeKey()); + } } From ef0fa703c47ec82f9218bb8eab1b325efefc6deb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:13:49 +0100 Subject: [PATCH 0050/4023] Revert internal deprecation This partially reverts commit 6c932a1bf49cce15e0214a063532c85ca50d7306. --- .../Framework/Features/Documentation/DocumentationSearchPage.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index d5d90690c25..d61a24b8105 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -54,7 +54,6 @@ protected static function anotherSearchPageExists(): bool return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } - /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ public static function routeKey(): string { return ltrim(DocumentationPage::outputDirectory().'/search'); From 883c09d9474ac9d003fede67f9f21e6ad2131186 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:21:48 +0100 Subject: [PATCH 0051/4023] Move up public method --- .../Features/Documentation/DocumentationSearchPage.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index d61a24b8105..f9d92c1556e 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -47,6 +47,11 @@ public static function enabled(): bool return Config::getBool('docs.create_search_page', true) && ! static::anotherSearchPageExists(); } + public static function routeKey(): string + { + return ltrim(DocumentationPage::outputDirectory().'/search'); + } + protected static function anotherSearchPageExists(): bool { // Since routes aren't discovered yet due to this page being added in the core extension, @@ -54,11 +59,6 @@ protected static function anotherSearchPageExists(): bool return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } - public static function routeKey(): string - { - return ltrim(DocumentationPage::outputDirectory().'/search'); - } - /** @experimental Fixes type issue {@see https://github.com/hydephp/develop/commit/37f7046251b8c0514b8d8ef821de4ef3d35bbac8#commitcomment-135026537} */ protected function makeDocument(): SemanticDocumentationArticle { From 89c63523196e5816938b3a9eecb957041faffaad Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:21:59 +0100 Subject: [PATCH 0052/4023] Import used function --- .../Features/Documentation/DocumentationSearchPage.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index f9d92c1556e..4e6c1778678 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -11,6 +11,8 @@ use Hyde\Framework\Actions\StaticPageBuilder; use Hyde\Facades\Config; +use function ltrim; + /** * @internal This page is used to render the search page for the documentation. * From 0f8fe02c68cace2d5ab9567195d8f6d7e6ce243c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:35:38 +0100 Subject: [PATCH 0053/4023] Fix missing trim argument Required in case of root outputs so that the route key is relative --- .../Features/Documentation/DocumentationSearchPage.php | 2 +- .../framework/tests/Feature/DocumentationSearchPageTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index 4e6c1778678..e16fe950279 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -51,7 +51,7 @@ public static function enabled(): bool public static function routeKey(): string { - return ltrim(DocumentationPage::outputDirectory().'/search'); + return ltrim(DocumentationPage::outputDirectory().'/search', '/'); } protected static function anotherSearchPageExists(): bool diff --git a/packages/framework/tests/Feature/DocumentationSearchPageTest.php b/packages/framework/tests/Feature/DocumentationSearchPageTest.php index cfb45b76a0c..e7a2adc4dc3 100644 --- a/packages/framework/tests/Feature/DocumentationSearchPageTest.php +++ b/packages/framework/tests/Feature/DocumentationSearchPageTest.php @@ -70,4 +70,10 @@ public function testStaticRouteKeyHelperWithCustomOutputDirectory() DocumentationPage::setOutputDirectory('foo'); $this->assertSame('foo/search', DocumentationSearchPage::routeKey()); } + + public function testStaticRouteKeyHelperWithRootOutputDirectory() + { + DocumentationPage::setOutputDirectory(''); + $this->assertSame('search', DocumentationSearchPage::routeKey()); + } } From b7a253777b8c0caca3d697f679fba3bb30450810 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:43:30 +0100 Subject: [PATCH 0054/4023] Extract internal route key helper Reduces the amount of times and places we call the exact same logic --- .../components/docs/search-scripts.blade.php | 2 +- .../GeneratesDocumentationSearchIndex.php | 3 ++- .../Documentation/DocumentationSearchIndex.php | 9 ++++++++- .../Feature/DocumentationSearchIndexTest.php | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/framework/resources/views/components/docs/search-scripts.blade.php b/packages/framework/resources/views/components/docs/search-scripts.blade.php index 0d381221c29..f2561c84b61 100644 --- a/packages/framework/resources/views/components/docs/search-scripts.blade.php +++ b/packages/framework/resources/views/components/docs/search-scripts.blade.php @@ -1,7 +1,7 @@ +@endif + +@if (file_exists(Hyde::mediaPath('favicon.ico'))) + +@endif +``` + +Some other example usages could be things like: + +```blade +Logo +``` + +We also use the Asset API helpers in the internal codebase that actually powers the static site generator. These kinds of usages would usually only be used by us, package developers, and serious power users. They have an important, but secondary role in the API design. Here are some examples from our codebase: + +```php +// Code that transfers media assets from the source directory to the site output directory +$this->createDirectoryifItDoesNotExist(Hyde::siteMediaPath()); +$this->mapWithProgressBar(MediaFile::files(), function (string $identifier): void { + copy(Hyde::mediaPath($identifier), Hyde::siteMediaPath($identifier)); +}); + +// Helpers in the featured image class +public function getSource(): string { + return Hyde::mediaLink($this->source); +} + +protected function setSource(string $source): string { + // Normalize away any leading media path prefixes. + return Str::after($source, Hyde::getMediaDirectory().'/'); +} +``` + ## Current State ### Asset Facade From 0a0a4bdcabb1781c39410517c3e55105feb54e7a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 09:57:04 +0200 Subject: [PATCH 2808/4023] Add example AI prompt --- spec.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec.md b/spec.md index bd834a652e2..6d43377d19e 100644 --- a/spec.md +++ b/spec.md @@ -237,6 +237,15 @@ class MediaFile extends ProjectFile } ``` +### AI Example Prompt + +```markdown +Task: Split out the HydeFront related parts of the AssetService to a new facade class. +Motivation: We are simplifying the Asset API in https://github.com/hydephp/develop/pull/1904, and most users won't need the HydeFront related parts of the AssetService. Later, we will be able to merge the simplified AssetService into the other Asset helpers. +Implementation: Make the necessary changes to the code and tests. Also update the release notes to detail all breaking changes and the upgrade path. Make sure the release notes contains all necessary information, but is not too verbose and should not contain any fluff. Also write a brief pull request description. +Context: This is for v2 of static site generator HydePHP. +``` + ## Proposals ### Fluent Asset API From cca95dbc113645c819bff8c1753c8d931bb34715 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 09:59:07 +0200 Subject: [PATCH 2809/4023] Update context --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 6d43377d19e..dd02d41f5c7 100644 --- a/spec.md +++ b/spec.md @@ -243,7 +243,7 @@ class MediaFile extends ProjectFile Task: Split out the HydeFront related parts of the AssetService to a new facade class. Motivation: We are simplifying the Asset API in https://github.com/hydephp/develop/pull/1904, and most users won't need the HydeFront related parts of the AssetService. Later, we will be able to merge the simplified AssetService into the other Asset helpers. Implementation: Make the necessary changes to the code and tests. Also update the release notes to detail all breaking changes and the upgrade path. Make sure the release notes contains all necessary information, but is not too verbose and should not contain any fluff. Also write a brief pull request description. -Context: This is for v2 of static site generator HydePHP. +Context: This is for v2 of static site generator HydePHP. Remember to match the code style of the existing codebase. ``` ## Proposals From 2f930e9be6fe1c3b5e77dae725c1e152109a4b1d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 10:20:38 +0200 Subject: [PATCH 2810/4023] Update context --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index dd02d41f5c7..b404251e8ea 100644 --- a/spec.md +++ b/spec.md @@ -242,7 +242,7 @@ class MediaFile extends ProjectFile ```markdown Task: Split out the HydeFront related parts of the AssetService to a new facade class. Motivation: We are simplifying the Asset API in https://github.com/hydephp/develop/pull/1904, and most users won't need the HydeFront related parts of the AssetService. Later, we will be able to merge the simplified AssetService into the other Asset helpers. -Implementation: Make the necessary changes to the code and tests. Also update the release notes to detail all breaking changes and the upgrade path. Make sure the release notes contains all necessary information, but is not too verbose and should not contain any fluff. Also write a brief pull request description. +Implementation: Make the necessary changes to the code and tests. Also update the release notes to detail all breaking changes and the upgrade path. Make sure the release notes contains all necessary information, but is not too verbose and should not contain any fluff. Also write a brief pull request description detailing the changes made and why they were made. Context: This is for v2 of static site generator HydePHP. Remember to match the code style of the existing codebase. ``` From 67ae2114d1a3a48b94fd16e94b62003e2b1acfae Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 10:43:52 +0200 Subject: [PATCH 2811/4023] Remove the HydeFront version and CDN URL configuration options I can't see a good reason to want to change the version to load assets that are unlikely to work with the versions in the views in the project Hyde version. Changing the CDN URL could be useful if you want to change the host to another CDN provider, but this current system is way too convoluted for that. --- config/hyde.php | 5 --- docs/digging-deeper/customization.md | 14 ------- packages/framework/config/hyde.php | 5 --- .../src/Framework/Services/AssetService.php | 4 +- .../tests/Unit/AssetServiceUnitTest.php | 39 ------------------- 5 files changed, 2 insertions(+), 65 deletions(-) diff --git a/config/hyde.php b/config/hyde.php index 67c1da3b43b..87f5481d00e 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -470,11 +470,6 @@ // Where should the build manifest be saved? (Relative to project root, for example _site/build-manifest.json) 'build_manifest_path' => 'app/storage/framework/cache/build-manifest.json', - // Here you can specify HydeFront version and URL for when loading app.css from the CDN. - // Only change these if you know what you're doing as some versions may be incompatible with your Hyde version. - 'hydefront_version' => \Hyde\Framework\Services\AssetService::HYDEFRONT_VERSION, - 'hydefront_cdn_url' => \Hyde\Framework\Services\AssetService::HYDEFRONT_CDN_URL, - // Should the theme toggle buttons be displayed in the layouts? 'theme_toggle_buttons' => true, diff --git a/docs/digging-deeper/customization.md b/docs/digging-deeper/customization.md index f9c7a0f5682..95965376d78 100644 --- a/docs/digging-deeper/customization.md +++ b/docs/digging-deeper/customization.md @@ -342,20 +342,6 @@ Specifies the path where the build manifest should be saved, relative to the pro 'build_manifest_path' => 'app/storage/framework/cache/build-manifest.json', ``` -### `hydefront_version` and `hydefront_cdn_url` - -These options allow you to specify the HydeFront version and CDN URL when loading `app.css` from the CDN. - -Only change these if you know what you're doing as some versions may be incompatible with your Hyde version. - -```php -// filepath config/hyde.php -use \Hyde\Framework\Services\AssetService; - -'hydefront_version' => AssetService::HYDEFRONT_VERSION, -'hydefront_cdn_url' => AssetService::HYDEFRONT_CDN_URL, -``` - ### `theme_toggle_buttons` >info This feature was added in HydePHP v1.7.0 diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index 67c1da3b43b..87f5481d00e 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -470,11 +470,6 @@ // Where should the build manifest be saved? (Relative to project root, for example _site/build-manifest.json) 'build_manifest_path' => 'app/storage/framework/cache/build-manifest.json', - // Here you can specify HydeFront version and URL for when loading app.css from the CDN. - // Only change these if you know what you're doing as some versions may be incompatible with your Hyde version. - 'hydefront_version' => \Hyde\Framework\Services\AssetService::HYDEFRONT_VERSION, - 'hydefront_cdn_url' => \Hyde\Framework\Services\AssetService::HYDEFRONT_CDN_URL, - // Should the theme toggle buttons be displayed in the layouts? 'theme_toggle_buttons' => true, diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 9373b676e10..d1f9bd54179 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -41,8 +41,8 @@ class AssetService public function __construct() { - $this->version = Config::getString('hyde.hydefront_version', self::HYDEFRONT_VERSION); - $this->cdnUrl = Config::getString('hyde.hydefront_url', self::HYDEFRONT_CDN_URL); + $this->version = self::HYDEFRONT_VERSION; + $this->cdnUrl = self::HYDEFRONT_CDN_URL; } public function version(): string diff --git a/packages/framework/tests/Unit/AssetServiceUnitTest.php b/packages/framework/tests/Unit/AssetServiceUnitTest.php index 9267b4715a6..352d8144101 100644 --- a/packages/framework/tests/Unit/AssetServiceUnitTest.php +++ b/packages/framework/tests/Unit/AssetServiceUnitTest.php @@ -36,50 +36,11 @@ public function testVersionStringDefaultsToConstant() $this->assertSame(AssetService::HYDEFRONT_VERSION, (new AssetService())->version()); } - public function testVersionCanBeSetInConfig() - { - self::mockConfig(['hyde.hydefront_version' => '1.0.0']); - $this->assertSame('1.0.0', (new AssetService())->version()); - } - public function testCdnPatternConstant() { $this->assertSame('https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}', AssetService::HYDEFRONT_CDN_URL); } - public function testCanSetCustomCdnUrlInConfig() - { - self::mockConfig(['hyde.hydefront_url' => 'https://example.com']); - $this->assertSame('https://example.com', (new AssetService())->cdnLink('')); - } - - public function testCanUseCustomCdnUrlWithVersion() - { - self::mockConfig(['hyde.hydefront_url' => '{{ $version }}']); - $this->assertSame('v3.4', (new AssetService())->cdnLink('')); - } - - public function testCanUseCustomCdnUrlWithFile() - { - self::mockConfig(['hyde.hydefront_url' => '{{ $file }}']); - $this->assertSame('styles.css', (new AssetService())->cdnLink('styles.css')); - } - - public function testCanUseCustomCdnUrlWithVersionAndFile() - { - self::mockConfig(['hyde.hydefront_url' => '{{ $version }}/{{ $file }}']); - $this->assertSame('v3.4/styles.css', (new AssetService())->cdnLink('styles.css')); - } - - public function testCanUseCustomCdnUrlWithCustomVersion() - { - self::mockConfig([ - 'hyde.hydefront_url' => '{{ $version }}', - 'hyde.hydefront_version' => '1.0.0', - ]); - $this->assertSame('1.0.0', (new AssetService())->cdnLink('')); - } - public function testCdnLinkHelper() { $this->assertSame( From 73cc657fb1fa3a6f8aae84e561e2ffecd2c889a8 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 10:51:25 +0200 Subject: [PATCH 2812/4023] Draft Asset API change section --- RELEASE_NOTES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 86740ca0d9c..780688dfe65 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -239,6 +239,12 @@ The following methods in the `Features` class have been renamed to follow a more Note that this class was previously marked as internal in v1, but the change is logged here in case it was used in configuration files or custom code. +### Asset API Changes + +The overall asset API has been improved and cleaned up. Unfortunately, this means that there are some breaking changes to the API. + + + ## Low impact ### Navigation internal changes From d7c1a225b427dff2d59abfc06c710018ff743635 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 10:54:25 +0200 Subject: [PATCH 2813/4023] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 86740ca0d9c..3852a7188b6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -59,6 +59,7 @@ This serves two purposes: - Moved the sidebar documentation to the documentation pages section for better organization. - The build command now groups together all `InMemoryPage` instances under one progress bar group in https://github.com/hydephp/develop/pull/1897 - The `Markdown::render()` method will now always render Markdown using the custom HydePHP Markdown service (thus getting smart features like our Markdown processors) in https://github.com/hydephp/develop/pull/1900 +- The HydeFront asset version and CDN URL are now hardcoded in the `AssetService` class instead of being configurable in https://github.com/hydephp/develop/pull/1909 ### Deprecated - for soon-to-be removed features. @@ -66,6 +67,7 @@ This serves two purposes: ### Removed - Breaking: Removed the build task `\Hyde\Framework\Actions\PostBuildTasks\GenerateSearch` (see upgrade guide below) - Breaking: Removed the deprecated `\Hyde\Framework\Services\BuildService::transferMediaAssets()` method (see upgrade guide below) +- Breaking: Removed the `hydefront_version` and `hydefront_cdn_url` configuration options from the `hyde.php` config file in https://github.com/hydephp/develop/pull/1909 - Removed the deprecated global`unslash()` function, replaced with the namespaced `\Hyde\unslash()` function in https://github.com/hydephp/develop/pull/1754 - Removed the deprecated `BaseUrlNotSetException` class, with the `Hyde::url()` helper now throwing `BadMethodCallException` if no base URL is set in https://github.com/hydephp/develop/pull/1760 - Removed: The deprecated `PostAuthor::getName()` method is now removed (use `$author->name`) in https://github.com/hydephp/develop/pull/1782 @@ -239,6 +241,31 @@ The following methods in the `Features` class have been renamed to follow a more Note that this class was previously marked as internal in v1, but the change is logged here in case it was used in configuration files or custom code. +### Asset API Changes + +The overall asset API has been improved and cleaned up. Unfortunately, this means that there are some breaking changes to the API. + +#### Removal of HydeFront version and CDN URL configuration options + +The `hydefront_version` and `hydefront_cdn_url` configuration options have been removed from the `config/hyde.php` file. These options were previously used to specify the HydeFront version and CDN URL for loading assets. + +**Impact:** Low. This change will only affect users who have customized these options. + +**Upgrade steps:** + + + +1. Remove the following lines from your `config/hyde.php` file if they exist: + ```php + 'hydefront_version' => \Hyde\Framework\Services\AssetService::HYDEFRONT_VERSION, + 'hydefront_cdn_url' => \Hyde\Framework\Services\AssetService::HYDEFRONT_CDN_URL, + ``` +2. If you were using a custom CDN URL, you will need to implement your own solution for serving HydeFront assets from a different CDN. Consider copying the assets to your preferred CDN and updating your templates accordingly. + +**Rationale:** The ability to change the HydeFront version was removed because using a different version than the one bundled with your Hyde project could lead to compatibility issues. The CDN URL configuration was removed to simplify the asset loading process. + +If you need to use a different CDN for serving HydeFront assets, you should implement a custom solution tailored to your specific needs. You may also open a feature request if you believe this functionality should be added back in a future release. + ## Low impact ### Navigation internal changes From 1393a9c8a15afb8efd213b3e175d458b9b328aec Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 11:40:48 +0200 Subject: [PATCH 2814/4023] Remove useless constructor --- packages/framework/src/Framework/Services/AssetService.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index d1f9bd54179..718a8dd6f81 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -39,12 +39,6 @@ class AssetService protected string $version = self::HYDEFRONT_VERSION; protected string $cdnUrl = self::HYDEFRONT_CDN_URL; - public function __construct() - { - $this->version = self::HYDEFRONT_VERSION; - $this->cdnUrl = self::HYDEFRONT_CDN_URL; - } - public function version(): string { return $this->version; From 6e16df9aac7c3230bfcd54bbdc5ac3f4abfcc755 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 11:45:12 +0200 Subject: [PATCH 2815/4023] Breaking: Make the AssetService constants protected --- .../src/Framework/Services/AssetService.php | 4 ++-- .../framework/tests/Unit/AssetServiceUnitTest.php | 15 --------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 718a8dd6f81..c306f623a09 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -31,10 +31,10 @@ class AssetService { /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ - final public const HYDEFRONT_VERSION = 'v3.4'; + final protected const HYDEFRONT_VERSION = 'v3.4'; /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ - final public const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; + final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; protected string $version = self::HYDEFRONT_VERSION; protected string $cdnUrl = self::HYDEFRONT_CDN_URL; diff --git a/packages/framework/tests/Unit/AssetServiceUnitTest.php b/packages/framework/tests/Unit/AssetServiceUnitTest.php index 352d8144101..02c33795d15 100644 --- a/packages/framework/tests/Unit/AssetServiceUnitTest.php +++ b/packages/framework/tests/Unit/AssetServiceUnitTest.php @@ -21,26 +21,11 @@ protected function setUp(): void self::mockConfig(); } - public function testVersionStringConstant() - { - $this->assertSame('v3.4', AssetService::HYDEFRONT_VERSION); - } - public function testServiceHasVersionString() { $this->assertIsString((new AssetService())->version()); } - public function testVersionStringDefaultsToConstant() - { - $this->assertSame(AssetService::HYDEFRONT_VERSION, (new AssetService())->version()); - } - - public function testCdnPatternConstant() - { - $this->assertSame('https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}', AssetService::HYDEFRONT_CDN_URL); - } - public function testCdnLinkHelper() { $this->assertSame( From 95a7955f82064df13d0d3ed5be14d5415f9833f5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:32:37 +0200 Subject: [PATCH 2816/4023] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3852a7188b6..57e542a72f0 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -33,6 +33,7 @@ This serves two purposes: - **Breaking:** The `Author::get()` method now returns `null` if an author is not found, rather than creating a new instance. For more information, see below. - **Breaking:** The custom navigation item configuration now uses array inputs instead of the previous format. For more information, see the upgrade guide below. - **Breaking:** Renamed the `hyde.navigation.subdirectories` configuration option to `hyde.navigation.subdirectory_display`. +- **Breaking:** The `HYDEFRONT_VERSION` and `HYDEFRONT_CDN_URL` constants in the `AssetService` class have been changed from `public` to `protected`. This improves encapsulation but may affect code that directly accessed these constants. For more information, see below. - Medium: The `route` function will now throw a `RouteNotFoundException` if the route does not exist in https://github.com/hydephp/develop/pull/1741 - Minor: Navigation menu items are now no longer filtered by duplicates (meaning two items with the same label can now exist in the same menu) in https://github.com/hydephp/develop/pull/1573 - Minor: Due to changes in the navigation system, it is possible that existing configuration files will need to be adjusted in order for menus to look the same (in terms of ordering etc.) @@ -73,6 +74,7 @@ This serves two purposes: - Removed: The deprecated `PostAuthor::getName()` method is now removed (use `$author->name`) in https://github.com/hydephp/develop/pull/1782 - Internal: Removed the internal `DocumentationSearchPage::generate()` method as it was unused in https://github.com/hydephp/develop/pull/1569 - Removed the deprecated `FeaturedImage::isRemote()` method in https://github.com/hydephp/develop/pull/1883. Use `Hyperlinks::isRemote()` instead. +- The `HYDEFRONT_VERSION` and `HYDEFRONT_CDN_URL` constants in the `AssetService` class have been removed from the public API in https://github.com/hydephp/develop/pull/1910 ### Fixed - Added missing collection key types in Hyde facade method annotations in https://github.com/hydephp/develop/pull/1784 @@ -266,6 +268,33 @@ The `hydefront_version` and `hydefront_cdn_url` configuration options have been If you need to use a different CDN for serving HydeFront assets, you should implement a custom solution tailored to your specific needs. You may also open a feature request if you believe this functionality should be added back in a future release. +#### AssetService constants visibility changes + +The `HYDEFRONT_VERSION` and `HYDEFRONT_CDN_URL` constants in the `AssetService` class are now `protected` instead of `public`. This change improves encapsulation and reduces the public API surface. + +**Impact:** Low. This change will only affect users who directly accessed these constants in their custom code. + +**Upgrade steps:** + +1. If you were directly accessing `AssetService::HYDEFRONT_VERSION` or `AssetService::HYDEFRONT_CDN_URL` in your code, you will need to update your implementation. +2. Instead of using these constants directly, use the public methods provided by the `AssetService` class to interact with asset-related functionality. + +For example, if you were using: + +```php +$version = AssetService::HYDEFRONT_VERSION; +``` + +You should now use: + +```php +$version = (new AssetService())->version(); +``` + +If you need access to the CDN URL pattern, consider using the `cdnLink()` method of the `AssetService` class instead. + +These changes were implemented to improve the API design and encapsulation of the `AssetService` class. If you have any custom implementations that relied on these constants, please review and update your code accordingly. + ## Low impact ### Navigation internal changes From 97c7b5a05aef19bf9e34f44931cd72532bfee2fd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:36:04 +0200 Subject: [PATCH 2817/4023] Reset release note changes that may get out of date --- RELEASE_NOTES.md | 56 ------------------------------------------------ 1 file changed, 56 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 57e542a72f0..86740ca0d9c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -33,7 +33,6 @@ This serves two purposes: - **Breaking:** The `Author::get()` method now returns `null` if an author is not found, rather than creating a new instance. For more information, see below. - **Breaking:** The custom navigation item configuration now uses array inputs instead of the previous format. For more information, see the upgrade guide below. - **Breaking:** Renamed the `hyde.navigation.subdirectories` configuration option to `hyde.navigation.subdirectory_display`. -- **Breaking:** The `HYDEFRONT_VERSION` and `HYDEFRONT_CDN_URL` constants in the `AssetService` class have been changed from `public` to `protected`. This improves encapsulation but may affect code that directly accessed these constants. For more information, see below. - Medium: The `route` function will now throw a `RouteNotFoundException` if the route does not exist in https://github.com/hydephp/develop/pull/1741 - Minor: Navigation menu items are now no longer filtered by duplicates (meaning two items with the same label can now exist in the same menu) in https://github.com/hydephp/develop/pull/1573 - Minor: Due to changes in the navigation system, it is possible that existing configuration files will need to be adjusted in order for menus to look the same (in terms of ordering etc.) @@ -60,7 +59,6 @@ This serves two purposes: - Moved the sidebar documentation to the documentation pages section for better organization. - The build command now groups together all `InMemoryPage` instances under one progress bar group in https://github.com/hydephp/develop/pull/1897 - The `Markdown::render()` method will now always render Markdown using the custom HydePHP Markdown service (thus getting smart features like our Markdown processors) in https://github.com/hydephp/develop/pull/1900 -- The HydeFront asset version and CDN URL are now hardcoded in the `AssetService` class instead of being configurable in https://github.com/hydephp/develop/pull/1909 ### Deprecated - for soon-to-be removed features. @@ -68,13 +66,11 @@ This serves two purposes: ### Removed - Breaking: Removed the build task `\Hyde\Framework\Actions\PostBuildTasks\GenerateSearch` (see upgrade guide below) - Breaking: Removed the deprecated `\Hyde\Framework\Services\BuildService::transferMediaAssets()` method (see upgrade guide below) -- Breaking: Removed the `hydefront_version` and `hydefront_cdn_url` configuration options from the `hyde.php` config file in https://github.com/hydephp/develop/pull/1909 - Removed the deprecated global`unslash()` function, replaced with the namespaced `\Hyde\unslash()` function in https://github.com/hydephp/develop/pull/1754 - Removed the deprecated `BaseUrlNotSetException` class, with the `Hyde::url()` helper now throwing `BadMethodCallException` if no base URL is set in https://github.com/hydephp/develop/pull/1760 - Removed: The deprecated `PostAuthor::getName()` method is now removed (use `$author->name`) in https://github.com/hydephp/develop/pull/1782 - Internal: Removed the internal `DocumentationSearchPage::generate()` method as it was unused in https://github.com/hydephp/develop/pull/1569 - Removed the deprecated `FeaturedImage::isRemote()` method in https://github.com/hydephp/develop/pull/1883. Use `Hyperlinks::isRemote()` instead. -- The `HYDEFRONT_VERSION` and `HYDEFRONT_CDN_URL` constants in the `AssetService` class have been removed from the public API in https://github.com/hydephp/develop/pull/1910 ### Fixed - Added missing collection key types in Hyde facade method annotations in https://github.com/hydephp/develop/pull/1784 @@ -243,58 +239,6 @@ The following methods in the `Features` class have been renamed to follow a more Note that this class was previously marked as internal in v1, but the change is logged here in case it was used in configuration files or custom code. -### Asset API Changes - -The overall asset API has been improved and cleaned up. Unfortunately, this means that there are some breaking changes to the API. - -#### Removal of HydeFront version and CDN URL configuration options - -The `hydefront_version` and `hydefront_cdn_url` configuration options have been removed from the `config/hyde.php` file. These options were previously used to specify the HydeFront version and CDN URL for loading assets. - -**Impact:** Low. This change will only affect users who have customized these options. - -**Upgrade steps:** - - - -1. Remove the following lines from your `config/hyde.php` file if they exist: - ```php - 'hydefront_version' => \Hyde\Framework\Services\AssetService::HYDEFRONT_VERSION, - 'hydefront_cdn_url' => \Hyde\Framework\Services\AssetService::HYDEFRONT_CDN_URL, - ``` -2. If you were using a custom CDN URL, you will need to implement your own solution for serving HydeFront assets from a different CDN. Consider copying the assets to your preferred CDN and updating your templates accordingly. - -**Rationale:** The ability to change the HydeFront version was removed because using a different version than the one bundled with your Hyde project could lead to compatibility issues. The CDN URL configuration was removed to simplify the asset loading process. - -If you need to use a different CDN for serving HydeFront assets, you should implement a custom solution tailored to your specific needs. You may also open a feature request if you believe this functionality should be added back in a future release. - -#### AssetService constants visibility changes - -The `HYDEFRONT_VERSION` and `HYDEFRONT_CDN_URL` constants in the `AssetService` class are now `protected` instead of `public`. This change improves encapsulation and reduces the public API surface. - -**Impact:** Low. This change will only affect users who directly accessed these constants in their custom code. - -**Upgrade steps:** - -1. If you were directly accessing `AssetService::HYDEFRONT_VERSION` or `AssetService::HYDEFRONT_CDN_URL` in your code, you will need to update your implementation. -2. Instead of using these constants directly, use the public methods provided by the `AssetService` class to interact with asset-related functionality. - -For example, if you were using: - -```php -$version = AssetService::HYDEFRONT_VERSION; -``` - -You should now use: - -```php -$version = (new AssetService())->version(); -``` - -If you need access to the CDN URL pattern, consider using the `cdnLink()` method of the `AssetService` class instead. - -These changes were implemented to improve the API design and encapsulation of the `AssetService` class. If you have any custom implementations that relied on these constants, please review and update your code accordingly. - ## Low impact ### Navigation internal changes From 4959e3b8356f594068e8daf41a8b605635d07b54 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:38:22 +0200 Subject: [PATCH 2818/4023] Deprecate the AssetService class --- packages/framework/src/Framework/Services/AssetService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index c306f623a09..82804bb6920 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -21,6 +21,8 @@ /** * Handles the retrieval of core asset files. Commonly used through the Asset facade. * + * @deprecated Will be merged into the Asset facade. + * * This class is loaded into the service container, making it easy to access and modify. * * The class also provides helper methods for interacting with versioned files, From 7e2b51acc5ca2bc164d07a7ec41aa59b37d207e6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:46:06 +0200 Subject: [PATCH 2819/4023] Remove mixin for deprecated AssetService --- _ide_helper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/_ide_helper.php b/_ide_helper.php index 228893b3169..a838afac059 100644 --- a/_ide_helper.php +++ b/_ide_helper.php @@ -33,7 +33,6 @@ class Hyde extends \Hyde\Hyde {} class Site extends \Hyde\Facades\Site {} class Meta extends \Hyde\Facades\Meta {} -/** @mixin \Hyde\Framework\Services\AssetService */ class Asset extends \Hyde\Facades\Asset {} class Author extends \Hyde\Facades\Author {} class Features extends \Hyde\Facades\Features {} From 19c7d17b930a9aac8ae849e2b922ca5e2c81ac2c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:50:54 +0200 Subject: [PATCH 2820/4023] Remove kernel binding test for deprecated AssetService --- .../framework/tests/Feature/HydeServiceProviderTest.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/framework/tests/Feature/HydeServiceProviderTest.php b/packages/framework/tests/Feature/HydeServiceProviderTest.php index 6904c5b11d6..ee7d35ae140 100644 --- a/packages/framework/tests/Feature/HydeServiceProviderTest.php +++ b/packages/framework/tests/Feature/HydeServiceProviderTest.php @@ -9,7 +9,6 @@ use Illuminate\Contracts\Container\BindingResolutionException; use Hyde\Console\ConsoleServiceProvider; use Hyde\Framework\HydeServiceProvider; -use Hyde\Framework\Services\AssetService; use Hyde\Framework\Services\BuildTaskService; use Hyde\Foundation\HydeCoreExtension; use Hyde\Hyde; @@ -54,13 +53,6 @@ public function testProviderHasBootMethod() $this->assertTrue(method_exists($this->provider, 'boot')); } - public function testProviderRegistersAssetServiceAsSingleton() - { - $this->assertTrue($this->app->bound(AssetService::class)); - $this->assertInstanceOf(AssetService::class, $this->app->make(AssetService::class)); - $this->assertSame($this->app->make(AssetService::class), $this->app->make(AssetService::class)); - } - public function testProviderRegistersBuildTaskServiceAsSingleton() { $this->assertTrue($this->app->bound(BuildTaskService::class)); From 293234076c1c20558799f19bb82afbd6afaaa7f0 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:51:42 +0200 Subject: [PATCH 2821/4023] Extend unit test case --- packages/framework/tests/Unit/Facades/AssetFacadeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php index df8344a3771..5bc4f02d01a 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php @@ -6,12 +6,12 @@ use Hyde\Facades\Asset; use Hyde\Framework\Services\AssetService; -use Hyde\Testing\TestCase; +use Hyde\Testing\UnitTestCase; /** * @covers \Hyde\Facades\Asset */ -class AssetFacadeTest extends TestCase +class AssetFacadeTest extends UnitTestCase { public function testAssetFacadeReturnsTheAssetService() { From 730f17783fabd039c9d1c658d52d381498be2e3a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:52:04 +0200 Subject: [PATCH 2822/4023] Remove legacy facade implementation tests --- .../tests/Unit/Facades/AssetFacadeTest.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php index 5bc4f02d01a..8335c4c7159 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php @@ -5,7 +5,6 @@ namespace Hyde\Framework\Testing\Unit\Facades; use Hyde\Facades\Asset; -use Hyde\Framework\Services\AssetService; use Hyde\Testing\UnitTestCase; /** @@ -13,19 +12,5 @@ */ class AssetFacadeTest extends UnitTestCase { - public function testAssetFacadeReturnsTheAssetService() - { - $this->assertInstanceOf(AssetService::class, Asset::getFacadeRoot()); - } - - public function testFacadeReturnsSameInstanceAsBoundByTheContainer() - { - $this->assertSame(Asset::getFacadeRoot(), app(AssetService::class)); - } - - public function testAssetFacadeCanCallMethodsOnTheAssetService() - { - $service = new AssetService(); - $this->assertEquals($service->version(), Asset::version()); - } + // } From 3e4d02377139f8bdaeb51e79ae43ba26bfc92f8f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:52:59 +0200 Subject: [PATCH 2823/4023] Move unit tests to new code location --- .../tests/Unit/AssetServiceUnitTest.php | 50 +------------------ .../tests/Unit/Facades/AssetFacadeTest.php | 50 ++++++++++++++++++- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/packages/framework/tests/Unit/AssetServiceUnitTest.php b/packages/framework/tests/Unit/AssetServiceUnitTest.php index 02c33795d15..21f80004078 100644 --- a/packages/framework/tests/Unit/AssetServiceUnitTest.php +++ b/packages/framework/tests/Unit/AssetServiceUnitTest.php @@ -4,9 +4,7 @@ namespace Hyde\Framework\Testing\Unit; -use Hyde\Framework\Services\AssetService; use Hyde\Testing\UnitTestCase; -use Hyde\Hyde; /** * @covers \Hyde\Framework\Services\AssetService @@ -15,51 +13,5 @@ */ class AssetServiceUnitTest extends UnitTestCase { - protected function setUp(): void - { - self::needsKernel(); - self::mockConfig(); - } - - public function testServiceHasVersionString() - { - $this->assertIsString((new AssetService())->version()); - } - - public function testCdnLinkHelper() - { - $this->assertSame( - 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css', - (new AssetService())->cdnLink('styles.css') - ); - } - - public function testHasMediaFileHelper() - { - $this->assertFalse((new AssetService())->hasMediaFile('styles.css')); - } - - public function testHasMediaFileHelperReturnsTrueForExistingFile() - { - $this->assertTrue((new AssetService())->hasMediaFile('app.css')); - } - - public function testInjectTailwindConfigReturnsExtractedTailwindConfig() - { - $service = new AssetService(); - $this->assertIsString($config = $service->injectTailwindConfig()); - $this->assertStringContainsString("darkMode: 'class'", $config); - $this->assertStringContainsString('theme: {', $config); - $this->assertStringContainsString('extend: {', $config); - $this->assertStringContainsString('typography: {', $config); - $this->assertStringNotContainsString('plugins', $config); - } - - public function testInjectTailwindConfigHandlesMissingConfigFileGracefully() - { - rename(Hyde::path('tailwind.config.js'), Hyde::path('tailwind.config.js.bak')); - $this->assertIsString((new AssetService())->injectTailwindConfig()); - $this->assertSame('', (new AssetService())->injectTailwindConfig()); - rename(Hyde::path('tailwind.config.js.bak'), Hyde::path('tailwind.config.js')); - } + // } diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php index 8335c4c7159..7d65f59d626 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php @@ -4,13 +4,61 @@ namespace Hyde\Framework\Testing\Unit\Facades; +use Hyde\Hyde; use Hyde\Facades\Asset; use Hyde\Testing\UnitTestCase; +use Hyde\Framework\Services\AssetService; /** * @covers \Hyde\Facades\Asset */ class AssetFacadeTest extends UnitTestCase { - // + protected function setUp(): void + { + self::needsKernel(); + self::mockConfig(); + } + + public function testServiceHasVersionString() + { + $this->assertIsString((new AssetService())->version()); + } + + public function testCdnLinkHelper() + { + $this->assertSame( + 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css', + (new AssetService())->cdnLink('styles.css') + ); + } + + public function testHasMediaFileHelper() + { + $this->assertFalse((new AssetService())->hasMediaFile('styles.css')); + } + + public function testHasMediaFileHelperReturnsTrueForExistingFile() + { + $this->assertTrue((new AssetService())->hasMediaFile('app.css')); + } + + public function testInjectTailwindConfigReturnsExtractedTailwindConfig() + { + $service = new AssetService(); + $this->assertIsString($config = $service->injectTailwindConfig()); + $this->assertStringContainsString("darkMode: 'class'", $config); + $this->assertStringContainsString('theme: {', $config); + $this->assertStringContainsString('extend: {', $config); + $this->assertStringContainsString('typography: {', $config); + $this->assertStringNotContainsString('plugins', $config); + } + + public function testInjectTailwindConfigHandlesMissingConfigFileGracefully() + { + rename(Hyde::path('tailwind.config.js'), Hyde::path('tailwind.config.js.bak')); + $this->assertIsString((new AssetService())->injectTailwindConfig()); + $this->assertSame('', (new AssetService())->injectTailwindConfig()); + rename(Hyde::path('tailwind.config.js.bak'), Hyde::path('tailwind.config.js')); + } } From e8d9939ad2724f6234a4031268eb04aca0dd1f86 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:56:26 +0200 Subject: [PATCH 2824/4023] Add temporary test interoperability --- packages/framework/tests/Unit/Facades/AssetFacadeTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php index 7d65f59d626..a2dae835e85 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php @@ -18,6 +18,9 @@ protected function setUp(): void { self::needsKernel(); self::mockConfig(); + + // Temporary interoperability with the old AssetService + Asset::swap(new AssetService()); } public function testServiceHasVersionString() From 422e96612c16947a11da0c15330659e0ffd8ff8e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:57:16 +0200 Subject: [PATCH 2825/4023] Call tests using the facade --- .../framework/tests/Unit/Facades/AssetFacadeTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php index a2dae835e85..a2e5ec2bf28 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeTest.php @@ -25,25 +25,25 @@ protected function setUp(): void public function testServiceHasVersionString() { - $this->assertIsString((new AssetService())->version()); + $this->assertIsString(Asset::version()); } public function testCdnLinkHelper() { $this->assertSame( 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css', - (new AssetService())->cdnLink('styles.css') + Asset::cdnLink('styles.css') ); } public function testHasMediaFileHelper() { - $this->assertFalse((new AssetService())->hasMediaFile('styles.css')); + $this->assertFalse(Asset::hasMediaFile('styles.css')); } public function testHasMediaFileHelperReturnsTrueForExistingFile() { - $this->assertTrue((new AssetService())->hasMediaFile('app.css')); + $this->assertTrue(Asset::hasMediaFile('app.css')); } public function testInjectTailwindConfigReturnsExtractedTailwindConfig() @@ -60,8 +60,8 @@ public function testInjectTailwindConfigReturnsExtractedTailwindConfig() public function testInjectTailwindConfigHandlesMissingConfigFileGracefully() { rename(Hyde::path('tailwind.config.js'), Hyde::path('tailwind.config.js.bak')); - $this->assertIsString((new AssetService())->injectTailwindConfig()); - $this->assertSame('', (new AssetService())->injectTailwindConfig()); + $this->assertIsString(Asset::injectTailwindConfig()); + $this->assertSame('', Asset::injectTailwindConfig()); rename(Hyde::path('tailwind.config.js.bak'), Hyde::path('tailwind.config.js')); } } From db2e12ecb18421ebf6cb0c8d843b866fae80d316 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:57:18 +0200 Subject: [PATCH 2826/4023] Delete AssetServiceUnitTest.php --- .../tests/Unit/AssetServiceUnitTest.php | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 packages/framework/tests/Unit/AssetServiceUnitTest.php diff --git a/packages/framework/tests/Unit/AssetServiceUnitTest.php b/packages/framework/tests/Unit/AssetServiceUnitTest.php deleted file mode 100644 index 21f80004078..00000000000 --- a/packages/framework/tests/Unit/AssetServiceUnitTest.php +++ /dev/null @@ -1,17 +0,0 @@ - Date: Fri, 26 Jul 2024 13:57:30 +0200 Subject: [PATCH 2827/4023] Rename test 'AssetFacadeTest' to 'AssetFacadeUnitTest' --- .../Facades/{AssetFacadeTest.php => AssetFacadeUnitTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename packages/framework/tests/Unit/Facades/{AssetFacadeTest.php => AssetFacadeUnitTest.php} (97%) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php similarity index 97% rename from packages/framework/tests/Unit/Facades/AssetFacadeTest.php rename to packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index a2e5ec2bf28..724981cfea6 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -12,7 +12,7 @@ /** * @covers \Hyde\Facades\Asset */ -class AssetFacadeTest extends UnitTestCase +class AssetFacadeUnitTest extends UnitTestCase { protected function setUp(): void { From 9d393ab21f5b2311dea166a889c80cfcebe10044 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:58:17 +0200 Subject: [PATCH 2828/4023] Rename test 'AssetServiceTest' to 'AssetFacadeTest' --- .../tests/Feature/{AssetServiceTest.php => AssetFacadeTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename packages/framework/tests/Feature/{AssetServiceTest.php => AssetFacadeTest.php} (97%) diff --git a/packages/framework/tests/Feature/AssetServiceTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php similarity index 97% rename from packages/framework/tests/Feature/AssetServiceTest.php rename to packages/framework/tests/Feature/AssetFacadeTest.php index ae8661b8118..2b1bcfa2be2 100644 --- a/packages/framework/tests/Feature/AssetServiceTest.php +++ b/packages/framework/tests/Feature/AssetFacadeTest.php @@ -13,7 +13,7 @@ * * @see \Hyde\Framework\Testing\Unit\AssetServiceUnitTest */ -class AssetServiceTest extends TestCase +class AssetFacadeTest extends TestCase { public function testMediaLinkReturnsMediaPathWithCacheKey() { From 171c4ac22dff39182285ea2d4c191b41e215bbb7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:58:30 +0200 Subject: [PATCH 2829/4023] Update covers annotation --- packages/framework/tests/Feature/AssetFacadeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/tests/Feature/AssetFacadeTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php index 2b1bcfa2be2..eb61d40829a 100644 --- a/packages/framework/tests/Feature/AssetFacadeTest.php +++ b/packages/framework/tests/Feature/AssetFacadeTest.php @@ -9,7 +9,7 @@ use Hyde\Testing\TestCase; /** - * @covers \Hyde\Framework\Services\AssetService + * @covers \Hyde\Facades\Asset * * @see \Hyde\Framework\Testing\Unit\AssetServiceUnitTest */ From 5d5f14d53cf82321cff5b18eb8b2438c6ecfb9b2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:58:59 +0200 Subject: [PATCH 2830/4023] Update test crosslinks --- packages/framework/tests/Feature/AssetFacadeTest.php | 2 +- packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/framework/tests/Feature/AssetFacadeTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php index eb61d40829a..20af8244fef 100644 --- a/packages/framework/tests/Feature/AssetFacadeTest.php +++ b/packages/framework/tests/Feature/AssetFacadeTest.php @@ -11,7 +11,7 @@ /** * @covers \Hyde\Facades\Asset * - * @see \Hyde\Framework\Testing\Unit\AssetServiceUnitTest + * @see \Hyde\Framework\Testing\Unit\Facades\AssetFacadeUnitTest */ class AssetFacadeTest extends TestCase { diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index 724981cfea6..4d210b8e071 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -11,6 +11,8 @@ /** * @covers \Hyde\Facades\Asset + * + * @see \Hyde\Framework\Testing\Feature\AssetFacadeTest */ class AssetFacadeUnitTest extends UnitTestCase { From 69b8f39353d0cce0fcdb6c84125c319c800a604a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 13:59:50 +0200 Subject: [PATCH 2831/4023] Call tests using the facade --- packages/framework/tests/Feature/AssetFacadeTest.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/framework/tests/Feature/AssetFacadeTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php index 20af8244fef..103230b296d 100644 --- a/packages/framework/tests/Feature/AssetFacadeTest.php +++ b/packages/framework/tests/Feature/AssetFacadeTest.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Testing\Feature; +use Hyde\Facades\Asset; use Hyde\Framework\Services\AssetService; use Hyde\Hyde; use Hyde\Testing\TestCase; @@ -17,9 +18,7 @@ class AssetFacadeTest extends TestCase { public function testMediaLinkReturnsMediaPathWithCacheKey() { - $service = new AssetService(); - - $this->assertIsString($path = $service->mediaLink('app.css')); + $this->assertIsString($path = Asset::mediaLink('app.css')); $this->assertSame('media/app.css?v='.md5_file(Hyde::path('_media/app.css')), $path); } @@ -27,8 +26,7 @@ public function testMediaLinkReturnsMediaPathWithoutCacheKeyIfCacheBustingIsDisa { config(['hyde.enable_cache_busting' => false]); - $service = new AssetService(); - $path = $service->mediaLink('app.css'); + $path = Asset::mediaLink('app.css'); $this->assertIsString($path); $this->assertSame('media/app.css', $path); @@ -41,8 +39,7 @@ public function testMediaLinkSupportsCustomMediaDirectories() Hyde::setMediaDirectory('_assets'); - $service = new AssetService(); - $path = $service->mediaLink('app.css'); + $path = Asset::mediaLink('app.css'); $this->assertIsString($path); $this->assertSame('assets/app.css?v='.md5_file(Hyde::path('_assets/app.css')), $path); From 5b48cef8bf7782b4bb4d4a5121dde41ed6163e95 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:03:12 +0200 Subject: [PATCH 2832/4023] Refactor class to be static --- .../src/Framework/Services/AssetService.php | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 82804bb6920..7391d1bcfdb 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -23,9 +23,7 @@ * * @deprecated Will be merged into the Asset facade. * - * This class is loaded into the service container, making it easy to access and modify. - * - * The class also provides helper methods for interacting with versioned files, + * This class provides static methods for interacting with versioned files, * as well as the HydeFront CDN service and the media directories. * * @see \Hyde\Facades\Asset @@ -41,27 +39,27 @@ class AssetService protected string $version = self::HYDEFRONT_VERSION; protected string $cdnUrl = self::HYDEFRONT_CDN_URL; - public function version(): string + public static function version(): string { - return $this->version; + return static::HYDEFRONT_VERSION; } - public function cdnLink(string $file): string + public static function cdnLink(string $file): string { - return $this->constructCdnPath($file); + return static::constructCdnPath($file); } - public function mediaLink(string $file): string + public static function mediaLink(string $file): string { - return Hyde::mediaLink($file).$this->getCacheBustKey($file); + return Hyde::mediaLink($file).static::getCacheBustKey($file); } - public function hasMediaFile(string $file): bool + public static function hasMediaFile(string $file): bool { return file_exists(Hyde::mediaPath($file)); } - public function injectTailwindConfig(): string + public static function injectTailwindConfig(): string { if (! file_exists(Hyde::path('tailwind.config.js'))) { return ''; @@ -79,15 +77,15 @@ public function injectTailwindConfig(): string return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); } - protected function constructCdnPath(string $file): string + protected static function constructCdnPath(string $file): string { return str_replace( - ['{{ $version }}', '{{ $file }}'], [$this->version(), $file], - $this->cdnUrl + ['{{ $version }}', '{{ $file }}'], [static::version(), $file], + static::HYDEFRONT_CDN_URL ); } - protected function getCacheBustKey(string $file): string + protected static function getCacheBustKey(string $file): string { return Config::getBool('hyde.enable_cache_busting', true) ? '?v='.md5_file(Hyde::mediaPath("$file")) From e4886a729ba7518dcbc542eede7fafc578aabcb3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:03:26 +0200 Subject: [PATCH 2833/4023] Remove now unused properties --- packages/framework/src/Framework/Services/AssetService.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 7391d1bcfdb..6796f31a9d8 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -36,9 +36,6 @@ class AssetService /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; - protected string $version = self::HYDEFRONT_VERSION; - protected string $cdnUrl = self::HYDEFRONT_CDN_URL; - public static function version(): string { return static::HYDEFRONT_VERSION; From 50600abebe5a3fcb4a92b830873f8b24f249b204 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:05:41 +0200 Subject: [PATCH 2834/4023] Call tests using the facade --- packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index 4d210b8e071..b7545267e0f 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -50,8 +50,7 @@ public function testHasMediaFileHelperReturnsTrueForExistingFile() public function testInjectTailwindConfigReturnsExtractedTailwindConfig() { - $service = new AssetService(); - $this->assertIsString($config = $service->injectTailwindConfig()); + $this->assertIsString($config = Asset::injectTailwindConfig()); $this->assertStringContainsString("darkMode: 'class'", $config); $this->assertStringContainsString('theme: {', $config); $this->assertStringContainsString('extend: {', $config); From f801942c40ac6eb9651a84e0a52a23f7df523d42 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:05:53 +0200 Subject: [PATCH 2835/4023] Revert temporary test interoperability --- packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index b7545267e0f..c300236bc8d 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -7,7 +7,6 @@ use Hyde\Hyde; use Hyde\Facades\Asset; use Hyde\Testing\UnitTestCase; -use Hyde\Framework\Services\AssetService; /** * @covers \Hyde\Facades\Asset @@ -20,9 +19,6 @@ protected function setUp(): void { self::needsKernel(); self::mockConfig(); - - // Temporary interoperability with the old AssetService - Asset::swap(new AssetService()); } public function testServiceHasVersionString() From 1675dd09a17443a86219210a29eb492eb2973765 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:06:33 +0200 Subject: [PATCH 2836/4023] Merge the AssetService into the Asset facade class --- packages/framework/src/Facades/Asset.php | 84 ++++++++++++++++--- .../src/Framework/Services/AssetService.php | 76 +---------------- 2 files changed, 72 insertions(+), 88 deletions(-) diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index f0bd3b6c651..49065d3b352 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -4,25 +4,83 @@ namespace Hyde\Facades; -use Hyde\Framework\Services\AssetService; -use Illuminate\Support\Facades\Facade; +use Hyde\Hyde; +use Illuminate\Support\Str; + +use function rtrim; +use function explode; +use function implode; +use function md5_file; +use function file_exists; +use function str_replace; +use function preg_replace; +use function str_contains; +use function file_get_contents; /** * Handles the retrieval of core asset files, either from the HydeFront CDN or from the local media folder. * - * @see \Hyde\Framework\Services\AssetService - * - * @method static string version() - * @method static string cdnLink(string $file) - * @method static string mediaLink(string $file) - * @method static bool hasMediaFile(string $file) - * @method static string injectTailwindConfig() + * This class provides static methods for interacting with versioned files, + * as well as the HydeFront CDN service and the media directories. */ -class Asset extends Facade +class Asset { - /** @psalm-return AssetService::class */ - protected static function getFacadeAccessor(): string + /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ + final protected const HYDEFRONT_VERSION = 'v3.4'; + + /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ + final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; + + public static function version(): string + { + return static::HYDEFRONT_VERSION; + } + + public static function cdnLink(string $file): string + { + return static::constructCdnPath($file); + } + + public static function mediaLink(string $file): string + { + return Hyde::mediaLink($file).static::getCacheBustKey($file); + } + + public static function hasMediaFile(string $file): bool + { + return file_exists(Hyde::mediaPath($file)); + } + + public static function injectTailwindConfig(): string + { + if (! file_exists(Hyde::path('tailwind.config.js'))) { + return ''; + } + + $config = Str::between(file_get_contents(Hyde::path('tailwind.config.js')), '{', '}'); + + // Remove the plugins array, as it is not used in the frontend. + if (str_contains($config, 'plugins: [')) { + $tokens = explode('plugins: [', $config, 2); + $tokens[1] = Str::after($tokens[1], ']'); + $config = implode('', $tokens); + } + + return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); + } + + protected static function constructCdnPath(string $file): string + { + return str_replace( + ['{{ $version }}', '{{ $file }}'], [static::version(), $file], + static::HYDEFRONT_CDN_URL + ); + } + + protected static function getCacheBustKey(string $file): string { - return AssetService::class; + return Config::getBool('hyde.enable_cache_busting', true) + ? '?v='.md5_file(Hyde::mediaPath("$file")) + : ''; } } diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 6796f31a9d8..d6159d32535 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -4,88 +4,14 @@ namespace Hyde\Framework\Services; -use Hyde\Hyde; -use Hyde\Facades\Config; -use Illuminate\Support\Str; - -use function rtrim; -use function explode; -use function implode; -use function md5_file; -use function file_exists; -use function str_replace; -use function preg_replace; -use function str_contains; -use function file_get_contents; - /** * Handles the retrieval of core asset files. Commonly used through the Asset facade. * * @deprecated Will be merged into the Asset facade. * - * This class provides static methods for interacting with versioned files, - * as well as the HydeFront CDN service and the media directories. - * * @see \Hyde\Facades\Asset */ class AssetService { - /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ - final protected const HYDEFRONT_VERSION = 'v3.4'; - - /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ - final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; - - public static function version(): string - { - return static::HYDEFRONT_VERSION; - } - - public static function cdnLink(string $file): string - { - return static::constructCdnPath($file); - } - - public static function mediaLink(string $file): string - { - return Hyde::mediaLink($file).static::getCacheBustKey($file); - } - - public static function hasMediaFile(string $file): bool - { - return file_exists(Hyde::mediaPath($file)); - } - - public static function injectTailwindConfig(): string - { - if (! file_exists(Hyde::path('tailwind.config.js'))) { - return ''; - } - - $config = Str::between(file_get_contents(Hyde::path('tailwind.config.js')), '{', '}'); - - // Remove the plugins array, as it is not used in the frontend. - if (str_contains($config, 'plugins: [')) { - $tokens = explode('plugins: [', $config, 2); - $tokens[1] = Str::after($tokens[1], ']'); - $config = implode('', $tokens); - } - - return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); - } - - protected static function constructCdnPath(string $file): string - { - return str_replace( - ['{{ $version }}', '{{ $file }}'], [static::version(), $file], - static::HYDEFRONT_CDN_URL - ); - } - - protected static function getCacheBustKey(string $file): string - { - return Config::getBool('hyde.enable_cache_busting', true) - ? '?v='.md5_file(Hyde::mediaPath("$file")) - : ''; - } + // } From fb0e40c4c22eb82aac6f08411360d960a25161be Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:06:46 +0200 Subject: [PATCH 2837/4023] Delete AssetService.php --- .../src/Framework/Services/AssetService.php | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 packages/framework/src/Framework/Services/AssetService.php diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php deleted file mode 100644 index d6159d32535..00000000000 --- a/packages/framework/src/Framework/Services/AssetService.php +++ /dev/null @@ -1,17 +0,0 @@ - Date: Fri, 26 Jul 2024 14:08:04 +0200 Subject: [PATCH 2838/4023] Remove unused import --- packages/framework/tests/Feature/AssetFacadeTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/tests/Feature/AssetFacadeTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php index 103230b296d..3e934eab38b 100644 --- a/packages/framework/tests/Feature/AssetFacadeTest.php +++ b/packages/framework/tests/Feature/AssetFacadeTest.php @@ -5,7 +5,6 @@ namespace Hyde\Framework\Testing\Feature; use Hyde\Facades\Asset; -use Hyde\Framework\Services\AssetService; use Hyde\Hyde; use Hyde\Testing\TestCase; From f0192f58f34404aa0d19406e0ab2707fa237e660 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:08:15 +0200 Subject: [PATCH 2839/4023] Remove AssetService container binding --- packages/framework/src/Framework/HydeServiceProvider.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/framework/src/Framework/HydeServiceProvider.php b/packages/framework/src/Framework/HydeServiceProvider.php index c2896efdc9b..e3dbd7eb5ea 100644 --- a/packages/framework/src/Framework/HydeServiceProvider.php +++ b/packages/framework/src/Framework/HydeServiceProvider.php @@ -10,7 +10,6 @@ use Hyde\Pages\MarkdownPost; use Hyde\Foundation\HydeKernel; use Hyde\Pages\DocumentationPage; -use Hyde\Framework\Services\AssetService; use Hyde\Framework\Services\BuildTaskService; use Hyde\Framework\Concerns\RegistersFileLocations; use Illuminate\Support\ServiceProvider; @@ -29,7 +28,6 @@ public function register(): void { $this->kernel = HydeKernel::getInstance(); - $this->app->singleton(AssetService::class, AssetService::class); $this->app->singleton(BuildTaskService::class, BuildTaskService::class); $this->kernel->setSourceRoot(Config::getString('hyde.source_root', '')); From 83e69f8d43cec53483a341158306e67dfbf816b8 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:12:35 +0200 Subject: [PATCH 2840/4023] Update internal docs for removed asset service --- monorepo/docs/hydefront.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monorepo/docs/hydefront.md b/monorepo/docs/hydefront.md index 377f920e6e0..cb7733eabcd 100644 --- a/monorepo/docs/hydefront.md +++ b/monorepo/docs/hydefront.md @@ -64,6 +64,6 @@ This will create commits in both the monorepo and submodule. Now follow the foll 9. Update the monorepo to use the new version. - [ ] `npm update hydefront` - **Note:** On major/minor version bumps, **remember to update** the `package.json` in the `packages/hyde` directory to use the new version! - - **Note:** On major version bumps, **remember to update the HydeFront version in the Asset Service!** + - **Note:** On major version bumps, **remember to update the HydeFront version in the Asset Facade!** 10. Amend the monorepo commit with the updated files (package-lock.json, _media/app.css, packages\hydefront, packages\hyde\package.json) - - [ ] `git add packages/hydefront && git add packages/hyde/package.json && git add package-lock.json && git add _media/app.css && git add packages/framework/src/Framework/Services/AssetService.php && git commit --amend --no-edit` + - [ ] `git add packages/hydefront && git add packages/hyde/package.json && git add package-lock.json && git add _media/app.css && git add packages/framework/src/Facades/Asset.php && git commit --amend --no-edit` From 251ed8bea4111d8effdffc137dcf9f46333ec3be Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:13:41 +0200 Subject: [PATCH 2841/4023] Clean up test --- packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index c300236bc8d..ddfafe2ec72 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -46,7 +46,9 @@ public function testHasMediaFileHelperReturnsTrueForExistingFile() public function testInjectTailwindConfigReturnsExtractedTailwindConfig() { - $this->assertIsString($config = Asset::injectTailwindConfig()); + $config = Asset::injectTailwindConfig(); + + $this->assertIsString($config); $this->assertStringContainsString("darkMode: 'class'", $config); $this->assertStringContainsString('theme: {', $config); $this->assertStringContainsString('extend: {', $config); From 02dbc14b919b7c495d9d535d0e5f39248fdbbaff Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:25:19 +0200 Subject: [PATCH 2842/4023] Create HydeFront.php --- packages/framework/src/Facades/HydeFront.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packages/framework/src/Facades/HydeFront.php diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php new file mode 100644 index 00000000000..5f5448313ee --- /dev/null +++ b/packages/framework/src/Facades/HydeFront.php @@ -0,0 +1,10 @@ + Date: Fri, 26 Jul 2024 14:26:32 +0200 Subject: [PATCH 2843/4023] Create HydeFrontFacadeTest.php --- .../tests/Unit/Facades/HydeFrontFacadeTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php diff --git a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php new file mode 100644 index 00000000000..e4c6d9e192f --- /dev/null +++ b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php @@ -0,0 +1,15 @@ + Date: Fri, 26 Jul 2024 14:26:53 +0200 Subject: [PATCH 2844/4023] Alias the HydeFront facade --- app/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/config.php b/app/config.php index 143a4a6dda4..009c0f586b7 100644 --- a/app/config.php +++ b/app/config.php @@ -94,6 +94,7 @@ 'Meta' => \Hyde\Facades\Meta::class, 'Asset' => \Hyde\Facades\Asset::class, 'Author' => \Hyde\Facades\Author::class, + 'HydeFront' => \Hyde\Facades\HydeFront::class, 'Features' => \Hyde\Facades\Features::class, 'Config' => \Hyde\Facades\Config::class, 'Filesystem' => \Hyde\Facades\Filesystem::class, From ee69a0a9e0b44afa58d7fce5f326450673292157 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:48:20 +0200 Subject: [PATCH 2845/4023] Move HydeFront related methods to the new HydeFront facade --- packages/framework/src/Facades/Asset.php | 53 ++++++++----------- packages/framework/src/Facades/HydeFront.php | 27 +++++++++- .../Unit/Facades/AssetFacadeUnitTest.php | 13 ----- .../Unit/Facades/HydeFrontFacadeTest.php | 12 ++++- 4 files changed, 60 insertions(+), 45 deletions(-) diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index 49065d3b352..6d7a3afaeb3 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -6,15 +6,10 @@ use Hyde\Hyde; use Illuminate\Support\Str; +use JetBrains\PhpStorm\Deprecated; -use function rtrim; -use function explode; -use function implode; use function md5_file; use function file_exists; -use function str_replace; -use function preg_replace; -use function str_contains; use function file_get_contents; /** @@ -25,22 +20,6 @@ */ class Asset { - /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ - final protected const HYDEFRONT_VERSION = 'v3.4'; - - /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ - final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; - - public static function version(): string - { - return static::HYDEFRONT_VERSION; - } - - public static function cdnLink(string $file): string - { - return static::constructCdnPath($file); - } - public static function mediaLink(string $file): string { return Hyde::mediaLink($file).static::getCacheBustKey($file); @@ -69,18 +48,32 @@ public static function injectTailwindConfig(): string return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); } - protected static function constructCdnPath(string $file): string - { - return str_replace( - ['{{ $version }}', '{{ $file }}'], [static::version(), $file], - static::HYDEFRONT_CDN_URL - ); - } - protected static function getCacheBustKey(string $file): string { return Config::getBool('hyde.enable_cache_busting', true) ? '?v='.md5_file(Hyde::mediaPath("$file")) : ''; } + + /** + * @deprecated Use HydeFront::version() instead. + * + * @codeCoverageIgnore Deprecated method. + */ + #[Deprecated(reason: 'Use HydeFront::version() instead.', replacement: '\Hyde\Facades\HydeFront::version()')] + public static function version(): string + { + return HydeFront::version(); + } + + /** + * @deprecated Use HydeFront::cdnLink() instead. + * + * @codeCoverageIgnore Deprecated method. + */ + #[Deprecated(reason: 'Use HydeFront::cdnLink() instead.', replacement: '\Hyde\Facades\HydeFront::cdnLink()')] + public static function cdnLink(string $file): string + { + return HydeFront::cdnLink($file); + } } diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 5f5448313ee..e3b5c76f606 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -4,7 +4,32 @@ namespace Hyde\Facades; +use function str_replace; + class HydeFront { - // + /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ + final protected const HYDEFRONT_VERSION = 'v3.4'; + + /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ + final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; + + public static function version(): string + { + return static::HYDEFRONT_VERSION; + } + + public static function cdnLink(string $file): string + { + return static::constructCdnPath($file); + } + + protected static function constructCdnPath(string $file): string + { + return str_replace( + ['{{ $version }}', '{{ $file }}'], + [static::version(), $file], + static::HYDEFRONT_CDN_URL + ); + } } diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index ddfafe2ec72..81cbfc029b4 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -21,19 +21,6 @@ protected function setUp(): void self::mockConfig(); } - public function testServiceHasVersionString() - { - $this->assertIsString(Asset::version()); - } - - public function testCdnLinkHelper() - { - $this->assertSame( - 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css', - Asset::cdnLink('styles.css') - ); - } - public function testHasMediaFileHelper() { $this->assertFalse(Asset::hasMediaFile('styles.css')); diff --git a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php index e4c6d9e192f..37425127bf7 100644 --- a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Testing\Unit\Facades; +use Hyde\Facades\HydeFront; use Hyde\Testing\UnitTestCase; /** @@ -11,5 +12,14 @@ */ class HydeFrontFacadeTest extends UnitTestCase { - // + public function testVersionReturnsString() + { + $this->assertIsString(HydeFront::version()); + } + + public function testCdnLinkReturnsCorrectUrl() + { + $expected = 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css'; + $this->assertSame($expected, HydeFront::cdnLink('styles.css')); + } } From 3db1b29adce5f88299de0fc990ce3b19ad3ecfd8 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:54:25 +0200 Subject: [PATCH 2846/4023] Use the new HydeFront facade --- packages/framework/resources/views/layouts/styles.blade.php | 2 +- .../framework/tests/Unit/Views/StylesComponentViewTest.php | 4 ++-- spec.md | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 497e524ae1b..2a345a4ce18 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -3,7 +3,7 @@ {{-- The compiled Tailwind/App styles --}} @if(config('hyde.load_app_styles_from_cdn', false)) - + @elseif(Asset::hasMediaFile('app.css')) @endif diff --git a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php index bfe078d00f1..bb5358f9e08 100644 --- a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php +++ b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php @@ -5,7 +5,7 @@ namespace Hyde\Framework\Testing\Unit\Views; use Hyde\Facades\Filesystem; -use Hyde\Facades\Asset; +use Hyde\Facades\HydeFront; use Hyde\Hyde; use Hyde\Support\Facades\Render; use Hyde\Testing\TestCase; @@ -80,7 +80,7 @@ public function testComponentRendersTailwindPlayCdnLinkWhenEnabledInConfig() public function testComponentRendersAppCdnLinkWhenEnabledInConfig() { config(['hyde.load_app_styles_from_cdn' => true]); - $this->assertStringContainsString(Asset::cdnLink('app.css'), $this->renderTestView()); + $this->assertStringContainsString(HydeFront::cdnLink('app.css'), $this->renderTestView()); } public function testComponentDoesNotRenderLinkToLocalAppCssWhenCdnLinkIsEnabledInConfig() diff --git a/spec.md b/spec.md index b404251e8ea..a1ca493ac41 100644 --- a/spec.md +++ b/spec.md @@ -15,7 +15,7 @@ For example: Consider these Blade snippets from the default views, showing commo ```blade {{-- The compiled Tailwind/App styles --}} @if(config('hyde.load_app_styles_from_cdn', false)) - + @elseif(Asset::hasMediaFile('app.css')) @endif @@ -61,7 +61,7 @@ protected function setSource(string $source): string { ### Asset Facade ```php -Asset::cdnLink(string $file) // Gets remote URL to any file in /dist/ in the HydeFront version +HydeFront::cdnLink(string $file) // Gets remote URL to any file in /dist/ in the HydeFront version Asset::mediaLink(string $file) // Returns Hyde::mediaLink but with a cache buster Asset::hasMediaFile(string $file) // Returns file_exists(Hyde::mediaPath($file)) @@ -576,7 +576,7 @@ $size = $logo->getSize(); $mimeType = $logo->getMimeType(); // HydeFront CDN link (for app.js or app.css) -$appJsUrl = Asset::cdnLink('app.js'); +$appJsUrl = HydeFront::cdnLink('app.js'); ``` This API maintains the simplicity-first approach of Hyde while providing power when needed. It should be intuitive for both Laravel-familiar developers and those new to the framework, aligning well with Hyde's philosophy and goals. From f5b752610ac5d9f8027afcaa13428669215b8110 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:52:35 +0200 Subject: [PATCH 2847/4023] Remove deprecated Asset facade methods See https://github.com/hydephp/develop/pull/1904 for why we are skipping the normal deprecation process. --- packages/framework/src/Facades/Asset.php | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index 6d7a3afaeb3..2300dd6dc72 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -6,7 +6,6 @@ use Hyde\Hyde; use Illuminate\Support\Str; -use JetBrains\PhpStorm\Deprecated; use function md5_file; use function file_exists; @@ -54,26 +53,4 @@ protected static function getCacheBustKey(string $file): string ? '?v='.md5_file(Hyde::mediaPath("$file")) : ''; } - - /** - * @deprecated Use HydeFront::version() instead. - * - * @codeCoverageIgnore Deprecated method. - */ - #[Deprecated(reason: 'Use HydeFront::version() instead.', replacement: '\Hyde\Facades\HydeFront::version()')] - public static function version(): string - { - return HydeFront::version(); - } - - /** - * @deprecated Use HydeFront::cdnLink() instead. - * - * @codeCoverageIgnore Deprecated method. - */ - #[Deprecated(reason: 'Use HydeFront::cdnLink() instead.', replacement: '\Hyde\Facades\HydeFront::cdnLink()')] - public static function cdnLink(string $file): string - { - return HydeFront::cdnLink($file); - } } From 48a8a94aa8a54f85b3cbeab72594aae8189f3f2e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 14:58:06 +0200 Subject: [PATCH 2848/4023] Remove unnecessary final modifiers from protected constants --- packages/framework/src/Facades/HydeFront.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index e3b5c76f606..22a25793caa 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -9,10 +9,10 @@ class HydeFront { /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ - final protected const HYDEFRONT_VERSION = 'v3.4'; + protected const HYDEFRONT_VERSION = 'v3.4'; /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ - final protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; + protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; public static function version(): string { From 57835e62662f90e7eae97d630b992e0f93d1f209 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:00:14 +0200 Subject: [PATCH 2849/4023] Inline helper method --- packages/framework/src/Facades/HydeFront.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 22a25793caa..aa45b7cfc3a 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -20,11 +20,6 @@ public static function version(): string } public static function cdnLink(string $file): string - { - return static::constructCdnPath($file); - } - - protected static function constructCdnPath(string $file): string { return str_replace( ['{{ $version }}', '{{ $file }}'], From 84a686456893f91fcf56ffed0e1fa6422af6fbda Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:00:37 +0200 Subject: [PATCH 2850/4023] Clean up helper method --- packages/framework/src/Facades/HydeFront.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index aa45b7cfc3a..b2a43426e92 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -22,8 +22,7 @@ public static function version(): string public static function cdnLink(string $file): string { return str_replace( - ['{{ $version }}', '{{ $file }}'], - [static::version(), $file], + ['{{ $version }}', '{{ $file }}'], [static::version(), $file], static::HYDEFRONT_CDN_URL ); } From 324b316ab148ed325df19391a220b28378f9e62d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:03:14 +0200 Subject: [PATCH 2851/4023] Simplify helper method implementation With the private API we can now use a more specific and cleaner implementation --- packages/framework/src/Facades/HydeFront.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index b2a43426e92..13892a380e1 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -4,15 +4,15 @@ namespace Hyde\Facades; -use function str_replace; +use function sprintf; class HydeFront { /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ protected const HYDEFRONT_VERSION = 'v3.4'; - /** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */ - protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}'; + /** @var string The default HydeFront CDN path pattern. */ + protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@%s/dist/%s'; public static function version(): string { @@ -21,9 +21,6 @@ public static function version(): string public static function cdnLink(string $file): string { - return str_replace( - ['{{ $version }}', '{{ $file }}'], [static::version(), $file], - static::HYDEFRONT_CDN_URL - ); + return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); } } From f2c63bcf3186a5d98973409e79fd39d38fe5f952 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:04:33 +0200 Subject: [PATCH 2852/4023] Add HydeFront facade class documentation --- packages/framework/src/Facades/HydeFront.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 13892a380e1..5c9223b7c85 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -6,6 +6,11 @@ use function sprintf; +/** + * HydeFront is the NPM package that bundles the default precompiled CSS and JavaScript assets for HydePHP. + * + * This facade makes it easy to access these assets from the HydeFront CDN, automatically getting the correct version. + */ class HydeFront { /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ From 24571037a9a2ba5eac12f03ffd60267756b9ca67 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:11:24 +0200 Subject: [PATCH 2853/4023] Add rich PHPDoc method annotations --- packages/framework/src/Facades/HydeFront.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 5c9223b7c85..00f5a6ce543 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -19,11 +19,21 @@ class HydeFront /** @var string The default HydeFront CDN path pattern. */ protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@%s/dist/%s'; + /** + * Get the current version of the HydeFront package. + * + * @return string {@see HYDEFRONT_VERSION} + */ public static function version(): string { return static::HYDEFRONT_VERSION; } + /** + * Get the CDN link for a specific file. + * + * @param 'app.css'|'hyde.css'|'hyde.css.map' $file + */ public static function cdnLink(string $file): string { return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); From e33c8213a700df0da06636fdb347674d4540117b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:13:03 +0200 Subject: [PATCH 2854/4023] Add more tests --- .../tests/Unit/Facades/HydeFrontFacadeTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php index 37425127bf7..4afe8ee9e36 100644 --- a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php @@ -22,4 +22,16 @@ public function testCdnLinkReturnsCorrectUrl() $expected = 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css'; $this->assertSame($expected, HydeFront::cdnLink('styles.css')); } + + public function testCdnLinkReturnsCorrectUrlForHydeCss() + { + $expected = 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/hyde.css'; + $this->assertSame($expected, HydeFront::cdnLink('hyde.css')); + } + + public function testCdnLinkReturnsCorrectUrlForInvalidFile() + { + $expected = 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/invalid'; + $this->assertSame($expected, HydeFront::cdnLink('invalid')); + } } From f00db0771ef14e40b146f6a5cc359ba2953bfef4 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:13:28 +0200 Subject: [PATCH 2855/4023] Update constant comment --- packages/framework/src/Facades/HydeFront.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 00f5a6ce543..b566839b999 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -16,7 +16,7 @@ class HydeFront /** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */ protected const HYDEFRONT_VERSION = 'v3.4'; - /** @var string The default HydeFront CDN path pattern. */ + /** @var string The default HydeFront CDN path pattern used to assemble CDN links. */ protected const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@%s/dist/%s'; /** From dc129051b7831a23ebe81f41e37783d5f8a2fac7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:17:26 +0200 Subject: [PATCH 2856/4023] Add todo --- packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php index 4afe8ee9e36..fd4336eff3a 100644 --- a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php @@ -12,6 +12,8 @@ */ class HydeFrontFacadeTest extends UnitTestCase { + // Todo: Check the version is correct? (When running in monorepo) + public function testVersionReturnsString() { $this->assertIsString(HydeFront::version()); From 397e19e3d0e622dad4267d219dc159326f903d9e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:52:48 +0200 Subject: [PATCH 2857/4023] Move Tailwind config injection to HydeFront facade This is more coupled to HydeFront than general Asset services --- .../resources/views/layouts/styles.blade.php | 2 +- packages/framework/src/Facades/Asset.php | 20 ---------------- packages/framework/src/Facades/HydeFront.php | 21 +++++++++++++++++ .../Unit/Facades/AssetFacadeUnitTest.php | 21 ----------------- .../Unit/Facades/HydeFrontFacadeTest.php | 23 +++++++++++++++++++ 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 2a345a4ce18..d1b374d73cf 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -11,7 +11,7 @@ {{-- Dynamic TailwindCSS Play CDN --}} @if(config('hyde.use_play_cdn', false)) - + @endif diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index 2300dd6dc72..9691a43c211 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -5,11 +5,9 @@ namespace Hyde\Facades; use Hyde\Hyde; -use Illuminate\Support\Str; use function md5_file; use function file_exists; -use function file_get_contents; /** * Handles the retrieval of core asset files, either from the HydeFront CDN or from the local media folder. @@ -29,24 +27,6 @@ public static function hasMediaFile(string $file): bool return file_exists(Hyde::mediaPath($file)); } - public static function injectTailwindConfig(): string - { - if (! file_exists(Hyde::path('tailwind.config.js'))) { - return ''; - } - - $config = Str::between(file_get_contents(Hyde::path('tailwind.config.js')), '{', '}'); - - // Remove the plugins array, as it is not used in the frontend. - if (str_contains($config, 'plugins: [')) { - $tokens = explode('plugins: [', $config, 2); - $tokens[1] = Str::after($tokens[1], ']'); - $config = implode('', $tokens); - } - - return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); - } - protected static function getCacheBustKey(string $file): string { return Config::getBool('hyde.enable_cache_busting', true) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index b566839b999..546989442a8 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -4,6 +4,9 @@ namespace Hyde\Facades; +use Hyde\Hyde; +use Illuminate\Support\Str; + use function sprintf; /** @@ -38,4 +41,22 @@ public static function cdnLink(string $file): string { return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); } + + public static function injectTailwindConfig(): string + { + if (! file_exists(Hyde::path('tailwind.config.js'))) { + return ''; + } + + $config = Str::between(file_get_contents(Hyde::path('tailwind.config.js')), '{', '}'); + + // Remove the plugins array, as it is not used in the frontend. + if (str_contains($config, 'plugins: [')) { + $tokens = explode('plugins: [', $config, 2); + $tokens[1] = Str::after($tokens[1], ']'); + $config = implode('', $tokens); + } + + return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); + } } diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index 81cbfc029b4..4c62090bbae 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -4,7 +4,6 @@ namespace Hyde\Framework\Testing\Unit\Facades; -use Hyde\Hyde; use Hyde\Facades\Asset; use Hyde\Testing\UnitTestCase; @@ -30,24 +29,4 @@ public function testHasMediaFileHelperReturnsTrueForExistingFile() { $this->assertTrue(Asset::hasMediaFile('app.css')); } - - public function testInjectTailwindConfigReturnsExtractedTailwindConfig() - { - $config = Asset::injectTailwindConfig(); - - $this->assertIsString($config); - $this->assertStringContainsString("darkMode: 'class'", $config); - $this->assertStringContainsString('theme: {', $config); - $this->assertStringContainsString('extend: {', $config); - $this->assertStringContainsString('typography: {', $config); - $this->assertStringNotContainsString('plugins', $config); - } - - public function testInjectTailwindConfigHandlesMissingConfigFileGracefully() - { - rename(Hyde::path('tailwind.config.js'), Hyde::path('tailwind.config.js.bak')); - $this->assertIsString(Asset::injectTailwindConfig()); - $this->assertSame('', Asset::injectTailwindConfig()); - rename(Hyde::path('tailwind.config.js.bak'), Hyde::path('tailwind.config.js')); - } } diff --git a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php index fd4336eff3a..3bcdf3a096d 100644 --- a/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php +++ b/packages/framework/tests/Unit/Facades/HydeFrontFacadeTest.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Testing\Unit\Facades; +use Hyde\Hyde; use Hyde\Facades\HydeFront; use Hyde\Testing\UnitTestCase; @@ -12,6 +13,8 @@ */ class HydeFrontFacadeTest extends UnitTestCase { + protected static bool $needsKernel = true; + // Todo: Check the version is correct? (When running in monorepo) public function testVersionReturnsString() @@ -36,4 +39,24 @@ public function testCdnLinkReturnsCorrectUrlForInvalidFile() $expected = 'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/invalid'; $this->assertSame($expected, HydeFront::cdnLink('invalid')); } + + public function testInjectTailwindConfigReturnsExtractedTailwindConfig() + { + $config = HydeFront::injectTailwindConfig(); + + $this->assertIsString($config); + $this->assertStringContainsString("darkMode: 'class'", $config); + $this->assertStringContainsString('theme: {', $config); + $this->assertStringContainsString('extend: {', $config); + $this->assertStringContainsString('typography: {', $config); + $this->assertStringNotContainsString('plugins', $config); + } + + public function testInjectTailwindConfigHandlesMissingConfigFileGracefully() + { + rename(Hyde::path('tailwind.config.js'), Hyde::path('tailwind.config.js.bak')); + $this->assertIsString(HydeFront::injectTailwindConfig()); + $this->assertSame('', HydeFront::injectTailwindConfig()); + rename(Hyde::path('tailwind.config.js.bak'), Hyde::path('tailwind.config.js')); + } } From eb5136a7e392c2edae6cbc6c5065a1b9b4864cff Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:55:21 +0200 Subject: [PATCH 2858/4023] Mark method as internal --- packages/framework/src/Facades/HydeFront.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 546989442a8..2529d2c2d91 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -42,6 +42,9 @@ public static function cdnLink(string $file): string return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); } + /** + * @internal This method is used to inject the Tailwind CSS configuration into the Play CDN integration. + */ public static function injectTailwindConfig(): string { if (! file_exists(Hyde::path('tailwind.config.js'))) { From bbd960b49b7843a6b5afb714f333f8326b8b5dfd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:55:24 +0200 Subject: [PATCH 2859/4023] Revert "Mark method as internal" This reverts commit eb5136a7e392c2edae6cbc6c5065a1b9b4864cff. --- packages/framework/src/Facades/HydeFront.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 2529d2c2d91..546989442a8 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -42,9 +42,6 @@ public static function cdnLink(string $file): string return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); } - /** - * @internal This method is used to inject the Tailwind CSS configuration into the Play CDN integration. - */ public static function injectTailwindConfig(): string { if (! file_exists(Hyde::path('tailwind.config.js'))) { From fc5b464287f3e840def2aa718fcb90720bb5c58f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:55:55 +0200 Subject: [PATCH 2860/4023] Document method --- packages/framework/src/Facades/HydeFront.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 546989442a8..97cc2bdb091 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -42,6 +42,9 @@ public static function cdnLink(string $file): string return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); } + /** + * This method is used to inject the Tailwind CSS configuration into the Play CDN integration. + */ public static function injectTailwindConfig(): string { if (! file_exists(Hyde::path('tailwind.config.js'))) { From 63b414a88724af984843ee2c77b95e586ae986a3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 15:56:09 +0200 Subject: [PATCH 2861/4023] Compress comment formatting --- packages/framework/src/Facades/HydeFront.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/framework/src/Facades/HydeFront.php b/packages/framework/src/Facades/HydeFront.php index 97cc2bdb091..ed2def95db9 100644 --- a/packages/framework/src/Facades/HydeFront.php +++ b/packages/framework/src/Facades/HydeFront.php @@ -42,9 +42,7 @@ public static function cdnLink(string $file): string return sprintf(static::HYDEFRONT_CDN_URL, static::version(), $file); } - /** - * This method is used to inject the Tailwind CSS configuration into the Play CDN integration. - */ + /** This method is used to inject the Tailwind CSS configuration into the Play CDN integration. */ public static function injectTailwindConfig(): string { if (! file_exists(Hyde::path('tailwind.config.js'))) { From 9ba410a818c2c4875a65634d4cd6cf51fd67f58a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:00:24 +0200 Subject: [PATCH 2862/4023] Refactor to merge feature test into unit test --- .../tests/Feature/AssetFacadeTest.php | 46 ------------------- .../Unit/Facades/AssetFacadeUnitTest.php | 44 +++++++++++++++++- 2 files changed, 42 insertions(+), 48 deletions(-) delete mode 100644 packages/framework/tests/Feature/AssetFacadeTest.php diff --git a/packages/framework/tests/Feature/AssetFacadeTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php deleted file mode 100644 index 3e934eab38b..00000000000 --- a/packages/framework/tests/Feature/AssetFacadeTest.php +++ /dev/null @@ -1,46 +0,0 @@ -assertIsString($path = Asset::mediaLink('app.css')); - $this->assertSame('media/app.css?v='.md5_file(Hyde::path('_media/app.css')), $path); - } - - public function testMediaLinkReturnsMediaPathWithoutCacheKeyIfCacheBustingIsDisabled() - { - config(['hyde.enable_cache_busting' => false]); - - $path = Asset::mediaLink('app.css'); - - $this->assertIsString($path); - $this->assertSame('media/app.css', $path); - } - - public function testMediaLinkSupportsCustomMediaDirectories() - { - $this->directory('_assets'); - $this->file('_assets/app.css'); - - Hyde::setMediaDirectory('_assets'); - - $path = Asset::mediaLink('app.css'); - - $this->assertIsString($path); - $this->assertSame('assets/app.css?v='.md5_file(Hyde::path('_assets/app.css')), $path); - } -} diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index 4c62090bbae..a004e805399 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -4,20 +4,31 @@ namespace Hyde\Framework\Testing\Unit\Facades; +use Hyde\Hyde; use Hyde\Facades\Asset; use Hyde\Testing\UnitTestCase; +use Hyde\Support\Facades\Render; +use Hyde\Support\Models\RenderData; +use Hyde\Testing\CreatesTemporaryFiles; /** * @covers \Hyde\Facades\Asset - * - * @see \Hyde\Framework\Testing\Feature\AssetFacadeTest */ class AssetFacadeUnitTest extends UnitTestCase { + use CreatesTemporaryFiles; + protected function setUp(): void { self::needsKernel(); self::mockConfig(); + + Render::swap(new RenderData()); + } + + protected function tearDown(): void + { + $this->cleanUpFilesystem(); } public function testHasMediaFileHelper() @@ -29,4 +40,33 @@ public function testHasMediaFileHelperReturnsTrueForExistingFile() { $this->assertTrue(Asset::hasMediaFile('app.css')); } + + public function testMediaLinkReturnsMediaPathWithCacheKey() + { + $this->assertIsString($path = Asset::mediaLink('app.css')); + $this->assertSame('media/app.css?v='.md5_file(Hyde::path('_media/app.css')), $path); + } + + public function testMediaLinkReturnsMediaPathWithoutCacheKeyIfCacheBustingIsDisabled() + { + self::mockConfig(['hyde.enable_cache_busting' => false]); + + $path = Asset::mediaLink('app.css'); + + $this->assertIsString($path); + $this->assertSame('media/app.css', $path); + } + + public function testMediaLinkSupportsCustomMediaDirectories() + { + $this->directory('_assets'); + $this->file('_assets/app.css'); + + Hyde::setMediaDirectory('_assets'); + + $path = Asset::mediaLink('app.css'); + + $this->assertIsString($path); + $this->assertSame('assets/app.css?v='.md5_file(Hyde::path('_assets/app.css')), $path); + } } From 9edfe944225a12e696f99183e305a98b0cb633cc Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:12:38 +0200 Subject: [PATCH 2863/4023] Refactor test to be a unit test --- .../{Feature => Unit}/Support/MediaFileTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) rename packages/framework/tests/{Feature => Unit}/Support/MediaFileTest.php (93%) diff --git a/packages/framework/tests/Feature/Support/MediaFileTest.php b/packages/framework/tests/Unit/Support/MediaFileTest.php similarity index 93% rename from packages/framework/tests/Feature/Support/MediaFileTest.php rename to packages/framework/tests/Unit/Support/MediaFileTest.php index 0782bfaf3bc..a4798f0db52 100644 --- a/packages/framework/tests/Feature/Support/MediaFileTest.php +++ b/packages/framework/tests/Unit/Support/MediaFileTest.php @@ -2,19 +2,30 @@ declare(strict_types=1); -namespace Hyde\Framework\Testing\Feature\Support; +namespace Hyde\Framework\Testing\Unit\Support; use Hyde\Facades\Filesystem; use Hyde\Framework\Exceptions\FileNotFoundException; use Hyde\Hyde; use Hyde\Support\Filesystem\MediaFile; -use Hyde\Testing\TestCase; +use Hyde\Testing\UnitTestCase; +use Hyde\Testing\CreatesTemporaryFiles; /** * @covers \Hyde\Support\Filesystem\MediaFile */ -class MediaFileTest extends TestCase +class MediaFileTest extends UnitTestCase { + use CreatesTemporaryFiles; + + protected static bool $needsKernel = true; + protected static bool $needsConfig = true; + + protected function tearDown(): void + { + $this->cleanUpFilesystem(); + } + public function testCanConstruct() { $file = new MediaFile('foo'); From b6eed88c1161093f44daee2b30a4c0474a113212 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:19:28 +0200 Subject: [PATCH 2864/4023] Draft new mediaPath helper --- packages/framework/src/Support/Filesystem/MediaFile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 45298a50694..e5f0fba95bf 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -41,6 +41,14 @@ public static function files(): array return array_keys(static::all()); } + /** + * Get the absolute path to the media source directory, or a file within it. + */ + public static function mediaPath(string $path = ''): string + { + return Hyde::mediaPath($path); + } + public function getIdentifier(): string { return Str::after($this->getPath(), Hyde::getMediaDirectory().'/'); From ccca1d773052be4e37f5204b774b1104983a3a76 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:20:01 +0200 Subject: [PATCH 2865/4023] Draft new siteMediaPath helper --- packages/framework/src/Support/Filesystem/MediaFile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index e5f0fba95bf..418ea84e73c 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -49,6 +49,14 @@ public static function mediaPath(string $path = ''): string return Hyde::mediaPath($path); } + /** + * Get the absolute path to the compiled site's media directory, or a file within it. + */ + public static function siteMediaPath(string $path = ''): string + { + return Hyde::siteMediaPath($path); + } + public function getIdentifier(): string { return Str::after($this->getPath(), Hyde::getMediaDirectory().'/'); From b6a1269272b9f9391f0ceb7a08539b426b3e1dfd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:21:31 +0200 Subject: [PATCH 2866/4023] Inline kernel access --- packages/framework/src/Support/Filesystem/MediaFile.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 418ea84e73c..539ac68f3fe 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -6,6 +6,7 @@ use Hyde\Hyde; use Hyde\Facades\Config; +use Hyde\Foundation\HydeKernel; use Hyde\Framework\Exceptions\FileNotFoundException; use Illuminate\Support\Str; @@ -46,7 +47,7 @@ public static function files(): array */ public static function mediaPath(string $path = ''): string { - return Hyde::mediaPath($path); + return HydeKernel::getInstance()->mediaPath($path); } /** @@ -54,7 +55,7 @@ public static function mediaPath(string $path = ''): string */ public static function siteMediaPath(string $path = ''): string { - return Hyde::siteMediaPath($path); + return HydeKernel::getInstance()->siteMediaPath($path); } public function getIdentifier(): string From ecd98dbd436cc29663d956fbb9b0ab94ab89c768 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:22:14 +0200 Subject: [PATCH 2867/4023] Rename added methods to match HydePage siblings --- packages/framework/src/Support/Filesystem/MediaFile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 539ac68f3fe..3b514361caf 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -45,7 +45,7 @@ public static function files(): array /** * Get the absolute path to the media source directory, or a file within it. */ - public static function mediaPath(string $path = ''): string + public static function sourcePath(string $path = ''): string { return HydeKernel::getInstance()->mediaPath($path); } @@ -53,7 +53,7 @@ public static function mediaPath(string $path = ''): string /** * Get the absolute path to the compiled site's media directory, or a file within it. */ - public static function siteMediaPath(string $path = ''): string + public static function outputPath(string $path = ''): string { return HydeKernel::getInstance()->siteMediaPath($path); } From beaf5114a3c086274430db9c2961a598c603062d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:23:27 +0200 Subject: [PATCH 2868/4023] Refactor base implementations to be class independent --- packages/framework/src/Foundation/Kernel/Filesystem.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index a8f36a32df1..cdd1685b295 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -97,10 +97,10 @@ public function pathToRelative(string $path): string public function mediaPath(string $path = ''): string { if (empty($path)) { - return $this->path(Hyde::getMediaDirectory()); + return Hyde::path(Hyde::getMediaDirectory()); } - return $this->path(path_join(Hyde::getMediaDirectory(), unslash($path))); + return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path))); } /** @@ -121,12 +121,12 @@ public function sitePath(string $path = ''): string public function siteMediaPath(string $path = ''): string { if (empty($path)) { - return $this->sitePath(Hyde::getMediaOutputDirectory()); + return Hyde::sitePath(Hyde::getMediaOutputDirectory()); } $path = unslash($path); - return $this->sitePath(Hyde::getMediaOutputDirectory()."/$path"); + return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path"); } /** From 9aa1f66db9d946cf41e7f1b16f0e5f04f8a0ceba Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:24:53 +0200 Subject: [PATCH 2869/4023] Move method logic to new code location --- .../src/Foundation/Kernel/Filesystem.php | 15 +++------------ .../src/Support/Filesystem/MediaFile.php | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index cdd1685b295..c637ed271b9 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -7,6 +7,7 @@ use Hyde\Hyde; use Hyde\Foundation\HydeKernel; use Hyde\Foundation\PharSupport; +use Hyde\Support\Filesystem\MediaFile; use Illuminate\Support\Collection; use function collect; @@ -96,11 +97,7 @@ public function pathToRelative(string $path): string */ public function mediaPath(string $path = ''): string { - if (empty($path)) { - return Hyde::path(Hyde::getMediaDirectory()); - } - - return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path))); + return MediaFile::sourcePath($path); } /** @@ -120,13 +117,7 @@ public function sitePath(string $path = ''): string */ public function siteMediaPath(string $path = ''): string { - if (empty($path)) { - return Hyde::sitePath(Hyde::getMediaOutputDirectory()); - } - - $path = unslash($path); - - return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path"); + return MediaFile::outputPath($path); } /** diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 3b514361caf..fbf6f04ea9b 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -6,10 +6,11 @@ use Hyde\Hyde; use Hyde\Facades\Config; -use Hyde\Foundation\HydeKernel; use Hyde\Framework\Exceptions\FileNotFoundException; use Illuminate\Support\Str; +use function Hyde\unslash; +use function Hyde\path_join; use function extension_loaded; use function file_exists; use function array_merge; @@ -47,7 +48,11 @@ public static function files(): array */ public static function sourcePath(string $path = ''): string { - return HydeKernel::getInstance()->mediaPath($path); + if (empty($path)) { + return Hyde::path(Hyde::getMediaDirectory()); + } + + return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path))); } /** @@ -55,7 +60,13 @@ public static function sourcePath(string $path = ''): string */ public static function outputPath(string $path = ''): string { - return HydeKernel::getInstance()->siteMediaPath($path); + if (empty($path)) { + return Hyde::sitePath(Hyde::getMediaOutputDirectory()); + } + + $path = unslash($path); + + return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path"); } public function getIdentifier(): string From 5863d03613db465499d3f26e6344f66480c01b9b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:27:20 +0200 Subject: [PATCH 2870/4023] Reorder methods to match sibling order --- .../hyde-kernel-filesystem-methods.md | 10 +++++----- .../Foundation/Concerns/ForwardsFilesystem.php | 8 ++++---- .../src/Foundation/Kernel/Filesystem.php | 16 ++++++++-------- spec.md | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md index bdbe12dd34d..204bb419328 100644 --- a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md +++ b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md @@ -1,7 +1,7 @@
- + #### `filesystem()` @@ -35,20 +35,20 @@ No description provided. Hyde::mediaPath(string $path): string ``` -#### `sitePath()` +#### `siteMediaPath()` No description provided. ```php -Hyde::sitePath(string $path): string +Hyde::siteMediaPath(string $path): string ``` -#### `siteMediaPath()` +#### `sitePath()` No description provided. ```php -Hyde::siteMediaPath(string $path): string +Hyde::sitePath(string $path): string ``` #### `pathToAbsolute()` diff --git a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php index 88e8aba452b..c0ac1518277 100644 --- a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php +++ b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php @@ -33,14 +33,14 @@ public function mediaPath(string $path = ''): string return $this->filesystem->mediaPath($path); } - public function sitePath(string $path = ''): string + public function siteMediaPath(string $path = ''): string { - return $this->filesystem->sitePath($path); + return $this->filesystem->siteMediaPath($path); } - public function siteMediaPath(string $path = ''): string + public function sitePath(string $path = ''): string { - return $this->filesystem->siteMediaPath($path); + return $this->filesystem->sitePath($path); } public function pathToAbsolute(string|array $path): string|array diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index c637ed271b9..f254440d3e8 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -100,6 +100,14 @@ public function mediaPath(string $path = ''): string return MediaFile::sourcePath($path); } + /** + * Get the absolute path to the compiled site's media directory, or a file within it. + */ + public function siteMediaPath(string $path = ''): string + { + return MediaFile::outputPath($path); + } + /** * Get the absolute path to the compiled site directory, or a file within it. */ @@ -112,14 +120,6 @@ public function sitePath(string $path = ''): string return $this->path(path_join(Hyde::getOutputDirectory(), unslash($path))); } - /** - * Get the absolute path to the compiled site's media directory, or a file within it. - */ - public function siteMediaPath(string $path = ''): string - { - return MediaFile::outputPath($path); - } - /** * Works similarly to the path() function, but returns a file in the Framework package. * diff --git a/spec.md b/spec.md index a1ca493ac41..cb78e76674c 100644 --- a/spec.md +++ b/spec.md @@ -78,17 +78,17 @@ Asset::hasMediaFile(string $file) // Returns file_exists(Hyde::mediaPath($file)) ```php Hyde::mediaPath() // Get the absolute path to the media source directory, or a file within it. (Intended as a sibling to Hyde::path and Hyde::sitePath helpers, and the HydePage::path methods) +Hyde::siteMediaPath() // Get the absolute path to the compiled site's media directory, or a file within it. (Intended as a sibling to Hyde::sitePath) Hyde::mediaLink() // Gets a relative web link to the given file stored in the _site/media folder. (Intended as a sibling to Hyde::relativeLink, which is called by this) (A second $validate parameter will return throw an exception if the file does not exist) Hyde::asset() // Gets a relative web link to the given image stored in the _site/media folder. (But leaves remote URLs alone) (A second $preferQualifiedUrl parameter will return a fully qualified URL if a site URL is set) -Hyde::siteMediaPath() // Get the absolute path to the compiled site's media directory, or a file within it. (Intended as a sibling to Hyde::sitePath) /** * Real implementations of the facade methods: * * @see \Hyde\Foundation\HydeKernel::mediaPath {@see \Hyde\Foundation\Kernel\Filesystem::mediaPath} + * @see \Hyde\Foundation\HydeKernel::siteMediaPath {@see \Hyde\Foundation\Kernel\Filesystem::siteMediaPath} * @see \Hyde\Foundation\HydeKernel::mediaLink {@see \Hyde\Foundation\Kernel\Hyperlinks::mediaLink} * @see \Hyde\Foundation\HydeKernel::asset {@see \Hyde\Foundation\Kernel\Hyperlinks::asset} - * @see \Hyde\Foundation\HydeKernel::siteMediaPath {@see \Hyde\Foundation\Kernel\Filesystem::siteMediaPath} */ ``` From a60e91b61659925ed17a370e37c5c69fc293bf5a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:37:07 +0200 Subject: [PATCH 2871/4023] Move tests to match new code locations --- .../Feature/Foundation/FilesystemTest.php | 25 +++++----------- .../tests/Unit/Support/MediaFileTest.php | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/packages/framework/tests/Feature/Foundation/FilesystemTest.php b/packages/framework/tests/Feature/Foundation/FilesystemTest.php index 6c2c2811cd8..0be01b45c22 100644 --- a/packages/framework/tests/Feature/Foundation/FilesystemTest.php +++ b/packages/framework/tests/Feature/Foundation/FilesystemTest.php @@ -13,6 +13,7 @@ use Hyde\Pages\HtmlPage; use Hyde\Pages\MarkdownPage; use Hyde\Pages\MarkdownPost; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Testing\UnitTestCase; use function Hyde\normalize_slashes; @@ -263,31 +264,19 @@ public function testHelperForDocumentationPages() public function testHelperForMediaPath() { $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); - } - - public function testHelperForMediaPathReturnsPathToFileWithinTheDirectory() - { - $this->assertSame(Hyde::path('_media/foo.css'), Hyde::mediaPath('foo.css')); - } + $this->assertSame(MediaFile::sourcePath(), Hyde::mediaPath()); - public function testGetMediaPathReturnsAbsolutePath() - { - $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); + $this->assertSame(Hyde::path('_media/foo.png'), Hyde::mediaPath('foo.png')); + $this->assertSame(MediaFile::sourcePath('foo.png'), Hyde::mediaPath('foo.png')); } public function testHelperForMediaOutputPath() { $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); - } - - public function testHelperForMediaOutputPathReturnsPathToFileWithinTheDirectory() - { - $this->assertSame(Hyde::path('_site/media/foo.css'), Hyde::siteMediaPath('foo.css')); - } + $this->assertSame(MediaFile::outputPath(), Hyde::siteMediaPath()); - public function testGetMediaOutputPathReturnsAbsolutePath() - { - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/media/foo.png'), Hyde::siteMediaPath('foo.png')); + $this->assertSame(MediaFile::outputPath('foo.png'), Hyde::siteMediaPath('foo.png')); } public function testHelperForSiteOutputPath() diff --git a/packages/framework/tests/Unit/Support/MediaFileTest.php b/packages/framework/tests/Unit/Support/MediaFileTest.php index a4798f0db52..86969b4d3ab 100644 --- a/packages/framework/tests/Unit/Support/MediaFileTest.php +++ b/packages/framework/tests/Unit/Support/MediaFileTest.php @@ -211,4 +211,34 @@ public function testGetIdentifierWithSubdirectory() { $this->assertSame('foo/bar', MediaFile::make('foo/bar')->getIdentifier()); } + + public function testHelperForMediaPath() + { + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + } + + public function testHelperForMediaPathReturnsPathToFileWithinTheDirectory() + { + $this->assertSame(Hyde::path('_media/foo.css'), MediaFile::sourcePath('foo.css')); + } + + public function testGetMediaPathReturnsAbsolutePath() + { + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + } + + public function testHelperForMediaOutputPath() + { + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + } + + public function testHelperForMediaOutputPathReturnsPathToFileWithinTheDirectory() + { + $this->assertSame(Hyde::path('_site/media/foo.css'), MediaFile::outputPath('foo.css')); + } + + public function testGetMediaOutputPathReturnsAbsolutePath() + { + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + } } From 8cfe0cd6d471f8c81bf259e0d1bc5066a57765f6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:38:13 +0200 Subject: [PATCH 2872/4023] Add todos to move more tests to match new code locations --- packages/framework/tests/Feature/HydeKernelTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index 8c1470b4206..bd22206502d 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -393,17 +393,23 @@ public function testGetMediaOutputDirectoryNameUsesTrimmedVersionOfMediaSourceDi public function testCanGetSiteMediaOutputDirectory() { + // Todo: Move to MediaFileTest + $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); } public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() { + // Todo: Move to MediaFileTest + Hyde::setMediaDirectory('_foo'); $this->assertSame(Hyde::path('_site/foo'), Hyde::siteMediaPath()); } public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() { + // Todo: Move to MediaFileTest + Hyde::setOutputDirectory(Hyde::path('foo')); Hyde::setMediaDirectory('bar'); From 89d0e52d4693ced01185fb7766c2d96208b47828 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:44:01 +0200 Subject: [PATCH 2873/4023] Create new internal trait for transitioning to v2 --- packages/framework/src/Hyde.php | 3 +++ .../framework/src/Support/V1Compatibility.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 packages/framework/src/Support/V1Compatibility.php diff --git a/packages/framework/src/Hyde.php b/packages/framework/src/Hyde.php index cc309a3b21c..105b42de812 100644 --- a/packages/framework/src/Hyde.php +++ b/packages/framework/src/Hyde.php @@ -7,6 +7,7 @@ use Hyde\Enums\Feature; use Hyde\Facades\Features; use Hyde\Foundation\HydeKernel; +use Hyde\Support\V1Compatibility; use Illuminate\Support\Collection; use Hyde\Foundation\Kernel\FileCollection; use Hyde\Foundation\Kernel\Filesystem; @@ -79,6 +80,8 @@ */ class Hyde extends Facade { + use V1Compatibility; + public static function version(): string { return HydeKernel::version(); diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php new file mode 100644 index 00000000000..ed03754713d --- /dev/null +++ b/packages/framework/src/Support/V1Compatibility.php @@ -0,0 +1,15 @@ + Date: Fri, 26 Jul 2024 16:46:05 +0200 Subject: [PATCH 2874/4023] Ignore class from code coverage --- packages/framework/src/Support/V1Compatibility.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index ed03754713d..d26d62cd504 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -8,6 +8,8 @@ * @internal Hyde Facade support to aid in the v1 to v2 transition. * * @deprecated All code here is deprecated, and exists to help you transition. + * + * @codeCoverageIgnore This class is ignored from code coverage. */ trait V1Compatibility { From 2004a4e67e8fd80b20ffb4f96d6dd177bf26b773 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:59:19 +0200 Subject: [PATCH 2875/4023] Revert "Ignore class from code coverage" This reverts commit 4091051785fcc5cba66b6b4eb76abe0c23008655. --- packages/framework/src/Support/V1Compatibility.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index d26d62cd504..ed03754713d 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -8,8 +8,6 @@ * @internal Hyde Facade support to aid in the v1 to v2 transition. * * @deprecated All code here is deprecated, and exists to help you transition. - * - * @codeCoverageIgnore This class is ignored from code coverage. */ trait V1Compatibility { From 650d5a7e815033bdbdc60c6eb0e6c4a7899883b2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:54:58 +0200 Subject: [PATCH 2876/4023] Manually proxy and deprecate legacy facade methods This is so we can get an overview of the outdated methods that are inconsistently named This means they are lost from the HydeKernel which could be a problem to review before merge. --- .../hyde-kernel-filesystem-methods.md | 18 +-------------- .../Concerns/ForwardsFilesystem.php | 10 -------- .../src/Foundation/Kernel/Filesystem.php | 17 -------------- packages/framework/src/Hyde.php | 2 -- .../framework/src/Support/V1Compatibility.php | 23 ++++++++++++++++++- 5 files changed, 23 insertions(+), 47 deletions(-) diff --git a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md index 204bb419328..eb5983597e6 100644 --- a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md +++ b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md @@ -1,7 +1,7 @@
- + #### `filesystem()` @@ -27,22 +27,6 @@ No description provided. Hyde::vendorPath(string $path, string $package): string ``` -#### `mediaPath()` - -No description provided. - -```php -Hyde::mediaPath(string $path): string -``` - -#### `siteMediaPath()` - -No description provided. - -```php -Hyde::siteMediaPath(string $path): string -``` - #### `sitePath()` No description provided. diff --git a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php index c0ac1518277..cea06f5bbc2 100644 --- a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php +++ b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php @@ -28,16 +28,6 @@ public function vendorPath(string $path = '', string $package = 'framework'): st return $this->filesystem->vendorPath($path, $package); } - public function mediaPath(string $path = ''): string - { - return $this->filesystem->mediaPath($path); - } - - public function siteMediaPath(string $path = ''): string - { - return $this->filesystem->siteMediaPath($path); - } - public function sitePath(string $path = ''): string { return $this->filesystem->sitePath($path); diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index f254440d3e8..8f3bb2fd2aa 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -7,7 +7,6 @@ use Hyde\Hyde; use Hyde\Foundation\HydeKernel; use Hyde\Foundation\PharSupport; -use Hyde\Support\Filesystem\MediaFile; use Illuminate\Support\Collection; use function collect; @@ -92,22 +91,6 @@ public function pathToRelative(string $path): string : $path); } - /** - * Get the absolute path to the media source directory, or a file within it. - */ - public function mediaPath(string $path = ''): string - { - return MediaFile::sourcePath($path); - } - - /** - * Get the absolute path to the compiled site's media directory, or a file within it. - */ - public function siteMediaPath(string $path = ''): string - { - return MediaFile::outputPath($path); - } - /** * Get the absolute path to the compiled site directory, or a file within it. */ diff --git a/packages/framework/src/Hyde.php b/packages/framework/src/Hyde.php index 105b42de812..9590fb6133a 100644 --- a/packages/framework/src/Hyde.php +++ b/packages/framework/src/Hyde.php @@ -34,8 +34,6 @@ * @method static string pathToAbsolute(string $path) * @method static string pathToRelative(string $path) * @method static string sitePath(string $path = '') - * @method static string mediaPath(string $path = '') - * @method static string siteMediaPath(string $path = '') * @method static string formatLink(string $destination) * @method static string relativeLink(string $destination) * @method static string mediaLink(string $destination, bool $validate = false) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index ed03754713d..f6bd2de40c7 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -4,6 +4,9 @@ namespace Hyde\Support; +use JetBrains\PhpStorm\Deprecated; +use Hyde\Support\Filesystem\MediaFile; + /** * @internal Hyde Facade support to aid in the v1 to v2 transition. * @@ -11,5 +14,23 @@ */ trait V1Compatibility { - // + /** + * @deprecated Use MediaFile::sourcePath() instead. + * @see \Hyde\Support\Filesystem\MediaFile::sourcePath() + */ + #[Deprecated(reason: 'Use MediaFile::sourcePath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::sourcePath()')] + public static function mediaPath(string $path = ''): string + { + return MediaFile::sourcePath($path); + } + + /** + * @deprecated Use MediaFile::outputPath() instead. + * @see \Hyde\Support\Filesystem\MediaFile::outputPath() + */ + #[Deprecated(reason: 'Use MediaFile::outputPath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::outputPath()')] + public static function siteMediaPath(string $path = ''): string + { + return MediaFile::outputPath($path); + } } From 8228d7a474666aeaf63b9d6d072f48e63305782f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:04:58 +0200 Subject: [PATCH 2877/4023] Set the parameters list --- packages/framework/src/Support/V1Compatibility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index f6bd2de40c7..863734b99cd 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -18,7 +18,7 @@ trait V1Compatibility * @deprecated Use MediaFile::sourcePath() instead. * @see \Hyde\Support\Filesystem\MediaFile::sourcePath() */ - #[Deprecated(reason: 'Use MediaFile::sourcePath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::sourcePath()')] + #[Deprecated(reason: 'Use MediaFile::sourcePath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::sourcePath(%parametersList%)')] public static function mediaPath(string $path = ''): string { return MediaFile::sourcePath($path); @@ -28,7 +28,7 @@ public static function mediaPath(string $path = ''): string * @deprecated Use MediaFile::outputPath() instead. * @see \Hyde\Support\Filesystem\MediaFile::outputPath() */ - #[Deprecated(reason: 'Use MediaFile::outputPath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::outputPath()')] + #[Deprecated(reason: 'Use MediaFile::outputPath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::outputPath(%parametersList%)')] public static function siteMediaPath(string $path = ''): string { return MediaFile::outputPath($path); From 2e96631d81859d470251c4e86706971ea969eb46 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:05:43 +0200 Subject: [PATCH 2878/4023] Alias the MediaFile class --- app/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/config.php b/app/config.php index 009c0f586b7..aed2519bbce 100644 --- a/app/config.php +++ b/app/config.php @@ -105,6 +105,7 @@ 'MarkdownPage' => \Hyde\Pages\MarkdownPage::class, 'MarkdownPost' => \Hyde\Pages\MarkdownPost::class, 'DocumentationPage' => \Hyde\Pages\DocumentationPage::class, + 'MediaFile' => \Hyde\Support\Filesystem\MediaFile::class, 'DataCollection' => \Hyde\Support\DataCollection::class, 'Includes' => \Hyde\Support\Includes::class, 'Feature' => \Hyde\Enums\Feature::class, From bbe66f46095bb275661de093239aa2acf9fbd824 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:09:33 +0200 Subject: [PATCH 2879/4023] Update deprecated method usages with new helpers --- .../resources/views/layouts/head.blade.php | 2 +- packages/framework/src/Facades/Asset.php | 5 +++-- .../Actions/PreBuildTasks/CleanSiteDirectory.php | 3 ++- .../PreBuildTasks/TransferMediaAssets.php | 7 +++---- .../Features/Blogging/Models/FeaturedImage.php | 3 ++- .../src/Framework/Services/ValidationService.php | 5 +++-- .../tests/Feature/Foundation/FilesystemTest.php | 16 ++++++++-------- .../framework/tests/Feature/HydeKernelTest.php | 11 ++++++----- 8 files changed, 28 insertions(+), 24 deletions(-) diff --git a/packages/framework/resources/views/layouts/head.blade.php b/packages/framework/resources/views/layouts/head.blade.php index 32ed4390d8b..111aced665b 100644 --- a/packages/framework/resources/views/layouts/head.blade.php +++ b/packages/framework/resources/views/layouts/head.blade.php @@ -2,7 +2,7 @@ {{ $page->title() }} -@if (file_exists(Hyde::mediaPath('favicon.ico'))) +@if (file_exists(MediaFile::sourcePath('favicon.ico'))) @endif diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index 9691a43c211..45e16a0a881 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -5,6 +5,7 @@ namespace Hyde\Facades; use Hyde\Hyde; +use Hyde\Support\Filesystem\MediaFile; use function md5_file; use function file_exists; @@ -24,13 +25,13 @@ public static function mediaLink(string $file): string public static function hasMediaFile(string $file): bool { - return file_exists(Hyde::mediaPath($file)); + return file_exists(MediaFile::sourcePath($file)); } protected static function getCacheBustKey(string $file): string { return Config::getBool('hyde.enable_cache_busting', true) - ? '?v='.md5_file(Hyde::mediaPath("$file")) + ? '?v='.md5_file(MediaFile::sourcePath("$file")) : ''; } } diff --git a/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php b/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php index 849f077b7cb..ba64f24ee76 100644 --- a/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php +++ b/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php @@ -7,6 +7,7 @@ use Hyde\Hyde; use Hyde\Facades\Config; use Hyde\Facades\Filesystem; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\Features\BuildTasks\PreBuildTask; use function basename; @@ -22,7 +23,7 @@ public function handle(): void { if ($this->isItSafeToCleanOutputDirectory()) { Filesystem::unlink(glob(Hyde::sitePath('*.{html,json}'), GLOB_BRACE)); - Filesystem::cleanDirectory(Hyde::siteMediaPath()); + Filesystem::cleanDirectory(MediaFile::outputPath()); } } diff --git a/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php b/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php index fdec03a75ff..3acb112ea9d 100644 --- a/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php +++ b/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php @@ -4,7 +4,6 @@ namespace Hyde\Framework\Actions\PreBuildTasks; -use Hyde\Hyde; use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\Features\BuildTasks\PreBuildTask; use Hyde\Framework\Concerns\InteractsWithDirectories; @@ -17,14 +16,14 @@ class TransferMediaAssets extends PreBuildTask public function handle(): void { - $this->needsDirectory(Hyde::siteMediaPath()); + $this->needsDirectory(MediaFile::outputPath()); $this->newLine(); $this->withProgressBar(MediaFile::files(), function (string $identifier): void { - $sitePath = Hyde::siteMediaPath($identifier); + $sitePath = MediaFile::outputPath($identifier); $this->needsParentDirectory($sitePath); - copy(Hyde::mediaPath($identifier), $sitePath); + copy(MediaFile::sourcePath($identifier), $sitePath); }); $this->newLine(); diff --git a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php index 0f42f961c87..5c4acef1996 100644 --- a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php +++ b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php @@ -11,6 +11,7 @@ use Hyde\Support\BuildWarnings; use Illuminate\Support\Facades\Http; use Hyde\Foundation\Kernel\Hyperlinks; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\Exceptions\FileNotFoundException; use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema; @@ -213,7 +214,7 @@ protected function has(string $property): bool protected function getContentLengthForLocalImage(): int { - $storagePath = Hyde::mediaPath($this->source); + $storagePath = MediaFile::sourcePath($this->source); if (! file_exists($storagePath)) { throw new FileNotFoundException(customMessage: sprintf('Featured image [%s] not found.', Hyde::pathToRelative($storagePath))); diff --git a/packages/framework/src/Framework/Services/ValidationService.php b/packages/framework/src/Framework/Services/ValidationService.php index 88deee3496b..052486d4041 100644 --- a/packages/framework/src/Framework/Services/ValidationService.php +++ b/packages/framework/src/Framework/Services/ValidationService.php @@ -11,6 +11,7 @@ use Hyde\Pages\MarkdownPage; use Hyde\Pages\DocumentationPage; use Hyde\Enums\Feature; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Support\Models\ValidationResult as Result; use function count; @@ -102,12 +103,12 @@ public function check_documentation_site_has_an_index_page(Result $result): Resu public function check_site_has_an_app_css_stylesheet(Result $result): Result { - if (file_exists(Hyde::siteMediaPath('/app.css')) || file_exists(Hyde::mediaPath('app.css'))) { + if (file_exists(MediaFile::outputPath('/app.css')) || file_exists(MediaFile::sourcePath('app.css'))) { return $result->pass('Your site has an app.css stylesheet'); } return $result->fail(sprintf('Could not find an app.css file in the %s or %s directory!', - Hyde::pathToRelative(Hyde::siteMediaPath()), Hyde::getMediaDirectory() + Hyde::pathToRelative(MediaFile::outputPath()), Hyde::getMediaDirectory() ))->withTip('You may need to run `npm run dev`.`'); } diff --git a/packages/framework/tests/Feature/Foundation/FilesystemTest.php b/packages/framework/tests/Feature/Foundation/FilesystemTest.php index 0be01b45c22..86bc2c76479 100644 --- a/packages/framework/tests/Feature/Foundation/FilesystemTest.php +++ b/packages/framework/tests/Feature/Foundation/FilesystemTest.php @@ -263,20 +263,20 @@ public function testHelperForDocumentationPages() public function testHelperForMediaPath() { - $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); - $this->assertSame(MediaFile::sourcePath(), Hyde::mediaPath()); + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + $this->assertSame(MediaFile::sourcePath(), MediaFile::sourcePath()); - $this->assertSame(Hyde::path('_media/foo.png'), Hyde::mediaPath('foo.png')); - $this->assertSame(MediaFile::sourcePath('foo.png'), Hyde::mediaPath('foo.png')); + $this->assertSame(Hyde::path('_media/foo.png'), MediaFile::sourcePath('foo.png')); + $this->assertSame(MediaFile::sourcePath('foo.png'), MediaFile::sourcePath('foo.png')); } public function testHelperForMediaOutputPath() { - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); - $this->assertSame(MediaFile::outputPath(), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + $this->assertSame(MediaFile::outputPath(), MediaFile::outputPath()); - $this->assertSame(Hyde::path('_site/media/foo.png'), Hyde::siteMediaPath('foo.png')); - $this->assertSame(MediaFile::outputPath('foo.png'), Hyde::siteMediaPath('foo.png')); + $this->assertSame(Hyde::path('_site/media/foo.png'), MediaFile::outputPath('foo.png')); + $this->assertSame(MediaFile::outputPath('foo.png'), MediaFile::outputPath('foo.png')); } public function testHelperForSiteOutputPath() diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index bd22206502d..9ff8799dd06 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -13,6 +13,7 @@ use Hyde\Foundation\HydeKernel; use Hyde\Enums\Feature; use Hyde\Foundation\Kernel\Filesystem; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\HydeServiceProvider; use Hyde\Hyde; use Hyde\Pages\BladePage; @@ -262,9 +263,9 @@ public function testFluentModelSourcePathHelpers() $this->assertSame(Hyde::path('_pages'), MarkdownPage::path()); $this->assertSame(Hyde::path('_docs'), DocumentationPage::path()); - $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); $this->assertSame(Hyde::path('_site'), Hyde::sitePath()); - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); } public function testPathToRelativeHelperReturnsRelativePathForGivenPath() @@ -395,7 +396,7 @@ public function testCanGetSiteMediaOutputDirectory() { // Todo: Move to MediaFileTest - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); } public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() @@ -403,7 +404,7 @@ public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDi // Todo: Move to MediaFileTest Hyde::setMediaDirectory('_foo'); - $this->assertSame(Hyde::path('_site/foo'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/foo'), MediaFile::outputPath()); } public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() @@ -413,7 +414,7 @@ public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory Hyde::setOutputDirectory(Hyde::path('foo')); Hyde::setMediaDirectory('bar'); - $this->assertSame(Hyde::path('foo/bar'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('foo/bar'), MediaFile::outputPath()); } public function testMediaOutputDirectoryCanBeChangedInConfiguration() From 74059a5cd81546649f58859c38ed9d0d28e521a6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:10:58 +0200 Subject: [PATCH 2880/4023] Remove inconsistent infix from internal helper methods --- packages/framework/src/Support/Filesystem/MediaFile.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index fbf6f04ea9b..3ed834e7562 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -34,7 +34,7 @@ class MediaFile extends ProjectFile /** @return array The array keys are the filenames relative to the _media/ directory */ public static function all(): array { - return static::discoverMediaAssetFiles(); + return static::discoverMediaFiles(); } /** @return array Array of filenames relative to the _media/ directory */ @@ -123,16 +123,16 @@ public function getMimeType(): string return 'text/plain'; } - protected static function discoverMediaAssetFiles(): array + protected static function discoverMediaFiles(): array { - return collect(static::getMediaAssetFiles())->mapWithKeys(function (string $path): array { + return collect(static::getMediaFiles())->mapWithKeys(function (string $path): array { $file = static::make($path); return [$file->getIdentifier() => $file]; })->all(); } - protected static function getMediaAssetFiles(): array + protected static function getMediaFiles(): array { return glob(Hyde::path(static::getMediaGlobPattern()), GLOB_BRACE) ?: []; } From 678b6f75c1c4fd60d989d2642e4f34aecae97d07 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:12:30 +0200 Subject: [PATCH 2881/4023] Reapply "Ignore class from code coverage" This reverts commit 2004a4e67e8fd80b20ffb4f96d6dd177bf26b773. --- packages/framework/src/Support/V1Compatibility.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index 863734b99cd..3d8f5b5cd0c 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -11,6 +11,8 @@ * @internal Hyde Facade support to aid in the v1 to v2 transition. * * @deprecated All code here is deprecated, and exists to help you transition. + * + * @codeCoverageIgnore This class is ignored from code coverage. */ trait V1Compatibility { From 46473331102f32baf8d6b5d0b374c084c1b6dda5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 18:32:38 +0200 Subject: [PATCH 2882/4023] Move the tests to the new code location --- .../tests/Feature/HydeKernelTest.php | 25 ------------------- .../tests/Unit/Support/MediaFileTest.php | 19 ++++++++++++++ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index 9ff8799dd06..b12a5ea19bb 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -392,31 +392,6 @@ public function testGetMediaOutputDirectoryNameUsesTrimmedVersionOfMediaSourceDi $this->assertSame('foo', Hyde::getMediaOutputDirectory()); } - public function testCanGetSiteMediaOutputDirectory() - { - // Todo: Move to MediaFileTest - - $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); - } - - public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() - { - // Todo: Move to MediaFileTest - - Hyde::setMediaDirectory('_foo'); - $this->assertSame(Hyde::path('_site/foo'), MediaFile::outputPath()); - } - - public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() - { - // Todo: Move to MediaFileTest - - Hyde::setOutputDirectory(Hyde::path('foo')); - Hyde::setMediaDirectory('bar'); - - $this->assertSame(Hyde::path('foo/bar'), MediaFile::outputPath()); - } - public function testMediaOutputDirectoryCanBeChangedInConfiguration() { $this->assertSame('_media', Hyde::getMediaDirectory()); diff --git a/packages/framework/tests/Unit/Support/MediaFileTest.php b/packages/framework/tests/Unit/Support/MediaFileTest.php index 86969b4d3ab..44ded0474c5 100644 --- a/packages/framework/tests/Unit/Support/MediaFileTest.php +++ b/packages/framework/tests/Unit/Support/MediaFileTest.php @@ -241,4 +241,23 @@ public function testGetMediaOutputPathReturnsAbsolutePath() { $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); } + + public function testCanGetSiteMediaOutputDirectory() + { + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + } + + public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() + { + Hyde::setMediaDirectory('_foo'); + $this->assertSame(Hyde::path('_site/foo'), MediaFile::outputPath()); + } + + public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() + { + Hyde::setOutputDirectory(Hyde::path('foo')); + Hyde::setMediaDirectory('bar'); + + $this->assertSame(Hyde::path('foo/bar'), MediaFile::outputPath()); + } } From a130f0321f44f3df2870ae25e748a863a15db7f5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 18:55:14 +0200 Subject: [PATCH 2883/4023] Deprecate the `preferQualifiedUrl` parameter in the asset helper --- packages/framework/src/Foundation/Kernel/Hyperlinks.php | 3 ++- packages/framework/src/helpers.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Foundation/Kernel/Hyperlinks.php b/packages/framework/src/Foundation/Kernel/Hyperlinks.php index e127cdfaa82..ab6866a6600 100644 --- a/packages/framework/src/Foundation/Kernel/Hyperlinks.php +++ b/packages/framework/src/Foundation/Kernel/Hyperlinks.php @@ -8,6 +8,7 @@ use BadMethodCallException; use Hyde\Support\Models\Route; use Hyde\Foundation\HydeKernel; +use JetBrains\PhpStorm\Deprecated; use Hyde\Framework\Exceptions\FileNotFoundException; use Illuminate\Support\Str; @@ -109,7 +110,7 @@ public function mediaLink(string $destination, bool $validate = false): string * If true is passed as the second argument, and a base URL is set, * the image will be returned with a qualified absolute URL. */ - public function asset(string $name, bool $preferQualifiedUrl = false): string + public function asset(string $name, #[Deprecated(reason: 'This will be enabled automatically when a site URL is set')] bool $preferQualifiedUrl = false): string { if (static::isRemote($name)) { return $name; diff --git a/packages/framework/src/helpers.php b/packages/framework/src/helpers.php index 34e8f9da12b..54f689619d3 100644 --- a/packages/framework/src/helpers.php +++ b/packages/framework/src/helpers.php @@ -4,6 +4,7 @@ namespace { use Hyde\Foundation\HydeKernel; + use JetBrains\PhpStorm\Deprecated; if (! function_exists('hyde')) { /** @@ -22,7 +23,7 @@ function hyde(): HydeKernel /** * Get a relative link or URL to an asset in the media directory. */ - function asset(string $name, bool $preferQualifiedUrl = false): string + function asset(string $name, #[Deprecated(reason: 'This will be enabled automatically when a site URL is set')] bool $preferQualifiedUrl = false): string { return hyde()->asset($name, $preferQualifiedUrl); } From 54f8f0314aca05f27b5d83482318ff9a5ec0685c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 20:01:18 +0200 Subject: [PATCH 2884/4023] No longer use the `preferQualifiedUrl` parameter --- packages/framework/src/Foundation/Kernel/Hyperlinks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Foundation/Kernel/Hyperlinks.php b/packages/framework/src/Foundation/Kernel/Hyperlinks.php index ab6866a6600..04dedf77f6a 100644 --- a/packages/framework/src/Foundation/Kernel/Hyperlinks.php +++ b/packages/framework/src/Foundation/Kernel/Hyperlinks.php @@ -118,7 +118,7 @@ public function asset(string $name, #[Deprecated(reason: 'This will be enabled a $name = Str::start($name, "{$this->kernel->getMediaOutputDirectory()}/"); - if ($preferQualifiedUrl && $this->hasSiteUrl()) { + if ($this->hasSiteUrl()) { return $this->url($name); } From 7f773b30deefb8803c9c8e119a1a01d686adc00b Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 26 Jul 2024 18:11:31 +0000 Subject: [PATCH 2885/4023] Remove the `preferQualifiedUrl` parameter --- .../hyde-kernel-hyperlink-methods.md | 4 ++-- docs/architecture-concepts/the-hydekernel.md | 2 +- .../Concerns/ForwardsHyperlinks.php | 4 ++-- .../src/Foundation/Kernel/Hyperlinks.php | 6 ++---- packages/framework/src/Hyde.php | 2 +- packages/framework/src/helpers.php | 5 ++--- .../Feature/Foundation/HyperlinksTest.php | 20 +++++++++---------- .../framework/tests/Feature/HelpersTest.php | 18 ++++++++--------- 8 files changed, 29 insertions(+), 32 deletions(-) diff --git a/docs/_data/partials/hyde-pages-api/hyde-kernel-hyperlink-methods.md b/docs/_data/partials/hyde-pages-api/hyde-kernel-hyperlink-methods.md index 1dceb9c542d..bd8d609104b 100644 --- a/docs/_data/partials/hyde-pages-api/hyde-kernel-hyperlink-methods.md +++ b/docs/_data/partials/hyde-pages-api/hyde-kernel-hyperlink-methods.md @@ -1,7 +1,7 @@