mirror of
https://github.com/getgrav/grav.git
synced 2026-07-06 01:19:30 +02:00
Cleanup
This commit is contained in:
@@ -7,13 +7,13 @@ class GPM extends Iterator
|
||||
{
|
||||
/**
|
||||
* Local installed Packages
|
||||
* @var Packages
|
||||
* @var Local\Packages
|
||||
*/
|
||||
private $installed;
|
||||
|
||||
/**
|
||||
* Remote available Packages
|
||||
* @var Packages
|
||||
* @var Remote\Packages
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
@@ -24,7 +24,7 @@ class GPM extends Iterator
|
||||
|
||||
/**
|
||||
* Internal cache
|
||||
* @var Iterator
|
||||
* @var
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
@@ -63,7 +63,7 @@ class GPM extends Iterator
|
||||
/**
|
||||
* Return the instance of a specific Plugin
|
||||
* @param string $slug The slug of the Plugin
|
||||
* @return Package The instance of the Plugin
|
||||
* @return Local\Package The instance of the Plugin
|
||||
*/
|
||||
public function getInstalledPlugin($slug)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ class GPM extends Iterator
|
||||
/**
|
||||
* Return the instance of a specific Theme
|
||||
* @param string $slug The slug of the Theme
|
||||
* @return Package The instance of the Theme
|
||||
* @return Local\Package The instance of the Theme
|
||||
*/
|
||||
public function getInstalledTheme($slug)
|
||||
{
|
||||
@@ -204,7 +204,7 @@ class GPM extends Iterator
|
||||
*/
|
||||
public function isPluginUpdatable($plugin)
|
||||
{
|
||||
return array_key_exists($plugin, $this->getUpdatablePlugins());
|
||||
return array_key_exists($plugin, (array) $this->getUpdatablePlugins());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,7 +249,7 @@ class GPM extends Iterator
|
||||
*/
|
||||
public function isThemeUpdatable($theme)
|
||||
{
|
||||
return array_key_exists($theme, $this->getUpdatableThemes());
|
||||
return array_key_exists($theme, (array) $this->getUpdatableThemes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +303,7 @@ class GPM extends Iterator
|
||||
/**
|
||||
* Searches for a Package in the repository
|
||||
* @param string $search Can be either the slug or the name
|
||||
* @return Package Package if found, FALSE if not
|
||||
* @return Remote\Package Package if found, FALSE if not
|
||||
*/
|
||||
public function findPackage($search)
|
||||
{
|
||||
|
||||
@@ -2,70 +2,98 @@
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
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\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class BackupCommand extends Command {
|
||||
/**
|
||||
* Class BackupCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class BackupCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $source;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $progress;
|
||||
|
||||
protected function configure() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("backup")
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::OPTIONAL,
|
||||
'Where to store the backup'
|
||||
->setName("backup")
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::OPTIONAL,
|
||||
'Where to store the backup'
|
||||
|
||||
)
|
||||
->setDescription("Creates a backup of the Grav instance")
|
||||
->setHelp('The <info>backup</info> creates a zipped backup. Optionally can be saved in a different destination.');
|
||||
)
|
||||
->setDescription("Creates a backup of the Grav instance")
|
||||
->setHelp('The <info>backup</info> creates a zipped backup. Optionally can be saved in a different destination.');
|
||||
|
||||
|
||||
$this->source = getcwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
|
||||
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
|
||||
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
|
||||
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
|
||||
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
|
||||
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
|
||||
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
|
||||
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
|
||||
|
||||
$this->progress = new ProgressBar($output);
|
||||
$this->progress->setFormat('Archiving <cyan>%current%</cyan> files [<green>%bar%</green>] %elapsed:6s% %memory:6s%');
|
||||
$this->progress = new ProgressBar($output);
|
||||
$this->progress->setFormat('Archiving <cyan>%current%</cyan> files [<green>%bar%</green>] %elapsed:6s% %memory:6s%');
|
||||
|
||||
$name = basename($this->source);
|
||||
$dir = dirname($this->source);
|
||||
$date = date('YmdHis', time());
|
||||
$filename = $name . '-' . $date . '.zip';
|
||||
$name = basename($this->source);
|
||||
$dir = dirname($this->source);
|
||||
$date = date('YmdHis', time());
|
||||
$filename = $name . '-' . $date . '.zip';
|
||||
|
||||
$destination = ($input->getArgument('destination')) ? $input->getArgument('destination') : ROOT_DIR;
|
||||
$destination = rtrim($destination, DS) . DS . $filename;
|
||||
$destination = ($input->getArgument('destination')) ? $input->getArgument('destination') : ROOT_DIR;
|
||||
$destination = rtrim($destination, DS) . DS . $filename;
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('Creating new Backup "'.$destination.'"');
|
||||
$this->progress->start();
|
||||
$output->writeln('');
|
||||
$output->writeln('Creating new Backup "' . $destination . '"');
|
||||
$this->progress->start();
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($destination, \ZipArchive::CREATE);
|
||||
$zip->addEmptyDir($name);
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($destination, \ZipArchive::CREATE);
|
||||
$zip->addEmptyDir($name);
|
||||
|
||||
$this->folderToZip($this->source, $zip, strlen($dir.DS), $this->progress);
|
||||
$zip->close();
|
||||
$this->progress->finish();
|
||||
$output->writeln('');
|
||||
$output->writeln('');
|
||||
$this->folderToZip($this->source, $zip, strlen($dir . DS), $this->progress);
|
||||
$zip->close();
|
||||
$this->progress->finish();
|
||||
$output->writeln('');
|
||||
$output->writeln('');
|
||||
|
||||
}
|
||||
|
||||
private static function folderToZip($folder, &$zipFile, $exclusiveLength, $progress) {
|
||||
/**
|
||||
* @param $folder
|
||||
* @param $zipFile
|
||||
* @param $exclusiveLength
|
||||
* @param $progress
|
||||
*/
|
||||
private static function folderToZip($folder, \ZipArchive &$zipFile, $exclusiveLength, ProgressBar $progress)
|
||||
{
|
||||
$handle = opendir($folder);
|
||||
while (false !== $f = readdir($handle)) {
|
||||
if ($f != '.' && $f != '..') {
|
||||
|
||||
@@ -3,14 +3,22 @@ namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
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\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
class CleanCommand extends Command {
|
||||
/**
|
||||
* Class CleanCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class CleanCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $paths_to_remove = [
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/.travis.yml',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/build.xml',
|
||||
@@ -128,13 +136,23 @@ class CleanCommand extends Command {
|
||||
'vendor/twig/twig/test',
|
||||
];
|
||||
|
||||
protected function configure() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("clean")
|
||||
->setDescription("Handles cleaning chores for Grav distribution")
|
||||
->setHelp('The <info>clean</info> clean extraneous folders and data');
|
||||
->setName("clean")
|
||||
->setDescription("Handles cleaning chores for Grav distribution")
|
||||
->setHelp('The <info>clean</info> clean extraneous folders and data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
@@ -151,14 +169,17 @@ class CleanCommand extends Command {
|
||||
}
|
||||
|
||||
// loops over the array of paths and deletes the files/folders
|
||||
private function cleanPaths($output)
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
private function cleanPaths(OutputInterface $output)
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<red>DELETING</red>');
|
||||
|
||||
$anything = false;
|
||||
|
||||
foreach($this->paths_to_remove as $path) {
|
||||
foreach ($this->paths_to_remove as $path) {
|
||||
$path = ROOT_DIR . $path;
|
||||
|
||||
if (is_dir($path) && @Folder::delete($path)) {
|
||||
|
||||
@@ -3,15 +3,23 @@ namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
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\Console\Formatter\OutputFormatterStyle;
|
||||
use \Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class ClearCacheCommand extends Command {
|
||||
/**
|
||||
* Class ClearCacheCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class ClearCacheCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $standard_remove = [
|
||||
'cache/twig/',
|
||||
'cache/doctrine/',
|
||||
@@ -21,20 +29,33 @@ class ClearCacheCommand extends Command {
|
||||
'assets/',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $all_remove = [
|
||||
'cache/',
|
||||
'images/',
|
||||
'assets/'
|
||||
];
|
||||
|
||||
protected function configure() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("clear-cache")
|
||||
->setDescription("Clears Grav cache")
|
||||
->addOption('all', null, InputOption::VALUE_NONE, 'If set will remove all')
|
||||
->setHelp('The <info>clear-cache</info> deletes all cache files');
|
||||
->setName("clear-cache")
|
||||
->setDescription("Clears Grav cache")
|
||||
->addOption('all', null, InputOption::VALUE_NONE, 'If set will remove all')
|
||||
->setHelp('The <info>clear-cache</info> deletes all cache files');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// Create a red output option
|
||||
@@ -47,7 +68,11 @@ class ClearCacheCommand extends Command {
|
||||
}
|
||||
|
||||
// loops over the array of paths and deletes the files/folders
|
||||
private function cleanPaths($input, $output)
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
private function cleanPaths(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<magenta>Clearing cache</magenta>');
|
||||
@@ -63,24 +88,29 @@ class ClearCacheCommand extends Command {
|
||||
$remove_paths = $this->standard_remove;
|
||||
}
|
||||
|
||||
foreach($remove_paths as $path) {
|
||||
foreach ($remove_paths as $path) {
|
||||
|
||||
$files = glob(ROOT_DIR . $path . '*');
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
if (@unlink($file)) $anything = true;
|
||||
}
|
||||
elseif (is_dir($file)) {
|
||||
if (@Folder::delete($file)) $anything = true;
|
||||
if (@unlink($file)) {
|
||||
$anything = true;
|
||||
}
|
||||
} elseif (is_dir($file)) {
|
||||
if (@Folder::delete($file)) {
|
||||
$anything = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($anything) $output->writeln('<red>Cleared: </red>' . $path . '*');
|
||||
if ($anything) {
|
||||
$output->writeln('<red>Cleared: </red>' . $path . '*');
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($user_config)) {
|
||||
touch ($user_config);
|
||||
touch($user_config);
|
||||
$output->writeln('');
|
||||
$output->writeln('<red>Touched: </red>' . $user_config);
|
||||
$output->writeln('');
|
||||
|
||||
@@ -2,39 +2,66 @@
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
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\Console\Formatter\OutputFormatterStyle;
|
||||
use \Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class InstallCommand extends Command {
|
||||
/**
|
||||
* Class InstallCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $config;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $local_config;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $destination;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $user_path;
|
||||
|
||||
protected function configure() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("install")
|
||||
->addOption(
|
||||
'symlink',
|
||||
's',
|
||||
InputOption::VALUE_NONE,
|
||||
'Symlink the required bits'
|
||||
)
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::OPTIONAL,
|
||||
'Where to install the required bits (default to current project)'
|
||||
->setName("install")
|
||||
->addOption(
|
||||
'symlink',
|
||||
's',
|
||||
InputOption::VALUE_NONE,
|
||||
'Symlink the required bits'
|
||||
)
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::OPTIONAL,
|
||||
'Where to install the required bits (default to current project)'
|
||||
|
||||
)
|
||||
->setDescription("Installs the dependencies needed by Grav. Optionally can create symbolic links")
|
||||
->setHelp('The <info>install</info> command installs the dependencies needed by Grav. Optionally can create symbolic links');
|
||||
)
|
||||
->setDescription("Installs the dependencies needed by Grav. Optionally can create symbolic links")
|
||||
->setHelp('The <info>install</info> command installs the dependencies needed by Grav. Optionally can create symbolic links');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
@@ -44,7 +71,7 @@ class InstallCommand extends Command {
|
||||
|
||||
// fix trailing slash
|
||||
$this->destination = rtrim($this->destination, DS) . DS;
|
||||
$this->user_path = $this->destination . USER_PATH;
|
||||
$this->user_path = $this->destination . USER_PATH;
|
||||
|
||||
// Create a red output option
|
||||
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
|
||||
@@ -60,7 +87,7 @@ class InstallCommand extends Command {
|
||||
// Look for dependencies file in ROOT and USER dir
|
||||
if (file_exists($this->user_path . $dependencies_file)) {
|
||||
$this->config = Yaml::parse($this->user_path . $dependencies_file);
|
||||
} elseif (file_exists($this->destination . $dependencies_file )) {
|
||||
} elseif (file_exists($this->destination . $dependencies_file)) {
|
||||
$this->config = Yaml::parse($this->destination . $dependencies_file);
|
||||
} else {
|
||||
$output->writeln('<red>ERROR</red> Missing .dependencies file in <cyan>user/</cyan> folder');
|
||||
@@ -68,7 +95,7 @@ class InstallCommand extends Command {
|
||||
|
||||
// Updates composer first
|
||||
$output->writeln("\nInstalling vendor dependencies");
|
||||
$output->writeln(system('php bin/composer.phar --working-dir="'.$this->destination.'" --no-interaction update'));
|
||||
$output->writeln(system('php bin/composer.phar --working-dir="' . $this->destination . '" --no-interaction update'));
|
||||
|
||||
// If yaml config, process
|
||||
if ($this->config) {
|
||||
@@ -78,21 +105,24 @@ class InstallCommand extends Command {
|
||||
$this->symlink($output);
|
||||
}
|
||||
} else {
|
||||
$output->writeln('<red>ERROR</red> invalid YAML in '. $dependencies_file);
|
||||
$output->writeln('<red>ERROR</red> invalid YAML in ' . $dependencies_file);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// loops over the array of paths and deletes the files/folders
|
||||
private function gitclone($output)
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
private function gitclone(OutputInterface $output)
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<green>Cloning Bits</green>');
|
||||
$output->writeln('============');
|
||||
$output->writeln('');
|
||||
|
||||
foreach($this->config['git'] as $repo => $data) {
|
||||
foreach ($this->config['git'] as $repo => $data) {
|
||||
$path = $this->destination . DS . $data['path'];
|
||||
if (!file_exists($path)) {
|
||||
exec('cd ' . $this->destination . ' && git clone -b ' . $data['branch'] . ' ' . $data['url'] . ' ' . $data['path']);
|
||||
@@ -107,7 +137,10 @@ class InstallCommand extends Command {
|
||||
}
|
||||
|
||||
// loops over the array of paths and deletes the files/folders
|
||||
private function symlink($output)
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
private function symlink(OutputInterface $output)
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<green>Symlinking Bits</green>');
|
||||
@@ -121,13 +154,13 @@ class InstallCommand extends Command {
|
||||
}
|
||||
|
||||
exec('cd ' . $this->destination);
|
||||
foreach($this->config['links'] as $repo => $data) {
|
||||
$from = $this->local_config[$data['scm'].'_repos'] . $data['src'];
|
||||
foreach ($this->config['links'] as $repo => $data) {
|
||||
$from = $this->local_config[$data['scm'] . '_repos'] . $data['src'];
|
||||
$to = $this->destination . $data['path'];
|
||||
|
||||
if (file_exists($from)) {
|
||||
if (!file_exists($to)) {
|
||||
symlink ($from, $to);
|
||||
symlink($from, $to);
|
||||
$output->writeln('<green>SUCCESS</green> symlinked <magenta>' . $data['src'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
|
||||
$output->writeln('');
|
||||
} else {
|
||||
|
||||
@@ -2,51 +2,66 @@
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
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\Console\Formatter\OutputFormatterStyle;
|
||||
use \Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class NewProjectCommand extends Command {
|
||||
/**
|
||||
* Class NewProjectCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class NewProjectCommand extends Command
|
||||
{
|
||||
|
||||
protected function configure() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("new-project")
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::REQUIRED,
|
||||
'The destination directory of your new Grav project'
|
||||
)
|
||||
->addOption(
|
||||
'symlink',
|
||||
's',
|
||||
InputOption::VALUE_NONE,
|
||||
'Symlink the required bits'
|
||||
)
|
||||
->setDescription("Creates a new Grav project with all the dependencies installed")
|
||||
->setHelp("The <info>new-project</info> command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.");
|
||||
->setName("new-project")
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::REQUIRED,
|
||||
'The destination directory of your new Grav project'
|
||||
)
|
||||
->addOption(
|
||||
'symlink',
|
||||
's',
|
||||
InputOption::VALUE_NONE,
|
||||
'Symlink the required bits'
|
||||
)
|
||||
->setDescription("Creates a new Grav project with all the dependencies installed")
|
||||
->setHelp("The <info>new-project</info> command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
$sandboxCommand = $this->getApplication()->find('sandbox');
|
||||
$sandboxCommand = $this->getApplication()->find('sandbox');
|
||||
$installCommand = $this->getApplication()->find('install');
|
||||
|
||||
$sandboxArguments = new ArrayInput(array(
|
||||
'command' => 'sandbox',
|
||||
'destination' => $input->getArgument('destination'),
|
||||
'-s' => $input->getOption('symlink')
|
||||
));
|
||||
'command' => 'sandbox',
|
||||
'destination' => $input->getArgument('destination'),
|
||||
'-s' => $input->getOption('symlink')
|
||||
));
|
||||
|
||||
$installArguments = new ArrayInput(array(
|
||||
'command' => 'install',
|
||||
'destination' => $input->getArgument('destination'),
|
||||
'-s' => $input->getOption('symlink')
|
||||
));
|
||||
'command' => 'install',
|
||||
'destination' => $input->getArgument('destination'),
|
||||
'-s' => $input->getOption('symlink')
|
||||
));
|
||||
|
||||
$sandboxCommand->run($sandboxArguments, $output);
|
||||
$installCommand->run($installArguments, $output);
|
||||
|
||||
@@ -3,98 +3,146 @@ namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
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\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
/**
|
||||
* Class SandboxCommand
|
||||
* @package Grav\Console\Cli
|
||||
*/
|
||||
class SandboxCommand extends Command
|
||||
{
|
||||
protected $directories = array('/cache',
|
||||
'/logs',
|
||||
'/images',
|
||||
'/assets',
|
||||
'/user/accounts',
|
||||
'/user/config',
|
||||
'/user/pages',
|
||||
'/user/data',
|
||||
'/user/plugins',
|
||||
'/user/themes',
|
||||
);
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $directories = array(
|
||||
'/cache',
|
||||
'/logs',
|
||||
'/images',
|
||||
'/assets',
|
||||
'/user/accounts',
|
||||
'/user/config',
|
||||
'/user/pages',
|
||||
'/user/data',
|
||||
'/user/plugins',
|
||||
'/user/themes',
|
||||
);
|
||||
|
||||
protected $files = array('/.dependencies',
|
||||
'/.htaccess',
|
||||
'/user/config/site.yaml',
|
||||
'/user/config/system.yaml',
|
||||
);
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $files = array(
|
||||
'/.dependencies',
|
||||
'/.editorconfig',
|
||||
'/.htaccess',
|
||||
'/user/config/site.yaml',
|
||||
'/user/config/system.yaml',
|
||||
);
|
||||
|
||||
protected $mappings = array('/index.php' => '/index.php',
|
||||
'/composer.json' => '/composer.json',
|
||||
'/bin' => '/bin',
|
||||
'/system' => '/system'
|
||||
);
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $mappings = array(
|
||||
'/index.php' => '/index.php',
|
||||
'/composer.json' => '/composer.json',
|
||||
'/bin' => '/bin',
|
||||
'/system' => '/system'
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $default_file = "---\ntitle: HomePage\n---\n# HomePage\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor eu felis sed ornare. Sed a mauris venenatis, pulvinar velit vel, dictum enim. Phasellus ac rutrum velit. Nunc lorem purus, hendrerit sit amet augue aliquet, iaculis ultricies nisl. Suspendisse tincidunt euismod risus, quis feugiat arcu tincidunt eget. Nulla eros mi, commodo vel ipsum vel, aliquet congue odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque velit orci, laoreet at adipiscing eu, interdum quis nibh. Nunc a accumsan purus.";
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $source;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $destination;
|
||||
/**
|
||||
* @var InputInterface $input
|
||||
*/
|
||||
protected $input;
|
||||
/**
|
||||
* @var OutputInterface $output
|
||||
*/
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('sandbox')
|
||||
->setDescription('Setup of a base Grav system in your webroot, good for development, playing around or starting fresh')
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::REQUIRED,
|
||||
'The destination directory to symlink into'
|
||||
)
|
||||
->addOption(
|
||||
'symlink',
|
||||
's',
|
||||
InputOption::VALUE_NONE,
|
||||
'Symlink the base grav system'
|
||||
)
|
||||
->setHelp("The <info>sandbox</info> command help create a development environment that can optionally use symbolic links to link the core of grav to the git cloned repository.\nGood for development, playing around or starting fresh");
|
||||
->setName('sandbox')
|
||||
->setDescription('Setup of a base Grav system in your webroot, good for development, playing around or starting fresh')
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::REQUIRED,
|
||||
'The destination directory to symlink into'
|
||||
)
|
||||
->addOption(
|
||||
'symlink',
|
||||
's',
|
||||
InputOption::VALUE_NONE,
|
||||
'Symlink the base grav system'
|
||||
)
|
||||
->setHelp("The <info>sandbox</info> command help create a development environment that can optionally use symbolic links to link the core of grav to the git cloned repository.\nGood for development, playing around or starting fresh");
|
||||
$this->source = getcwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->destination = $input->getArgument('destination');
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
// Create a red output option
|
||||
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
|
||||
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
|
||||
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
|
||||
$this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
|
||||
$this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
|
||||
$this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
|
||||
|
||||
// Symlink the Core Stuff
|
||||
if ($input->getOption('symlink')) {
|
||||
// Create Some core stuff if it doesn't exist
|
||||
$this->createDirectories($output);
|
||||
$this->createDirectories();
|
||||
|
||||
// Loop through the symlink mappings and create the symlinks
|
||||
$this->symlink($output);
|
||||
$this->symlink();
|
||||
|
||||
// Copy the Core STuff
|
||||
// Copy the Core STuff
|
||||
} else {
|
||||
// Create Some core stuff if it doesn't exist
|
||||
$this->createDirectories($output);
|
||||
$this->createDirectories();
|
||||
|
||||
// Loop through the symlink mappings and copy what otherwise would be symlinks
|
||||
$this->copy($output);
|
||||
$this->copy();
|
||||
}
|
||||
|
||||
$this->pages($output);
|
||||
$this->initFiles($output);
|
||||
$this->perms($output);
|
||||
$this->pages();
|
||||
$this->initFiles();
|
||||
$this->perms();
|
||||
}
|
||||
|
||||
private function createDirectories($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function createDirectories()
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>Creating Directories</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Creating Directories</comment>');
|
||||
$dirs_created = false;
|
||||
|
||||
if (!file_exists($this->destination)) {
|
||||
@@ -104,50 +152,56 @@ class SandboxCommand extends Command
|
||||
foreach ($this->directories as $dir) {
|
||||
if (!file_exists($this->destination . $dir)) {
|
||||
$dirs_created = true;
|
||||
$output->writeln(' <cyan>' . $dir . '</cyan>');
|
||||
$this->output->writeln(' <cyan>' . $dir . '</cyan>');
|
||||
mkdir($this->destination . $dir, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$dirs_created) {
|
||||
$output->writeln(' <red>Directories already exist</red>');
|
||||
$this->output->writeln(' <red>Directories already exist</red>');
|
||||
}
|
||||
}
|
||||
|
||||
private function copy($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function copy()
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>Copying Files</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Copying Files</comment>');
|
||||
|
||||
|
||||
foreach ($this->mappings as $source => $target) {
|
||||
if ((int) $source == $source) {
|
||||
if ((int)$source == $source) {
|
||||
$source = $target;
|
||||
}
|
||||
|
||||
$from = $this->source . $source;
|
||||
$to = $this->destination . $target;
|
||||
|
||||
$output->writeln(' <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
|
||||
$this->output->writeln(' <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
|
||||
$this->rcopy($from, $to);
|
||||
}
|
||||
}
|
||||
|
||||
private function symlink($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function symlink()
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>Resetting Symbolic Links</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Resetting Symbolic Links</comment>');
|
||||
|
||||
|
||||
foreach ($this->mappings as $source => $target) {
|
||||
if ((int) $source == $source) {
|
||||
if ((int)$source == $source) {
|
||||
$source = $target;
|
||||
}
|
||||
|
||||
$from = $this->source . $source;
|
||||
$to = $this->destination . $target;
|
||||
|
||||
$output->writeln(' <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
|
||||
$this->output->writeln(' <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
|
||||
|
||||
if (is_dir($to)) {
|
||||
@Folder::delete($to);
|
||||
@@ -158,17 +212,20 @@ class SandboxCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function initFiles($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function initFiles()
|
||||
{
|
||||
$this->check($output);
|
||||
$this->check($this->output);
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>File Initializing</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>File Initializing</comment>');
|
||||
$files_init = false;
|
||||
|
||||
// Copy files if they do not exist
|
||||
foreach ($this->files as $source => $target) {
|
||||
if ((int) $source == $source) {
|
||||
foreach ($this->files as $source => $target) {
|
||||
if ((int)$source == $source) {
|
||||
$source = $target;
|
||||
}
|
||||
|
||||
@@ -178,21 +235,24 @@ class SandboxCommand extends Command
|
||||
if (!file_exists($to)) {
|
||||
$files_init = true;
|
||||
copy($from, $to);
|
||||
$output->writeln(' <cyan>'.$target.'</cyan> <comment>-></comment> Created');
|
||||
$this->output->writeln(' <cyan>' . $target . '</cyan> <comment>-></comment> Created');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$files_init) {
|
||||
$output->writeln(' <red>Files already exist</red>');
|
||||
$this->output->writeln(' <red>Files already exist</red>');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function pages($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function pages()
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>Pages Initializing</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Pages Initializing</comment>');
|
||||
|
||||
// get pages files and initialize if no pages exist
|
||||
$pages_dir = $this->destination . '/user/pages';
|
||||
@@ -201,70 +261,83 @@ class SandboxCommand extends Command
|
||||
if (count($pages_files) == 0) {
|
||||
$destination = $this->source . '/user/pages';
|
||||
$this->rcopy($destination, $pages_dir);
|
||||
$output->writeln(' <cyan>'.$destination.'</cyan> <comment>-></comment> Created');
|
||||
$this->output->writeln(' <cyan>' . $destination . '</cyan> <comment>-></comment> Created');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function perms($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function perms()
|
||||
{
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>Permisions Initializing</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Permisions Initializing</comment>');
|
||||
|
||||
$dir_perms = 0755;
|
||||
|
||||
$binaries = glob($this->destination . DS .'bin' . DS . '*');
|
||||
$binaries = glob($this->destination . DS . 'bin' . DS . '*');
|
||||
|
||||
foreach($binaries as $bin) {
|
||||
foreach ($binaries as $bin) {
|
||||
chmod($bin, $dir_perms);
|
||||
$output->writeln(' <cyan>bin/' . basename($bin) . '</cyan> permissions reset to '. decoct($dir_perms));
|
||||
$this->output->writeln(' <cyan>bin/' . basename($bin) . '</cyan> permissions reset to ' . decoct($dir_perms));
|
||||
}
|
||||
|
||||
$output->writeln("");
|
||||
$this->output->writeln("");
|
||||
}
|
||||
|
||||
|
||||
private function check($output)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function check()
|
||||
{
|
||||
$success = true;
|
||||
|
||||
if (!file_exists($this->destination)) {
|
||||
$output->writeln(' file: <red>$this->destination</red> does not exist!');
|
||||
$this->output->writeln(' file: <red>$this->destination</red> does not exist!');
|
||||
$success = false;
|
||||
}
|
||||
|
||||
foreach ($this->directories as $dir) {
|
||||
if (!file_exists($this->destination . $dir)) {
|
||||
$output->writeln(' directory: <red>' . $dir . '</red> does not exist!');
|
||||
$this->output->writeln(' directory: <red>' . $dir . '</red> does not exist!');
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->mappings as $target => $link) {
|
||||
if (!file_exists($this->destination . $target)) {
|
||||
$output->writeln(' mappings: <red>' . $target . '</red> does not exist!');
|
||||
$this->output->writeln(' mappings: <red>' . $target . '</red> does not exist!');
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
if (!$success) {
|
||||
$output->writeln('');
|
||||
$output->writeln('<comment>install should be run with --symlink|--s to symlink first</comment>');
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>install should be run with --symlink|--s to symlink first</comment>');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function rcopy($src, $dest){
|
||||
/**
|
||||
* @param $src
|
||||
* @param $dest
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function rcopy($src, $dest)
|
||||
{
|
||||
|
||||
// If the src is not a directory do a simple file copy
|
||||
if(!is_dir($src)) {
|
||||
if (!is_dir($src)) {
|
||||
copy($src, $dest);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the destination directory does not exist create it
|
||||
if(!is_dir($dest)) {
|
||||
if(!mkdir($dest)) {
|
||||
// If the destination directory could not be created stop processing
|
||||
if (!is_dir($dest)) {
|
||||
if (!mkdir($dest)) {
|
||||
// If the destination directory could not be created stop processing
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -272,11 +345,13 @@ class SandboxCommand extends Command
|
||||
// Open the source directory to read in files
|
||||
$i = new \DirectoryIterator($src);
|
||||
/** @var \DirectoryIterator $f */
|
||||
foreach($i as $f) {
|
||||
if($f->isFile()) {
|
||||
foreach ($i as $f) {
|
||||
if ($f->isFile()) {
|
||||
copy($f->getRealPath(), "$dest/" . $f->getFilename());
|
||||
} else if(!$f->isDot() && $f->isDir()) {
|
||||
$this->rcopy($f->getRealPath(), "$dest/$f");
|
||||
} else {
|
||||
if (!$f->isDot() && $f->isDir()) {
|
||||
$this->rcopy($f->getRealPath(), "$dest/$f");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -5,19 +5,35 @@ use Grav\Common\GravTrait;
|
||||
use Grav\Console\Cli\ClearCacheCommand;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Class ConsoleTrait
|
||||
* @package Grav\Console
|
||||
*/
|
||||
trait ConsoleTrait
|
||||
{
|
||||
use GravTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $argv;
|
||||
|
||||
/* @var InputInterface $output */
|
||||
protected $input;
|
||||
|
||||
/* @var OutputInterface $output */
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* Set colors style definition for the formatter.
|
||||
*
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
public function setupConsole($input, $output)
|
||||
public function setupConsole(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (self::$grav) {
|
||||
self::$grav['config']->set('system.cache.driver', 'default');
|
||||
@@ -37,7 +53,10 @@ trait ConsoleTrait
|
||||
$this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold')));
|
||||
}
|
||||
|
||||
private function isGravInstance($path)
|
||||
/**
|
||||
* @param $path
|
||||
*/
|
||||
public function isGravInstance($path)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
$this->output->writeln('');
|
||||
@@ -64,6 +83,12 @@ trait ConsoleTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $all
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function clearCache($all = [])
|
||||
{
|
||||
if ($all) {
|
||||
|
||||
@@ -8,13 +8,26 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Class IndexCommand
|
||||
* @package Grav\Console\Gpm
|
||||
*/
|
||||
class IndexCommand extends Command
|
||||
{
|
||||
use ConsoleTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $data;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $gpm;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -29,11 +42,17 @@ class IndexCommand extends Command
|
||||
->setHelp('The <info>index</info> command lists the plugins and themes available for installation');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->setupConsole($input, $output);
|
||||
|
||||
$this->gpm = new GPM($this->input->getOption('force'));
|
||||
$this->gpm = new GPM($this->input->getOption('force'));
|
||||
|
||||
$this->data = $this->gpm->getRepository();
|
||||
|
||||
@@ -45,8 +64,8 @@ class IndexCommand extends Command
|
||||
$index = 0;
|
||||
foreach ($packages as $slug => $package) {
|
||||
$this->output->writeln(
|
||||
// index
|
||||
str_pad($index+++1, 2, '0', STR_PAD_LEFT) . ". " .
|
||||
// index
|
||||
str_pad($index++ + 1, 2, '0', STR_PAD_LEFT) . ". " .
|
||||
// package name
|
||||
"<cyan>" . str_pad($package->name, 15) . "</cyan> " .
|
||||
// slug
|
||||
@@ -67,17 +86,22 @@ class IndexCommand extends Command
|
||||
$this->output->writeln('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function versionDetails($package)
|
||||
{
|
||||
$list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
|
||||
$package = isset($list[$package->slug]) ? $list[$package->slug] : $package;
|
||||
$type = ucfirst(preg_replace("/s$/", '', $package->package_type));
|
||||
$list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
|
||||
$package = isset($list[$package->slug]) ? $list[$package->slug] : $package;
|
||||
$type = ucfirst(preg_replace("/s$/", '', $package->package_type));
|
||||
$updatable = $this->gpm->{'is' . $type . 'Updatable'}($package->slug);
|
||||
$installed = $this->gpm->{'is' . $type . 'Installed'}($package->slug);
|
||||
$local = $this->gpm->{'getInstalled' . $type}($package->slug);
|
||||
$local = $this->gpm->{'getInstalled' . $type}($package->slug);
|
||||
|
||||
if (!$installed || !$updatable) {
|
||||
$version = $installed ? $local->version : $package->version;
|
||||
$version = $installed ? $local->version : $package->version;
|
||||
$installed = !$installed ? ' (<magenta>not installed</magenta>)' : ' (<cyan>installed</cyan>)';
|
||||
|
||||
return str_pad(" [v<green>" . $version . "</green>]", 35) . $installed;
|
||||
@@ -86,8 +110,10 @@ class IndexCommand extends Command
|
||||
if ($updatable) {
|
||||
$installed = !$installed ? ' (<magenta>not installed</magenta>)' : ' (<cyan>installed</cyan>)';
|
||||
|
||||
return str_pad(" [v<red>" . $package->version . "</red> <cyan>➜</cyan> v<green>" . $package->available . "</green>]", 61) . $installed;
|
||||
return str_pad(" [v<red>" . $package->version . "</red> <cyan>➜</cyan> v<green>" . $package->available . "</green>]",
|
||||
61) . $installed;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,26 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Class InfoCommand
|
||||
* @package Grav\Console\Gpm
|
||||
*/
|
||||
class InfoCommand extends Command
|
||||
{
|
||||
use ConsoleTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $data;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $gpm;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -35,6 +48,12 @@ class InfoCommand extends Command
|
||||
->setHelp('The <info>info</info> shows more informations about a package');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->setupConsole($input, $output);
|
||||
@@ -63,9 +82,22 @@ class InfoCommand extends Command
|
||||
$packageURL = '<' . $foundPackage->author->url . '>';
|
||||
}
|
||||
|
||||
$this->output->writeln("<green>".str_pad("Author", 12).":</green> " . $foundPackage->author->name . ' <' . $foundPackage->author->email . '> '.$packageURL);
|
||||
$this->output->writeln("<green>" . str_pad("Author",
|
||||
12) . ":</green> " . $foundPackage->author->name . ' <' . $foundPackage->author->email . '> ' . $packageURL);
|
||||
|
||||
foreach (array('version', 'keywords', 'date', 'homepage', 'demo', 'docs', 'guide', 'repository', 'bugs', 'zipball_url', 'license') as $info) {
|
||||
foreach (array(
|
||||
'version',
|
||||
'keywords',
|
||||
'date',
|
||||
'homepage',
|
||||
'demo',
|
||||
'docs',
|
||||
'guide',
|
||||
'repository',
|
||||
'bugs',
|
||||
'zipball_url',
|
||||
'license'
|
||||
) as $info) {
|
||||
if (isset($foundPackage->$info)) {
|
||||
$name = ucfirst($info);
|
||||
$data = $foundPackage->$info;
|
||||
@@ -80,7 +112,7 @@ class InfoCommand extends Command
|
||||
}
|
||||
|
||||
$name = str_pad($name, 12);
|
||||
$this->output->writeln("<green>".$name.":</green> " . $data);
|
||||
$this->output->writeln("<green>" . $name . ":</green> " . $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,16 +13,38 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
/**
|
||||
* Class InstallCommand
|
||||
* @package Grav\Console\Gpm
|
||||
*/
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
use ConsoleTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $data;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $gpm;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $destination;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $file;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $tmp;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -48,21 +70,27 @@ class InstallCommand extends Command
|
||||
)
|
||||
->addArgument(
|
||||
'package',
|
||||
InputArgument::IS_ARRAY|InputArgument::REQUIRED,
|
||||
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
|
||||
'The package of which more informations are desired. Use the "index" command for a list of packages'
|
||||
)
|
||||
->setDescription("Performs the installation of plugins and themes")
|
||||
->setHelp('The <info>install</info> command allows to install plugins and themes');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->setupConsole($input, $output);
|
||||
|
||||
$this->gpm = new GPM($this->input->getOption('force'));
|
||||
$this->gpm = new GPM($this->input->getOption('force'));
|
||||
$this->destination = realpath($this->input->getOption('destination'));
|
||||
|
||||
$packages = array_map('strtolower', $this->input->getArgument('package'));
|
||||
$packages = array_map('strtolower', $this->input->getArgument('package'));
|
||||
$this->data = $this->gpm->findPackages($packages);
|
||||
|
||||
if (
|
||||
@@ -82,7 +110,8 @@ class InstallCommand extends Command
|
||||
}
|
||||
|
||||
if (count($this->data['not_found'])) {
|
||||
$this->output->writeln("These packages were not found on Grav: <red>" . implode('</red>, <red>', $this->data['not_found']) . "</red>");
|
||||
$this->output->writeln("These packages were not found on Grav: <red>" . implode('</red>, <red>',
|
||||
$this->data['not_found']) . "</red>");
|
||||
}
|
||||
|
||||
unset($this->data['not_found']);
|
||||
@@ -119,11 +148,16 @@ class InstallCommand extends Command
|
||||
$this->clearCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function downloadPackage($package)
|
||||
{
|
||||
$this->tmp = CACHE_DIR . DS . 'tmp/Grav-' . uniqid();
|
||||
$filename = $package->slug . basename($package->zipball_url);
|
||||
$output = Response::get($package->zipball_url, [], [$this, 'progress']);
|
||||
$output = Response::get($package->zipball_url, [], [$this, 'progress']);
|
||||
|
||||
Folder::mkdir($this->tmp);
|
||||
|
||||
@@ -136,10 +170,15 @@ class InstallCommand extends Command
|
||||
return $this->tmp . DS . $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $package
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkDestination($package)
|
||||
{
|
||||
$questionHelper = $this->getHelper('question');
|
||||
$skipPrompt = $this->input->getOption('all-yes');
|
||||
$skipPrompt = $this->input->getOption('all-yes');
|
||||
|
||||
Installer::isValidDestination($this->destination . DS . $package->install_path);
|
||||
|
||||
@@ -148,8 +187,9 @@ class InstallCommand extends Command
|
||||
$this->output->write("\x0D");
|
||||
$this->output->writeln(" |- Checking destination... <yellow>exists</yellow>");
|
||||
|
||||
$question = new ConfirmationQuestion(" | '- The package has been detected as installed already, do you want to overwrite it? [y|N] ", false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
$question = new ConfirmationQuestion(" | '- The package has been detected as installed already, do you want to overwrite it? [y|N] ",
|
||||
false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
|
||||
if (!$answer) {
|
||||
$this->output->writeln(" | '- <red>You decided to not overwrite the already installed package.</red>");
|
||||
@@ -169,8 +209,9 @@ class InstallCommand extends Command
|
||||
return false;
|
||||
}
|
||||
|
||||
$question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ", false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
$question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ",
|
||||
false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
|
||||
if (!$answer) {
|
||||
$this->output->writeln(" | '- <red>You decided to not delete the symlink automatically.</red>");
|
||||
@@ -185,17 +226,22 @@ class InstallCommand extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $package
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function installPackage($package)
|
||||
{
|
||||
$installer = Installer::install($this->file, $this->destination, ['install_path' => $package->install_path]);
|
||||
$errorCode = Installer::lastErrorCode();
|
||||
Installer::install($this->file, $this->destination, ['install_path' => $package->install_path]);
|
||||
$errorCode = Installer::lastErrorCode();
|
||||
Folder::delete($this->tmp);
|
||||
|
||||
if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
|
||||
$this->output->write("\x0D");
|
||||
// extra white spaces to clear out the buffer properly
|
||||
$this->output->writeln(" |- Installing package... <red>error</red> ");
|
||||
$this->output->writeln(" | '- " . $installer->lastErrorMsg());
|
||||
$this->output->writeln(" | '- " . Installer::lastErrorMsg());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -207,9 +253,13 @@ class InstallCommand extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $progress
|
||||
*/
|
||||
public function progress($progress)
|
||||
{
|
||||
$this->output->write("\x0D");
|
||||
$this->output->write(" |- Downloading package... " . str_pad($progress['percent'], 5, " ", STR_PAD_LEFT) . '%');
|
||||
$this->output->write(" |- Downloading package... " . str_pad($progress['percent'], 5, " ",
|
||||
STR_PAD_LEFT) . '%');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
namespace Grav\Console\Gpm;
|
||||
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
use Grav\Common\GPM\Upgrader;
|
||||
use Grav\Common\GPM\Installer;
|
||||
use Grav\Common\GPM\Response;
|
||||
use Grav\Common\GPM\Upgrader;
|
||||
use Grav\Console\ConsoleTrait;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@@ -12,16 +12,46 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
/**
|
||||
* Class SelfupgradeCommand
|
||||
* @package Grav\Console\Gpm
|
||||
*/
|
||||
class SelfupgradeCommand extends Command
|
||||
{
|
||||
use ConsoleTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $data;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $extensions;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $updatable;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $file;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $types = array('plugins', 'themes');
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $tmp;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $upgrader;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -43,14 +73,20 @@ class SelfupgradeCommand extends Command
|
||||
->setHelp('The <info>update</info> command updates plugins and themes when a new version is available');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->setupConsole($input, $output);
|
||||
$this->upgrader = new Upgrader($this->input->getOption('force'));
|
||||
|
||||
$local = $this->upgrader->getLocalVersion();
|
||||
$remote = $this->upgrader->getRemoteVersion();
|
||||
$update = $this->upgrader->getAssets()->{'grav-update'};
|
||||
$local = $this->upgrader->getLocalVersion();
|
||||
$remote = $this->upgrader->getRemoteVersion();
|
||||
$update = $this->upgrader->getAssets()->{'grav-update'};
|
||||
$release = strftime('%c', strtotime($this->upgrader->getReleaseDate()));
|
||||
|
||||
if (!$this->upgrader->isUpgradable()) {
|
||||
@@ -59,14 +95,15 @@ class SelfupgradeCommand extends Command
|
||||
}
|
||||
|
||||
$questionHelper = $this->getHelper('question');
|
||||
$skipPrompt = $this->input->getOption('all-yes');
|
||||
$skipPrompt = $this->input->getOption('all-yes');
|
||||
|
||||
$this->output->writeln("Grav v<cyan>$remote</cyan> is now available [release date: $release].");
|
||||
$this->output->writeln("You are currently using v<cyan>".GRAV_VERSION."</cyan>.");
|
||||
$this->output->writeln("You are currently using v<cyan>" . GRAV_VERSION . "</cyan>.");
|
||||
|
||||
if (!$skipPrompt) {
|
||||
$question = new ConfirmationQuestion("Would you like to read the changelog before proceeding? [y|N] ", false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
$question = new ConfirmationQuestion("Would you like to read the changelog before proceeding? [y|N] ",
|
||||
false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
|
||||
if ($answer) {
|
||||
$changelog = $this->upgrader->getChangelog(GRAV_VERSION);
|
||||
@@ -74,8 +111,8 @@ class SelfupgradeCommand extends Command
|
||||
$this->output->writeln("");
|
||||
foreach ($changelog as $version => $log) {
|
||||
$title = $version . ' [' . $log->date . ']';
|
||||
$content = preg_replace_callback("/\d\.\s\[\]\(#(.*)\)/", function($match){
|
||||
return "\n".ucfirst($match[1]).":";
|
||||
$content = preg_replace_callback("/\d\.\s\[\]\(#(.*)\)/", function ($match) {
|
||||
return "\n" . ucfirst($match[1]) . ":";
|
||||
}, $log->content);
|
||||
|
||||
$this->output->writeln($title);
|
||||
@@ -89,7 +126,7 @@ class SelfupgradeCommand extends Command
|
||||
}
|
||||
|
||||
$question = new ConfirmationQuestion("Would you like to upgrade now? [y|N] ", false);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
|
||||
if (!$answer) {
|
||||
$this->output->writeln("Aborting...");
|
||||
@@ -116,13 +153,18 @@ class SelfupgradeCommand extends Command
|
||||
}
|
||||
|
||||
// clear cache after successful upgrade
|
||||
$this->clearCache(true);
|
||||
$this->clearCache('all');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function download($package)
|
||||
{
|
||||
$this->tmp = CACHE_DIR . DS . 'tmp/Grav-' . uniqid();
|
||||
$output = Response::get($package->download, [], [$this, 'progress']);
|
||||
$output = Response::get($package->download, [], [$this, 'progress']);
|
||||
|
||||
Folder::mkdir($this->tmp);
|
||||
|
||||
@@ -135,17 +177,21 @@ class SelfupgradeCommand extends Command
|
||||
return $this->tmp . DS . $package->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function upgrade()
|
||||
{
|
||||
$installer = Installer::install($this->file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]);
|
||||
$errorCode = Installer::lastErrorCode();
|
||||
Installer::install($this->file, GRAV_ROOT,
|
||||
['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]);
|
||||
$errorCode = Installer::lastErrorCode();
|
||||
Folder::delete($this->tmp);
|
||||
|
||||
if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
|
||||
$this->output->write("\x0D");
|
||||
// extra white spaces to clear out the buffer properly
|
||||
$this->output->writeln(" |- Installing upgrade... <red>error</red> ");
|
||||
$this->output->writeln(" | '- " . $installer->lastErrorMsg());
|
||||
$this->output->writeln(" | '- " . Installer::lastErrorMsg());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -157,17 +203,27 @@ class SelfupgradeCommand extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $progress
|
||||
*/
|
||||
public function progress($progress)
|
||||
{
|
||||
$this->output->write("\x0D");
|
||||
$this->output->write(" |- Downloading upgrade [" . $this->formatBytes($progress["filesize"]) . "]... " . str_pad($progress['percent'], 5, " ", STR_PAD_LEFT) . '%');
|
||||
$this->output->write(" |- Downloading upgrade [" . $this->formatBytes($progress["filesize"]) . "]... " . str_pad($progress['percent'],
|
||||
5, " ", STR_PAD_LEFT) . '%');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $size
|
||||
* @param int $precision
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatBytes($size, $precision = 2)
|
||||
{
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array('', 'k', 'M', 'G', 'T');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[(int)floor($base)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,46 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
/**
|
||||
* Class UpdateCommand
|
||||
* @package Grav\Console\Gpm
|
||||
*/
|
||||
class UpdateCommand extends Command
|
||||
{
|
||||
use ConsoleTrait;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $data;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $extensions;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $updatable;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $destination;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $file;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $types = array('plugins', 'themes');
|
||||
/**
|
||||
* @var GPM $gpm
|
||||
*/
|
||||
protected $gpm;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -42,18 +71,24 @@ class UpdateCommand extends Command
|
||||
)
|
||||
->addArgument(
|
||||
'package',
|
||||
InputArgument::IS_ARRAY|InputArgument::OPTIONAL,
|
||||
InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
|
||||
'The package or packages that is desired to update. By default all available updates will be applied.'
|
||||
)
|
||||
->setDescription("Detects and performs an update of plugins and themes when available")
|
||||
->setHelp('The <info>update</info> command updates plugins and themes when a new version is available');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->setupConsole($input, $output);
|
||||
|
||||
$this->gpm = new GPM($this->input->getOption('force'));
|
||||
$this->gpm = new GPM($this->input->getOption('force'));
|
||||
$this->destination = realpath($this->input->getOption('destination'));
|
||||
|
||||
if (!Installer::isGravInstance($this->destination)) {
|
||||
@@ -61,7 +96,7 @@ class UpdateCommand extends Command
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->data = $this->gpm->getUpdatable();
|
||||
$this->data = $this->gpm->getUpdatable();
|
||||
$onlyPackages = array_map('strtolower', $this->input->getArgument('package'));
|
||||
|
||||
if (!$this->data['total']) {
|
||||
@@ -90,7 +125,7 @@ class UpdateCommand extends Command
|
||||
}
|
||||
|
||||
$this->output->writeln(
|
||||
// index
|
||||
// index
|
||||
str_pad($index++ + 1, 2, '0', STR_PAD_LEFT) . ". " .
|
||||
// name
|
||||
"<cyan>" . str_pad($package->name, 15) . "</cyan> " .
|
||||
@@ -104,8 +139,8 @@ class UpdateCommand extends Command
|
||||
// prompt to continue
|
||||
$this->output->writeln("");
|
||||
$questionHelper = $this->getHelper('question');
|
||||
$question = new ConfirmationQuestion("Continue with the update process? [Y|n] ", true);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
$question = new ConfirmationQuestion("Continue with the update process? [Y|n] ", true);
|
||||
$answer = $questionHelper->ask($this->input, $this->output, $question);
|
||||
|
||||
if (!$answer) {
|
||||
$this->output->writeln("Update aborted. Exiting...");
|
||||
@@ -115,13 +150,13 @@ class UpdateCommand extends Command
|
||||
// finally update
|
||||
$installCommand = $this->getApplication()->find('install');
|
||||
|
||||
$args = new ArrayInput(array(
|
||||
'command' => 'install',
|
||||
'package' => $slugs,
|
||||
'-f' => $this->input->getOption('force'),
|
||||
'-d' => $this->destination,
|
||||
'-y' => true
|
||||
));
|
||||
$args = new ArrayInput(array(
|
||||
'command' => 'install',
|
||||
'package' => $slugs,
|
||||
'-f' => $this->input->getOption('force'),
|
||||
'-d' => $this->destination,
|
||||
'-y' => true
|
||||
));
|
||||
$commandExec = $installCommand->run($args, $this->output);
|
||||
|
||||
if ($commandExec != 0) {
|
||||
@@ -133,9 +168,14 @@ class UpdateCommand extends Command
|
||||
$this->clearCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $onlyPackages
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function userInputPackages($onlyPackages)
|
||||
{
|
||||
$found = ['total' => 0];
|
||||
$found = ['total' => 0];
|
||||
$ignore = [];
|
||||
|
||||
if (!count($onlyPackages)) {
|
||||
@@ -159,15 +199,17 @@ class UpdateCommand extends Command
|
||||
$list = array_keys($list);
|
||||
|
||||
if ($found['total'] !== $this->data['total']) {
|
||||
$this->output->write(", only <magenta>".$found['total']."</magenta> will be updated");
|
||||
$this->output->write(", only <magenta>" . $found['total'] . "</magenta> will be updated");
|
||||
}
|
||||
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln("Limiting updates for only <cyan>".implode('</cyan>, <cyan>', $list)."</cyan>");
|
||||
$this->output->writeln("Limiting updates for only <cyan>" . implode('</cyan>, <cyan>',
|
||||
$list) . "</cyan>");
|
||||
}
|
||||
|
||||
if (count($ignore)) {
|
||||
$this->output->writeln("Packages not found or not requiring updates: <red>".implode('</red>, <red>', $ignore)."</red>");
|
||||
$this->output->writeln("Packages not found or not requiring updates: <red>" . implode('</red>, <red>',
|
||||
$ignore) . "</red>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user