From bfa72d3d4d648924cb845694dfeea14d48690a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucian=20V=C4=83c=C4=83roiu?= Date: Sat, 25 Oct 2025 19:52:46 +0300 Subject: [PATCH] refactor: small updates for some services --- .gitignore | 2 +- app/Contracts/BaseCommand.php | 8 +++++++- app/Services/EnvService.php | 2 +- app/Services/IOService.php | 5 +++++ app/Services/InventoryService.php | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 39dfdf47..50d40b8b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,5 @@ vendor/ .env.* *.cache *.log -inventory.yml +deployer.yml Thumbs.db diff --git a/app/Contracts/BaseCommand.php b/app/Contracts/BaseCommand.php index 197e616d..e6396f8d 100644 --- a/app/Contracts/BaseCommand.php +++ b/app/Contracts/BaseCommand.php @@ -7,7 +7,9 @@ use Bigpixelrocket\DeployerPHP\Container; use Bigpixelrocket\DeployerPHP\Repositories\ServerRepository; use Bigpixelrocket\DeployerPHP\Repositories\SiteRepository; +use Bigpixelrocket\DeployerPHP\Services\DigitalOceanService; use Bigpixelrocket\DeployerPHP\Services\EnvService; +use Bigpixelrocket\DeployerPHP\Services\FilesystemService; use Bigpixelrocket\DeployerPHP\Services\GitService; use Bigpixelrocket\DeployerPHP\Services\InventoryService; use Bigpixelrocket\DeployerPHP\Services\IOService; @@ -39,6 +41,7 @@ public function __construct( // Base services protected readonly EnvService $env, + protected readonly FilesystemService $fs, protected readonly GitService $git, protected readonly InventoryService $inventory, protected readonly IOService $io, @@ -48,6 +51,9 @@ public function __construct( protected readonly ServerRepository $servers, protected readonly SiteRepository $sites, protected readonly SSHService $ssh, + + // Providers + protected readonly DigitalOceanService $digitalOcean, ) { parent::__construct(); } @@ -74,7 +80,7 @@ protected function configure(): void 'inventory', null, InputOption::VALUE_OPTIONAL, - 'Custom path to inventory.yml file (defaults to inventory.yml in the current working directory)' + 'Custom path to deployer.yml file (defaults to deployer.yml in the current working directory)' ); } diff --git a/app/Services/EnvService.php b/app/Services/EnvService.php index 1fecbdfa..398bb998 100644 --- a/app/Services/EnvService.php +++ b/app/Services/EnvService.php @@ -53,7 +53,7 @@ public function get(array|string $keys, bool $required = true): ?string if ($required) { $list = implode(', ', $keysList); $label = count($keysList) > 1 ? 'variables' : 'variable'; - throw new \RuntimeException("Missing required environment {$label}: {$list}"); + throw new \InvalidArgumentException("Missing required environment {$label}: {$list}"); } return null; diff --git a/app/Services/IOService.php b/app/Services/IOService.php index d895f4fc..aa04e556 100644 --- a/app/Services/IOService.php +++ b/app/Services/IOService.php @@ -440,6 +440,11 @@ public function promptSpin( Closure $callback, string $message = 'Loading...' ): mixed { + // Bypass spinner in test environment to prevent terminal conflicts in parallel execution + if (defined('PHPUNIT_COMPOSER_INSTALL') || defined('__PEST_RUNNING__')) { + return $callback(); + } + return spin( callback: $callback, message: $message diff --git a/app/Services/InventoryService.php b/app/Services/InventoryService.php index 218486c0..26dedc9e 100644 --- a/app/Services/InventoryService.php +++ b/app/Services/InventoryService.php @@ -219,7 +219,7 @@ private function unsetByPath(array &$data, array $segments): bool */ private function getInventoryPath(): string { - return $this->inventoryPath ?? rtrim($this->fs->getCwd(), '/') . '/inventory.yml'; + return $this->inventoryPath ?? rtrim($this->fs->getCwd(), '/') . '/deployer.yml'; } /**