refactor: site remove local source support - #87
Conversation
Remove isLocal() method and make repo/branch properties required strings. Update SiteRepository to always store and load repo/branch data.
Remove isLocal() conditional logic and always display Git as source type.
Remove --source option and always collect Git repository details. Simplify command flow by eliminating local vs git branching.
WalkthroughThe pull request eliminates local deployment support, consolidating to a git-only model. It removes the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/Console/Site/SiteAddCommand.php (1)
152-152: Consider handling when git detection returns null.Line 152 sets
$defaultRepo = $this->git->detectRemoteUrl() ?? '', which means an empty string will be used as the default if detection fails. This could result in a confusing UX where the prompt shows an empty default.Consider providing a more helpful placeholder or informing the user when detection fails:
-$defaultRepo = $this->git->detectRemoteUrl() ?? ''; +$detectedRepo = $this->git->detectRemoteUrl(); +$defaultRepo = $detectedRepo ?? ''; + +if ($detectedRepo === null) { + $this->io->note('Could not detect git repository. Please enter manually.'); +}Alternatively, you could omit the
defaultparameter when detection fails to avoid showing an empty default.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/Console/Site/SiteAddCommand.php(4 hunks)app/DTOs/SiteDTO.php(1 hunks)app/Repositories/SiteRepository.php(1 hunks)app/Traits/SitesTrait.php(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.php
📄 CodeRabbit inference engine (.cursor/rules/00-main.mdc)
**/*.php: Eliminate single-use methods: inline if a method is called only once
Cache computed values: initialize expensive calculations in the constructor
Avoid method call overhead: prefer direct property access when appropriate
Files:
app/Traits/SitesTrait.phpapp/DTOs/SiteDTO.phpapp/Console/Site/SiteAddCommand.phpapp/Repositories/SiteRepository.php
🔇 Additional comments (13)
app/Traits/SitesTrait.php (1)
113-118: LGTM! Clean removal of local/git branching.The uniform initialization of the details array correctly reflects the git-only model. The hardcoded
'Source' => 'Git'aligns with the PR objective to remove local source support.app/DTOs/SiteDTO.php (2)
13-14: LGTM! Documentation correctly reflects non-nullable types.The docblock updates accurately reflect the constructor signature changes for
repoandbranch.
19-20: Type change from?stringtostringis valid; empty strings are prevented at creation.The validators in
SitesTrait.php(lines 165-173, 183-191) enforce that bothrepoandbranchcannot be empty strings—they checktrim($value) === ''and reject accordingly. New sites created viaSiteAddCommandgo through these validators.The
SiteRepository::hydrateSiteDTOmethod defaults to empty strings only when loading from existing inventory data that may lack these fields. This is a safe defensive pattern: empty strings represent missing legacy data, not invalid new sites. The type change to non-nullablestringis correct because:
- Empty strings are still non-null values
- Creation paths enforce non-empty via validation
- Load paths handle missing data gracefully with empty string fallbacks
app/Repositories/SiteRepository.php (5)
170-170: LGTM! Documentation accurately reflects the uniform data structure.The docblock correctly indicates that
repoandbranchare always included in the serialized output.
174-179: LGTM! Simplified serialization logic.The uniform serialization correctly reflects the git-only model by always including
repoandbranchin the stored data.
186-186: LGTM! Clear documentation of fallback behavior.The docblock explicitly documents that
repoandbranchdefault to empty strings when missing, which aligns with the implementation.
191-192: Consider validation for empty string defaults.The defaults to empty strings for missing
repoandbranchvalues are consistent with the non-nullable contract, but may allow invalid sites to be hydrated from corrupted or legacy inventory data.This relates to the validation concern raised in
SiteDTO.php(lines 19-20). Consider whether hydration should:
- Accept empty strings as valid fallbacks, or
- Throw an exception or log a warning when required fields are missing
197-198: Good defensive type checking.The
is_string()checks provide additional safety against corrupted inventory data, though empty strings remain possible as discussed in lines 191-192.app/Console/Site/SiteAddCommand.php (5)
34-36: LGTM! Command options correctly reflect git-only model.The removal of
siteSourceand the retention ofrepoandbranchoptions align with the PR objective to consolidate to git-based deployments.
97-102: LGTM! Command replay correctly reflects updated options.The replay hint now includes
repoandbranchwithoutsiteSource, matching the new command signature.
114-114: LGTM! Return type accurately reflects git-only structure.The updated return type correctly shows non-nullable
repoandbranchstrings withoutsiteSource.
154-188: LGTM! Comprehensive validation ensures non-empty values.The git details gathering flow correctly:
- Validates repo and branch using the trait's validation methods
- Ensures non-empty strings through
validateSiteRepoandvalidateSiteBranch- Handles null returns from prompts appropriately
- Provides sensible defaults ('main' for branch when detection fails)
This validation ensures that empty strings flagged in
SiteDTO.phpandSiteRepository.phpreviews can only occur from legacy/corrupted inventory data, not from the creation flow.
190-195: LGTM! Return structure matches type annotation.The return statement correctly provides all required fields matching the updated return type on line 114.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor