Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Console/Commands/RebuildPageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@

/**
* 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
{
/** @var string */
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);

Expand All @@ -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')));
Expand Down
12 changes: 12 additions & 0 deletions tests/Feature/Commands/RebuildPageCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Loading