release aufiting

This commit is contained in:
Mark Gregory
2026-07-24 14:06:28 +01:00
parent c91ac80ab6
commit a541acb23e
+20 -20
View File
@@ -76,9 +76,9 @@ class ReleaseAuditCommand extends Command
try {
Artisan::call('about', ['--only' => 'environment']);
$this->pass('Laravel boots successfully.');
$this->recordPass('Laravel boots successfully.');
} 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 {
DB::connection()->getPdo();
$this->pass('Database connection is available.');
$this->recordPass('Database connection is available.');
} catch (Throwable $exception) {
$this->fail('Database connection failed: '.$exception->getMessage());
$this->recordFailure('Database connection failed: '.$exception->getMessage());
return;
}
if (! Schema::hasTable('migrations')) {
$this->fail('The migrations table does not exist.');
$this->recordFailure('The migrations table does not exist.');
return;
}
@@ -104,12 +104,12 @@ class ReleaseAuditCommand extends Command
$output = Artisan::output();
if (str_contains($output, 'Pending')) {
$this->fail('One or more database migrations are pending.');
$this->recordFailure('One or more database migrations are pending.');
} else {
$this->pass('No pending database migrations were detected.');
$this->recordPass('No pending database migrations were detected.');
}
} 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');
if (! is_dir($modulePath)) {
$this->fail('Modules directory is missing.');
$this->recordFailure('Modules directory is missing.');
return;
}
@@ -130,15 +130,15 @@ class ReleaseAuditCommand extends Command
$data = json_decode((string) file_get_contents($manifest), true, 512, JSON_THROW_ON_ERROR);
$name = $data['name'] ?? basename(dirname($manifest));
$available[] = $name;
$this->pass("Module manifest is valid: {$name}.");
$this->recordPass("Module manifest is valid: {$name}.");
} 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) {
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])) {
$this->fail("Duplicate named route detected: {$name}.");
$this->recordFailure("Duplicate named route detected: {$name}.");
}
$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) {
$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
{
if ($condition) {
$this->pass($message);
$this->recordPass($message);
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</>');
}
private function warn(string $message): void
private function recordWarning(string $message): void
{
$this->warnings[] = $message;
}
private function fail(string $message): void
private function recordFailure(string $message): void
{
$this->failures[] = $message;
}