Move helper generation to new command
This commit is contained in:
44
app/Console/Commands/ComposerCommand.php
Normal file
44
app/Console/Commands/ComposerCommand.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use Artisan;
|
||||
|
||||
/**
|
||||
* Class ComposerCommand
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class ComposerCommand extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:composer {cmd}';
|
||||
protected $description = 'Composer related tasks';
|
||||
|
||||
/**
|
||||
* Run composer update related commands
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
switch(trim($this->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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
|
||||
/**
|
||||
* Class Install
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class Install extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:install
|
||||
{--update}
|
||||
{--airline-name?}
|
||||
{--airline-code?}';
|
||||
|
||||
protected $description = 'Install or update phpVMS';
|
||||
|
||||
/**
|
||||
* Install constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->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
|
||||
}
|
||||
}
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user