Skip to content

Commit 71dc5eb

Browse files
committed
fix: hide deployment messages about dns records if they exist
1 parent 11077e3 commit 71dc5eb

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

src/Command/Project/AbstractProjectDeploymentCommand.php

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,51 @@ protected function perform(InputInterface $input, ConsoleOutput $output)
5454
{
5555
$deployment = $this->createDeployment($input, $output);
5656
$environment = $this->getStringArgument($input, 'environment');
57-
$projectId = $this->projectConfiguration->getProjectId();
5857

5958
foreach ($this->deploymentSteps as $deploymentStep) {
6059
$deploymentStep->perform($deployment, $output);
6160
}
6261

6362
$output->info($this->getSuccessMessage($environment));
6463

65-
$unmanagedDomains = (array) $this->apiClient->getDeployment($deployment->get('id'))->get('unmanaged_domains');
66-
$vanityDomainName = $this->apiClient->getEnvironmentVanityDomainName($projectId, $environment);
67-
6864
$this->invoke($output, GetEnvironmentUrlCommand::NAME, ['environment' => $environment]);
6965

70-
if (!empty($unmanagedDomains)) {
71-
$output->newLine();
72-
$output->warn('Not all domains in this project are managed by Ymir. The following DNS record(s) need to be manually added to your DNS server for these domains to work:');
73-
$output->newLine();
74-
$output->table(
75-
['Type', 'Name', 'Value'],
76-
array_map(function (string $unmanagedDomain) use ($vanityDomainName) {
77-
return ['CNAME', $unmanagedDomain, $vanityDomainName];
78-
}, $unmanagedDomains)
79-
);
80-
}
81-
8266
if (!array_key_exists('domain', $this->projectConfiguration->getEnvironment($environment))) {
8367
$output->newLine();
8468
$output->writeln(sprintf('<comment>Note:</comment> You cannot send emails using the "<comment>ymirsites.com</comment>" domain. Please use the "<comment>%s</comment>" command to add an email address or domain for sending emails.', CreateEmailIdentityCommand::NAME));
69+
70+
return;
71+
}
72+
73+
$unmanagedDomains = collect($this->apiClient->getDeployment($deployment->get('id'))->get('unmanaged_domains'));
74+
75+
if ($unmanagedDomains->isEmpty()) {
76+
return;
8577
}
78+
79+
$vanityDomainName = $this->apiClient->getEnvironmentVanityDomainName($this->projectConfiguration->getProjectId(), $environment);
80+
81+
$unmanagedDomains = $unmanagedDomains->filter(function (string $unmanagedDomain) use ($vanityDomainName) {
82+
try {
83+
return !collect(dns_get_record($unmanagedDomain, DNS_CNAME))->contains('target', $vanityDomainName);
84+
} catch (\Throwable $exception) {
85+
return true;
86+
}
87+
});
88+
89+
if ($unmanagedDomains->isEmpty()) {
90+
return;
91+
}
92+
93+
$output->newLine();
94+
$output->warn('Not all domains in this project are managed by Ymir. The following DNS record(s) need to be manually added to your DNS server for these domains to work:');
95+
$output->newLine();
96+
$output->table(
97+
['Type', 'Name', 'Value'],
98+
$unmanagedDomains->map(function (string $unmanagedDomain) use ($vanityDomainName) {
99+
return ['CNAME', $unmanagedDomain, $vanityDomainName];
100+
})->all()
101+
);
86102
}
87103

88104
/**

0 commit comments

Comments
 (0)