mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
36
app/Console/Commands/Plugins/InstallPluginCommand.php
Normal file
36
app/Console/Commands/Plugins/InstallPluginCommand.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Plugins;
|
||||
|
||||
use App\Facades\Plugins;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class InstallPluginCommand extends Command
|
||||
{
|
||||
protected $signature = 'plugins:install {url} {--branch=} {--tag=}';
|
||||
|
||||
protected $description = 'Install a plugin from a repository';
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$url = $this->argument('url');
|
||||
$branch = $this->option('branch');
|
||||
$tag = $this->option('tag');
|
||||
|
||||
$this->info('Installing plugin from '.$url);
|
||||
|
||||
try {
|
||||
Plugins::install($url, $branch, $tag);
|
||||
} catch (Exception $e) {
|
||||
$this->output->error($e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->info('Plugin installed successfully');
|
||||
}
|
||||
}
|
34
app/Console/Commands/Plugins/LoadPluginsCommand.php
Normal file
34
app/Console/Commands/Plugins/LoadPluginsCommand.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Plugins;
|
||||
|
||||
use App\Facades\Plugins;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class LoadPluginsCommand extends Command
|
||||
{
|
||||
protected $signature = 'plugins:load';
|
||||
|
||||
protected $description = 'Load all plugins from the storage/plugins directory';
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Loading plugins...');
|
||||
|
||||
try {
|
||||
Plugins::load();
|
||||
} catch (Exception $e) {
|
||||
$this->output->error($e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Plugins::cleanup();
|
||||
|
||||
$this->info('Plugins loaded successfully.');
|
||||
}
|
||||
}
|
18
app/Console/Commands/Plugins/PluginsListCommand.php
Normal file
18
app/Console/Commands/Plugins/PluginsListCommand.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Plugins;
|
||||
|
||||
use App\Facades\Plugins;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PluginsListCommand extends Command
|
||||
{
|
||||
protected $signature = 'plugins:list';
|
||||
|
||||
protected $description = 'List all installed plugins';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->table(['Name', 'Version'], Plugins::all());
|
||||
}
|
||||
}
|
29
app/Console/Commands/Plugins/UninstallPluginCommand.php
Normal file
29
app/Console/Commands/Plugins/UninstallPluginCommand.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Plugins;
|
||||
|
||||
use App\Facades\Plugins;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UninstallPluginCommand extends Command
|
||||
{
|
||||
protected $signature = 'plugins:uninstall {name}';
|
||||
|
||||
protected $description = 'Uninstall a plugin by name';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Uninstalling '.$this->argument('name').'...');
|
||||
|
||||
try {
|
||||
Plugins::uninstall($this->argument('name'));
|
||||
} catch (Exception $e) {
|
||||
$this->output->error($e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->info('Plugin uninstalled successfully.');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user