release aufiting
This commit is contained in:
@@ -76,9 +76,9 @@ class ReleaseAuditCommand extends Command
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Artisan::call('about', ['--only' => 'environment']);
|
Artisan::call('about', ['--only' => 'environment']);
|
||||||
$this->pass('Laravel boots successfully.');
|
$this->recordPass('Laravel boots successfully.');
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->fail('Laravel failed to boot: '.$exception->getMessage());
|
$this->recordFailure('Laravel failed to boot: '.$exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,15 +86,15 @@ class ReleaseAuditCommand extends Command
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::connection()->getPdo();
|
DB::connection()->getPdo();
|
||||||
$this->pass('Database connection is available.');
|
$this->recordPass('Database connection is available.');
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->fail('Database connection failed: '.$exception->getMessage());
|
$this->recordFailure('Database connection failed: '.$exception->getMessage());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! Schema::hasTable('migrations')) {
|
if (! Schema::hasTable('migrations')) {
|
||||||
$this->fail('The migrations table does not exist.');
|
$this->recordFailure('The migrations table does not exist.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,12 +104,12 @@ class ReleaseAuditCommand extends Command
|
|||||||
$output = Artisan::output();
|
$output = Artisan::output();
|
||||||
|
|
||||||
if (str_contains($output, 'Pending')) {
|
if (str_contains($output, 'Pending')) {
|
||||||
$this->fail('One or more database migrations are pending.');
|
$this->recordFailure('One or more database migrations are pending.');
|
||||||
} else {
|
} else {
|
||||||
$this->pass('No pending database migrations were detected.');
|
$this->recordPass('No pending database migrations were detected.');
|
||||||
}
|
}
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->fail('Migration status check failed: '.$exception->getMessage());
|
$this->recordFailure('Migration status check failed: '.$exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ class ReleaseAuditCommand extends Command
|
|||||||
$modulePath = base_path('Modules');
|
$modulePath = base_path('Modules');
|
||||||
|
|
||||||
if (! is_dir($modulePath)) {
|
if (! is_dir($modulePath)) {
|
||||||
$this->fail('Modules directory is missing.');
|
$this->recordFailure('Modules directory is missing.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -130,15 +130,15 @@ class ReleaseAuditCommand extends Command
|
|||||||
$data = json_decode((string) file_get_contents($manifest), true, 512, JSON_THROW_ON_ERROR);
|
$data = json_decode((string) file_get_contents($manifest), true, 512, JSON_THROW_ON_ERROR);
|
||||||
$name = $data['name'] ?? basename(dirname($manifest));
|
$name = $data['name'] ?? basename(dirname($manifest));
|
||||||
$available[] = $name;
|
$available[] = $name;
|
||||||
$this->pass("Module manifest is valid: {$name}.");
|
$this->recordPass("Module manifest is valid: {$name}.");
|
||||||
} catch (JsonException $exception) {
|
} catch (JsonException $exception) {
|
||||||
$this->fail(sprintf('Invalid module manifest %s: %s', $manifest, $exception->getMessage()));
|
$this->recordFailure(sprintf('Invalid module manifest %s: %s', $manifest, $exception->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (config('release.required_modules', []) as $required) {
|
foreach (config('release.required_modules', []) as $required) {
|
||||||
if (! in_array($required, $available, true)) {
|
if (! in_array($required, $available, true)) {
|
||||||
$this->warn("Expected module is not present: {$required}.");
|
$this->recordWarning("Expected module is not present: {$required}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,15 +157,15 @@ class ReleaseAuditCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($names[$name])) {
|
if (isset($names[$name])) {
|
||||||
$this->fail("Duplicate named route detected: {$name}.");
|
$this->recordFailure("Duplicate named route detected: {$name}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$names[$name] = true;
|
$names[$name] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pass(sprintf('Route registry loaded with %d route(s).', count($routes)));
|
$this->recordPass(sprintf('Route registry loaded with %d route(s).', count($routes)));
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->fail('Route audit failed: '.$exception->getMessage());
|
$this->recordFailure('Route audit failed: '.$exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,25 +186,25 @@ class ReleaseAuditCommand extends Command
|
|||||||
private function check(bool $condition, string $message, bool $warning = false): void
|
private function check(bool $condition, string $message, bool $warning = false): void
|
||||||
{
|
{
|
||||||
if ($condition) {
|
if ($condition) {
|
||||||
$this->pass($message);
|
$this->recordPass($message);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$warning ? $this->warn($message) : $this->fail($message);
|
$warning ? $this->recordWarning($message) : $this->recordFailure($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function pass(string $message): void
|
private function recordPass(string $message): void
|
||||||
{
|
{
|
||||||
$this->components->twoColumnDetail($message, '<fg=green>PASS</>');
|
$this->components->twoColumnDetail($message, '<fg=green>PASS</>');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function warn(string $message): void
|
private function recordWarning(string $message): void
|
||||||
{
|
{
|
||||||
$this->warnings[] = $message;
|
$this->warnings[] = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fail(string $message): void
|
private function recordFailure(string $message): void
|
||||||
{
|
{
|
||||||
$this->failures[] = $message;
|
$this->failures[] = $message;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user