From ca2f8e1aa5bace411e548dc9de86ec6c436a8629 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 25 Mar 2018 16:50:48 -0500 Subject: [PATCH] Move helper generation to new command --- app/Console/Commands/ComposerCommand.php | 44 +++++++++++++ app/Console/Commands/DevCommands.php | 1 + app/Console/Commands/Install.php | 84 ------------------------ composer.json | 5 +- 4 files changed, 47 insertions(+), 87 deletions(-) create mode 100644 app/Console/Commands/ComposerCommand.php delete mode 100644 app/Console/Commands/Install.php diff --git a/app/Console/Commands/ComposerCommand.php b/app/Console/Commands/ComposerCommand.php new file mode 100644 index 00000000..f828dbc8 --- /dev/null +++ b/app/Console/Commands/ComposerCommand.php @@ -0,0 +1,44 @@ +argument('cmd'))) + { + case 'post-update': + $this->postUpdate(); + break; + default: + $this->error('Command exists'); + } + } + + /** + * Any composer post update tasks + */ + protected function postUpdate(): void + { + if (config('app.env') === 'dev') { + if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) { + Artisan::call('ide-helper:generate'); + Artisan::call('ide-helper:meta'); + } + } + } +} diff --git a/app/Console/Commands/DevCommands.php b/app/Console/Commands/DevCommands.php index 4eb6a048..aec2ccb0 100644 --- a/app/Console/Commands/DevCommands.php +++ b/app/Console/Commands/DevCommands.php @@ -8,6 +8,7 @@ use App\Models\Airline; use App\Models\Pirep; use App\Models\User; use App\Services\AwardService; +use Artisan; use DB; use PDO; use Symfony\Component\Yaml\Yaml; diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php deleted file mode 100644 index cef22473..00000000 --- a/app/Console/Commands/Install.php +++ /dev/null @@ -1,84 +0,0 @@ -info('Installing phpVMS...'); - - $this->setupDatabase(); - - # Only run these if we're doing an initial install - if (!$this->option('update')) { - $this->writeLocalConfig(); - $this->initialData(); - } - } - - /** - * Setup the database and run the migrations - * Only call the database creation if we're not - * explicitly trying to upgrade - */ - protected function setupDatabase() - { - if (!$this->option('update')) { - $this->call('database:create'); - } - - $this->info('Running database migrations...'); - $this->call('migrate'); - # TODO: Call initial seed data, for the groups and other supporting data - } - - /** - * Write a local config file - */ - protected function writeLocalConfig(): void - { - } - - /** - * Set an initial airline and admin user/password - */ - protected function initialData() - { - # TODO: Prompt for initial airline info - $airline_name = $this->option('airline-name'); - if (!$airline_name) { - $airline_name = $this->ask('Enter your airline name'); - } - - $airline_code = $this->option('airline-code'); - if (!$airline_code) { - $airline_code = $this->ask('Enter your airline code'); - } - # TODO: Prompt for admin user/password - } -} diff --git a/composer.json b/composer.json index 854b628a..8a487677 100755 --- a/composer.json +++ b/composer.json @@ -90,12 +90,11 @@ ], "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate", - "php artisan ide-helper:generate", - "php artisan ide-helper:meta" + "php artisan phpvms:composer post-update" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover" + "php artisan package:discover" ] }, "config": {