Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(deployments): add log copying functionality to clipboard in dev

Andras Bacsaid63802e03d16
diff --git a/app/Livewire/Project/Application/DeploymentNavbar.php b/app/Livewire/Project/Application/DeploymentNavbar.php
index dccd1e4996..ebdc014ae1 100644
--- a/app/Livewire/Project/Application/DeploymentNavbar.php
+++ b/app/Livewire/Project/Application/DeploymentNavbar.php
@@ -50,6 +50,28 @@ class DeploymentNavbar extends Component
}
}
+ public function copyLogsToClipboard(): string
+ {
+ $logs = json_decode($this->application_deployment_queue->logs, associative: true, flags: JSON_THROW_ON_ERROR);
+
+ if (! $logs) {
+ return '';
+ }
+
+ $markdown = "# Deployment Logs\n\n";
+ $markdown .= "```\n";
+
+ foreach ($logs as $log) {
+ if (isset($log['output'])) {
+ $markdown .= $log['output']."\n";
+ }
+ }
+
+ $markdown .= "```\n";
+
+ return $markdown;
+ }
+
public function cancel()
{
$deployment_uuid = $this->application_deployment_queue->deployment_uuid;
diff --git a/resources/views/livewire/project/application/deployment-navbar.blade.php b/resources/views/livewire/project/application/deployment-navbar.blade.php
index effb6b6fe5..60c660bf75 100644
--- a/resources/views/livewire/project/application/deployment-navbar.blade.php
+++ b/resources/views/livewire/project/application/deployment-navbar.blade.php
@@ -5,6 +5,9 @@
@else
<x-forms.button wire:click.prevent="show_debug">Show Debug Logs</x-forms.button>
@endif
+ @if (isDev())
+ <x-forms.button x-on:click="$wire.copyLogsToClipboard().then(text => navigator.clipboard.writeText(text))">Copy Logs</x-forms.button>
+ @endif
@if (data_get($application_deployment_queue, 'status') === 'queued')
<x-forms.button wire:click.prevent="force_start">Force Start</x-forms.button>
@endif