move into sonardesk
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user