File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525
2626/**
2727 * Build a single static site file.
28+ *
29+ * @deprecated This command is deprecated and will be removed in HydePHP v3.0. Use \Hyde\Framework\Actions\StaticPageBuilder::handle() instead.
2830 */
2931class RebuildPageCommand extends Command
3032{
3133 /** @var string */
3234 protected $ signature = 'rebuild {path : The relative file path (example: _posts/hello-world.md)} ' ;
3335
3436 /** @var string */
35- protected $ description = 'Run the static site builder for a single file ' ;
37+ protected $ description = 'Run the static site builder for a single file [Deprecated, will be removed in v3.0] ' ;
3638
3739 public function handle (): int
3840 {
41+ $ this ->printDeprecationWarning ();
42+
3943 if ($ this ->argument ('path ' ) === Hyde::getMediaDirectory ()) {
4044 return (new TransferMediaAssets ())->run ($ this ->output );
4145
@@ -47,6 +51,16 @@ public function handle(): int
4751 return $ this ->makeBuildTask ($ this ->output , $ this ->getNormalizedPathString ())->run ();
4852 }
4953
54+ /**
55+ * @deprecated The `rebuild` command is deprecated and will be removed in HydePHP v3.0.
56+ */
57+ protected function printDeprecationWarning (): void
58+ {
59+ $ this ->warn ('The `rebuild` command is deprecated and will be removed in HydePHP v3.0. ' );
60+ $ this ->line ('If you need to build a single page programmatically, use Hyde\Framework\Actions\StaticPageBuilder::handle() instead. ' );
61+ $ this ->newLine ();
62+ }
63+
5064 protected function getNormalizedPathString (): string
5165 {
5266 return str_replace ('\\' , '/ ' , unslash ($ this ->argument ('path ' )));
Original file line number Diff line number Diff line change @@ -23,6 +23,18 @@ public function testHandleIsSuccessfulWithValidPath()
2323 $ this ->resetSite ();
2424 }
2525
26+ public function testCommandOutputsDeprecationWarning ()
27+ {
28+ $ this ->file ('_pages/test-page.md ' , 'foo ' );
29+
30+ $ this ->artisan ('rebuild _pages/test-page.md ' )
31+ ->expectsOutput ('The `rebuild` command is deprecated and will be removed in HydePHP v3.0. ' )
32+ ->expectsOutput ('If you need to build a single page programmatically, use Hyde\Framework\Actions\StaticPageBuilder::handle() instead. ' )
33+ ->assertExitCode (0 );
34+
35+ $ this ->resetSite ();
36+ }
37+
2638 public function testMediaFilesCanBeTransferred ()
2739 {
2840 $ this ->directory (Hyde::path ('_site/media ' ));
You can’t perform that action at this time.
0 commit comments