Files

36 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Services\PlatformOverrides;
use Illuminate\Console\Command;
/**
* Read-only report on the platform folder: which config is used, whether its public files are served, and
* overrides that went stale (translation keys the code no longer has, templates whose original changed).
* Exit code 1 when something is broken (e.g. invalid JSON); warnings alone exit 0.
*/
class PlatformCheck extends Command
{
protected $signature = 'platform:check';
protected $description = 'Report on the platform folder and overrides that went stale (read-only)';
public function handle(PlatformOverrides $overrides): int
{
$marks = ['ok' => '<info> ✓</info>', 'info' => '<comment> i</comment>', 'warn' => '<comment> !</comment>', 'fail' => '<error> ✗</error>'];
$findings = $overrides->check();
$this->line('Platform folder: ' . platform_path());
foreach ($findings as $finding) {
$this->line("{$marks[$finding['level']]} {$finding['message']}");
}
$count = fn (string $level) => count(array_filter($findings, fn ($f) => $f['level'] === $level));
$this->newLine();
$this->line("{$count('warn')} warnings, {$count('fail')} failed");
return $count('fail') ? self::FAILURE : self::SUCCESS;
}
}