mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-18 02:06:36 +00:00
refactor: simplify and remove duplicate code across operations files
* Consolidate installation check logic using SettingsManager methods * Simplify component retrieval by delegating to SettingsManager * Add 'all' components shorthand support in installer
This commit is contained in:
parent
f7311bf480
commit
379908a797
@ -12,8 +12,7 @@ from datetime import datetime
|
||||
from typing import List, Optional, Dict, Any, Tuple
|
||||
import argparse
|
||||
|
||||
from ..core.settings_manager import SettingsManager
|
||||
from ..core.file_manager import FileManager
|
||||
from ..managers.settings_manager import SettingsManager
|
||||
from ..utils.ui import (
|
||||
display_header, display_info, display_success, display_error,
|
||||
display_warning, Menu, confirm, ProgressBar, Colors, format_size
|
||||
@ -138,8 +137,10 @@ def get_backup_directory(args: argparse.Namespace) -> Path:
|
||||
|
||||
|
||||
def check_installation_exists(install_dir: Path) -> bool:
|
||||
"""Check if SuperClaude installation exists"""
|
||||
return install_dir.exists() and (install_dir / "settings.json").exists()
|
||||
"""Check if SuperClaude installation (v2 included) exists"""
|
||||
settings_manager = SettingsManager(install_dir)
|
||||
|
||||
return settings_manager.check_installation_exists() or settings_manager.check_v2_installation_exists()
|
||||
|
||||
|
||||
def get_backup_info(backup_path: Path) -> Dict[str, Any]:
|
||||
|
||||
@ -11,7 +11,7 @@ import argparse
|
||||
|
||||
from ..base.installer import Installer
|
||||
from ..core.registry import ComponentRegistry
|
||||
from ..core.config_manager import ConfigManager
|
||||
from ..managers.config_manager import ConfigManager
|
||||
from ..core.validator import Validator
|
||||
from ..utils.ui import (
|
||||
display_header, display_info, display_success, display_error,
|
||||
@ -137,6 +137,8 @@ def get_components_to_install(args: argparse.Namespace, registry: ComponentRegis
|
||||
|
||||
# Explicit components specified
|
||||
if args.components:
|
||||
if 'all' in args.components:
|
||||
return ["core", "commands", "hooks", "mcp"]
|
||||
return args.components
|
||||
|
||||
# Profile-based selection
|
||||
|
||||
@ -10,8 +10,8 @@ from typing import List, Optional, Dict, Any
|
||||
import argparse
|
||||
|
||||
from ..core.registry import ComponentRegistry
|
||||
from ..core.settings_manager import SettingsManager
|
||||
from ..core.file_manager import FileManager
|
||||
from ..managers.settings_manager import SettingsManager
|
||||
from ..managers.file_manager import FileManager
|
||||
from ..utils.ui import (
|
||||
display_header, display_info, display_success, display_error,
|
||||
display_warning, Menu, confirm, ProgressBar, Colors
|
||||
@ -89,28 +89,11 @@ Examples:
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def check_installation_exists(install_dir: Path) -> bool:
|
||||
"""Check if SuperClaude is installed"""
|
||||
settings_file = install_dir / "settings.json"
|
||||
return settings_file.exists() and install_dir.exists()
|
||||
|
||||
|
||||
def get_installed_components(install_dir: Path) -> Dict[str, str]:
|
||||
def get_installed_components(install_dir: Path) -> Dict[str, Dict[str, Any]]:
|
||||
"""Get currently installed components and their versions"""
|
||||
try:
|
||||
settings_manager = SettingsManager(install_dir)
|
||||
components = {}
|
||||
|
||||
# Check for framework configuration in metadata
|
||||
framework_config = settings_manager.get_metadata_setting("framework")
|
||||
if framework_config and "components" in framework_config:
|
||||
for component_name in framework_config["components"]:
|
||||
version = settings_manager.get_component_version(component_name)
|
||||
if version:
|
||||
components[component_name] = version
|
||||
|
||||
return components
|
||||
return settings_manager.get_installed_components()
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
@ -11,8 +11,7 @@ import argparse
|
||||
|
||||
from ..base.installer import Installer
|
||||
from ..core.registry import ComponentRegistry
|
||||
from ..core.config_manager import ConfigManager
|
||||
from ..core.settings_manager import SettingsManager
|
||||
from ..managers.settings_manager import SettingsManager
|
||||
from ..core.validator import Validator
|
||||
from ..utils.ui import (
|
||||
display_header, display_info, display_success, display_error,
|
||||
@ -85,28 +84,17 @@ Examples:
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def check_installation_exists(install_dir: Path) -> bool:
|
||||
"""Check if SuperClaude is installed"""
|
||||
settings_file = install_dir / "settings.json"
|
||||
return settings_file.exists()
|
||||
"""Check if SuperClaude installation exists"""
|
||||
settings_manager = SettingsManager(install_dir)
|
||||
|
||||
return settings_manager.check_installation_exists()
|
||||
|
||||
def get_installed_components(install_dir: Path) -> Dict[str, str]:
|
||||
def get_installed_components(install_dir: Path) -> Dict[str, Dict[str, Any]]:
|
||||
"""Get currently installed components and their versions"""
|
||||
try:
|
||||
settings_manager = SettingsManager(install_dir)
|
||||
components = {}
|
||||
|
||||
# Check for framework configuration in metadata
|
||||
framework_config = settings_manager.get_metadata_setting("framework")
|
||||
if framework_config and "components" in framework_config:
|
||||
for component_name in framework_config["components"]:
|
||||
version = settings_manager.get_component_version(component_name)
|
||||
if version:
|
||||
components[component_name] = version
|
||||
|
||||
return components
|
||||
return settings_manager.get_installed_components()
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user