mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-23 12:46:33 +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
|
from typing import List, Optional, Dict, Any, Tuple
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ..core.settings_manager import SettingsManager
|
from ..managers.settings_manager import SettingsManager
|
||||||
from ..core.file_manager import FileManager
|
|
||||||
from ..utils.ui import (
|
from ..utils.ui import (
|
||||||
display_header, display_info, display_success, display_error,
|
display_header, display_info, display_success, display_error,
|
||||||
display_warning, Menu, confirm, ProgressBar, Colors, format_size
|
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:
|
def check_installation_exists(install_dir: Path) -> bool:
|
||||||
"""Check if SuperClaude installation exists"""
|
"""Check if SuperClaude installation (v2 included) exists"""
|
||||||
return install_dir.exists() and (install_dir / "settings.json").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]:
|
def get_backup_info(backup_path: Path) -> Dict[str, Any]:
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import argparse
|
|||||||
|
|
||||||
from ..base.installer import Installer
|
from ..base.installer import Installer
|
||||||
from ..core.registry import ComponentRegistry
|
from ..core.registry import ComponentRegistry
|
||||||
from ..core.config_manager import ConfigManager
|
from ..managers.config_manager import ConfigManager
|
||||||
from ..core.validator import Validator
|
from ..core.validator import Validator
|
||||||
from ..utils.ui import (
|
from ..utils.ui import (
|
||||||
display_header, display_info, display_success, display_error,
|
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
|
# Explicit components specified
|
||||||
if args.components:
|
if args.components:
|
||||||
|
if 'all' in args.components:
|
||||||
|
return ["core", "commands", "hooks", "mcp"]
|
||||||
return args.components
|
return args.components
|
||||||
|
|
||||||
# Profile-based selection
|
# Profile-based selection
|
||||||
|
|||||||
@ -10,8 +10,8 @@ from typing import List, Optional, Dict, Any
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ..core.registry import ComponentRegistry
|
from ..core.registry import ComponentRegistry
|
||||||
from ..core.settings_manager import SettingsManager
|
from ..managers.settings_manager import SettingsManager
|
||||||
from ..core.file_manager import FileManager
|
from ..managers.file_manager import FileManager
|
||||||
from ..utils.ui import (
|
from ..utils.ui import (
|
||||||
display_header, display_info, display_success, display_error,
|
display_header, display_info, display_success, display_error,
|
||||||
display_warning, Menu, confirm, ProgressBar, Colors
|
display_warning, Menu, confirm, ProgressBar, Colors
|
||||||
@ -89,28 +89,11 @@ Examples:
|
|||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def get_installed_components(install_dir: Path) -> Dict[str, Dict[str, Any]]:
|
||||||
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]:
|
|
||||||
"""Get currently installed components and their versions"""
|
"""Get currently installed components and their versions"""
|
||||||
try:
|
try:
|
||||||
settings_manager = SettingsManager(install_dir)
|
settings_manager = SettingsManager(install_dir)
|
||||||
components = {}
|
return settings_manager.get_installed_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
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,7 @@ import argparse
|
|||||||
|
|
||||||
from ..base.installer import Installer
|
from ..base.installer import Installer
|
||||||
from ..core.registry import ComponentRegistry
|
from ..core.registry import ComponentRegistry
|
||||||
from ..core.config_manager import ConfigManager
|
from ..managers.settings_manager import SettingsManager
|
||||||
from ..core.settings_manager import SettingsManager
|
|
||||||
from ..core.validator import Validator
|
from ..core.validator import Validator
|
||||||
from ..utils.ui import (
|
from ..utils.ui import (
|
||||||
display_header, display_info, display_success, display_error,
|
display_header, display_info, display_success, display_error,
|
||||||
@ -85,28 +84,17 @@ Examples:
|
|||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def check_installation_exists(install_dir: Path) -> bool:
|
def check_installation_exists(install_dir: Path) -> bool:
|
||||||
"""Check if SuperClaude is installed"""
|
"""Check if SuperClaude installation exists"""
|
||||||
settings_file = install_dir / "settings.json"
|
settings_manager = SettingsManager(install_dir)
|
||||||
return settings_file.exists()
|
|
||||||
|
|
||||||
|
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"""
|
"""Get currently installed components and their versions"""
|
||||||
try:
|
try:
|
||||||
settings_manager = SettingsManager(install_dir)
|
settings_manager = SettingsManager(install_dir)
|
||||||
components = {}
|
return settings_manager.get_installed_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
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user