use App\Console\Commands\Traits\ExecutesShellCommands;
use Illuminate\Console\Command;
class Update extends Command
{
use ExecutesShellCommands;
const COMPILE = [
'live' => true,
'local' => false,
'mapping' => true,
'staging' => true,
];
const COMPILE_AS = [
'live' => 'production',
'local' => 'dev',
'mapping' => 'production',
'staging' => 'dev',
];
public function handle()
{
$environment = $this->argument('environment');
// Regenerate IDE helper
$this->call('clear-compiled');
$this->call('ide-helper:generate');
$this->call('ide-helper:meta');
$this->call('horizon:publish');
$this->call('migrate', [
'--database' => 'migrate',
'--force' => true
]);
$this->call('modelCache:clear');
$this->call('db:seed', [
'--database' => 'migrate',
'--force' => true
]);
if ($environment === 'live') {
$this->call('make:githubrelease');
$this->shell([
'git pull',
]);
}
$this->shell([
'git tag | sort -V | (tail -n 1) > version',
self::COMPILE[$environment] ? sprintf('npm run %s -- --env.full true', self::COMPILE_AS[$environment]) : null,
]);
$this->call('optimize:clear');
if ($environment === 'live') {
$this->call('route:cache');
} else {
$this->call('route:clear');
}
$this->call('config:clear');
$this->call('queue:restart');
$this->call('supervisor:start');
$this->call('affixgroupeasetiers:refresh');
return 0;
}
}