Skip to content

Commit f74681f

Browse files
committed
Show logs for v3 deploys
1 parent 24be244 commit f74681f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/BrefCloudClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public function startDeployment(int $deploymentId): void
9999
* message: string,
100100
* error_message: string|null,
101101
* url: string,
102+
* app_url: string|null,
103+
* logs: list<array{line: string, timestamp: int}>,
102104
* outputs?: array<string, string>,
103105
* }
104106
*

src/Commands/Deploy.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
115115

116116
IO::writeln("<href={$deployment['url']}>" . Styles::gray($deployment['url']) . '</>');
117117

118-
if ($config['type'] === 'serverless-framework') {
118+
$isServerlessFrameworkDeploy = $config['type'] === 'serverless-framework';
119+
120+
if ($isServerlessFrameworkDeploy) {
119121
if ($credentials === null) {
120122
IO::spinError();
121123
throw new Exception('Internal error: Bref Cloud did not provide AWS credentials, it should have in its response. Please report this issue.');
@@ -146,10 +148,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
146148
}
147149

148150
$startTime = time();
151+
$deployLogs = [];
149152

150153
// Timeout after 15 minutes
151154
while (time() - $startTime < 15 * 60) {
152155
$deployment = $brefCloud->getDeployment($deploymentId);
156+
157+
// Logs
158+
if (! $isServerlessFrameworkDeploy) {
159+
// Diff between all the deployment logs and the ones we already know about
160+
$newLogs = array_slice($deployment['logs'], count($deployLogs));
161+
IO::verbose(array_map(fn ($record) => $record['line'], $newLogs));
162+
$deployLogs = $deployment['logs'];
163+
}
164+
153165
if ($deployment['status'] === 'success') {
154166
IO::spinSuccess($deployment['message'], $deployment['app_url'] ?? null);
155167
return 0;
@@ -163,6 +175,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
163175
]);
164176
return 1;
165177
}
178+
166179
delay(1);
167180
}
168181

0 commit comments

Comments
 (0)