Skip to content

Commit

Permalink
Show asset domain in output (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon authored Oct 11, 2022
1 parent c4d8c04 commit ac6be7d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Commands/DeployCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ protected function buildProject(array $project)
*/
protected function assetDomain(array $project)
{
if ($this->usesCloudFront() && $domain = $this->customAssetDomain()) {
return "https://$domain";
}

if ($this->usesCloudFront() && $project['cloudfront_status'] == 'deployed') {
return $project['asset_domains']['cloudfront'] ??
$project['asset_domains']['s3'];
Expand All @@ -155,6 +159,16 @@ protected function usesCloudFront()
return Manifest::current()['environments'][$this->argument('environment')]['cloudfront'] ?? true;
}

/**
* Determine if the project uses a custom asset domain.
*
* @return string|null
*/
protected function customAssetDomain()
{
return Manifest::current()['asset-domain'] ?? null;
}

/**
* Upload the deployment artifact.
*
Expand Down
29 changes: 29 additions & 0 deletions src/Commands/Output/DeploymentSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function render(Deployment $deployment, DateTimeInterface $startedAt)
}

$this->displayFunctionUrl($deployment);

$this->displayAssetDomainDnsRecordChanges($deployment);
}

/**
Expand Down Expand Up @@ -118,4 +120,31 @@ protected function displayFunctionUrl(Deployment $deployment)
"<options=bold>{$deployment->functionUrl()}</>",
]]);
}

/**
* Display the DNS Records changes related to the asset domain.
*
* @param \Laravel\VaporCli\Models\Deployment $deployment
* @return void
*/
protected function displayAssetDomainDnsRecordChanges(Deployment $deployment)
{
if (! $assetDomain = $deployment->manifest['asset-domain'] ?? null) {
return;
}

Helpers::line();

if ($deployment->created_asset_domain) {
Helpers::line('<comment>Custom asset domain created:</comment> Custom domains may take up to an hour to become active after provisioning.');

Helpers::line();
}

Helpers::table([
'Domain', 'Alias / CNAME',
], [[
$assetDomain, $deployment->project['cloudfront_domain'],
]]);
}
}

0 comments on commit ac6be7d

Please sign in to comment.