Added a new console command `october:util` for performing utility and maintenance tasks.
This commit is contained in:
parent
3ac3a7318f
commit
19a3fe2b43
|
|
@ -1,5 +1,11 @@
|
|||
* **Build 129** (2014-07-25)
|
||||
- Fixes a bug where the active theme is not editable in the back-end.
|
||||
- Added a new console command `october:util` for performing utility and maintenance tasks.
|
||||
- Added new utility command for deleting thumbs in the uploads directory `october:util purge thumbs`.
|
||||
- Improved console command confirmation dialogs.
|
||||
|
||||
* **Build 125** (2014-07-24)
|
||||
- Theme support added.
|
||||
- Added support for Themes.
|
||||
- Added new Theme picker to the backend via Settings > Front-end theme
|
||||
- New shorthand method for `$this->getClassExtension('Backend.Behaviors.FormController')` becomes `$this->asExtension('FormController')`.
|
||||
- Buttons inside a popup support new `data-popup-load-indicator` attribute.
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
$this->registerConsoleCommand('october.up', 'System\Console\OctoberUp');
|
||||
$this->registerConsoleCommand('october.down', 'System\Console\OctoberDown');
|
||||
$this->registerConsoleCommand('october.update', 'System\Console\OctoberUpdate');
|
||||
$this->registerConsoleCommand('october.util', 'System\Console\OctoberUtil');
|
||||
$this->registerConsoleCommand('plugin.install', 'System\Console\PluginInstall');
|
||||
$this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove');
|
||||
$this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh');
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
class OctoberDown extends Command
|
||||
{
|
||||
|
||||
use \Illuminate\Console\ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*/
|
||||
|
|
@ -31,14 +33,14 @@ class OctoberDown extends Command
|
|||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ($this->confirm('Destroy all database tables? [yes|no]')) {
|
||||
if (!$this->confirmToProceed('This will DESTROY all database tables.'))
|
||||
return;
|
||||
|
||||
$manager = UpdateManager::instance()->resetNotes()->uninstall();
|
||||
|
||||
foreach ($manager->getNotes() as $note)
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
|
|
@ -53,7 +55,18 @@ class OctoberDown extends Command
|
|||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default confirmation callback.
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function getDefaultConfirmCallback()
|
||||
{
|
||||
return function() { return true; };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<?php namespace System\Console;
|
||||
|
||||
use File;
|
||||
use Config;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
/**
|
||||
* Utility command
|
||||
*
|
||||
* Supported commands:
|
||||
*
|
||||
* - purge thumbs: Deletes all thumbnail files in the uploads directory.
|
||||
*/
|
||||
class OctoberUtil extends Command
|
||||
{
|
||||
|
||||
use \Illuminate\Console\ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*/
|
||||
protected $name = 'october:util';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*/
|
||||
protected $description = 'Utility commands for October';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$command = implode(' ', (array) $this->argument('name'));
|
||||
$method = 'util'.studly_case($command);
|
||||
|
||||
if (!method_exists($this, $method)) {
|
||||
$this->error(sprintf('<error>Utility command "%s" does not exist!</error>', $command));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->$method();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::IS_ARRAY, 'A utility command to perform.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
];
|
||||
}
|
||||
|
||||
//
|
||||
// Utilties
|
||||
//
|
||||
|
||||
protected function utilPurgeThumbs()
|
||||
{
|
||||
if (!$uploadsDir = Config::get('cms.uploadsDir'))
|
||||
return $this->error('No uploads directory defined in config (cms.uploadsDir)');
|
||||
|
||||
if (!$this->confirmToProceed('This will PERMANENTLY DELETE all thumbs in the uploads directory.'))
|
||||
return;
|
||||
|
||||
$uploadsDir = base_path() . $uploadsDir;
|
||||
$totalCount = 0;
|
||||
|
||||
/*
|
||||
* Recursive function to scan the directory for files beginning
|
||||
* with "thumb_" and repeat itself on directories.
|
||||
*/
|
||||
$purgeFunc = function($targetDir) use (&$purgeFunc, &$totalCount) {
|
||||
if ($files = File::glob($targetDir.'/thumb_*')) {
|
||||
foreach ($files as $file) {
|
||||
$this->info('Purged: '. basename($file));
|
||||
$totalCount++;
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($dirs = File::directories($targetDir)) {
|
||||
foreach ($dirs as $dir) {
|
||||
$purgeFunc($dir);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$purgeFunc($uploadsDir);
|
||||
|
||||
if ($totalCount > 0)
|
||||
$this->comment(sprintf('Successfully deleted %s thumbs', $totalCount));
|
||||
else
|
||||
$this->comment('No thumbs found to delete');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
class PluginRemove extends Command
|
||||
{
|
||||
|
||||
use \Illuminate\Console\ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
* @var string
|
||||
|
|
@ -37,9 +39,15 @@ class PluginRemove extends Command
|
|||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ($this->confirm('Are you sure you want to uninstall this plugin? [yes|no]')) {
|
||||
$pluginManager = PluginManager::instance();
|
||||
$pluginName = $this->argument('name');
|
||||
$pluginName = PluginManager::instance()->normalizeIdentifier($pluginName);
|
||||
$pluginName = $pluginManager->normalizeIdentifier($pluginName);
|
||||
|
||||
if (!$pluginManager->hasPlugin($pluginName))
|
||||
return $this->error(sprintf('Unable to find a registered plugin called "%s"', $pluginName));
|
||||
|
||||
if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName)))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Rollback plugin
|
||||
|
|
@ -53,12 +61,11 @@ class PluginRemove extends Command
|
|||
/*
|
||||
* Delete from file system
|
||||
*/
|
||||
if ($pluginPath = PluginManager::instance()->getPluginPath($pluginName)) {
|
||||
if ($pluginPath = $pluginManager->getPluginPath($pluginName)) {
|
||||
File::deleteDirectory($pluginPath);
|
||||
$this->output->writeln(sprintf('<info>Deleted: %s</info>', $pluginName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
|
|
@ -77,7 +84,18 @@ class PluginRemove extends Command
|
|||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default confirmation callback.
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function getDefaultConfirmCallback()
|
||||
{
|
||||
return function() { return true; };
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue