-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: site and server CRUD improvements #60
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| use Bigpixelrocket\DeployerPHP\Contracts\BaseCommand; | ||
| use Bigpixelrocket\DeployerPHP\DTOs\SiteDTO; | ||
| use Bigpixelrocket\DeployerPHP\Traits\ServerHelpersTrait; | ||
| use Bigpixelrocket\DeployerPHP\Traits\SiteHelpersTrait; | ||
| use Bigpixelrocket\DeployerPHP\Traits\SiteValidationTrait; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
|
|
@@ -22,6 +23,7 @@ | |
| #[AsCommand(name: 'site:add', description: 'Add a new site to the inventory')] | ||
| class SiteAddCommand extends BaseCommand | ||
| { | ||
| use ServerHelpersTrait; | ||
| use SiteHelpersTrait; | ||
| use SiteValidationTrait; | ||
|
|
||
|
|
@@ -35,10 +37,10 @@ protected function configure(): void | |
|
|
||
| $this | ||
| ->addOption('domain', null, InputOption::VALUE_REQUIRED, 'Domain name') | ||
| ->addOption('type', null, InputOption::VALUE_REQUIRED, 'Site type: git or local') | ||
| ->addOption('source', null, InputOption::VALUE_REQUIRED, 'Site source: git or local') | ||
| ->addOption('repo', null, InputOption::VALUE_REQUIRED, 'Git repository URL (for git sites)') | ||
| ->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Git branch name (for git sites)') | ||
| ->addOption('servers', null, InputOption::VALUE_REQUIRED, 'Comma-separated server names'); | ||
| ->addOption('server', null, InputOption::VALUE_REQUIRED, 'Server name'); | ||
| } | ||
|
|
||
| // | ||
|
|
@@ -50,23 +52,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
| parent::execute($input, $output); | ||
|
|
||
| $this->io->hr(); | ||
|
|
||
| $this->io->h1('Add New Site'); | ||
|
|
||
| // | ||
| // Check if there are any servers | ||
|
|
||
| if (count($this->servers->all()) === 0) { | ||
| $this->io->warning('No servers available'); | ||
| $this->io->writeln([ | ||
| '', | ||
| 'You must add at least one server before adding a site.', | ||
| 'Run <fg=cyan>server:provision</> to provision your first server,', | ||
| 'or run <fg=cyan>server:add</> to add an existing server.', | ||
| '', | ||
| ]); | ||
| // Select server | ||
|
|
||
| return Command::FAILURE; | ||
| $server = $this->selectServer(); | ||
|
|
||
| if (is_int($server)) { | ||
| return $server; | ||
| } | ||
|
Comment on lines
+60
to
64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify selectServer() return values for proper error handling. The current code correctly propagates the integer status from 🏁 Script executed: #!/bin/bash
# Check selectServer() implementation to verify return values
ast-grep --pattern $'function selectServer($$$) {
$$$
}'Length of output: 0 🏁 Script executed: #!/bin/bash
# Find ServerHelpersTrait file
fd -t f "ServerHelpersTrait" --type fLength of output: 33 🏁 Script executed: #!/bin/bash
# Search for selectServer function definition
rg -n "function selectServer" --type php -A 20Length of output: 1437 🏁 Script executed: #!/bin/bash
# Also search for selectServer calls to understand usage
rg -n "selectServer" --type php -B 2 -A 2Length of output: 1092 🏁 Script executed: #!/bin/bash
# Find ensureServersAvailable() implementation
rg -n "function ensureServersAvailable" --type php -A 15Length of output: 1157 🏁 Script executed: #!/bin/bash
# Look for any warnings or messages about "no servers" or "must add"
rg -n "must add\|no servers" --type php -i -B 2 -A 2Length of output: 0 Fix The verification confirms a critical issue: 🤖 Prompt for AI Agents |
||
|
|
||
| // | ||
|
|
@@ -89,19 +83,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
| } | ||
|
|
||
| // | ||
| // Select site type | ||
| // Select site source | ||
|
|
||
| /** @var string $siteType */ | ||
| $siteType = $this->io->getOptionOrPrompt( | ||
| 'type', | ||
| /** @var string $siteSource */ | ||
| $siteSource = $this->io->getOptionOrPrompt( | ||
| 'source', | ||
| fn (): string => (string) $this->io->promptSelect( | ||
| label: 'Deploy from:', | ||
| options: ['git' => 'Git Repository', 'local' => 'Local files'], | ||
| default: 'git' | ||
| ) | ||
| ); | ||
|
|
||
| $isLocal = $siteType === 'local'; | ||
| $isLocal = $siteSource === 'local'; | ||
|
|
||
| // | ||
| // Gather git-specific details | ||
|
|
@@ -149,36 +143,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
| } | ||
| } | ||
|
|
||
| // | ||
| // Select servers | ||
|
|
||
| try { | ||
| $selectedServers = $this->selectServers(); | ||
| } catch (\RuntimeException $e) { | ||
| $this->io->error($e->getMessage()); | ||
|
|
||
| return Command::FAILURE; | ||
| } | ||
|
|
||
| // | ||
| // Validate selections | ||
|
|
||
| try { | ||
| $this->validateServers($selectedServers); | ||
| } catch (\RuntimeException $e) { | ||
| $this->io->error($e->getMessage()); | ||
|
|
||
| return Command::FAILURE; | ||
| } | ||
|
|
||
| // | ||
| // Create DTO and display site info | ||
|
|
||
| $site = new SiteDTO( | ||
| domain: $domain, | ||
| repo: $repo, | ||
| branch: $branch, | ||
| servers: $selectedServers | ||
| servers: [$server->name] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainClarify single-server design decision. The change from multi-server to single-server selection is significant. While this may simplify the UX, users who previously added a site to multiple servers in one command will now need multiple invocations. Is this intentional? Will users be able to add the same site to multiple servers easily, or is this a breaking change that should be documented? 🌐 Web query: 💡 Result: Do you mean the Deployer (deployer.org / deployerphp) project or the “Deployer for Git” WordPress plugin — or another "deployer-php" repo? If you tell me which repository or provide a link, I’ll search the project issues/roadmap and report any planned follow-up command/feature for multi‑server site management (with citations). I need to search the repository more specifically. Let me explore the codebase to understand the design decision and look for any documentation or issues about multi-server support. Length of output: 3150 🏁 Script executed: #!/bin/bash
# Check for any comments or TODOs about multi-server support
rg -n "TODO|FIXME|multi.*server|multi-server" --type=php | head -30Length of output: 0 🏁 Script executed: #!/bin/bash
# Look for git history or comments explaining the change
git log -n 20 --oneline -- app/Console/Site/SiteAddCommand.php 2>/dev/null || echo "Git history not available"Length of output: 169 🏁 Script executed: #!/bin/bash
# Search for issues or feature discussions in common locations
find . -type f \( -name "*.md" -o -name "CHANGELOG*" -o -name "TODO*" -o -name ".github" \) -exec grep -l "multi.*server\|SiteAdd" {} \; 2>/dev/null | head -10Length of output: 0 Length of output: 20 🏁 Script executed: #!/bin/bash
# Get full SiteAddCommand.php to see complete context
cat app/Console/Site/SiteAddCommand.php | head -200Length of output: 5569 🏁 Script executed: #!/bin/bash
# Search for other site commands to see if multi-server is handled elsewhere
fd "Site.*Command.php" --type=f | xargs ls -la 2>/dev/nullLength of output: 258 🏁 Script executed: #!/bin/bash
# Look for Site management services that might handle multi-server
rg -n "class.*Service.*Site\|function.*addSite\|function.*createSite" --type=php -A3 | head -40Length of output: 0 Length of output: 936 🏁 Script executed: #!/bin/bash
# Find and inspect SiteRepository.create() method
rg -n "class SiteRepository\|function create\|public function create" --type=php -A15 app/Repositories/SiteRepository.php 2>/dev/null | head -60Length of output: 0 🏁 Script executed: #!/bin/bash
# Check SiteDeleteCommand to see if it handles multi-server deletes
cat app/Console/Site/SiteDeleteCommand.phpLength of output: 3215 🏁 Script executed: #!/bin/bash
# Look at git diff for the refactor commit to understand what changed
git show 97b52bd --stat 2>/dev/null | head -30Length of output: 733 Length of output: 4894 🏁 Script executed: #!/bin/bash
# Search for any edit/update site command or mechanism
fd "SiteUpdateCommand\|SiteEditCommand\|updateSite\|editSite" --type=fLength of output: 0 🏁 Script executed: #!/bin/bash
# Search for any way to modify existing sites (add servers, etc.)
rg -n "class.*Site.*\|update.*site\|edit.*site\|add.*server.*site" --type=php -i | grep -v "test\|Test" | head -20Length of output: 0 🏁 Script executed: #!/bin/bash
# Check if there are any comments in code about multi-server or server list
rg -n "servers|multiple.*server" app/Console/Site/ --type=php -B2 -A2 | head -40Length of output: 302 Document the single-server limitation or provide a migration path. The refactor intentionally changed Either document this limitation explicitly in help text or CHANGELOG, or add a |
||
| ); | ||
|
|
||
| $this->io->hr(); | ||
|
|
@@ -204,8 +176,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
|
|
||
| $hintOptions = [ | ||
| 'domain' => $domain, | ||
| 'type' => $siteType, | ||
| 'servers' => implode(',', $selectedServers), | ||
| 'source' => $siteSource, | ||
| 'server' => $server->name, | ||
| ]; | ||
|
|
||
| if (!$isLocal) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.