argument('identifier'); try { // 모듈 디렉토리 스캔 및 로드 $this->moduleManager->loadModules(); // 모듈이 설치되어 있는지 확인 $moduleRecord = $this->moduleRepository->findByIdentifier($identifier); if (! $moduleRecord) { $this->error('❌ '.__('modules.commands.uninstall.not_installed', ['module' => $identifier])); return Command::FAILURE; } // 모듈 인스턴스에서 role 개수 조회 $moduleInstance = $this->moduleManager->getModule($identifier); $rolesCount = 0; if ($moduleInstance && method_exists($moduleInstance, 'getRoles')) { $rolesCount = count($moduleInstance->getRoles()); } // 권한, 메뉴, 레이아웃 개수 조회 $permissionsCount = Permission::byExtension(ExtensionOwnerType::Module, $identifier)->count(); $menusCount = Menu::byExtension(ExtensionOwnerType::Module, $identifier)->count(); $layoutsCount = $this->moduleManager->getModuleLayoutsCount($identifier); // 확인 프롬프트 (--force 옵션이 없는 경우) if (! $this->option('force')) { $this->warn(__('modules.commands.uninstall.confirm_prompt', ['module' => $identifier])); $this->line(__('modules.commands.uninstall.confirm_details.roles', ['count' => $rolesCount])); $this->line(__('modules.commands.uninstall.confirm_details.permissions', ['count' => $permissionsCount])); $this->line(__('modules.commands.uninstall.confirm_details.menus', ['count' => $menusCount])); $this->line(__('modules.commands.uninstall.confirm_details.layouts', ['count' => $layoutsCount])); $this->line(__('modules.commands.uninstall.confirm_details.data')); if ($this->option('delete-data')) { $this->warn('⚠️ --delete-data: 마이그레이션 롤백 및 환경설정 파일이 함께 삭제됩니다.'); } $this->newLine(); if (! $this->unifiedConfirm(__('modules.commands.uninstall.confirm_question'), false)) { $this->info(__('modules.commands.uninstall.aborted')); return Command::SUCCESS; } } // 모듈 제거 $deleteData = $this->option('delete-data'); $onProgress = $this->createProgressCallback(ModuleManager::UNINSTALL_STEPS); try { $result = $this->moduleManager->uninstallModule( $identifier, $deleteData, $onProgress, $uninstallFailureReason, $preservedBackups ); $this->finishProgress(); } catch (\Exception $e) { $this->finishProgress(); throw $e; } if ($result) { $this->info('✅ '.__('modules.commands.uninstall.success', ['module' => $identifier])); $this->info(' - '.__('modules.commands.uninstall.roles_deleted', ['count' => $rolesCount])); $this->info(' - '.__('modules.commands.uninstall.permissions_deleted', ['count' => $permissionsCount])); $this->info(' - '.__('modules.commands.uninstall.menus_deleted', ['count' => $menusCount])); $this->info(' - '.__('modules.commands.uninstall.layouts_deleted', ['count' => $layoutsCount])); // 운영자가 넣은 `custom/` 은 삭제 전에 사본을 남긴다 — 그 경로를 알리지 않으면 // 로그를 뒤지지 않는 한 사본의 존재를 알 수 없다. foreach ($preservedBackups ?? [] as $backup) { $this->info(' - '.__('modules.commands.uninstall.custom_preserved', [ 'directory' => $backup['directory'], 'archive' => $backup['archive'], ])); } Log::info(__('modules.commands.uninstall.success', ['module' => $identifier])); return Command::SUCCESS; } return Command::FAILURE; } catch (\Exception $e) { $this->error('❌ '.$e->getMessage()); Log::error('모듈 제거 실패', [ 'module' => $identifier, 'error' => $e->getMessage(), ]); return Command::FAILURE; } } }