From b958cdd6edb6a058af6e866e587a4a2eb7bb4809 Mon Sep 17 00:00:00 2001 From: Emma De Silva Date: Fri, 3 Jul 2026 19:45:49 +0000 Subject: [PATCH] Merge pull request #2491 from hydephp/v2/deprecate-rebuild-command [2.x] Deprecate the rebuild command https://github.com/hydephp/develop/commit/e4c6d403f05ab66d548dd41e3c4afc99a37a67e6 --- src/Console/Commands/RebuildPageCommand.php | 16 +++++++++++++++- .../Feature/Commands/RebuildPageCommandTest.php | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) 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'));