error("Key store path does not exist: {$storage}"); return self::FAILURE; } $directories = collect(File::directories($storage)) ->filter(fn ($path) => Str::lower(basename($path)) !== 'archive') ->values() ->map(function (string $path) use ($currentKid) { $kid = basename($path); $publicKey = $path.DIRECTORY_SEPARATOR.'public.key'; $privateKey = $path.DIRECTORY_SEPARATOR.'private.key'; return [ 'kid' => $kid, 'status' => $kid === $currentKid ? 'current' : 'legacy', 'public' => File::exists($publicKey), 'private' => File::exists($privateKey), 'updated_at' => File::exists($path) ? date('c', File::lastModified($path)) : null, 'path' => $path, ]; }) ->sortBy(fn ($entry) => ($entry['status'] === 'current' ? '0-' : '1-').$entry['kid']) ->values(); if ($this->option('json')) { $this->line($directories->toJson(JSON_PRETTY_PRINT)); return self::SUCCESS; } if ($directories->isEmpty()) { $this->warn('No signing key directories found.'); return self::SUCCESS; } $this->table( ['KID', 'Status', 'Public.key', 'Private.key', 'Updated At', 'Path'], $directories->map(fn ($entry) => [ $entry['kid'], $entry['status'], $entry['public'] ? 'yes' : 'no', $entry['private'] ? 'yes' : 'no', $entry['updated_at'] ?? 'n/a', $entry['path'], ]) ); return self::SUCCESS; } }