Skip to content

Commit

Permalink
feat: added confirmation before dispatcing sync on deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed May 22, 2024
1 parent 6a0304e commit 4d1a2d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/Console/Commands/CreateRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Models\Repository;
use Illuminate\Console\Command;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
use function Laravel\Prompts\text;
use function Laravel\Prompts\textarea;
Expand Down Expand Up @@ -63,7 +64,15 @@ public function handle(): void
'sub_dir' => $source_folder,
'delay' => $delay,
]);
info('Repository created, sync will be started.');
SyncRepository::dispatch($repository);
$syncNow = confirm(
label: 'Do you want to sync the repository now?',
default: true
);
if ($syncNow) {
info('Sync will be started now by worker.');
SyncRepository::dispatch($repository);
} else {
info('Sync will be started when all repositories are synced.');
}
}
}
1 change: 1 addition & 0 deletions tests/Feature/CommandLineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
->expectsQuestion('Provide the command to be ran to sync this repository.', $repository->command)
->expectsQuestion('Provide the folder where the data is.', $repository->source_folder)
->expectsQuestion('Please provide how much time the repository must be kept back from upstream.', $repository->delay)
->expectsConfirmation('Do you want to sync the repository now?', 'yes')
->assertExitCode(0);
assertDatabaseHas('repositories', $repository->toArray());
Queue::assertPushed(SyncRepository::class);
Expand Down

0 comments on commit 4d1a2d9

Please sign in to comment.