forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallCommand.php
More file actions
58 lines (47 loc) · 1.43 KB
/
InstallCommand.php
File metadata and controls
58 lines (47 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
class InstallCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:install {--force}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install a fresh version of the Speedtest Tracker application.';
/**
* Execute the console command.
*/
public function handle(): void
{
if (! $this->option('force')) {
$confirmed = confirm('Are you sure you want to continue?');
if (! $confirmed) {
$this->fail('Application install cancelled.');
}
}
$this->info('⏳ Starting to install the application...');
if (app()->environment('production') || app()->environment('testing')) {
$this->call('filament:cache-components');
$this->call('optimize');
} else {
$this->call('optimize:clear');
}
try {
$this->call('migrate:fresh', [
'--force' => true,
]);
} catch (\Throwable $th) {
$this->fail('❌ There was an issue migrating the database, check the logs.');
}
info('🚀 Finished installing Speedtest Tracker!');
}
}