mirror of
https://github.com/getgrav/grav.git
synced 2026-03-06 12:31:53 +01:00
added new composer update command
This commit is contained in:
3
bin/grav
3
bin/grav
@@ -9,7 +9,7 @@ if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
|
||||
if (!file_exists(__DIR__ . '/../vendor')){
|
||||
// Before we can even start, we need to run composer first
|
||||
echo "Preparing to install vendor dependencies...\n\n";
|
||||
echo system('php bin/composer.phar --working-dir="'.__DIR__.'/../" --no-interaction install');
|
||||
echo system('php bin/composer.phar --working-dir="'.__DIR__.'/../" --no-interaction --no-dev --prefer-dist install');
|
||||
echo "\n\n";
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ if (!file_exists(ROOT_DIR . 'index.php')) {
|
||||
$app = new Application('Grav CLI Application', '0.1.0');
|
||||
$app->addCommands(array(
|
||||
new Grav\Console\Cli\InstallCommand(),
|
||||
new Grav\Console\Cli\ComposerCommand(),
|
||||
new Grav\Console\Cli\SandboxCommand(),
|
||||
new Grav\Console\Cli\CleanCommand(),
|
||||
new Grav\Console\Cli\ClearCacheCommand(),
|
||||
|
||||
80
system/src/Grav/Console/Cli/ComposerCommand.php
Normal file
80
system/src/Grav/Console/Cli/ComposerCommand.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Console\ConsoleTrait;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Class ComposerCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class ComposerCommand extends Command
|
||||
{
|
||||
use ConsoleTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $config;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $local_config;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $destination;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $user_path;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("composer")
|
||||
->addOption(
|
||||
'install',
|
||||
'i',
|
||||
InputOption::VALUE_NONE,
|
||||
'install the dependencies'
|
||||
)
|
||||
->addOption(
|
||||
'update',
|
||||
'u',
|
||||
InputOption::VALUE_NONE,
|
||||
'update the dependencies'
|
||||
)
|
||||
->setDescription("Updates the composer vendordependencies needed by Grav.")
|
||||
->setHelp('The <info>composer</info> command updates the composer vendordependencies needed by Grav');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$action = 'update';
|
||||
|
||||
if ($input->getOption('install')) {
|
||||
$action = 'install';
|
||||
}
|
||||
|
||||
// Updates composer first
|
||||
$output->writeln("\nInstalling vendor dependencies");
|
||||
$output->writeln($this->composerUpdate(GRAV_ROOT, $action));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Console\ConsoleTrait;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -15,7 +16,7 @@ use Symfony\Component\Yaml\Yaml;
|
||||
*/
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
|
||||
use ConsoleTrait;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
@@ -98,7 +99,7 @@ class InstallCommand extends Command
|
||||
if (!$input->getOption('symlink')) {
|
||||
// Updates composer first
|
||||
$output->writeln("\nInstalling vendor dependencies");
|
||||
$output->writeln(system('php bin/composer.phar --working-dir="'.$this->destination.'" --no-interaction --no-dev --prefer-dist -o install'));
|
||||
$output->writeln($this->composerUpdate(GRAV_ROOT, 'install'));
|
||||
|
||||
$this->gitclone($output);
|
||||
} else {
|
||||
|
||||
@@ -83,6 +83,11 @@ trait ConsoleTrait
|
||||
}
|
||||
}
|
||||
|
||||
public function composerUpdate($path, $action = 'install')
|
||||
{
|
||||
return system('php bin/composer.phar --working-dir="'.$path.'" --no-interaction --no-dev --prefer-dist -o '. $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $all
|
||||
*
|
||||
|
||||
@@ -154,7 +154,7 @@ class SelfupgradeCommand extends Command
|
||||
}
|
||||
|
||||
$this->output->writeln("\nInstalling vendor dependencies");
|
||||
$this->output->writeln(system('php bin/composer.phar --working-dir="'.GRAV_ROOT.'" --no-interaction --no-dev --prefer-dist -o install'));
|
||||
$this->output->writeln($this->composerUpdate(GRAV_ROOT, 'update'));
|
||||
|
||||
// clear cache after successful upgrade
|
||||
$this->clearCache('all');
|
||||
|
||||
Reference in New Issue
Block a user