Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 15 additions & 46 deletions app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;

class InstallCommand extends Command
{
Expand All @@ -19,71 +21,38 @@ class InstallCommand extends Command
*
* @var string
*/
protected $description = 'A fresh install of Speedtest Tracker.';
protected $description = 'Install a fresh version of the Speedtest Tracker application.';

/**
* Execute the console command.
*/
public function handle(): void
{
if (! $this->option('force')) {
$this->newLine(2);

$this->info("Running the install will reset all of the application's data.");
$this->warn('!!! ALL OF THE DATA WILL BE DELETED !!!');

if (! $this->confirm('Do you wish to continue?')) {
$this->info('Install cancelled.');
$confirmed = confirm('Are you sure you want to continue?');

return;
if (! $confirmed) {
$this->fail('Application install cancelled.');
}
}

$this->info('Starting to install the application...');

$this->newLine();

$this->checkAppKey();

$this->line('⏳ Optimizing the cache...');
$this->info('⏳ Starting to install the application...');

if (app()->environment('production') || app()->environment('testing')) {
Artisan::call('view:clear');
Artisan::call('filament:cache-components');
Artisan::call('optimize');
$this->call('filament:cache-components');
$this->call('optimize');
} else {
$this->call('optimize:clear');
}

$this->line('βœ… Optimized cache');

$this->newLine();

$this->line('⏳ Migrating the database...');

try {
Artisan::call('migrate:fresh', [
$this->call('migrate:fresh', [
'--force' => true,
]);
} catch (\Throwable $th) {
$this->error('❌ There was an issue migrating the database, check the logs.');

return;
$this->fail('❌ There was an issue migrating the database, check the logs.');
}

$this->line('βœ… Database migrated');

$this->newLine();

$this->line('πŸš€ Finished installing the application!');
}

public function checkAppKey()
{
if (empty(config('app.key'))) {
$this->line('πŸ”‘ Creating an application key');

Artisan::call('key:generate');

$this->line('βœ… Application key created');
}
info('πŸš€ Finished installing Speedtest Tracker!');
}
}
46 changes: 0 additions & 46 deletions app/Console/Commands/ResetUserPassword.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\DB;

class FixResultStatuses extends Command
class ResultFixStatuses extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:fix-result-statuses';
protected $signature = 'app:result-fix-statuses';

/**
* The console command description.
Expand All @@ -34,7 +34,7 @@ public function handle(): void
$this->info('πŸ“– Read the docs: https://docs.speedtest-tracker.dev/other/commands');

if (! $this->confirm('Do you want to continue?')) {
return;
$this->fail('Command cancelled.');
}

/**
Expand Down
46 changes: 0 additions & 46 deletions app/Console/Commands/SystemMaintenance.php

This file was deleted.

46 changes: 1 addition & 45 deletions app/Console/Commands/UpdateGeneralSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Console\Command;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\select;
use function Laravel\Prompts\text;

class UpdateGeneralSettings extends Command
Expand All @@ -25,7 +24,7 @@ class UpdateGeneralSettings extends Command
*
* @var string
*/
protected $description = 'CLI to update the general settings.';
protected $description = 'Update the application\'s general settings.';

/**
* Execute the console command.
Expand All @@ -34,8 +33,6 @@ public function handle(): void
{
$settings = new GeneralSettings();

$this->updateSiteName($settings);
$this->updatePublicDashboard($settings);
$this->updateTimeZone($settings);
$this->updateSchedule($settings);
$this->resetSevers($settings);
Expand All @@ -59,26 +56,6 @@ protected function resetSevers($settings): void
}
}

protected function updatePublicDashboard($settings): void
{
$publicDashboard = select(
label: 'Make the dashboard public?',
options: ['Yes', 'No'],
default: 'Yes',
required: true,
);

if ($publicDashboard == 'Yes') {
$settings->public_dashboard_enabled = true;

$settings->save();
} else {
$settings->public_dashboard_enabled = false;
}

$settings->save();
}

protected function updateSchedule($settings): void
{
$cron = text(
Expand All @@ -99,27 +76,6 @@ protected function updateSchedule($settings): void
}
}

protected function updateSiteName($settings): void
{
$name = text(
label: 'What is the site name?',
placeholder: 'Speedtest Tracker',
default: $settings->site_name,
required: true,
validate: fn (string $value) => match (true) {
strlen($value) < 2 => 'The site name must be at least 2 characters.',
strlen($value) > 50 => 'The site name must not exceed 50 characters.',
default => null
}
);

if ($name) {
$settings->site_name = $name;

$settings->save();
}
}

protected function updateTimeZone($settings): void
{
$timezone = text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
use App\Models\User;
use Illuminate\Console\Command;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
use function Laravel\Prompts\select;
use function Laravel\Prompts\text;

class UpdateUserRole extends Command
class UserChangeRole extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:update-user-role';
protected $signature = 'app:user-change-role';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Change the role for a given user.';
protected $description = 'Change the role for a user.';

/**
* Execute the console command.
Expand All @@ -49,18 +48,11 @@ public function handle(): void
default: 'user'
);

$confirmed = confirm(
label: 'Are you sure?',
required: true
);

if ($confirmed) {
User::firstWhere('email', $email)
->update([
'role' => $role,
]);
User::where('email', '=', $email)
->update([
'role' => $role,
]);

info('User role updated.');
}
info('User role updated.');
}
}
Loading