-
Notifications
You must be signed in to change notification settings - Fork 142
Structurally refactor Site class into Facade and separate Managers #2775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* Decouple monolithic Site god class. * Organize classes in Site/index.ts for git history, tracking before evict to separate files. * Extract responsibilities into dedicated manager classes - `SiteAssetsManager` - `SitePagesManager` (handling page collection and generation logic) - `SiteDeployManager` - `SiteGenerationManager` (orchestrating the build process) - Refactor `Site` class as Facade, delegate logic to underlying managers - Maintain public API compatibility for now.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2775 +/- ##
==========================================
+ Coverage 62.30% 63.17% +0.87%
==========================================
Files 130 133 +3
Lines 7184 7265 +81
Branches 1580 1512 -68
==========================================
+ Hits 4476 4590 +114
+ Misses 2644 2611 -33
Partials 64 64 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5c66e94 to
3f72158
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the monolithic Site class into a facade pattern with specialized manager classes, improving code maintainability and separation of concerns without breaking the public API.
Changes:
- Introduced four new manager classes to handle distinct responsibilities:
SiteAssetsManager,SitePagesManager,SiteDeployManager, andSiteGenerationManager - Refactored the
Siteclass as a facade that delegates to these managers while maintaining backward compatibility - Moved constants to a centralized location and reorganized test files to match the new structure
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/Site/index.ts | Refactored Site class as facade delegating to manager classes |
| packages/core/src/Site/SitePagesManager.ts | New manager handling page creation and collection logic |
| packages/core/src/Site/SiteGenerationManager.ts | New manager orchestrating build process and page generation |
| packages/core/src/Site/SiteDeployManager.ts | New manager handling deployment operations |
| packages/core/src/Site/SiteAssetsManager.ts | New manager handling asset operations (CSS, JS, fonts, images) |
| packages/core/src/Site/constants.ts | Added new constants extracted from Site class |
| packages/core/test/unit/Site.test.ts | Removed old monolithic test file |
| packages/core/test/unit/Site/Site.test.ts | New test file for refactored Site facade |
| packages/core/test/unit/Site/SitePagesManager.test.ts | New test file for SitePagesManager |
| packages/core/test/unit/Site/SiteGenerationManager.test.ts | New test file for SiteGenerationManager |
| packages/core/test/unit/Site/SiteDeployManager.test.ts | New test file for SiteDeployManager |
| packages/core/test/unit/Site/SiteAssetsManager.test.ts | New test file for SiteAssetsManager |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Removed internal and unused delegation methods from Site class. - Methods delegated without being used by CLI or external consumers removed. - Properties representing internal states (getters) removed as they break encapsulation and are unused. - This enforces the Facade pattern by hiding implementation details and ensure Site object does not act as "God Class" exposing internal helpers. - Consumers can now clearly see the key interfaces intended for public use. - Removed associated unit tests and Jest mocks for the deleted facade methods in testcases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What is the purpose of this pull request?
Overview of changes:
Closes #2774
Closes #1756
Anything you'd like to highlight/discuss:
The
Siteclass had become a "God Class" with many responsibilities, making it hard to maintain and test.This PR refactors and decouples the monolithic Site god class class into a Facade provided by Site/index.ts. It delegates responsibilities to four newly created manager classes (SiteAssetsManager, SitePagesManager, SiteDeployManager, and SiteGenerationManager), which are currently defined within the same file.
SiteAssetsManager: Asset handling (copying, building, removing).SitePagesManager: Page collection and dependency management.SiteDeployManager: GH Pages and others deployment logic.SiteGenerationManager: Core build orchestration (generate, rebuild, lazy loading).Siteclass as Facade, delegate logic to underlying managersAdditionally, using
Siteclass as a Facade now enables us to hide some of the methods that are not used and not overexpose internal methods. Instead, we can easily see the key interfaces thecorepackage (Siteobject) exposes for consumers to use.Testing instructions:
npm run testProposed commit message: (wrap lines at 72 characters)
Rebase and Merge
to preserve commit history as much as possible
Checklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major,r.Minor,r.Patch.Breaking change release note preparation (if applicable):