Files
ABSDEV/Modules/Developer/Console/Commands/InspectModulesCommand.php
T
2026-07-24 11:52:58 +01:00

33 lines
1.3 KiB
PHP

<?php
namespace Modules\Developer\Console\Commands;
use Illuminate\Console\Command;
final class InspectModulesCommand extends Command
{
protected $signature = 'module:inspect {name?} {--json}';
protected $description = 'Validate module manifests and display dependencies and providers.';
public function handle(): int
{
$files = glob(base_path('Modules/*/module.json')) ?: [];
$name = $this->argument('name');
$rows = [];
foreach ($files as $file) {
$manifest = json_decode((string) file_get_contents($file), true);
if (! is_array($manifest)) { $this->error("Invalid JSON: {$file}"); return self::FAILURE; }
if ($name && strcasecmp((string) ($manifest['name'] ?? ''), (string) $name) !== 0) { continue; }
$rows[] = [
'name' => $manifest['name'] ?? basename(dirname($file)),
'version' => $manifest['version'] ?? 'unknown',
'requires' => implode(', ', $manifest['requires'] ?? []),
'providers' => count($manifest['providers'] ?? []),
];
}
if ($this->option('json')) { $this->line(json_encode($rows, JSON_PRETTY_PRINT)); return self::SUCCESS; }
$this->table(['Module', 'Version', 'Requires', 'Providers'], $rows);
return self::SUCCESS;
}
}