From 72bf76000ff1018a4101c326b83faaa1b1e8e2cb Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Mon, 29 Mar 2021 14:08:28 +0100 Subject: [PATCH 1/2] feature: clear cache command --- composer.json | 4 ++++ src/Commands/ClearCommand.php | 28 ++++++++++++++++++++++++++++ src/OrbitServiceProvider.php | 4 ++++ 3 files changed, 36 insertions(+) create mode 100644 src/Commands/ClearCommand.php diff --git a/composer.json b/composer.json index 90e3dd7..194940a 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "illuminate/database": "^8.0", "illuminate/events": "^8.0", "illuminate/support": "^8.0", + "illuminate/console": "^8.0", "spatie/yaml-front-matter": "^2.0", "symfony/yaml": "^3.0 || ^4.0 || ^5.0", "symplify/git-wrapper": "^9.2" @@ -47,5 +48,8 @@ "scripts": { "psalm": "vendor/bin/psalm", "test": "vendor/bin/phpunit --colors=always" + }, + "config": { + "sort-packages": true } } diff --git a/src/Commands/ClearCommand.php b/src/Commands/ClearCommand.php new file mode 100644 index 0000000..a464420 --- /dev/null +++ b/src/Commands/ClearCommand.php @@ -0,0 +1,28 @@ +info('Succesfully cleared the Orbit cache.'); + + return 0; + } +} diff --git a/src/OrbitServiceProvider.php b/src/OrbitServiceProvider.php index b998d5c..332eb89 100644 --- a/src/OrbitServiceProvider.php +++ b/src/OrbitServiceProvider.php @@ -49,6 +49,10 @@ public function register() public function boot() { if ($this->app->runningInConsole()) { + $this->commands([ + Commands\ClearCommand::class, + ]); + $this->publishes([ __DIR__.'/../config/orbit.php' => config_path('orbit.php'), ], 'orbit:config'); From cf309285b1750cc1510c41f9ac31f6f403ca62eb Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Mon, 29 Mar 2021 14:08:51 +0100 Subject: [PATCH 2/2] fix: dont clear in testing --- src/Commands/ClearCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Commands/ClearCommand.php b/src/Commands/ClearCommand.php index a464420..70fa34f 100644 --- a/src/Commands/ClearCommand.php +++ b/src/Commands/ClearCommand.php @@ -13,6 +13,10 @@ class ClearCommand extends Command public function handle() { + if (Orbit::isTesting()) { + return 0; + } + $path = Orbit::getDatabasePath(); if (! file_exists($path)) {