diff --git a/src/Console/Commands/RebuildPageCommand.php b/src/Console/Commands/RebuildPageCommand.php index dba3e103..f6cdb201 100644 --- a/src/Console/Commands/RebuildPageCommand.php +++ b/src/Console/Commands/RebuildPageCommand.php @@ -25,6 +25,8 @@ /** * Build a single static site file. + * + * @deprecated This command is deprecated and will be removed in HydePHP v3.0. Use \Hyde\Framework\Actions\StaticPageBuilder::handle() instead. */ class RebuildPageCommand extends Command { @@ -32,10 +34,12 @@ class RebuildPageCommand extends Command protected $signature = 'rebuild {path : The relative file path (example: _posts/hello-world.md)}'; /** @var string */ - protected $description = 'Run the static site builder for a single file'; + protected $description = 'Run the static site builder for a single file [Deprecated, will be removed in v3.0]'; public function handle(): int { + $this->printDeprecationWarning(); + if ($this->argument('path') === Hyde::getMediaDirectory()) { return (new TransferMediaAssets())->run($this->output); @@ -47,6 +51,16 @@ public function handle(): int return $this->makeBuildTask($this->output, $this->getNormalizedPathString())->run(); } + /** + * @deprecated The `rebuild` command is deprecated and will be removed in HydePHP v3.0. + */ + protected function printDeprecationWarning(): void + { + $this->warn('The `rebuild` command is deprecated and will be removed in HydePHP v3.0.'); + $this->line('If you need to build a single page programmatically, use Hyde\Framework\Actions\StaticPageBuilder::handle() instead.'); + $this->newLine(); + } + protected function getNormalizedPathString(): string { return str_replace('\\', '/', unslash($this->argument('path'))); diff --git a/tests/Feature/Commands/RebuildPageCommandTest.php b/tests/Feature/Commands/RebuildPageCommandTest.php index fbe8a839..df3e6aca 100644 --- a/tests/Feature/Commands/RebuildPageCommandTest.php +++ b/tests/Feature/Commands/RebuildPageCommandTest.php @@ -23,6 +23,18 @@ public function testHandleIsSuccessfulWithValidPath() $this->resetSite(); } + public function testCommandOutputsDeprecationWarning() + { + $this->file('_pages/test-page.md', 'foo'); + + $this->artisan('rebuild _pages/test-page.md') + ->expectsOutput('The `rebuild` command is deprecated and will be removed in HydePHP v3.0.') + ->expectsOutput('If you need to build a single page programmatically, use Hyde\Framework\Actions\StaticPageBuilder::handle() instead.') + ->assertExitCode(0); + + $this->resetSite(); + } + public function testMediaFilesCanBeTransferred() { $this->directory(Hyde::path('_site/media'));