Init
This commit is contained in:
43
Career/Others/Untitled.md
Normal file
43
Career/Others/Untitled.md
Normal file
@@ -0,0 +1,43 @@
|
||||
```bash
|
||||
php artisan make:command AuditDependenciesCommand
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Spatie\FlareClient\Enums\MessageLevels;
|
||||
use Spatie\LaravelIgnition\Facades\Flare;
|
||||
|
||||
class AuditDependenciesCommand extends Command
|
||||
{
|
||||
protected $signature = 'app:audit-dependencies';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$composer = Process::run('composer audit');
|
||||
|
||||
if (!blank($composer->output())) {
|
||||
$this->warn('Composer audit found vulnerabilities');
|
||||
Flare::glow('Composer audit found vulnerabilities', MessageLevels::WARNING, ['output' => $composer->output()]);
|
||||
Flare::report(new Exception('Composer audit found vulnerabilities'));
|
||||
}
|
||||
|
||||
$npm = Process::run('npm audit');
|
||||
|
||||
if (trim($npm->output()) !== "found 0 vulnerabilities") {
|
||||
$this->warn('NPM audit found vulnerabilities');
|
||||
Flare::glow('NPM audit found vulnerabilities', MessageLevels::WARNING, ['output' => $npm->output()]);
|
||||
Flare::report(new Exception('NPM audit found vulnerabilities'));
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```php in kernel
|
||||
$schedule->command(\App\Console\Commands\AuditDependenciesCommand::class)->daily();
|
||||
```
|
||||
Reference in New Issue
Block a user