Skip to content

The text description of the statuses is moved to StatusEnum #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Enums/StatusEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace DragonCode\LaravelDeployOperations\Enums;

enum StatusEnum
{
case Ran;
case Pending;
case Skipped;

public function toColor(): string
{
return match ($this) {
self::Ran => '<fg=green;options=bold>Ran</>',
self::Pending => '<fg=blue;options=bold>Pending</>',
self::Skipped => '<fg=yellow;options=bold>Skipped</>',
};
}
}
9 changes: 3 additions & 6 deletions src/Processors/StatusProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace DragonCode\LaravelDeployOperations\Processors;

use DragonCode\LaravelDeployOperations\Enums\StatusEnum;
use DragonCode\Support\Facades\Helpers\Arr;

use function sprintf;
Expand All @@ -14,10 +15,6 @@ class StatusProcessor extends Processor

protected string $columnStatus = '<fg=gray>Batch / Status</>';

protected string $statusRan = '<fg=green;options=bold>Ran</>';

protected string $statusPending = '<fg=yellow;options=bold>Pending</>';

public function handle(): void
{
if ($this->tableNotFound()) {
Expand Down Expand Up @@ -72,10 +69,10 @@ protected function getData(): array
protected function getStatusFor(array $completed, string $item): string
{
if ($batch = Arr::get($completed, $item)) {
return sprintf('[%s] %s', $batch, $this->statusRan);
return sprintf('[%s] %s', $batch, StatusEnum::Ran->toColor());
}

return $this->statusPending;
return StatusEnum::Pending->toColor();
}

protected function getCompleted(): array
Expand Down
5 changes: 3 additions & 2 deletions src/Services/MigratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace DragonCode\LaravelDeployOperations\Services;

use DragonCode\LaravelDeployOperations\Data\OptionsData;
use DragonCode\LaravelDeployOperations\Enums\StatusEnum;
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
use DragonCode\LaravelDeployOperations\Jobs\OperationJob;
use DragonCode\LaravelDeployOperations\Notifications\Notification;
Expand Down Expand Up @@ -52,15 +53,15 @@ public function runUp(string $filename, int $batch, OptionsData $options): void
$name = $this->resolveOperationName($path);

if (! $this->allowOperation($operation, $options)) {
$this->notification->twoColumn($name, '<fg=yellow;options=bold>SKIPPED</>');
$this->notification->twoColumn($name, StatusEnum::Skipped->toColor());

return;
}

if ($this->hasAsync($operation, $options)) {
OperationJob::dispatch($name);

$this->notification->twoColumn($name, '<fg=blue;options=bold>PENDING</>');
$this->notification->twoColumn($name, StatusEnum::Pending->toColor());

return;
}
Expand Down