Skip to content

Commit a222135

Browse files
authored
Merge pull request #824 from hydephp/refactor-BuildService-to-not-use-deprecated-method
Refactor build service to not use deprecated method
2 parents 4caa7d3 + 10b977f commit a222135

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

packages/framework/src/Framework/Services/BuildService.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Hyde\Framework\Actions\StaticPageBuilder;
1111
use Hyde\Framework\Concerns\InteractsWithDirectories;
1212
use Hyde\Hyde;
13+
use Hyde\Pages\Concerns\HydePage;
1314
use Hyde\Support\Models\Route;
1415
use Illuminate\Console\Concerns\InteractsWithIO;
1516
use Illuminate\Console\OutputStyle;
@@ -40,7 +41,7 @@ public function __construct(OutputStyle $output)
4041

4142
public function compileStaticPages(): void
4243
{
43-
collect(Hyde::getDiscoveredPageTypes())->each(function (string $pageClass): void {
44+
collect($this->getPageTypes())->each(function (string $pageClass): void {
4445
$this->compilePagesForClass($pageClass);
4546
});
4647
}
@@ -121,4 +122,12 @@ protected function safeOutputDirectories(): array
121122
{
122123
return config('hyde.safe_output_directories', ['_site', 'docs', 'build']);
123124
}
125+
126+
/** @return array<class-string<\Hyde\Pages\Concerns\HydePage> */
127+
protected function getPageTypes(): array
128+
{
129+
return Hyde::pages()->map(function (HydePage $page): string {
130+
return $page::class;
131+
})->unique()->values()->toArray();
132+
}
124133
}

packages/framework/tests/Feature/StaticSiteServiceTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public function test_all_page_types_can_be_compiled()
7676
$this->file('_docs/docs.md');
7777

7878
$this->artisan('build')
79+
->expectsOutput('Creating Html Pages...')
80+
->expectsOutput('Creating Blade Pages...')
81+
->expectsOutput('Creating Markdown Pages...')
82+
->expectsOutput('Creating Markdown Posts...')
83+
->expectsOutput('Creating Documentation Pages...')
84+
->doesntExpectOutputToContain('Creating')
7985
->assertExitCode(0);
8086

8187
$this->assertFileExists(Hyde::path('_site/html.html'));
@@ -91,6 +97,26 @@ public function test_all_page_types_can_be_compiled()
9197
unlink(Hyde::path('_site/docs/docs.html'));
9298
}
9399

100+
public function test_only_progress_bars_for_types_with_pages_are_shown()
101+
{
102+
$this->file('_pages/blade.blade.php');
103+
$this->file('_pages/markdown.md');
104+
105+
$this->artisan('build')
106+
->doesntExpectOutput('Creating Html Pages...')
107+
->expectsOutput('Creating Blade Pages...')
108+
->expectsOutput('Creating Markdown Pages...')
109+
->doesntExpectOutput('Creating Markdown Posts...')
110+
->doesntExpectOutput('Creating Documentation Pages...')
111+
->doesntExpectOutputToContain('Creating')
112+
->assertExitCode(0);
113+
114+
$this->assertFileExists(Hyde::path('_site/blade.html'));
115+
$this->assertFileExists(Hyde::path('_site/markdown.html'));
116+
unlink(Hyde::path('_site/blade.html'));
117+
unlink(Hyde::path('_site/markdown.html'));
118+
}
119+
94120
public function test_print_initial_information_allows_api_to_be_disabled()
95121
{
96122
$this->artisan('build --no-api')

0 commit comments

Comments
 (0)