Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fancy serve command cleanup #1449

Merged
merged 5 commits into from
Nov 11, 2023
Merged
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
5 changes: 4 additions & 1 deletion packages/framework/src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
class ServeCommand extends Command
{
/** @var string */
protected $signature = 'serve {--host= : <comment>[default: "localhost"]</comment>}} {--port= : <comment>[default: 8080]</comment>}';
protected $signature = 'serve
{--host= : <comment>[default: "localhost"]</comment>}}
{--port= : <comment>[default: 8080]</comment>}
';

/** @var string */
protected $description = 'Start the realtime compiler server.';
Expand Down
14 changes: 12 additions & 2 deletions packages/realtime-compiler/src/Http/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public function __construct()
{
$this->title = config('hyde.name').' - Dashboard';
$this->request = Request::capture();
$this->console = new ConsoleOutput();

if (((bool) env('HYDE_RC_REQUEST_OUTPUT', false)) === true) {
$this->console = new ConsoleOutput();
}

$this->loadFlashData();

Expand Down Expand Up @@ -355,7 +358,7 @@ protected function createPage(): void
$this->abort($exception->getCode(), $exception->getMessage());
}

$this->console->printMessage("Created file '$path'", 'dashboard@createPage');
$this->writeToConsole("Created file '$path'", 'dashboard@createPage');

$this->flash('justCreatedPage', RouteKey::fromPage($pageClass, $pageClass::pathToIdentifier($path))->get());
$this->setJsonResponse(201, "Created file '$path'!");
Expand Down Expand Up @@ -510,4 +513,11 @@ protected function hasAsyncHeaders(): bool
{
return (getallheaders()['X-RC-Handler'] ?? getallheaders()['x-rc-handler'] ?? null) === 'Async';
}

protected function writeToConsole(string $message, string $context = 'dashboard'): void
{
if (isset($this->console)) {
$this->console->printMessage($message, $context);
}
}
}
Loading