Skip to content

Commit 28ef423

Browse files
committed
fix: display new database server credentials after provisioning during project initialization
1 parent fb13119 commit 28ef423

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Project/Initialization/DatabaseInitializationStep.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Ymir\Cli\Project\Initialization;
1515

1616
use Illuminate\Support\Collection;
17+
use Symfony\Component\Console\Helper\TableSeparator;
1718
use Ymir\Cli\ExecutionContext;
1819
use Ymir\Cli\Project\Configuration\ConfigurationChangeInterface;
1920
use Ymir\Cli\Project\Configuration\DatabaseConfigurationChange;
@@ -85,6 +86,16 @@ private function selectDatabaseServer(ExecutionContext $context, string $region)
8586
|| ($databaseServers->isEmpty() && $output->confirm(sprintf('Your team doesn\'t have any configured database servers in the "<comment>%s</comment>" region. Would you like to create one for this team first?', $region)))
8687
) {
8788
$databaseServer = $context->provision(DatabaseServer::class, ['region' => $region]);
89+
90+
if ($databaseServer instanceof DatabaseServer) {
91+
$output->important('Please write down the password shown below as it won\'t be displayed again. Ymir will inject it automatically whenever you assign this database server to a project. If you lose the password, use the "<comment>database:server:rotate-password</comment>" command to generate a new one.');
92+
$output->newLine();
93+
94+
$output->horizontalTable(
95+
['Database Sever', new TableSeparator(), 'Username', 'Password', new TableSeparator(), 'Type', 'Public', 'Storage (in GB)'],
96+
[[$databaseServer->getName(), new TableSeparator(), $databaseServer->getUsername(), $databaseServer->getPassword(), new TableSeparator(), $databaseServer->getType(), $output->formatBoolean($databaseServer->isPublic()), $databaseServer->getStorage() ?? 'N/A']]
97+
);
98+
}
8899
}
89100

90101
return $databaseServer instanceof DatabaseServer ? $databaseServer : null;

tests/Unit/Project/Initialization/DatabaseInitializationStepTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function testPerformProvisionsNewServerIfRequested(): void
6868
$this->apiClient->shouldReceive('getDatabaseServers')->once()->andReturn(new ResourceCollection([]));
6969
$this->output->shouldReceive('confirm')->with(\Mockery::pattern('/Your team doesn\'t have any configured database servers/'))->once()->andReturn(true);
7070
$this->context->shouldReceive('provision')->with(DatabaseServer::class, ['region' => 'us-east-1'])->once()->andReturn($databaseServer);
71+
$this->output->shouldReceive('important')->once()->with(\Mockery::pattern('/Please write down the password shown below/'));
72+
$this->output->shouldReceive('newLine')->once();
73+
$this->output->shouldReceive('horizontalTable')->once();
74+
$this->output->shouldReceive('formatBoolean')->once()->with(false)->andReturn('no');
7175
$this->output->shouldReceive('askSlug')->once()->andReturn('prefix_');
7276
$this->output->shouldReceive('warning')->once();
7377

0 commit comments

Comments
 (0)