v7.0.0-beta.1 release
This commit is contained in:
commit
6595fd0eb5
3967 files changed
+1875383
No files matched your search
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Plugin;
|
||||
|
||||
use App\Contracts\Repositories\PluginRepositoryInterface;
|
||||
use App\Enums\ExtensionStatus;
|
||||
use App\Extension\PluginManager;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ListPluginCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
protected $signature = 'plugin:list
|
||||
{--status= : 상태로 필터 (installed, uninstalled, active, inactive)}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*/
|
||||
protected $description = '플러그인 목록을 조회합니다';
|
||||
|
||||
/**
|
||||
* 플러그인 관리자 및 리포지토리
|
||||
*/
|
||||
public function __construct(
|
||||
private PluginManager $pluginManager,
|
||||
private PluginRepositoryInterface $pluginRepository
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
// 플러그인 디렉토리 스캔 및 로드
|
||||
$this->pluginManager->loadPlugins();
|
||||
|
||||
$statusFilter = $this->option('status');
|
||||
|
||||
// 상태 필터 검증
|
||||
if ($statusFilter && ! in_array($statusFilter, ['installed', 'uninstalled', 'active', 'inactive'])) {
|
||||
$this->error('❌ '.__('plugins.commands.list.invalid_status'));
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
// 설치된 플러그인 정보
|
||||
$installedPlugins = $this->pluginManager->getInstalledPluginsWithDetails();
|
||||
|
||||
// 미설치 플러그인 정보
|
||||
$uninstalledPlugins = $this->pluginManager->getUninstalledPlugins();
|
||||
|
||||
// 테이블 데이터 준비
|
||||
$tableData = [];
|
||||
|
||||
// 설치된 플러그인 추가
|
||||
foreach ($installedPlugins as $identifier => $plugin) {
|
||||
// 상태 필터
|
||||
if ($statusFilter) {
|
||||
if ($statusFilter === 'uninstalled') {
|
||||
continue;
|
||||
}
|
||||
if ($statusFilter === 'active' && $plugin['status'] !== ExtensionStatus::Active->value) {
|
||||
continue;
|
||||
}
|
||||
if ($statusFilter === 'inactive' && $plugin['status'] !== ExtensionStatus::Inactive->value) {
|
||||
continue;
|
||||
}
|
||||
if ($statusFilter === 'installed' && ! in_array($plugin['status'], [ExtensionStatus::Active->value, ExtensionStatus::Inactive->value])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
'identifier' => $identifier,
|
||||
'name' => $plugin['name'],
|
||||
'vendor' => $plugin['vendor'],
|
||||
'version' => $plugin['version'],
|
||||
'status' => $this->formatStatus($plugin['status']),
|
||||
];
|
||||
}
|
||||
|
||||
// 미설치 플러그인 추가
|
||||
if (! $statusFilter || $statusFilter === 'uninstalled') {
|
||||
foreach ($uninstalledPlugins as $identifier => $plugin) {
|
||||
// 상태 필터 (uninstalled 또는 필터 없음)
|
||||
if ($statusFilter && $statusFilter !== 'uninstalled') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
'identifier' => $identifier,
|
||||
'name' => $plugin['name'],
|
||||
'vendor' => $plugin['vendor'],
|
||||
'version' => $plugin['version'],
|
||||
'status' => $this->formatStatus('uninstalled'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 플러그인이 없는 경우
|
||||
if (empty($tableData)) {
|
||||
$this->info(__('plugins.commands.list.no_plugins'));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
// 테이블 헤더
|
||||
$headers = [
|
||||
__('plugins.commands.list.headers.identifier'),
|
||||
__('plugins.commands.list.headers.name'),
|
||||
__('plugins.commands.list.headers.vendor'),
|
||||
__('plugins.commands.list.headers.version'),
|
||||
__('plugins.commands.list.headers.status'),
|
||||
];
|
||||
|
||||
// 테이블 출력
|
||||
$this->table($headers, $tableData);
|
||||
|
||||
// 요약 정보
|
||||
$totalCount = count($tableData);
|
||||
$activeCount = count(array_filter($tableData, fn ($p) => str_contains($p['status'], __('plugins.commands.list.status.active'))));
|
||||
$installedCount = count(array_filter($tableData, fn ($p) => ! str_contains($p['status'], __('plugins.commands.list.status.uninstalled'))));
|
||||
|
||||
$this->newLine();
|
||||
$this->info(__('plugins.commands.list.summary', [
|
||||
'total' => $totalCount,
|
||||
'installed' => $installedCount,
|
||||
'active' => $activeCount,
|
||||
]));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태 포맷팅
|
||||
*/
|
||||
private function formatStatus(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
ExtensionStatus::Active->value => '✅ '.__('plugins.commands.list.status.active'),
|
||||
ExtensionStatus::Inactive->value => '⏸️ '.__('plugins.commands.list.status.inactive'),
|
||||
'uninstalled' => '📦 '.__('plugins.commands.list.status.uninstalled'),
|
||||
default => $status,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user