ComposerCommand.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @package Grav\Console\Cli
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Console\Cli;
  9. use Grav\Console\ConsoleCommand;
  10. use Symfony\Component\Console\Input\InputOption;
  11. class ComposerCommand extends ConsoleCommand
  12. {
  13. protected function configure()
  14. {
  15. $this
  16. ->setName("composer")
  17. ->addOption(
  18. 'install',
  19. 'i',
  20. InputOption::VALUE_NONE,
  21. 'install the dependencies'
  22. )
  23. ->addOption(
  24. 'update',
  25. 'u',
  26. InputOption::VALUE_NONE,
  27. 'update the dependencies'
  28. )
  29. ->setDescription("Updates the composer vendor dependencies needed by Grav.")
  30. ->setHelp('The <info>composer</info> command updates the composer vendor dependencies needed by Grav');
  31. }
  32. protected function serve()
  33. {
  34. $action = $this->input->getOption('install') ? 'install' : ($this->input->getOption('update') ? 'update' : 'install');
  35. if ($this->input->getOption('install')) {
  36. $action = 'install';
  37. }
  38. // Updates composer first
  39. $this->output->writeln("\nInstalling vendor dependencies");
  40. $this->output->writeln($this->composerUpdate(GRAV_ROOT, $action));
  41. }
  42. }