Skip to content

Commit

Permalink
🎨 Improve the optimize and optimize:clear console commands (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Jul 16, 2024
1 parent 7b8b7ef commit 156b32b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
17 changes: 11 additions & 6 deletions src/Roots/Acorn/Console/Commands/OptimizeClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ class OptimizeClearCommand extends FoundationOptimizeClearCommand
*/
public function handle()
{
$this->gracefulCall('view:clear');
$this->gracefulCall('cache:clear');
$this->gracefulCall('route:clear');
$this->gracefulCall('config:clear');
$this->gracefulCall('clear-compiled');
$this->components->info('Clearing cached bootstrap files.');

$this->info('Caches cleared successfully!');
collect([
'cache' => fn () => $this->gracefulCallSilent('cache:clear') == 0,
'compiled' => fn () => $this->gracefulCallSilent('clear-compiled') == 0,
'config' => fn () => $this->gracefulCallSilent('config:clear') == 0,
'events' => fn () => $this->gracefulCallSilent('event:clear') == 0,
'routes' => fn () => $this->gracefulCallSilent('route:clear') == 0,
'views' => fn () => $this->gracefulCallSilent('view:clear') == 0,
])->each(fn ($task, $description) => $this->components->task($description, $task));

$this->newLine();
}
}
12 changes: 9 additions & 3 deletions src/Roots/Acorn/Console/Commands/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ class OptimizeCommand extends FoundationOptimizeCommand
*/
public function handle()
{
$this->gracefulCall('config:cache');
$this->gracefulCall('route:cache');
$this->components->info('Caching framework bootstrap, configuration, and metadata.');

$this->info('Files cached successfully!');
collect([
'config' => fn () => $this->gracefulCallSilent('config:cache') == 0,
'events' => fn () => $this->gracefulCallSilent('event:cache') == 0,
'routes' => fn () => $this->gracefulCallSilent('route:cache') == 0,
'views' => fn () => $this->gracefulCallSilent('view:cache') == 0,
])->each(fn ($task, $description) => $this->components->task($description, $task));

$this->newLine();
}
}

0 comments on commit 156b32b

Please sign in to comment.