Primo Committ

This commit is contained in:
paoloar77
2024-05-07 12:17:25 +02:00
commit e73d0e5113
7204 changed files with 884387 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use Facade\Ignition\DumpRecorder\DumpRecorder;
class AddDumps
{
/** @var \Facade\Ignition\DumpRecorder\DumpRecorder */
protected $dumpRecorder;
public function __construct(DumpRecorder $dumpRecorder)
{
$this->dumpRecorder = $dumpRecorder;
}
public function handle(Report $report, $next)
{
$report->group('dumps', $this->dumpRecorder->getDumps());
return $next($report);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
class AddEnvironmentInformation
{
public function handle(Report $report, $next)
{
$report->frameworkVersion(app()->version());
$report->group('env', [
'laravel_version' => app()->version(),
'laravel_locale' => app()->getLocale(),
'laravel_config_cached' => app()->configurationIsCached(),
'php_version' => phpversion(),
]);
return $next($report);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use Illuminate\Database\QueryException;
class AddExceptionInformation
{
public function handle(Report $report, $next)
{
$throwable = $report->getThrowable();
if (! $throwable instanceof QueryException) {
return $next($report);
}
$report->group('exception', [
'raw_sql' => $throwable->getSql(),
]);
return $next($report);
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use ReflectionClass;
use Symfony\Component\Process\Exception\RuntimeException;
use Symfony\Component\Process\Process;
class AddGitInformation
{
public function handle(Report $report, $next)
{
try {
$report->group('git', [
'hash' => $this->hash(),
'message' => $this->message(),
'tag' => $this->tag(),
'remote' => $this->remote(),
]);
} catch (RuntimeException $exception) {
}
return $next($report);
}
public function hash(): ?string
{
return $this->command("git log --pretty=format:'%H' -n 1");
}
public function message(): ?string
{
return $this->command("git log --pretty=format:'%s' -n 1");
}
public function tag(): ?string
{
return $this->command('git describe --tags --abbrev=0');
}
public function remote(): ?string
{
return $this->command('git config --get remote.origin.url');
}
protected function command($command)
{
$process = (new ReflectionClass(Process::class))->hasMethod('fromShellCommandline')
? Process::fromShellCommandline($command, base_path())
: new Process($command, base_path());
$process->run();
return trim($process->getOutput());
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use Facade\Ignition\JobRecorder\JobRecorder;
class AddJobInformation
{
/** @var \Facade\Ignition\JobRecorder\JobRecorder */
protected $jobRecorder;
public function __construct(JobRecorder $jobRecorder)
{
$this->jobRecorder = $jobRecorder;
}
public function handle(Report $report, $next)
{
if ($this->jobRecorder->getJob()) {
$report->group('job', $this->jobRecorder->toArray());
}
return $next($report);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use Facade\Ignition\LogRecorder\LogRecorder;
class AddLogs
{
/** @var \Facade\Ignition\LogRecorder\LogRecorder */
protected $logRecorder;
public function __construct(LogRecorder $logRecorder)
{
$this->logRecorder = $logRecorder;
}
public function handle(Report $report, $next)
{
$report->group('logs', $this->logRecorder->getLogMessages());
return $next($report);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use Facade\Ignition\QueryRecorder\QueryRecorder;
class AddQueries
{
/** @var \Facade\Ignition\QueryRecorder\QueryRecorder */
protected $queryRecorder;
public function __construct(QueryRecorder $queryRecorder)
{
$this->queryRecorder = $queryRecorder;
}
public function handle(Report $report, $next)
{
$report->group('queries', $this->queryRecorder->getQueries());
return $next($report);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
use Facade\IgnitionContracts\SolutionProviderRepository;
class AddSolutions
{
/** @var \Facade\IgnitionContracts\SolutionProviderRepository */
protected $solutionProviderRepository;
public function __construct(SolutionProviderRepository $solutionProviderRepository)
{
$this->solutionProviderRepository = $solutionProviderRepository;
}
public function handle(Report $report, $next)
{
if ($throwable = $report->getThrowable()) {
$solutions = $this->solutionProviderRepository->getSolutionsForThrowable($throwable);
foreach ($solutions as $solution) {
$report->addSolution($solution);
}
}
return $next($report);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Facade\Ignition\Middleware;
use Facade\FlareClient\Report;
class SetNotifierName
{
public const NOTIFIER_NAME = 'Laravel Client';
public function handle(Report $report, $next)
{
$report->notifierName(static::NOTIFIER_NAME);
return $next($report);
}
}