first commit
This commit is contained in:
90
system/src/Grav/Console/Cli/BackupCommand.php
Normal file
90
system/src/Grav/Console/Cli/BackupCommand.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Backup\ZipBackup;
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use RocketTheme\Toolbox\File\JsonFile;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class BackupCommand extends ConsoleCommand
|
||||
{
|
||||
/** @var string $source */
|
||||
protected $source;
|
||||
|
||||
/** @var ProgressBar $progress */
|
||||
protected $progress;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("backup")
|
||||
->addArgument(
|
||||
'destination',
|
||||
InputArgument::OPTIONAL,
|
||||
'Where to store the backup (/backup is default)'
|
||||
|
||||
)
|
||||
->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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
$this->progress = new ProgressBar($this->output);
|
||||
$this->progress->setFormat('Archiving <cyan>%current%</cyan> files [<green>%bar%</green>] %elapsed:6s% %memory:6s%');
|
||||
|
||||
Grav::instance()['config']->init();
|
||||
|
||||
$destination = ($this->input->getArgument('destination')) ? $this->input->getArgument('destination') : null;
|
||||
$log = JsonFile::instance(Grav::instance()['locator']->findResource("log://backup.log", true, true));
|
||||
$backup = ZipBackup::backup($destination, [$this, 'output']);
|
||||
|
||||
$log->content([
|
||||
'time' => time(),
|
||||
'location' => $backup
|
||||
]);
|
||||
$log->save();
|
||||
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
*/
|
||||
public function output($args)
|
||||
{
|
||||
switch ($args['type']) {
|
||||
case 'message':
|
||||
$this->output->writeln($args['message']);
|
||||
break;
|
||||
case 'progress':
|
||||
if ($args['complete']) {
|
||||
$this->progress->finish();
|
||||
} else {
|
||||
$this->progress->advance();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
278
system/src/Grav/Console/Cli/CleanCommand.php
Normal file
278
system/src/Grav/Console/Cli/CleanCommand.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
class CleanCommand extends Command
|
||||
{
|
||||
/* @var InputInterface $output */
|
||||
protected $input;
|
||||
|
||||
/* @var OutputInterface $output */
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $paths_to_remove = [
|
||||
'codeception.yml',
|
||||
'tests/',
|
||||
'user/plugins/admin/vendor/bacon/bacon-qr-code/tests',
|
||||
'user/plugins/admin/vendor/bacon/bacon-qr-code/.gitignore',
|
||||
'user/plugins/admin/vendor/bacon/bacon-qr-code/.travis.yml',
|
||||
'user/plugins/admin/vendor/bacon/bacon-qr-code/composer.json',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/demo',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/.vs',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/tests',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/.gitignore',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/.travis.yml',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/composer.json',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/composer.lock',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/logo.png',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/multifactorauthforeveryone.png',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/TwoFactorAuth.phpproj',
|
||||
'user/plugins/admin/vendor/robthree/twofactorauth/TwoFactorAuth.sin',
|
||||
'user/plugins/admin/vendor/zendframework/zendxml/tests',
|
||||
'user/plugins/admin/vendor/zendframework/zendxml/.gitignore',
|
||||
'user/plugins/admin/vendor/zendframework/zendxml/.travis.yml',
|
||||
'user/plugins/admin/vendor/zendframework/zendxml/composer.json',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/.travis.yml',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/build.xml',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/composer.json',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/create_pear_package.php',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/package.xml.tpl',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/.gitattributes',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/.gitignore',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/README.git',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/tests',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/test-suite',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/notes',
|
||||
'user/plugins/email/vendor/swiftmailer/swiftmailer/doc',
|
||||
'user/themes/antimatter/.sass-cache',
|
||||
'vendor/antoligy/dom-string-iterators/composer.json',
|
||||
'vendor/doctrine/cache/.travis.yml',
|
||||
'vendor/doctrine/cache/build.properties',
|
||||
'vendor/doctrine/cache/build.xml',
|
||||
'vendor/doctrine/cache/composer.json',
|
||||
'vendor/doctrine/cache/phpunit.xml.dist',
|
||||
'vendor/doctrine/cache/.coveralls.yml',
|
||||
'vendor/doctrine/cache/.gitignore',
|
||||
'vendor/doctrine/cache/.git',
|
||||
'vendor/doctrine/cache/tests',
|
||||
'vendor/doctrine/collections/composer.json',
|
||||
'vendor/doctrine/collections/phpunit.xml.dist',
|
||||
'vendor/doctrine/collections/tests',
|
||||
'vendor/donatj/phpuseragentparser/.git',
|
||||
'vendor/donatj/phpuseragentparser/.gitignore',
|
||||
'vendor/donatj/phpuseragentparser/.travis.yml',
|
||||
'vendor/donatj/phpuseragentparser/composer.json',
|
||||
'vendor/donatj/phpuseragentparser/phpunit.xml.dist',
|
||||
'vendor/donatj/phpuseragentparser/Tests',
|
||||
'vendor/donatj/phpuseragentparser/Tools',
|
||||
'vendor/erusev/parsedown/composer.json',
|
||||
'vendor/erusev/parsedown/phpunit.xml.dist',
|
||||
'vendor/erusev/parsedown/.travis.yml',
|
||||
'vendor/erusev/parsedown/.git',
|
||||
'vendor/erusev/parsedown/test',
|
||||
'vendor/erusev/parsedown-extra/composer.json',
|
||||
'vendor/erusev/parsedown-extra/phpunit.xml.dist',
|
||||
'vendor/erusev/parsedown-extra/.travis.yml',
|
||||
'vendor/erusev/parsedown-extra/.git',
|
||||
'vendor/erusev/parsedown-extra/test',
|
||||
'vendor/filp/whoops/composer.json',
|
||||
'vendor/filp/whoops/docs',
|
||||
'vendor/filp/whoops/examples',
|
||||
'vendor/filp/whoops/tests',
|
||||
'vendor/filp/whoops/.git',
|
||||
'vendor/filp/whoops/.gitignore',
|
||||
'vendor/filp/whoops/.scrutinizer.yml',
|
||||
'vendor/filp/whoops/.travis.yml',
|
||||
'vendor/filp/whoops/phpunit.xml.dist',
|
||||
'vendor/gregwar/image/Gregwar/Image/composer.json',
|
||||
'vendor/gregwar/image/Gregwar/Image/phpunit.xml',
|
||||
'vendor/gregwar/image/Gregwar/Image/.gitignore',
|
||||
'vendor/gregwar/image/Gregwar/Image/.git',
|
||||
'vendor/gregwar/image/Gregwar/Image/doc',
|
||||
'vendor/gregwar/image/Gregwar/Image/demo',
|
||||
'vendor/gregwar/image/Gregwar/Image/tests',
|
||||
'vendor/gregwar/cache/Gregwar/Cache/composer.json',
|
||||
'vendor/gregwar/cache/Gregwar/Cache/phpunit.xml',
|
||||
'vendor/gregwar/cache/Gregwar/Cache/.gitignore',
|
||||
'vendor/gregwar/cache/Gregwar/Cache/.git',
|
||||
'vendor/gregwar/cache/Gregwar/Cache/demo',
|
||||
'vendor/gregwar/cache/Gregwar/Cache/tests',
|
||||
'vendor/ircmaxell/password-compat/composer.json',
|
||||
'vendor/ircmaxell/password-compat/phpunit.xml.dist',
|
||||
'vendor/ircmaxell/password-compat/version-test.php',
|
||||
'vendor/ircmaxell/password-compat/.travis.yml',
|
||||
'vendor/ircmaxell/password-compat/test',
|
||||
'vendor/league/climate/composer.json',
|
||||
'vendor/matthiasmullie/minify/bin',
|
||||
'vendor/matthiasmullie/minify/composer.json',
|
||||
'vendor/matthiasmullie/minify/docker-composer.yml',
|
||||
'vendor/matthiasmullie/minify/Dockerfile',
|
||||
'vendor/matthiasmullie/minify/CONTRIBUTING.md',
|
||||
'vendor/matthiasmullie/path-converter/composer.json',
|
||||
'vendor/maximebf/debugbar/bower.json',
|
||||
'vendor/maximebf/debugbar/composer.json',
|
||||
'vendor/maximebf/debugbar/.bowerrc',
|
||||
'vendor/maximebf/debugbar/src/DebugBar/Resources/vendor',
|
||||
'vendor/maximebf/debugbar/demo',
|
||||
'vendor/maximebf/debugbar/docs',
|
||||
'vendor/maximebf/debugbar/tests',
|
||||
'vendor/maximebf/debugbar/phpunit.xml.dist',
|
||||
'vendor/miljar/php-exif/.coveralls.yml',
|
||||
'vendor/miljar/php-exif/.gitignore',
|
||||
'vendor/miljar/php-exif/.travis.yml',
|
||||
'vendor/miljar/php-exif/composer.json',
|
||||
'vendor/miljar/php-exif/composer.lock',
|
||||
'vendor/miljar/php-exif/phpunit.xml.dist',
|
||||
'vendor/miljar/php-exif/Resources',
|
||||
'vendor/miljar/php-exif/tests',
|
||||
'vendor/monolog/monolog/composer.json',
|
||||
'vendor/monolog/monolog/doc',
|
||||
'vendor/monolog/monolog/phpunit.xml.dist',
|
||||
'vendor/monolog/monolog/.php_cs',
|
||||
'vendor/monolog/monolog/tests',
|
||||
'vendor/pimple/pimple/.gitignore',
|
||||
'vendor/pimple/pimple/.travis.yml',
|
||||
'vendor/pimple/pimple/composer.json',
|
||||
'vendor/pimple/pimple/ext',
|
||||
'vendor/pimple/pimple/phpunit.xml.dist',
|
||||
'vendor/pimple/pimple/src/Pimple/Tests',
|
||||
'vendor/psr/container/composer.json',
|
||||
'vendor/psr/container/.gitignore',
|
||||
'vendor/psr/simple-cache/composer.json',
|
||||
'vendor/psr/log/composer.json',
|
||||
'vendor/psr/log/.gitignore',
|
||||
'vendor/rockettheme/toolbox/.git',
|
||||
'vendor/rockettheme/toolbox/.gitignore',
|
||||
'vendor/rockettheme/toolbox/.scrutinizer.yml',
|
||||
'vendor/rockettheme/toolbox/.travis.yml',
|
||||
'vendor/rockettheme/toolbox/composer.json',
|
||||
'vendor/rockettheme/toolbox/phpunit.xml',
|
||||
'vendor/seld/cli-prompt/composer.json',
|
||||
'vendor/seld/cli-prompt/.gitignore',
|
||||
'vendor/symfony/console/composer.json',
|
||||
'vendor/symfony/console/phpunit.xml.dist',
|
||||
'vendor/symfony/console/.gitignore',
|
||||
'vendor/symfony/console/.git',
|
||||
'vendor/symfony/console/Tester',
|
||||
'vendor/symfony/console/Tests',
|
||||
'vendor/symfony/debug/.gitignore',
|
||||
'vendor/symfony/debug/.git',
|
||||
'vendor/symfony/debug/phpunit.xml.dist',
|
||||
'vendor/symfony/debug/composer.json',
|
||||
'vendor/symfony/debug/Tests',
|
||||
'vendor/symfony/debug/Resources',
|
||||
'vendor/symfony/event-dispatcher/.git',
|
||||
'vendor/symfony/event-dispatcher/.gitignore',
|
||||
'vendor/symfony/event-dispatcher/composer.json',
|
||||
'vendor/symfony/event-dispatcher/phpunit.xml.dist',
|
||||
'vendor/symfony/event-dispatcher/Tests',
|
||||
'vendor/symfony/polyfill-iconv/.git',
|
||||
'vendor/symfony/polyfill-iconv/.gitignore',
|
||||
'vendor/symfony/polyfill-iconv/composer.json',
|
||||
'vendor/symfony/polyfill-mbstring/.git',
|
||||
'vendor/symfony/polyfill-mbstring/.gitignore',
|
||||
'vendor/symfony/polyfill-mbstring/composer.json',
|
||||
'vendor/symfony/var-dumper/.git',
|
||||
'vendor/symfony/var-dumper/.gitignore',
|
||||
'vendor/symfony/var-dumper/composer.json',
|
||||
'vendor/symfony/var-dumper/phpunit.xml.dist',
|
||||
'vendor/symfony/var-dumper/Test',
|
||||
'vendor/symfony/var-dumper/Tests',
|
||||
'vendor/symfony/yaml/composer.json',
|
||||
'vendor/symfony/yaml/phpunit.xml.dist',
|
||||
'vendor/symfony/yaml/.gitignore',
|
||||
'vendor/symfony/yaml/.git',
|
||||
'vendor/symfony/yaml/Tests',
|
||||
'vendor/twig/twig/.editorconfig',
|
||||
'vendor/twig/twig/.php_cs.dist',
|
||||
'vendor/twig/twig/.travis.yml',
|
||||
'vendor/twig/twig/.gitignore',
|
||||
'vendor/twig/twig/.git',
|
||||
'vendor/twig/twig/composer.json',
|
||||
'vendor/twig/twig/phpunit.xml.dist',
|
||||
'vendor/twig/twig/doc',
|
||||
'vendor/twig/twig/ext',
|
||||
'vendor/twig/twig/test',
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->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)
|
||||
{
|
||||
$this->setupConsole($input, $output);
|
||||
|
||||
$this->cleanPaths();
|
||||
}
|
||||
|
||||
private function cleanPaths()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<red>DELETING</red>');
|
||||
$anything = false;
|
||||
foreach ($this->paths_to_remove as $path) {
|
||||
$path = ROOT_DIR . $path;
|
||||
if (is_dir($path) && @Folder::delete($path)) {
|
||||
$anything = true;
|
||||
$this->output->writeln('<red>dir: </red>' . $path);
|
||||
} elseif (is_file($path) && @unlink($path)) {
|
||||
$anything = true;
|
||||
$this->output->writeln('<red>file: </red>' . $path);
|
||||
}
|
||||
}
|
||||
if (!$anything) {
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<green>Nothing to clean...</green>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colors style definition for the formatter.
|
||||
*
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
public function setupConsole(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
$this->output->getFormatter()->setStyle('normal', new OutputFormatterStyle('white'));
|
||||
$this->output->getFormatter()->setStyle('yellow', new OutputFormatterStyle('yellow', null, ['bold']));
|
||||
$this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, ['bold']));
|
||||
$this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, ['bold']));
|
||||
$this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, ['bold']));
|
||||
$this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, ['bold']));
|
||||
$this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, ['bold']));
|
||||
}
|
||||
|
||||
}
|
70
system/src/Grav/Console/Cli/ClearCacheCommand.php
Normal file
70
system/src/Grav/Console/Cli/ClearCacheCommand.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Cache;
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ClearCacheCommand extends ConsoleCommand
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('clear-cache')
|
||||
->setAliases(['clearcache'])
|
||||
->setDescription('Clears Grav cache')
|
||||
->addOption('all', null, InputOption::VALUE_NONE, 'If set will remove all including compiled, twig, doctrine caches')
|
||||
->addOption('assets-only', null, InputOption::VALUE_NONE, 'If set will remove only assets/*')
|
||||
->addOption('images-only', null, InputOption::VALUE_NONE, 'If set will remove only images/*')
|
||||
->addOption('cache-only', null, InputOption::VALUE_NONE, 'If set will remove only cache/*')
|
||||
->addOption('tmp-only', null, InputOption::VALUE_NONE, 'If set will remove only tmp/*')
|
||||
->setHelp('The <info>clear-cache</info> deletes all cache files');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
$this->cleanPaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* loops over the array of paths and deletes the files/folders
|
||||
*/
|
||||
private function cleanPaths()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<magenta>Clearing cache</magenta>');
|
||||
$this->output->writeln('');
|
||||
|
||||
if ($this->input->getOption('all')) {
|
||||
$remove = 'all';
|
||||
} elseif ($this->input->getOption('assets-only')) {
|
||||
$remove = 'assets-only';
|
||||
} elseif ($this->input->getOption('images-only')) {
|
||||
$remove = 'images-only';
|
||||
} elseif ($this->input->getOption('cache-only')) {
|
||||
$remove = 'cache-only';
|
||||
} elseif ($this->input->getOption('tmp-only')) {
|
||||
$remove = 'tmp-only';
|
||||
} else {
|
||||
$remove = 'standard';
|
||||
}
|
||||
|
||||
foreach (Cache::clearCache($remove) as $result) {
|
||||
$this->output->writeln($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
72
system/src/Grav/Console/Cli/ComposerCommand.php
Normal file
72
system/src/Grav/Console/Cli/ComposerCommand.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ComposerCommand extends ConsoleCommand
|
||||
{
|
||||
/**
|
||||
* @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 vendor dependencies needed by Grav.")
|
||||
->setHelp('The <info>composer</info> command updates the composer vendor dependencies needed by Grav');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
$action = $this->input->getOption('install') ? 'install' : ($this->input->getOption('update') ? 'update' : 'install');
|
||||
|
||||
if ($this->input->getOption('install')) {
|
||||
$action = 'install';
|
||||
}
|
||||
|
||||
// Updates composer first
|
||||
$this->output->writeln("\nInstalling vendor dependencies");
|
||||
$this->output->writeln($this->composerUpdate(GRAV_ROOT, $action));
|
||||
}
|
||||
|
||||
}
|
186
system/src/Grav/Console/Cli/InstallCommand.php
Normal file
186
system/src/Grav/Console/Cli/InstallCommand.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use RocketTheme\Toolbox\File\YamlFile;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class InstallCommand extends ConsoleCommand
|
||||
{
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $config;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $local_config;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $destination;
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $user_path;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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)'
|
||||
)
|
||||
->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');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
$dependencies_file = '.dependencies';
|
||||
$this->destination = ($this->input->getArgument('destination')) ? $this->input->getArgument('destination') : ROOT_DIR;
|
||||
|
||||
// fix trailing slash
|
||||
$this->destination = rtrim($this->destination, DS) . DS;
|
||||
$this->user_path = $this->destination . USER_PATH;
|
||||
if ($local_config_file = $this->loadLocalConfig()) {
|
||||
$this->output->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
|
||||
}
|
||||
|
||||
// Look for dependencies file in ROOT and USER dir
|
||||
if (file_exists($this->user_path . $dependencies_file)) {
|
||||
$file = YamlFile::instance($this->user_path . $dependencies_file);
|
||||
} elseif (file_exists($this->destination . $dependencies_file)) {
|
||||
$file = YamlFile::instance($this->destination . $dependencies_file);
|
||||
} else {
|
||||
$this->output->writeln('<red>ERROR</red> Missing .dependencies file in <cyan>user/</cyan> folder');
|
||||
if ($this->input->getArgument('destination')) {
|
||||
$this->output->writeln('<yellow>HINT</yellow> <info>Are you trying to install a plugin or a theme? Make sure you use <cyan>bin/gpm install <something></cyan>, not <cyan>bin/grav install</cyan>. This command is only used to install Grav skeletons.');
|
||||
} else {
|
||||
$this->output->writeln('<yellow>HINT</yellow> <info>Are you trying to install Grav? Grav is already installed. You need to run this command only if you download a skeleton from GitHub directly.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->config = $file->content();
|
||||
$file->free();
|
||||
|
||||
// If yaml config, process
|
||||
if ($this->config) {
|
||||
if (!$this->input->getOption('symlink')) {
|
||||
// Updates composer first
|
||||
$this->output->writeln("\nInstalling vendor dependencies");
|
||||
$this->output->writeln($this->composerUpdate(GRAV_ROOT, 'install'));
|
||||
|
||||
$this->gitclone();
|
||||
} else {
|
||||
$this->symlink();
|
||||
}
|
||||
} else {
|
||||
$this->output->writeln('<red>ERROR</red> invalid YAML in ' . $dependencies_file);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones from Git
|
||||
*/
|
||||
private function gitclone()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<green>Cloning Bits</green>');
|
||||
$this->output->writeln('============');
|
||||
$this->output->writeln('');
|
||||
|
||||
foreach ($this->config['git'] as $repo => $data) {
|
||||
$this->destination = rtrim($this->destination, DS);
|
||||
$path = $this->destination . DS . $data['path'];
|
||||
if (!file_exists($path)) {
|
||||
exec('cd "' . $this->destination . '" && git clone -b ' . $data['branch'] . ' --depth 1 ' . $data['url'] . ' ' . $data['path'], $output, $return);
|
||||
|
||||
if (!$return) {
|
||||
$this->output->writeln('<green>SUCCESS</green> cloned <magenta>' . $data['url'] . '</magenta> -> <cyan>' . $path . '</cyan>');
|
||||
} else {
|
||||
$this->output->writeln('<red>ERROR</red> cloning <magenta>' . $data['url']);
|
||||
|
||||
}
|
||||
|
||||
$this->output->writeln('');
|
||||
} else {
|
||||
$this->output->writeln('<red>' . $path . ' already exists, skipping...</red>');
|
||||
$this->output->writeln('');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Symlinks
|
||||
*/
|
||||
private function symlink()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<green>Symlinking Bits</green>');
|
||||
$this->output->writeln('===============');
|
||||
$this->output->writeln('');
|
||||
|
||||
if (!$this->local_config) {
|
||||
$this->output->writeln('<red>No local configuration available, aborting...</red>');
|
||||
$this->output->writeln('');
|
||||
return;
|
||||
}
|
||||
|
||||
exec('cd ' . $this->destination);
|
||||
foreach ($this->config['links'] as $repo => $data) {
|
||||
$repos = (array) $this->local_config[$data['scm'] . '_repos'];
|
||||
$from = false;
|
||||
$to = $this->destination . $data['path'];
|
||||
|
||||
foreach ($repos as $repo) {
|
||||
$path = $repo . $data['src'];
|
||||
if (file_exists($path)) {
|
||||
$from = $path;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$from) {
|
||||
$this->output->writeln('<red>source for ' . $data['src'] . ' does not exists, skipping...</red>');
|
||||
$this->output->writeln('');
|
||||
} else {
|
||||
if (!file_exists($to)) {
|
||||
symlink($from, $to);
|
||||
$this->output->writeln('<green>SUCCESS</green> symlinked <magenta>' . $data['src'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
|
||||
$this->output->writeln('');
|
||||
} else {
|
||||
$this->output->writeln('<red>destination: ' . $to . ' already exists, skipping...</red>');
|
||||
$this->output->writeln('');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
65
system/src/Grav/Console/Cli/NewProjectCommand.php
Normal file
65
system/src/Grav/Console/Cli/NewProjectCommand.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class NewProjectCommand extends ConsoleCommand
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('new-project')
|
||||
->setAliases(['newproject'])
|
||||
->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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
$sandboxCommand = $this->getApplication()->find('sandbox');
|
||||
$installCommand = $this->getApplication()->find('install');
|
||||
|
||||
$sandboxArguments = new ArrayInput([
|
||||
'command' => 'sandbox',
|
||||
'destination' => $this->input->getArgument('destination'),
|
||||
'-s' => $this->input->getOption('symlink')
|
||||
]);
|
||||
|
||||
$installArguments = new ArrayInput([
|
||||
'command' => 'install',
|
||||
'destination' => $this->input->getArgument('destination'),
|
||||
'-s' => $this->input->getOption('symlink')
|
||||
]);
|
||||
|
||||
$sandboxCommand->run($sandboxArguments, $this->output);
|
||||
$installCommand->run($installArguments, $this->output);
|
||||
|
||||
}
|
||||
}
|
304
system/src/Grav/Console/Cli/SandboxCommand.php
Normal file
304
system/src/Grav/Console/Cli/SandboxCommand.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use Grav\Common\Filesystem\Folder;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class SandboxCommand extends ConsoleCommand
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $directories = [
|
||||
'/assets',
|
||||
'/backup',
|
||||
'/cache',
|
||||
'/images',
|
||||
'/logs',
|
||||
'/tmp',
|
||||
'/user/accounts',
|
||||
'/user/config',
|
||||
'/user/data',
|
||||
'/user/pages',
|
||||
'/user/plugins',
|
||||
'/user/themes',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $files = [
|
||||
'/.dependencies',
|
||||
'/.htaccess',
|
||||
'/user/config/site.yaml',
|
||||
'/user/config/system.yaml',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $mappings = [
|
||||
'/.gitignore' => '/.gitignore',
|
||||
'/CHANGELOG.md' => '/CHANGELOG.md',
|
||||
'/LICENSE.txt' => '/LICENSE.txt',
|
||||
'/README.md' => '/README.md',
|
||||
'/CONTRIBUTING.md' => '/CONTRIBUTING.md',
|
||||
'/index.php' => '/index.php',
|
||||
'/composer.json' => '/composer.json',
|
||||
'/bin' => '/bin',
|
||||
'/system' => '/system',
|
||||
'/vendor' => '/vendor',
|
||||
'/webserver-configs' => '/webserver-configs',
|
||||
];
|
||||
|
||||
/**
|
||||
* @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.";
|
||||
|
||||
protected $source;
|
||||
protected $destination;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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");
|
||||
$this->source = getcwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
$this->destination = $this->input->getArgument('destination');
|
||||
|
||||
// Symlink the Core Stuff
|
||||
if ($this->input->getOption('symlink')) {
|
||||
// Create Some core stuff if it doesn't exist
|
||||
$this->createDirectories();
|
||||
|
||||
// Loop through the symlink mappings and create the symlinks
|
||||
$this->symlink();
|
||||
|
||||
// Copy the Core STuff
|
||||
} else {
|
||||
// Create Some core stuff if it doesn't exist
|
||||
$this->createDirectories();
|
||||
|
||||
// Loop through the symlink mappings and copy what otherwise would be symlinks
|
||||
$this->copy();
|
||||
}
|
||||
|
||||
$this->pages();
|
||||
$this->initFiles();
|
||||
$this->perms();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function createDirectories()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Creating Directories</comment>');
|
||||
$dirs_created = false;
|
||||
|
||||
if (!file_exists($this->destination)) {
|
||||
mkdir($this->destination, 0777, true);
|
||||
}
|
||||
|
||||
foreach ($this->directories as $dir) {
|
||||
if (!file_exists($this->destination . $dir)) {
|
||||
$dirs_created = true;
|
||||
$this->output->writeln(' <cyan>' . $dir . '</cyan>');
|
||||
mkdir($this->destination . $dir, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$dirs_created) {
|
||||
$this->output->writeln(' <red>Directories already exist</red>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function copy()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Copying Files</comment>');
|
||||
|
||||
|
||||
foreach ($this->mappings as $source => $target) {
|
||||
if ((int)$source == $source) {
|
||||
$source = $target;
|
||||
}
|
||||
|
||||
$from = $this->source . $source;
|
||||
$to = $this->destination . $target;
|
||||
|
||||
$this->output->writeln(' <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
|
||||
@Folder::rcopy($from, $to);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function symlink()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Resetting Symbolic Links</comment>');
|
||||
|
||||
|
||||
foreach ($this->mappings as $source => $target) {
|
||||
if ((int)$source == $source) {
|
||||
$source = $target;
|
||||
}
|
||||
|
||||
$from = $this->source . $source;
|
||||
$to = $this->destination . $target;
|
||||
|
||||
$this->output->writeln(' <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
|
||||
|
||||
if (is_dir($to)) {
|
||||
@Folder::delete($to);
|
||||
} else {
|
||||
@unlink($to);
|
||||
}
|
||||
symlink($from, $to);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function initFiles()
|
||||
{
|
||||
$this->check();
|
||||
|
||||
$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) {
|
||||
$source = $target;
|
||||
}
|
||||
|
||||
$from = $this->source . $source;
|
||||
$to = $this->destination . $target;
|
||||
|
||||
if (!file_exists($to)) {
|
||||
$files_init = true;
|
||||
copy($from, $to);
|
||||
$this->output->writeln(' <cyan>' . $target . '</cyan> <comment>-></comment> Created');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$files_init) {
|
||||
$this->output->writeln(' <red>Files already exist</red>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function pages()
|
||||
{
|
||||
$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';
|
||||
$pages_files = array_diff(scandir($pages_dir), ['..', '.']);
|
||||
|
||||
if (count($pages_files) == 0) {
|
||||
$destination = $this->source . '/user/pages';
|
||||
Folder::rcopy($destination, $pages_dir);
|
||||
$this->output->writeln(' <cyan>' . $destination . '</cyan> <comment>-></comment> Created');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function perms()
|
||||
{
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>Permissions Initializing</comment>');
|
||||
|
||||
$dir_perms = 0755;
|
||||
|
||||
$binaries = glob($this->destination . DS . 'bin' . DS . '*');
|
||||
|
||||
foreach ($binaries as $bin) {
|
||||
chmod($bin, $dir_perms);
|
||||
$this->output->writeln(' <cyan>bin/' . basename($bin) . '</cyan> permissions reset to ' . decoct($dir_perms));
|
||||
}
|
||||
|
||||
$this->output->writeln("");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function check()
|
||||
{
|
||||
$success = true;
|
||||
|
||||
if (!file_exists($this->destination)) {
|
||||
$this->output->writeln(' file: <red>$this->destination</red> does not exist!');
|
||||
$success = false;
|
||||
}
|
||||
|
||||
foreach ($this->directories as $dir) {
|
||||
if (!file_exists($this->destination . $dir)) {
|
||||
$this->output->writeln(' directory: <red>' . $dir . '</red> does not exist!');
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->mappings as $target => $link) {
|
||||
if (!file_exists($this->destination . $target)) {
|
||||
$this->output->writeln(' mappings: <red>' . $target . '</red> does not exist!');
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
$this->output->writeln('');
|
||||
$this->output->writeln('<comment>install should be run with --symlink|--s to symlink first</comment>');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
113
system/src/Grav/Console/Cli/SecurityCommand.php
Normal file
113
system/src/Grav/Console/Cli/SecurityCommand.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Grav.Console
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Console\Cli;
|
||||
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Security;
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class SecurityCommand extends ConsoleCommand
|
||||
{
|
||||
/** @var ProgressBar $progress */
|
||||
protected $progress;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("security")
|
||||
->setDescription("Capable of running various Security checks")
|
||||
->setHelp('The <info>security</info> runs various security checks on your Grav site');
|
||||
|
||||
$this->source = getcwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null|void
|
||||
*/
|
||||
protected function serve()
|
||||
{
|
||||
|
||||
|
||||
/** @var Grav $grav */
|
||||
$grav = Grav::instance();
|
||||
|
||||
$grav['uri']->init();
|
||||
$grav['config']->init();
|
||||
$grav['debugger']->enabled(false);
|
||||
$grav['streams'];
|
||||
$grav['plugins']->init();
|
||||
$grav['themes']->init();
|
||||
|
||||
|
||||
$grav['twig']->init();
|
||||
$grav['pages']->init();
|
||||
|
||||
$this->progress = new ProgressBar($this->output, (count($grav['pages']->routes()) - 1));
|
||||
$this->progress->setFormat('Scanning <cyan>%current%</cyan> pages [<green>%bar%</green>] <white>%percent:3s%%</white> %elapsed:6s%');
|
||||
$this->progress->setBarWidth(100);
|
||||
|
||||
$io = new SymfonyStyle($this->input, $this->output);
|
||||
$io->title('Grav Security Check');
|
||||
|
||||
$output = Security::detectXssFromPages($grav['pages'], [$this, 'outputProgress']);
|
||||
|
||||
$io->newline(2);
|
||||
|
||||
if (!empty($output)) {
|
||||
|
||||
$counter = 1;
|
||||
foreach ($output as $route => $results) {
|
||||
|
||||
$results_parts = array_map(function($value, $key) {
|
||||
return $key.': \''.$value . '\'';
|
||||
}, array_values($results), array_keys($results));
|
||||
|
||||
$io->writeln($counter++ .' - <cyan>' . $route . '</cyan> → <red>' . implode(', ', $results_parts) . '</red>');
|
||||
}
|
||||
|
||||
$io->error('Security Scan complete: ' . count($output) . ' potential XSS issues found...');
|
||||
|
||||
} else {
|
||||
$io->success('Security Scan complete: No issues found...');
|
||||
}
|
||||
|
||||
$io->newline(1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
*/
|
||||
public function outputProgress($args)
|
||||
{
|
||||
switch ($args['type']) {
|
||||
case 'count':
|
||||
$steps = $args['steps'];
|
||||
$freq = intval($steps > 100 ? round($steps / 100) : $steps);
|
||||
$this->progress->setMaxSteps($steps);
|
||||
$this->progress->setRedrawFrequency($freq);
|
||||
break;
|
||||
case 'progress':
|
||||
if (isset($args['complete']) && $args['complete']) {
|
||||
$this->progress->finish();
|
||||
} else {
|
||||
$this->progress->advance();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user