39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Stylist\Console;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Modules\Stylist\Diagnostics\ThemeInspector;
|
|
|
|
final class ThemeDoctorCommand extends Command
|
|
{
|
|
protected $signature = 'stylist:doctor';
|
|
|
|
protected $description = 'Diagnose manifests, inheritance, duplicate views, and theme configuration.';
|
|
|
|
public function __construct(private readonly ThemeInspector $inspector)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function handle(): int
|
|
{
|
|
$issues = $this->inspector->issues();
|
|
if ($issues === []) {
|
|
$this->info('Stylist is healthy. No theme issues found.');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$this->table(['Severity', 'Theme', 'Message'], array_map(fn (array $issue): array => [
|
|
strtoupper($issue['severity']), $issue['theme'], $issue['message'],
|
|
], $issues));
|
|
|
|
$errors = count(array_filter($issues, fn (array $issue): bool => $issue['severity'] === 'error'));
|
|
$warnings = count($issues) - $errors;
|
|
$this->line("{$errors} error(s), {$warnings} warning(s).");
|
|
|
|
return $errors > 0 ? self::FAILURE : self::SUCCESS;
|
|
}
|
|
}
|