findCommand('brew') === null) { return CheckResult::fail('Homebrew is not installed', 'brew'); } return CheckResult::ok(); } #[AsCheckItem('if necessary tools are installed', limit_os: 'Darwin')] public function checkCliTools(): ?CheckResult { $missing = []; foreach (self::REQUIRED_COMMANDS as $cmd) { if ($this->findCommand($cmd) === null) { $missing[] = $cmd; } } if (!empty($missing)) { return CheckResult::fail('missing system commands: ' . implode(', ', $missing), 'build-tools', [$missing]); } return CheckResult::ok(); } #[AsFixItem('brew')] public function fixBrew(): bool { try { shell(true)->exec('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'); } catch (RuntimeException) { return false; } return true; } #[AsFixItem('build-tools')] public function fixBuildTools(array $missing): bool { foreach ($missing as $cmd) { try { shell(true)->exec('brew install --formula ' . escapeshellarg($cmd)); } catch (RuntimeException) { return false; } } return true; } }