From 8519b3a2e6beddd22bd1f4eb2a4f1c9ce7cf0cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucian=20V=C4=83c=C4=83roiu?= Date: Wed, 12 Nov 2025 12:36:36 +0200 Subject: [PATCH 1/2] refactor: rename getServerInfo function into serverInfo --- app/Console/Server/ServerAddCommand.php | 2 +- app/Console/Server/ServerDeleteCommand.php | 4 ++-- app/Console/Server/ServerInfoCommand.php | 2 +- app/Console/Server/ServerInstallCommand.php | 2 +- app/Console/Server/ServerInstallPhpCommand.php | 2 +- app/Console/Server/ServerLogsCommand.php | 2 +- .../Server/ServerProvisionDigitalOceanCommand.php | 2 +- app/Traits/ServersTrait.php | 10 ++++------ 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/Console/Server/ServerAddCommand.php b/app/Console/Server/ServerAddCommand.php index 3de7e308..3dfc921c 100644 --- a/app/Console/Server/ServerAddCommand.php +++ b/app/Console/Server/ServerAddCommand.php @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Get server info (verifies SSH connection and validates distribution & permissions) // ---- - $info = $this->getServerInfo($server); + $info = $this->serverInfo($server); if (is_int($info)) { return $info; diff --git a/app/Console/Server/ServerDeleteCommand.php b/app/Console/Server/ServerDeleteCommand.php index fda81738..52c0622c 100644 --- a/app/Console/Server/ServerDeleteCommand.php +++ b/app/Console/Server/ServerDeleteCommand.php @@ -181,10 +181,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->yay("Server '{$server->name}' deleted from inventory"); if (!$destroyed) { + $this->io->warning('Your server may still be running and incurring costs!'); $this->io->writeln([ '', - 'Your server may still be running and incurring costs:', - ' • Double-check with your cloud provider to ensure it is fully terminated.', + 'Check with your cloud provider to ensure it is fully terminated.', '', ]); } diff --git a/app/Console/Server/ServerInfoCommand.php b/app/Console/Server/ServerInfoCommand.php index 8c60000c..bdf2fc81 100644 --- a/app/Console/Server/ServerInfoCommand.php +++ b/app/Console/Server/ServerInfoCommand.php @@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Get server info (verifies SSH connection and validates distribution & permissions) // ---- - $info = $this->getServerInfo($server); + $info = $this->serverInfo($server); if (is_int($info)) { return $info; diff --git a/app/Console/Server/ServerInstallCommand.php b/app/Console/Server/ServerInstallCommand.php index 8fd63b0c..ee0cc13f 100644 --- a/app/Console/Server/ServerInstallCommand.php +++ b/app/Console/Server/ServerInstallCommand.php @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Get server info (verifies SSH connection and validates distribution & permissions) // ---- - $info = $this->getServerInfo($server); + $info = $this->serverInfo($server); if (is_int($info)) { return $info; diff --git a/app/Console/Server/ServerInstallPhpCommand.php b/app/Console/Server/ServerInstallPhpCommand.php index dd75802b..4ad6d73b 100644 --- a/app/Console/Server/ServerInstallPhpCommand.php +++ b/app/Console/Server/ServerInstallPhpCommand.php @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Get server info (verifies SSH connection and validates distribution & permissions) // ---- - $info = $this->getServerInfo($server); + $info = $this->serverInfo($server); if (is_int($info)) { return $info; diff --git a/app/Console/Server/ServerLogsCommand.php b/app/Console/Server/ServerLogsCommand.php index 26e43032..d091f281 100644 --- a/app/Console/Server/ServerLogsCommand.php +++ b/app/Console/Server/ServerLogsCommand.php @@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Get server info (verifies SSH connection and validates distribution & permissions) // ---- - $info = $this->getServerInfo($server); + $info = $this->serverInfo($server); if (is_int($info)) { return $info; diff --git a/app/Console/Server/ServerProvisionDigitalOceanCommand.php b/app/Console/Server/ServerProvisionDigitalOceanCommand.php index 5b02425c..dbcc678c 100644 --- a/app/Console/Server/ServerProvisionDigitalOceanCommand.php +++ b/app/Console/Server/ServerProvisionDigitalOceanCommand.php @@ -165,7 +165,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->displayServerDeets($server); // Get server info (verifies SSH connection and validates distribution & permissions) - $info = $this->getServerInfo($server); + $info = $this->serverInfo($server); if (is_int($info)) { throw new \RuntimeException('Failed to validate server distribution'); diff --git a/app/Traits/ServersTrait.php b/app/Traits/ServersTrait.php index 84810491..9e9525f7 100644 --- a/app/Traits/ServersTrait.php +++ b/app/Traits/ServersTrait.php @@ -44,7 +44,7 @@ trait ServersTrait * @param ServerDTO $server Server to get information for * @return array|int Returns parsed server info or failure code on failure */ - protected function getServerInfo(ServerDTO $server): array|int + protected function serverInfo(ServerDTO $server): array|int { $info = $this->executePlaybook( $server, @@ -264,12 +264,10 @@ protected function displayServerInfo(array $info): void } } - if (count($phpItems) === 0) { - $phpItems[] = 'No PHP installed'; + if (count($phpItems) > 0) { + $this->io->displayDeets(['PHP' => $phpItems]); + $this->io->writeln(''); } - - $this->io->displayDeets(['PHP' => $phpItems]); - $this->io->writeln(''); } // Display PHP-FPM information if available (multiple versions) From b253b9e6524a339b0987ce3899e91f12d1443be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucian=20V=C4=83c=C4=83roiu?= Date: Wed, 12 Nov 2025 12:50:11 +0200 Subject: [PATCH 2/2] fix: replace references in docs and comments --- .cursor/rules/04-exceptions.mdc | 2 +- app/Traits/ServersTrait.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.cursor/rules/04-exceptions.mdc b/.cursor/rules/04-exceptions.mdc index 15c3c8dd..0ccce49c 100644 --- a/.cursor/rules/04-exceptions.mdc +++ b/.cursor/rules/04-exceptions.mdc @@ -106,7 +106,7 @@ Traits mixed into Commands ARE Command layer. Display errors directly without re ```php // ✅ CORRECT - Display exception directly, no prefix -protected function getServerInfo(ServerDTO $server): array|int +protected function serverInfo(ServerDTO $server): array|int { try { $result = $this->executePlaybook($server, 'server-info', 'Gathering...'); diff --git a/app/Traits/ServersTrait.php b/app/Traits/ServersTrait.php index 9e9525f7..3c2bde07 100644 --- a/app/Traits/ServersTrait.php +++ b/app/Traits/ServersTrait.php @@ -16,7 +16,7 @@ * Reusable server things. * * Requires classes using this trait to have IOService, ServerRepository, SSHService, and SiteRepository properties. - * Also requires PlaybooksTrait for getServerInfo() method. + * Also requires PlaybooksTrait for serverInfo() method. * * @property IOService $io * @property ServerRepository $servers @@ -390,7 +390,7 @@ private function formatUptime(int $seconds): string * Automatically sets first PHP install as default, otherwise prompts user. * * @param ServerDTO $server Server to install PHP on - * @param array $info Server information from getServerInfo() + * @param array $info Server information from serverInfo() * @return array{status: int, php_version: string, php_default: bool}|int Returns array with status and values, or int on failure */ protected function installPhp(ServerDTO $server, array $info): array|int