From b1de3b6b4e467854130e9c1c71009ae36662155b Mon Sep 17 00:00:00 2001 From: Joseph Cohen Date: Mon, 2 Jan 2017 14:07:18 -0600 Subject: [PATCH 1/4] Add user on cachet install command --- app/Console/Commands/InstallCommand.php | 42 ++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/InstallCommand.php b/app/Console/Commands/InstallCommand.php index b6d106065cc6..1f7c1716b98d 100644 --- a/app/Console/Commands/InstallCommand.php +++ b/app/Console/Commands/InstallCommand.php @@ -11,6 +11,7 @@ namespace CachetHQ\Cachet\Console\Commands; +use CachetHQ\Cachet\Models\User; use Dotenv\Dotenv; use Dotenv\Exception\InvalidPathException; use Illuminate\Console\Command; @@ -72,6 +73,7 @@ public function handle() $this->configureCachet(); } +<<<<<<< HEAD $this->line('Installing Cachet...'); $this->events->fire('command.installing', $this); @@ -85,6 +87,15 @@ public function handle() $this->events->fire('command.linkstorage', $this); $this->events->fire('command.extrastuff', $this); $this->events->fire('command.installed', $this); +======= + $this->configureEnvironmentFile(); + $this->configureKey(); + $this->configureDatabase(); + $this->configureDrivers(); + $this->configureMail(); + $this->configureCachet(); + $this->configureUser(); +>>>>>>> Add user on cachet install command $this->info('Cachet is installed ⚡'); } @@ -139,9 +150,15 @@ protected function configureDatabase(array $default = []) ], $default); $config['DB_DRIVER'] = $this->choice('Which database driver do you want to use?', [ +<<<<<<< HEAD 'mysql' => 'MySQL', 'pgsql' => 'PostgreSQL', 'sqlite' => 'SQLite', +======= + 'mysql' => 'MySQL', + 'pgsql' => 'PostgreSQL', + 'sqlite' => 'SQLite', +>>>>>>> Add user on cachet install command ], $config['DB_DRIVER']); if ($config['DB_DRIVER'] === 'sqlite') { @@ -313,9 +330,11 @@ protected function configureMail(array $config = []) /** * Configure Cachet. * + * @param array $config + * * @return void */ - protected function configureCachet() + protected function configureCachet(array $config = []) { $config = []; if ($this->confirm('Do you wish to use Cachet Beacon?')) { @@ -332,6 +351,27 @@ protected function configureCachet() } } + /** + * Configure the fisrt user. + * + * @return void + */ + protected function configureUser() + { + if (!$this->confirm('Do you want to create an admin user?')) { + return; + } + + $user = [ + 'username' => $this->ask('Please enter your username'), + 'email' => $this->ask('Please enter your email'), + 'password' => $this->secret('Please enter your password'), + 'level' => User::LEVEL_ADMIN, + ]; + + User::create($user); + } + /** * Configure the redis connection. * From 98b213bb62217f26b2c6528bc3657309e4c6b55d Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 3 Jan 2017 14:23:30 +0000 Subject: [PATCH 2/4] Get a fresh configuration --- app/Console/Commands/InstallCommand.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Console/Commands/InstallCommand.php b/app/Console/Commands/InstallCommand.php index 1f7c1716b98d..58f04452687d 100644 --- a/app/Console/Commands/InstallCommand.php +++ b/app/Console/Commands/InstallCommand.php @@ -362,6 +362,12 @@ protected function configureUser() return; } + // We need to refresh the config to get access to the newly connected database. + $this->getFreshConfiguration(); + + // Now we need to install the application. + $this->call('app:install'); + $user = [ 'username' => $this->ask('Please enter your username'), 'email' => $this->ask('Please enter your email'), @@ -412,6 +418,18 @@ protected function formatConfigsTable(array $config) $this->table(['Setting', 'Value'], $configRows); } + /** + * Boot a fresh copy of the application configuration. + * + * @return void + */ + protected function getFreshConfiguration() + { + $app = require $this->laravel->bootstrapPath().'/app.php'; + + $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); + } + /** * Writes to the .env file with given parameters. * From ce9a7323175e4739ff109b69ab5c538d7f4ceb8d Mon Sep 17 00:00:00 2001 From: James Brooks Date: Thu, 5 Jan 2017 19:25:51 +0000 Subject: [PATCH 3/4] Use class notation --- app/Console/Commands/InstallCommand.php | 33 +++++++------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/app/Console/Commands/InstallCommand.php b/app/Console/Commands/InstallCommand.php index 58f04452687d..277582ac4734 100644 --- a/app/Console/Commands/InstallCommand.php +++ b/app/Console/Commands/InstallCommand.php @@ -16,6 +16,7 @@ use Dotenv\Exception\InvalidPathException; use Illuminate\Console\Command; use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Contracts\Console\Kernel; /** * This is the install command class. @@ -71,9 +72,9 @@ public function handle() $this->configureDrivers(); $this->configureMail(); $this->configureCachet(); + $this->configureUser(); } -<<<<<<< HEAD $this->line('Installing Cachet...'); $this->events->fire('command.installing', $this); @@ -87,15 +88,6 @@ public function handle() $this->events->fire('command.linkstorage', $this); $this->events->fire('command.extrastuff', $this); $this->events->fire('command.installed', $this); -======= - $this->configureEnvironmentFile(); - $this->configureKey(); - $this->configureDatabase(); - $this->configureDrivers(); - $this->configureMail(); - $this->configureCachet(); - $this->configureUser(); ->>>>>>> Add user on cachet install command $this->info('Cachet is installed ⚡'); } @@ -150,15 +142,9 @@ protected function configureDatabase(array $default = []) ], $default); $config['DB_DRIVER'] = $this->choice('Which database driver do you want to use?', [ -<<<<<<< HEAD 'mysql' => 'MySQL', 'pgsql' => 'PostgreSQL', 'sqlite' => 'SQLite', -======= - 'mysql' => 'MySQL', - 'pgsql' => 'PostgreSQL', - 'sqlite' => 'SQLite', ->>>>>>> Add user on cachet install command ], $config['DB_DRIVER']); if ($config['DB_DRIVER'] === 'sqlite') { @@ -329,7 +315,7 @@ protected function configureMail(array $config = []) /** * Configure Cachet. - * + * * @param array $config * * @return void @@ -352,7 +338,7 @@ protected function configureCachet(array $config = []) } /** - * Configure the fisrt user. + * Configure the first user. * * @return void */ @@ -364,17 +350,17 @@ protected function configureUser() // We need to refresh the config to get access to the newly connected database. $this->getFreshConfiguration(); - + // Now we need to install the application. - $this->call('app:install'); - + // $this->call('cachet:install'); + $user = [ 'username' => $this->ask('Please enter your username'), 'email' => $this->ask('Please enter your email'), 'password' => $this->secret('Please enter your password'), 'level' => User::LEVEL_ADMIN, ]; - + User::create($user); } @@ -426,8 +412,7 @@ protected function formatConfigsTable(array $config) protected function getFreshConfiguration() { $app = require $this->laravel->bootstrapPath().'/app.php'; - - $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); + $app->make(Kernel::class)->bootstrap(); } /** From ba5d865bcf2126696ab602f7d0ee34928697d891 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Fri, 1 Feb 2019 21:34:18 +0000 Subject: [PATCH 4/4] Apply fixes from StyleCI --- app/Console/Commands/InstallCommand.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/InstallCommand.php b/app/Console/Commands/InstallCommand.php index 277582ac4734..7c71cbc0de2e 100644 --- a/app/Console/Commands/InstallCommand.php +++ b/app/Console/Commands/InstallCommand.php @@ -15,8 +15,8 @@ use Dotenv\Dotenv; use Dotenv\Exception\InvalidPathException; use Illuminate\Console\Command; -use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Console\Kernel; +use Illuminate\Contracts\Events\Dispatcher; /** * This is the install command class. @@ -315,7 +315,7 @@ protected function configureMail(array $config = []) /** * Configure Cachet. - * + * * @param array $config * * @return void @@ -350,17 +350,17 @@ protected function configureUser() // We need to refresh the config to get access to the newly connected database. $this->getFreshConfiguration(); - + // Now we need to install the application. // $this->call('cachet:install'); - + $user = [ 'username' => $this->ask('Please enter your username'), 'email' => $this->ask('Please enter your email'), 'password' => $this->secret('Please enter your password'), 'level' => User::LEVEL_ADMIN, ]; - + User::create($user); } @@ -412,7 +412,7 @@ protected function formatConfigsTable(array $config) protected function getFreshConfiguration() { $app = require $this->laravel->bootstrapPath().'/app.php'; - $app->make(Kernel::class)->bootstrap(); + $app->make(Kernel::class)->bootstrap(); } /**