Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Commands/Init/BaseInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ public function initializeConfigRepo(string $repo_dir, InputInterface $input, Ou
// Setup remote URL
$configRemoteUrl = $preExistingRemoteUrl ?: Git::RemoteUrl($configrepo);
if (!$configRemoteUrl) {
$question = new Question('What is the remote git URL for your config repo? (optional)', false);
$output->writeln('');
$output->writeln(" <fg=gray>If you have a remote repository for your config, enter the URL below.</>");
$output->writeln('');
$question = new Question(' Config repo GitHub URL: ', false);
$configRemoteUrl = $helper->ask($input, $output, $question);

if ($configRemoteUrl) {
Expand Down
64 changes: 51 additions & 13 deletions src/Commands/ProtocolInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,32 +273,70 @@ protected function flowExistingProject(
$helper,
SymfonyStyle $io
): int {
$totalSteps = 4;
$hasDockerCompose = file_exists(rtrim($repo_dir, '/') . '/docker-compose.yml');
$totalSteps = $hasDockerCompose ? 4 : 5;
$step = 0;

// Step 1: Project type + scaffold
$this->writeStep($output, 1, $totalSteps, 'Project Type');
$output->writeln(" <fg=gray>Choose the Docker base image for your project. This determines</>");
$output->writeln(" <fg=gray>which PHP version, extensions, and tools are available.</>");
// Step: Repository URL
$this->writeStep($output, ++$step, $totalSteps, 'Repository');
$output->writeln(" <fg=gray>Tell us the GitHub URL for your existing repository.</>");
$output->writeln('');
$selectedInitializer = $this->selectProjectType($input, $output, $helper);
$selectedInitializer->initialize($repo_dir, $input, $output, $helper);

$existingRemote = Git::RemoteUrl($repo_dir);
$defaultRemote = $existingRemote ?: '';

$question = new Question(
' GitHub URL: ' . ($defaultRemote ? "[<fg=green>{$defaultRemote}</>] " : ''),
$defaultRemote
);
$gitRemote = $helper->ask($input, $output, $question);

if ($gitRemote) {
// Set or update the remote
if (!$existingRemote) {
Shell::run("git -C " . escapeshellarg($repo_dir) . " remote add origin " . escapeshellarg($gitRemote) . " 2>/dev/null");
} elseif ($existingRemote !== $gitRemote) {
Shell::run("git -C " . escapeshellarg($repo_dir) . " remote set-url origin " . escapeshellarg($gitRemote) . " 2>/dev/null");
}
$output->writeln('');
$output->writeln(" <fg=green>✓</> Remote: <fg=white>{$gitRemote}</>");
} else {
$output->writeln('');
$output->writeln(" <fg=yellow>!</> No URL provided — skipping remote setup");
}

// Step: Project type + scaffold (only if no docker-compose.yml exists)
if (!$hasDockerCompose) {
$this->writeStep($output, ++$step, $totalSteps, 'Project Type');
$output->writeln(" <fg=gray>Choose the Docker base image for your project. This determines</>");
$output->writeln(" <fg=gray>which PHP version, extensions, and tools are available.</>");
$output->writeln('');
$selectedInitializer = $this->selectProjectType($input, $output, $helper);
$selectedInitializer->initialize($repo_dir, $input, $output, $helper);
} else {
$output->writeln('');
$output->writeln(" <fg=green>✓</> Existing docker-compose.yml detected — keeping current container config");
$initializers = $this->getAvailableInitializers();
$selectedInitializer = reset($initializers);
}

$selectedKey = $this->getInitializerKey($selectedInitializer);
$selectedInitializer->createProtocolJson($repo_dir, $selectedKey, $output, self::SCHEMA_VERSION);

// Step 2: Deployment strategy
$this->writeStep($output, 2, $totalSteps, 'Deployment Strategy');
// Step: Deployment strategy
$this->writeStep($output, ++$step, $totalSteps, 'Deployment Strategy');
$output->writeln(" <fg=gray>This controls how code gets to your servers. Release-based</>");
$output->writeln(" <fg=gray>creates tagged versions you can roll back. Branch-based</>");
$output->writeln(" <fg=gray>just follows the tip of a branch.</>");
$output->writeln('');
$this->configureDeploymentStrategy($repo_dir, $input, $output, $helper);

// Step 3: Secrets
$this->writeStep($output, 3, $totalSteps, 'Secrets Management');
// Step: Secrets
$this->writeStep($output, ++$step, $totalSteps, 'Secrets Management');
$this->configureSecrets($repo_dir, $input, $output, $helper);

// Step 4: Config repo
$this->writeStep($output, 4, $totalSteps, 'Configuration Repository');
// Step: Config repo
$this->writeStep($output, ++$step, $totalSteps, 'Configuration Repository');
$this->configureConfigRepo($repo_dir, $input, $output, $helper, $selectedInitializer);

// Done
Expand Down
Loading