From 92fc7a1ead2a24e803706f3e6696ad96a8101215 Mon Sep 17 00:00:00 2001 From: Ahmet Bora Date: Mon, 26 Feb 2024 12:01:09 +0300 Subject: [PATCH] Use PHP native functions --- commands/plugin/delete.php | 3 +-- commands/plugin/install.php | 3 +-- commands/plugin/update.php | 11 ++++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/commands/plugin/delete.php b/commands/plugin/delete.php index 0cea81a..462f3d8 100644 --- a/commands/plugin/delete.php +++ b/commands/plugin/delete.php @@ -3,7 +3,6 @@ declare(strict_types = 1); use Kirby\CLI\CLI; -use Kirby\Filesystem\Dir; return [ 'description' => 'Deletes a kirby plugin', @@ -17,7 +16,7 @@ $repo = $cli->arg('repo'); if ($plugin = $cli->kirby()->plugin($repo)) { - Dir::remove($plugin->root()); + $cli->rmdir($plugin->root()); $cli->success('The ' . $repo . ' plugin has been deleted'); } else { $cli->error('The ' . $repo . ' plugin could not found'); diff --git a/commands/plugin/install.php b/commands/plugin/install.php index bc3ba34..b235950 100644 --- a/commands/plugin/install.php +++ b/commands/plugin/install.php @@ -3,7 +3,6 @@ declare(strict_types = 1); use Kirby\CLI\CLI; -use Kirby\Filesystem\F; return [ 'description' => 'Installs a kirby plugin repository from the Github', @@ -45,7 +44,7 @@ $cli->run('unzip', $zip, $dir); // remove the zip - F::unlink($zip); + unlink($zip); $cli->success('The ' . $repo . ' plugin has been installed ' . $version . ' version'); } diff --git a/commands/plugin/update.php b/commands/plugin/update.php index e141c89..6802afa 100644 --- a/commands/plugin/update.php +++ b/commands/plugin/update.php @@ -3,7 +3,6 @@ declare(strict_types = 1); use Kirby\CLI\CLI; -use Kirby\Filesystem\Dir; return [ 'description' => 'Updates a kirby plugin', @@ -23,13 +22,15 @@ if ($plugin = $cli->kirby()->plugin($repo)) { try { - // move plugin directory to prevent overwrite - Dir::move($plugin->root(), $plugin->root() . '.bak'); + // move plugin temp directory to prevent overwrite + rename($plugin->root(), $plugin->root() . '.temp'); + $cli->run('plugin:install', $repo, $version); - Dir::remove($plugin->root() . '.bak'); + $cli->rmdir($plugin->root() . '.bak'); + $cli->success('The ' . $repo . ' plugin has been updated to ' . $version . ' version'); } catch (Throwable) { - Dir::move($plugin->root() . '.bak', $plugin->root()); + rename($plugin->root() . '.bak', $plugin->root()); $cli->error('The ' . $repo . ' plugin could not updated'); } } else {