diff --git a/packages/realtime-compiler/src/ConsoleOutput.php b/packages/realtime-compiler/src/ConsoleOutput.php index 01e6dd60e24..ecc0d7c6b0d 100644 --- a/packages/realtime-compiler/src/ConsoleOutput.php +++ b/packages/realtime-compiler/src/ConsoleOutput.php @@ -24,31 +24,41 @@ public function __construct(bool $verbose = false, ?SymfonyOutput $output = null $this->output = $output ?? new SymfonyOutput(); } - public function printStartMessage(string $host, int $port, array $environment): void + public function printStartMessage(string $host, int $port, array $environment = []): void { $url = sprintf('%s://%s:%d', $port === 443 ? 'https' : 'http', $host, $port); - $statusOptions = [ - 'enabled' => 'green-500', - 'disabled' => 'red-500', - 'overridden' => 'yellow-500', - ]; - - $dashboardStatusValue = config('hyde.server.dashboard.enabled'); - $dashboardOverridden = Arr::has($environment, 'HYDE_SERVER_DASHBOARD'); - $dashboardStatus = $dashboardOverridden ? 'overridden' : ($dashboardStatusValue ? 'enabled' : 'disabled'); - $dashboardStatusMessage = sprintf('Dashboard: %s', $statusOptions[$dashboardStatus], $dashboardStatusValue ? 'enabled' : 'disabled'); - $lines = [ '', sprintf('%s %s', 'HydePHP Realtime Compiler', 'v'.Hyde::getInstance()->version()), '', sprintf('Listening on %s', $url, $url), '', - $dashboardStatusMessage, - '', ]; + if ($environment !== []) { + $statusOptions = [ + 'enabled' => 'green-500', + 'disabled' => 'red-500', + ]; + + if (Arr::has($environment, 'HYDE_SERVER_DASHBOARD')) { + $dashboardStatus = Arr::get($environment, 'HYDE_SERVER_DASHBOARD'); + $dashboardStatusValue = $dashboardStatus === 'enabled'; + $dashboardStatusMessage = sprintf('Dashboard: %s', $statusOptions[$dashboardStatus], $dashboardStatusValue ? 'enabled' : 'disabled'); + } + + $optionLines = Arr::whereNotNull([ + $dashboardStatusMessage ?? null, + ]); + + if ($optionLines !== []) { + $optionLines[] = ''; + } + + $lines = array_merge($lines, $optionLines); + } + $lineLength = max(array_map('strlen', array_map('strip_tags', $lines))); $lines = array_map(function (string $line) use ($lineLength): string {