2020-04-20 00:35:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Composer\Composer;
|
|
|
|
use Composer\Factory;
|
|
|
|
use Composer\IO\NullIO;
|
|
|
|
use Composer\Installer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
|
|
|
use Composer\Console\Application;
|
|
|
|
|
|
|
|
class PostUpdate extends Command
|
|
|
|
{
|
|
|
|
|
|
|
|
protected $name = 'ninja:post-update';
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'ninja:post-update';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Run basic upgrade commands';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
set_time_limit(0);
|
|
|
|
|
2020-05-25 01:45:12 +02:00
|
|
|
info("running post update");
|
|
|
|
|
2020-04-20 00:35:48 +02:00
|
|
|
try {
|
|
|
|
Artisan::call('migrate');
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Log::error("I wasn't able to migrate the data.");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Artisan::call('optimize');
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Log::error("I wasn't able to optimize.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$composer_data = array(
|
|
|
|
'url' => 'https://getcomposer.org/composer.phar',
|
|
|
|
'dir' => __DIR__.'/.code',
|
|
|
|
'bin' => __DIR__.'/.code/composer.phar',
|
|
|
|
'json' => __DIR__.'/.code/composer.json',
|
|
|
|
'conf' => array(
|
|
|
|
"autoload" => array(
|
|
|
|
"psr-4" => array(
|
|
|
|
"" => "local/"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
if(!is_dir($composer_data['dir']))
|
|
|
|
mkdir($composer_data['dir'],0777,true);
|
|
|
|
|
|
|
|
if(!is_dir("{$composer_data['dir']}/local"))
|
|
|
|
mkdir("{$composer_data['dir']}/local",0777,true);
|
|
|
|
|
|
|
|
copy($composer_data['url'],$composer_data['bin']);
|
|
|
|
require_once "phar://{$composer_data['bin']}/src/bootstrap.php";
|
|
|
|
|
|
|
|
$conf_json = json_encode($composer_data['conf'],JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
|
|
file_put_contents($composer_data['json'],$conf_json);
|
|
|
|
chdir($composer_data['dir']);
|
|
|
|
putenv("COMPOSER_HOME={$composer_data['dir']}");
|
|
|
|
putenv("OSTYPE=OS400");
|
|
|
|
$app = new \Composer\Console\Application();
|
|
|
|
|
|
|
|
$factory = new \Composer\Factory();
|
|
|
|
$output = $factory->createOutput();
|
|
|
|
|
|
|
|
$input = new \Symfony\Component\Console\Input\ArrayInput(array(
|
2020-05-25 01:45:12 +02:00
|
|
|
'command' => 'install',
|
2020-04-20 00:35:48 +02:00
|
|
|
));
|
|
|
|
$input->setInteractive(false);
|
|
|
|
echo "<pre>";
|
|
|
|
$cmdret = $app->doRun($input,$output);
|
|
|
|
echo "end!";
|
|
|
|
|
2020-05-20 00:49:58 +02:00
|
|
|
\Log::error(print_r($cmdret,1));
|
|
|
|
|
2020-04-20 00:35:48 +02:00
|
|
|
}
|
|
|
|
}
|