Skip to content

Commit 60824d1

Browse files
committed
Added ability to remove inertia support on teardown
1 parent 13bde7e commit 60824d1

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

app/Commands/TearDownCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use App\Services\Forge\Pipeline\FindServer;
1919
use App\Services\Forge\Pipeline\FindSiteOrFail;
2020
use App\Services\Forge\Pipeline\RemoveDatabaseUser;
21+
use App\Services\Forge\Pipeline\RemoveInertiaSupport;
2122
use App\Services\Forge\Pipeline\RemoveTaskScheduler;
2223
use App\Services\Forge\Pipeline\RunOptionalCommands;
2324
use App\Traits\Outputifier;
@@ -38,6 +39,7 @@ public function handle(ForgeService $service): void
3839
->through([
3940
FindServer::class,
4041
FindSiteOrFail::class,
42+
RemoveInertiaSupport::class,
4143
RunOptionalCommands::class,
4244
RemoveTaskScheduler::class,
4345
RemoveDatabaseUser::class,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of Laravel Harbor.
7+
*
8+
* (c) Mehran Rasulian <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace App\Services\Forge\Pipeline;
15+
16+
use App\Services\Forge\ForgeService;
17+
use App\Traits\Outputifier;
18+
use Closure;
19+
use Illuminate\Support\Arr;
20+
use Laravel\Forge\Resources\Daemon;
21+
22+
class RemoveInertiaSupport
23+
{
24+
use Outputifier;
25+
26+
public function __invoke(ForgeService $service, Closure $next)
27+
{
28+
if (! $service->setting->inertiaSsrEnabled) {
29+
return $next($service);
30+
}
31+
32+
if ($daemon = $this->getInertiaDaemon($service)) {
33+
$this->information('Removing the daemon for Inertia.js SSR command.');
34+
35+
$service->forge->deleteDaemon($service->server->id, $daemon->id);
36+
}
37+
38+
return $next($service);
39+
}
40+
41+
protected function getInertiaDaemon(ForgeService $service): ?Daemon
42+
{
43+
$daemons = $service->forge->daemons($service->server->id);
44+
$command = 'php artisan inertia:start-ssr';
45+
46+
return Arr::first(
47+
$daemons,
48+
fn ($daemon) => $daemon->directory == $service->siteDirectory() && $daemon->command == $command
49+
);
50+
}
51+
}

0 commit comments

Comments
 (0)