1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 08:30:07 +01:00

remove date logic on renewal

This commit is contained in:
Austin Drummond
2023-12-20 00:39:12 -05:00
parent cd198cb0c9
commit a3a483e45c
2 changed files with 8 additions and 19 deletions

View File

@@ -3,7 +3,6 @@
namespace Valet;
use DateTime;
use DateInterval;
use DomainException;
use Illuminate\Support\Collection;
use PhpFpm;
@@ -503,21 +502,12 @@ public function secure(string $url, string $siteConf = null, int $certificateExp
}
/**
* Renews expired or expiring (within 60 days) domains with a trusted TLS certificate.
* Renews all domains with a trusted TLS certificate.
*/
public function renew($expireIn = 368, $days = 60): void
public function renew($expireIn): void
{
$now = (new DateTime())->add(new DateInterval('P' . $days . 'D'));
// Update anything expiring in the next 60 days
$sites = collect(Site::securedWithDates())
->filter(fn ($row) => $row['exp'] < $now)
->values();
if ($sites->isEmpty()) {
info('No sites need renewing.');
exit;
}
$sites->each(function ($row) use ($expireIn) {
$url = Site::domain($row['site']);
collect($this->securedWithDates())->each(function ($row) use ($expireIn) {
$url = $this->domain($row['site']);
$this->secure($url, null, $expireIn);

View File

@@ -297,14 +297,13 @@ function (ConsoleCommandEvent $event) {
]);
/**
* Renews expired or expiring (within 60 days) domains with a trusted TLS certificate.
* Renews all domains with a trusted TLS certificate.
*/
$app->command('renew [--expireIn=] [--days=]', function (OutputInterface $output, $expireIn = 368, $days = 60) {
Site::renew($expireIn, $days);
$app->command('renew [--expireIn=]', function (OutputInterface $output, $expireIn = 368) {
Site::renew($expireIn);
Nginx::restart();
})->descriptions('Renews expired or expiring (within 60 days) domains with a trusted TLS certificate.', [
})->descriptions('Renews all domains with a trusted TLS certificate.', [
'--expireIn' => 'The amount of days the self signed certificate is valid for. Default is set to "368"',
'--days' => 'Renews sites expiring within the next X days. Default is set to 60.',
]);
/**