Skip to content

Refactor: Reorganize code into modular command and utility structure#33

Open
wirwolf wants to merge 2 commits intomasterfrom
claude/refactor-app-structure-vZ5LN
Open

Refactor: Reorganize code into modular command and utility structure#33
wirwolf wants to merge 2 commits intomasterfrom
claude/refactor-app-structure-vZ5LN

Conversation

@wirwolf
Copy link
Contributor

@wirwolf wirwolf commented Feb 6, 2026

Summary

This PR refactors the codebase to improve modularity and maintainability by breaking down monolithic classes into focused, single-responsibility modules organized by feature and concern.

Key Changes

Structural Reorganization

  • Removed monolithic classes: Deleted Logic.ts and Helpers.ts which contained mixed concerns
  • Created command modules: Extracted command handlers into dedicated files:
    • src/commands/download.ts - Secret download functionality
    • src/commands/checkDiff.ts - Diff checking functionality
    • src/commands/apply.ts - Change application functionality
    • src/commands/common.ts - Shared command utilities

Utility Extraction

  • Created utility modules for better code organization:
    • src/utils/diff.ts - Deep diff mapping logic (moved from Helpers.ts)
    • src/utils/file.ts - JSON file I/O operations (moved from Helpers.ts)
    • src/utils/process.ts - Child process execution utilities (moved from Helpers.ts)

Service Refactoring

  • Renamed VaultUtility to VaultService for clarity and consistency
  • Updated imports in VaultService.ts to use new utility functions instead of Helpers class methods

Entry Point Updates

  • Updated src/App.ts to import command functions directly instead of using Logic class methods
  • Removed .bind(this) calls as functions are now standalone exports rather than class methods

Benefits

  • Improved testability: Smaller, focused modules are easier to unit test
  • Better code organization: Clear separation of concerns with dedicated directories for commands and utilities
  • Reduced coupling: Removed dependency on monolithic helper classes
  • Enhanced maintainability: Easier to locate and modify specific functionality

https://claude.ai/code/session_01KWCApFXhxZ6HqyYy9zoDUE

Split the flat src/ structure into organized directories:
- commands/ — individual command handlers (download, checkDiff, apply, common)
- services/ — vault interaction layer (VaultService, VaultNormalizer)
- utils/ — generic utilities (diff, process, file)

Removed monolithic Helpers.ts and Logic.ts in favor of focused,
single-responsibility modules. Updated test imports accordingly.

https://claude.ai/code/session_01KWCApFXhxZ6HqyYy9zoDUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants