set('system.cache.cli_compatibility', true);
Grav::instance()['cache'];
$this->argv = $_SERVER['argv'][0];
$this->input = $input;
$this->output = $output;
$this->output->getFormatter()->setStyle('normal', new OutputFormatterStyle('white'));
$this->output->getFormatter()->setStyle('yellow', new OutputFormatterStyle('yellow', null, array('bold')));
$this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, array('bold')));
$this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, array('bold')));
$this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, array('bold')));
$this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, array('bold')));
$this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold')));
}
/**
* @param $path
*/
public function isGravInstance($path)
{
if (!file_exists($path)) {
$this->output->writeln('');
$this->output->writeln("ERROR: Destination doesn't exist:");
$this->output->writeln(" $path");
$this->output->writeln('');
exit;
}
if (!is_dir($path)) {
$this->output->writeln('');
$this->output->writeln("ERROR: Destination chosen to install is not a directory:");
$this->output->writeln(" $path");
$this->output->writeln('');
exit;
}
if (!file_exists($path . DS . 'index.php') || !file_exists($path . DS . '.dependencies') || !file_exists($path . DS . 'system' . DS . 'config' . DS . 'system.yaml')) {
$this->output->writeln('');
$this->output->writeln("ERROR: Destination chosen to install does not appear to be a Grav instance:");
$this->output->writeln(" $path");
$this->output->writeln('');
exit;
}
}
public function composerUpdate($path, $action = 'install')
{
$composer = Composer::getComposerExecutor();
return system($composer . ' --working-dir="'.$path.'" --no-interaction --no-dev --prefer-dist -o '. $action);
}
/**
* @param array $all
*
* @return int
* @throws \Exception
*/
public function clearCache($all = [])
{
if ($all) {
$all = ['--all' => true];
}
$command = new ClearCacheCommand();
$input = new ArrayInput($all);
return $command->run($input, $this->output);
}
/**
* Load the local config file
*
* @return mixed string the local config file name. false if local config does not exist
*/
public function loadLocalConfig()
{
$home_folder = getenv('HOME') ?: getenv('HOMEDRIVE') . getenv('HOMEPATH');
$local_config_file = $home_folder . '/.grav/config';
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse(file_get_contents($local_config_file));
return $local_config_file;
}
return false;
}
}