Skip to content

refactor(cli): ♻️ separate UI logic into dedicated module#40

Merged
YagoBorba merged 2 commits into
developfrom
refactor/separate-ui-logic
Aug 7, 2025
Merged

refactor(cli): ♻️ separate UI logic into dedicated module#40
YagoBorba merged 2 commits into
developfrom
refactor/separate-ui-logic

Conversation

@YagoBorba
Copy link
Copy Markdown
Owner

📋 Description

This PR executes a significant architectural refactoring of the CLI commands. It separates the business logic and orchestration from the UI logic (user prompts and console logging) by introducing a dedicated UI module located at packages/cli/src/ui.ts.

This change dramatically improves code quality, testability, and maintainability by adhering to the Single Responsibility Principle. Command files are now cleaner and focused on what to do, while the ui.ts module handles how to interact with the user.

🔗 Related Issue

Fixes #25

🧪 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🔧 Configuration change
  • 🧹 Code cleanup
  • ♻️ Refactoring

📝 How Has This Been Tested?

  • Unit tests pass: The entire existing test suite was run to ensure no regressions were introduced.
  • Manual testing completed: Manually executed the primary flows of init, generate, git, release, and config to verify that the refactored UI prompts and logs behave identically to the previous implementation.
  • CI/CD pipeline passes: The build and test jobs complete successfully.

✅ Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellspellings

🔄 Dependencies

None.

📚 Additional Notes

This refactoring significantly improves the testability of the CLI commands. Future unit tests can now mock the ui.ts module as a whole, rather than mocking inquirer and console.log individually, leading to cleaner and more robust tests.

Issue Reference: Closes #25

@YagoBorba YagoBorba merged commit 2189465 into develop Aug 7, 2025
4 checks passed
@YagoBorba YagoBorba deleted the refactor/separate-ui-logic branch August 7, 2025 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor CLI Commands to Separate UI Logic

3 participants