Skip to content

Commit

Permalink
Add an artisan command to remove ray calls from your codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandijck committed Jan 25, 2024
1 parent aa51e6d commit 5f1c5f3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"illuminate/database": "^7.20|^8.19|^9.0|^10.0",
"illuminate/queue": "^7.20|^8.19|^9.0|^10.0",
"illuminate/support": "^7.20|^8.19|^9.0|^10.0",
"rector/rector": "^0.19.2",
"spatie/backtrace": "^1.0",
"spatie/ray": "^1.37",
"spatie/ray": "^1.41.1",
"symfony/stopwatch": "4.2|^5.1|^6.0|^7.0",
"zbateson/mail-mime-parser": "^1.3.1|^2.0"
},
Expand All @@ -32,7 +33,7 @@
"laravel/framework": "^7.20|^8.19|^9.0|^10.0",
"orchestra/testbench-core": "^5.0|^6.0|^7.0|^8.0",
"pestphp/pest": "^1.22",
"phpstan/phpstan": "^0.12.93",
"phpstan/phpstan": "^1.10.57",
"phpunit/phpunit": "^9.3",
"spatie/pest-plugin-snapshots": "^1.1"
},
Expand Down
39 changes: 39 additions & 0 deletions src/Commands/CleanRayCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Spatie\LaravelRay\Commands;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Process;

class CleanRayCommand extends Command
{
protected $signature = 'ray:clean';

protected $description = 'Remove all Ray calls from your codebase.';

public function handle()
{
$directories = [
'app',
'config',
'database',
'public',
'resources',
'routes',
'tests',
];

$this->withProgressBar($directories, function ($directory) {
$result = Process::run('./vendor/bin/remove-ray.sh ' . $directory);

Check failure on line 28 in src/Commands/CleanRayCommand.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to static method run() on an unknown class Illuminate\Support\Facades\Process.

if (!$result->successful()) {
$this->error($result->errorOutput());
return;
}
});

$this->newLine(2);
$this->info('All Ray calls have been removed from your codebase.');
}
}
2 changes: 2 additions & 0 deletions src/RayServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Support\Stringable;
use Illuminate\Testing\TestResponse;
use Illuminate\View\Compilers\BladeCompiler;
use Spatie\LaravelRay\Commands\CleanRayCommand;
use Spatie\LaravelRay\Commands\PublishConfigCommand;
use Spatie\LaravelRay\Payloads\MailablePayload;
use Spatie\LaravelRay\Payloads\ModelPayload;
Expand Down Expand Up @@ -59,6 +60,7 @@ public function boot()
protected function registerCommands(): self
{
$this->commands(PublishConfigCommand::class);
$this->commands(CleanRayCommand::class);

return $this;
}
Expand Down

0 comments on commit 5f1c5f3

Please sign in to comment.