From c165c0be57e1c3649861a04ea4647b2bd8a9b101 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Mon, 2 Jul 2018 12:33:30 +0200 Subject: [PATCH 1/3] Merge cachet:install and app:install --- app/Console/Commands/AppInstallCommand.php | 76 ---------------------- app/Console/Commands/InstallCommand.php | 50 +++++++++++--- 2 files changed, 40 insertions(+), 86 deletions(-) delete mode 100644 app/Console/Commands/AppInstallCommand.php diff --git a/app/Console/Commands/AppInstallCommand.php b/app/Console/Commands/AppInstallCommand.php deleted file mode 100644 index 6f5a0cfe..00000000 --- a/app/Console/Commands/AppInstallCommand.php +++ /dev/null @@ -1,76 +0,0 @@ - - */ -class AppInstallCommand extends Command -{ - /** - * The name and signature of the console command. - * - * @var string - */ - protected $signature = 'app:install'; - - /** - * The console command description. - * - * @var string - */ - protected $description = 'Installs the application'; - - /** - * The events instance. - * - * @var \Illuminate\Contracts\Events\Dispatcher - */ - protected $events; - - /** - * Create a new command instance. - * - * @return void - */ - public function __construct(Dispatcher $events) - { - $this->events = $events; - - parent::__construct(); - } - - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() - { - $this->events->fire('command.installing', $this); - $this->events->fire('command.generatekey', $this); - $this->events->fire('command.cacheconfig', $this); - $this->events->fire('command.cacheroutes', $this); - $this->events->fire('command.publishvendors', $this); - $this->events->fire('command.runmigrations', $this); - $this->events->fire('command.runseeding', $this); - $this->events->fire('command.updatecache', $this); - $this->events->fire('command.linkstorage', $this); - $this->events->fire('command.extrastuff', $this); - $this->events->fire('command.installed', $this); - } -} diff --git a/app/Console/Commands/InstallCommand.php b/app/Console/Commands/InstallCommand.php index aa747b49..06fd8410 100644 --- a/app/Console/Commands/InstallCommand.php +++ b/app/Console/Commands/InstallCommand.php @@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Console\Commands; use Dotenv\Dotenv; use Dotenv\Exception\InvalidPathException; use Illuminate\Console\Command; +use Illuminate\Contracts\Events\Dispatcher; /** * This is the install command class. @@ -36,6 +37,25 @@ class InstallCommand extends Command */ protected $description = 'Install Cachet'; + /** + * The events instance. + * + * @var \Illuminate\Contracts\Events\Dispatcher + */ + protected $events; + + /** + * Create a new command instance. + * + * @param Dispatcher $events + */ + public function __construct(Dispatcher $events) + { + $this->events = $events; + + parent::__construct(); + } + /** * Execute the console command. * @@ -43,18 +63,28 @@ class InstallCommand extends Command */ public function handle() { - if (!$this->confirm('Do you want to install Cachet?')) { - $this->line('Installation aborted. Goodbye!'); - - return; + if ($this->confirm('Do you want to configure Cachet before installing?')) { + $this->configureEnvironmentFile(); + $this->configureKey(); + $this->configureDatabase(); + $this->configureDrivers(); + $this->configureMail(); + $this->configureCachet(); } - $this->configureEnvironmentFile(); - $this->configureKey(); - $this->configureDatabase(); - $this->configureDrivers(); - $this->configureMail(); - $this->configureCachet(); + $this->line('Installing Cachet...'); + + $this->events->fire('command.installing', $this); + $this->events->fire('command.generatekey', $this); + $this->events->fire('command.cacheconfig', $this); + $this->events->fire('command.cacheroutes', $this); + $this->events->fire('command.publishvendors', $this); + $this->events->fire('command.runmigrations', $this); + $this->events->fire('command.runseeding', $this); + $this->events->fire('command.updatecache', $this); + $this->events->fire('command.linkstorage', $this); + $this->events->fire('command.extrastuff', $this); + $this->events->fire('command.installed', $this); $this->info('Cachet is installed ⚡'); } From 65f138dc2de34f3a32cd33e4cb21523d4421db67 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Mon, 2 Jul 2018 12:35:01 +0200 Subject: [PATCH 2/3] hardcode for db:backup parameters that is ran when installing cachet Future improvements should dynamically configure the databases used --- app/Subscribers/CommandSubscriber.php | 8 ++------ config/backup.php | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/Subscribers/CommandSubscriber.php b/app/Subscribers/CommandSubscriber.php index bc388df0..52b267fe 100644 --- a/app/Subscribers/CommandSubscriber.php +++ b/app/Subscribers/CommandSubscriber.php @@ -15,7 +15,6 @@ use CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent; use CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent; use CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent; use CachetHQ\Cachet\Settings\Cache; -use Carbon\Carbon; use Exception; use Illuminate\Console\Command; use Illuminate\Contracts\Config\Repository; @@ -153,11 +152,8 @@ class CommandSubscriber $command->line('Backing up database...'); try { - $command->call('db:backup', [ - '--compression' => 'gzip', - '--database' => $this->config->get('database.default'), - '--destination' => 'local', - '--destinationPath' => Carbon::now()->format('Y-m-d H.i.s'), + $command->call('backup:run', [ + '--only-db' => true, '--no-interaction' => true, ]); } catch (Exception $e) { diff --git a/config/backup.php b/config/backup.php index 24c6814a..c9682b15 100644 --- a/config/backup.php +++ b/config/backup.php @@ -132,7 +132,7 @@ return [ 'monitorBackups' => [ [ 'name' => config('app.name'), - 'disks' => ['local'], + 'disks' => ['database'], 'newestBackupsShouldNotBeOlderThanDays' => 1, 'storageUsedMayNotBeHigherThanMegabytes' => 5000, ], From 3a50f3c5bff97b428d573cc36eec5afe2a6b03e3 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Mon, 2 Jul 2018 13:50:08 +0200 Subject: [PATCH 3/3] Remove reference to AppInstallCommand --- app/Console/Kernel.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index b3d16aac..12bc4a2a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -11,7 +11,6 @@ namespace CachetHQ\Cachet\Console; -use CachetHQ\Cachet\Console\Commands\AppInstallCommand; use CachetHQ\Cachet\Console\Commands\AppResetCommand; use CachetHQ\Cachet\Console\Commands\AppUpdateCommand; use CachetHQ\Cachet\Console\Commands\BeaconCommand; @@ -37,7 +36,6 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - AppInstallCommand::class, AppResetCommand::class, AppUpdateCommand::class, BeaconCommand::class,