From 09cef7bb0ca29f0f5281b73d1b2540155a87b75d Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Fri, 9 Feb 2024 20:53:45 +0100 Subject: [PATCH 1/7] Start test --- src/Commands/CheckCommand.php | 4 ++-- src/Commands/UpdaterCommand.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Commands/CheckCommand.php b/src/Commands/CheckCommand.php index 03fc134..3fac7bd 100644 --- a/src/Commands/CheckCommand.php +++ b/src/Commands/CheckCommand.php @@ -16,12 +16,12 @@ public function handle(): int { $newVersionAvailable = Updater::newVersionAvailable(); if (! is_array($newVersionAvailable)) { - $this->info('No new version available'); + $this->components->info('No new version available'); return self::SUCCESS; } - $this->info('New version available: '.$newVersionAvailable['latest_version']); + $this->components->info('New version available: '.$newVersionAvailable['latest_version']); event(new NewVersionAvailable($newVersionAvailable['current_version'], $newVersionAvailable['latest_version'])); diff --git a/src/Commands/UpdaterCommand.php b/src/Commands/UpdaterCommand.php index b799c13..d5ad757 100644 --- a/src/Commands/UpdaterCommand.php +++ b/src/Commands/UpdaterCommand.php @@ -15,18 +15,18 @@ public function handle(): int { $newVersionAvailable = Updater::newVersionAvailable(); if (! is_array($newVersionAvailable)) { - $this->error('No new version available'); + $this->components->error('No new version available'); return self::FAILURE; } - $this->comment('Updating to version '.$newVersionAvailable['latest_version']); + $this->components->info('Updating to version '.$newVersionAvailable['latest_version']); Updater::update(output: function ($message) { - $this->comment($message); + $this->components->task($message); }); - $this->info('Application updated! You are now on version '.Updater::getCurrentVersion().'!'); + $this->components->twoColumnDetails('Application updated', 'You are now on version '.Updater::getCurrentVersion()); return self::SUCCESS; } From ae49590ad2cc4b0bb8e45ecdef82bf6ea59fc0ee Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Sat, 10 Feb 2024 11:38:51 +0100 Subject: [PATCH 2/7] wip --- src/Commands/UpdaterCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/UpdaterCommand.php b/src/Commands/UpdaterCommand.php index d5ad757..ae0aecb 100644 --- a/src/Commands/UpdaterCommand.php +++ b/src/Commands/UpdaterCommand.php @@ -26,7 +26,7 @@ public function handle(): int $this->components->task($message); }); - $this->components->twoColumnDetails('Application updated', 'You are now on version '.Updater::getCurrentVersion()); + $this->components->twoColumnDetail('Application updated', 'You are now on version '.Updater::getCurrentVersion()); return self::SUCCESS; } From b0183c0fcf1181c5520d54c752e1ee8a7cb083b1 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Sat, 10 Feb 2024 11:55:58 +0100 Subject: [PATCH 3/7] wip tests --- tests/Commands/CheckCommandTest.php | 6 +++--- tests/Commands/UpdaterCommandTest.php | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Commands/CheckCommandTest.php b/tests/Commands/CheckCommandTest.php index 439ebdd..a6ad693 100644 --- a/tests/Commands/CheckCommandTest.php +++ b/tests/Commands/CheckCommandTest.php @@ -15,7 +15,7 @@ public function it_does_not_show_any_message_if_no_new_version_is_available() Updater::shouldReceive('newVersionAvailable')->once()->andReturn(false); $this->artisan('updater:check') - ->expectsOutput('No new version available') + ->expectsOutputToContain('No new version available') ->assertExitCode(CheckCommand::SUCCESS); } @@ -28,7 +28,7 @@ public function it_shows_a_message_if_a_new_version_is_available() ]); $this->artisan('updater:check') - ->expectsOutput('New version available: 1.1.0') + ->expectsOutputToContain('New version available: 1.1.0') ->assertExitCode(CheckCommand::SUCCESS); } @@ -43,7 +43,7 @@ public function it_fires_a_new_version_available_event_if_a_new_version_is_avail ]); $this->artisan('updater:check') - ->expectsOutput('New version available: 1.1.0'); + ->expectsOutputToContain('New version available: 1.1.0'); Event::assertDispatched(NewVersionAvailable::class, function ($event) { return $event->currentVersion === '1.0.0' && $event->newVersion === '1.1.0'; diff --git a/tests/Commands/UpdaterCommandTest.php b/tests/Commands/UpdaterCommandTest.php index c9ff548..48fc516 100644 --- a/tests/Commands/UpdaterCommandTest.php +++ b/tests/Commands/UpdaterCommandTest.php @@ -37,8 +37,10 @@ public function it_updates_the_application() // Call the UpdaterCommand $this->artisan('updater:update') - ->expectsOutput('Updating to version v1.0.1') - ->expectsOutput('Application updated! You are now on version v1.0.0!') // in real life this should be v1.0.1 but we mock it to v1.0.0 + ->expectsOutputToContain('Updating to version v1.0.1') + ->expectsOutputToContain('Application updated') // in real life this should be v1.0.1 but we mock it to v1.0.0 + // ->expectsOutputToContain('v1.0.0') // in real life this should be v1.0.1 but we mock it to v1.0.0 + // ->expectsOutputToContain('You are now on version') // in real life this should be v1.0.1 but we mock it to v1.0.0 ->assertExitCode(0); } @@ -52,7 +54,7 @@ public function it_does_not_update_when_no_new_version_available() // Call the UpdaterCommand $this->artisan('updater:update') - ->expectsOutput('No new version available') + ->expectsOutputToContain('No new version available') ->assertExitCode(1); } } From 91fa78db7c2c5e2e5a2349097b8651240208470e Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Sat, 10 Feb 2024 12:06:14 +0100 Subject: [PATCH 4/7] add start to messages --- src/Pipelines/ArtisanCallCacheClearPipe.php | 2 +- src/Pipelines/ArtisanCallConfigClearPipe.php | 2 +- src/Pipelines/ArtisanCallMigratePipe.php | 2 +- src/Pipelines/ArtisanCallOptimizePipe.php | 2 +- src/Pipelines/ArtisanCallRouteClearPipe.php | 2 +- src/Pipelines/ArtisanCallViewClearPipe.php | 2 +- src/Pipelines/GitPipe.php | 2 +- src/Pipelines/SeedersPipe.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Pipelines/ArtisanCallCacheClearPipe.php b/src/Pipelines/ArtisanCallCacheClearPipe.php index 57793e9..5b8c81d 100644 --- a/src/Pipelines/ArtisanCallCacheClearPipe.php +++ b/src/Pipelines/ArtisanCallCacheClearPipe.php @@ -18,7 +18,7 @@ class ArtisanCallCacheClearPipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Clearing cache...'); + call_user_func($content['output'], 'Start clearing cache'); } Artisan::call('cache:clear'); diff --git a/src/Pipelines/ArtisanCallConfigClearPipe.php b/src/Pipelines/ArtisanCallConfigClearPipe.php index 0ba9bb9..500936e 100644 --- a/src/Pipelines/ArtisanCallConfigClearPipe.php +++ b/src/Pipelines/ArtisanCallConfigClearPipe.php @@ -18,7 +18,7 @@ class ArtisanCallConfigClearPipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Clearing config cache...'); + call_user_func($content['output'], 'Start clearing config cache'); } Artisan::call('config:clear'); diff --git a/src/Pipelines/ArtisanCallMigratePipe.php b/src/Pipelines/ArtisanCallMigratePipe.php index aaa6811..22ecd9a 100644 --- a/src/Pipelines/ArtisanCallMigratePipe.php +++ b/src/Pipelines/ArtisanCallMigratePipe.php @@ -18,7 +18,7 @@ class ArtisanCallMigratePipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Migrating...'); + call_user_func($content['output'], 'Start migrating'); } Artisan::call('migrate', [ diff --git a/src/Pipelines/ArtisanCallOptimizePipe.php b/src/Pipelines/ArtisanCallOptimizePipe.php index 2b4af32..511f258 100644 --- a/src/Pipelines/ArtisanCallOptimizePipe.php +++ b/src/Pipelines/ArtisanCallOptimizePipe.php @@ -18,7 +18,7 @@ class ArtisanCallOptimizePipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Optimizing...'); + call_user_func($content['output'], 'Start optimizing'); } Artisan::call('optimize'); diff --git a/src/Pipelines/ArtisanCallRouteClearPipe.php b/src/Pipelines/ArtisanCallRouteClearPipe.php index 58130d5..08e4cbc 100644 --- a/src/Pipelines/ArtisanCallRouteClearPipe.php +++ b/src/Pipelines/ArtisanCallRouteClearPipe.php @@ -18,7 +18,7 @@ class ArtisanCallRouteClearPipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Clearing route cache...'); + call_user_func($content['output'], 'Start clearing route cache'); } Artisan::call('route:clear'); diff --git a/src/Pipelines/ArtisanCallViewClearPipe.php b/src/Pipelines/ArtisanCallViewClearPipe.php index a3759b0..ff94c3f 100644 --- a/src/Pipelines/ArtisanCallViewClearPipe.php +++ b/src/Pipelines/ArtisanCallViewClearPipe.php @@ -18,7 +18,7 @@ class ArtisanCallViewClearPipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Clearing view cache...'); + call_user_func($content['output'], 'Start clearing view cache'); } Artisan::call('view:clear'); diff --git a/src/Pipelines/GitPipe.php b/src/Pipelines/GitPipe.php index 75fd641..ecd801b 100644 --- a/src/Pipelines/GitPipe.php +++ b/src/Pipelines/GitPipe.php @@ -21,7 +21,7 @@ public function handle($content, Closure $next) $version = $content['new_version']; if (is_callable($content['output'])) { - call_user_func($content['output'], 'Downloading version '.$version.' ...'); + call_user_func($content['output'], 'Start downloading version '.$version); } Git::auth(); diff --git a/src/Pipelines/SeedersPipe.php b/src/Pipelines/SeedersPipe.php index 063d753..0e6bdc1 100644 --- a/src/Pipelines/SeedersPipe.php +++ b/src/Pipelines/SeedersPipe.php @@ -18,7 +18,7 @@ class SeedersPipe implements Pipeline public function handle($content, Closure $next) { if (is_callable($content['output'])) { - call_user_func($content['output'], 'Seeding...'); + call_user_func($content['output'], 'Start seeding'); } $classes = config('updater.seeders', []); From 2f67f0c72f2871e1e65fe5b21f77908b64f8b8e8 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Sat, 10 Feb 2024 12:06:20 +0100 Subject: [PATCH 5/7] wip tests --- tests/Pipelines/ArtisanCallCacheClearPipeTest.php | 2 +- tests/Pipelines/ArtisanCallConfigClearPipeTest.php | 2 +- tests/Pipelines/ArtisanCallMigratePipeTest.php | 2 +- tests/Pipelines/ArtisanCallOptimizePipeTest.php | 2 +- tests/Pipelines/ArtisanCallRouteClearPipeTest.php | 2 +- tests/Pipelines/ArtisanCallViewClearPipeTest.php | 2 +- tests/Pipelines/GitPipeTest.php | 4 ++-- tests/Pipelines/SeedersPipeTest.php | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Pipelines/ArtisanCallCacheClearPipeTest.php b/tests/Pipelines/ArtisanCallCacheClearPipeTest.php index 42b4508..1e9bc2e 100644 --- a/tests/Pipelines/ArtisanCallCacheClearPipeTest.php +++ b/tests/Pipelines/ArtisanCallCacheClearPipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Clearing cache...', + 'Start clearing cache', 'Cache cleared!', ]; diff --git a/tests/Pipelines/ArtisanCallConfigClearPipeTest.php b/tests/Pipelines/ArtisanCallConfigClearPipeTest.php index 49f095e..94b1024 100644 --- a/tests/Pipelines/ArtisanCallConfigClearPipeTest.php +++ b/tests/Pipelines/ArtisanCallConfigClearPipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Clearing config cache...', + 'Start clearing config cache', 'Config cache cleared!', ]; diff --git a/tests/Pipelines/ArtisanCallMigratePipeTest.php b/tests/Pipelines/ArtisanCallMigratePipeTest.php index 1a49bc1..b791a57 100644 --- a/tests/Pipelines/ArtisanCallMigratePipeTest.php +++ b/tests/Pipelines/ArtisanCallMigratePipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Migrating...', + 'Start migrating', 'Migrated!', ]; diff --git a/tests/Pipelines/ArtisanCallOptimizePipeTest.php b/tests/Pipelines/ArtisanCallOptimizePipeTest.php index 2297a10..7285648 100644 --- a/tests/Pipelines/ArtisanCallOptimizePipeTest.php +++ b/tests/Pipelines/ArtisanCallOptimizePipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Optimizing...', + 'Start optimizing', 'Optimized!', ]; diff --git a/tests/Pipelines/ArtisanCallRouteClearPipeTest.php b/tests/Pipelines/ArtisanCallRouteClearPipeTest.php index bb8741f..4d9c6ae 100644 --- a/tests/Pipelines/ArtisanCallRouteClearPipeTest.php +++ b/tests/Pipelines/ArtisanCallRouteClearPipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Clearing route cache...', + 'Start clearing route cache', 'Route cache cleared!', ]; diff --git a/tests/Pipelines/ArtisanCallViewClearPipeTest.php b/tests/Pipelines/ArtisanCallViewClearPipeTest.php index 49825fe..6a96846 100644 --- a/tests/Pipelines/ArtisanCallViewClearPipeTest.php +++ b/tests/Pipelines/ArtisanCallViewClearPipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Clearing view cache...', + 'Start clearing view cache', 'View cache cleared!', ]; diff --git a/tests/Pipelines/GitPipeTest.php b/tests/Pipelines/GitPipeTest.php index 809b93a..ce0cc38 100644 --- a/tests/Pipelines/GitPipeTest.php +++ b/tests/Pipelines/GitPipeTest.php @@ -15,7 +15,7 @@ public function test_run_handle() ]); $messages = [ - 'Downloading version 1.0.0 ...', + 'Start downloading version 1.0.0', 'Checkout success', ]; @@ -42,7 +42,7 @@ public function test_run_handle_with_error() ]); $messages = [ - 'Downloading version 1.0.0 ...', + 'Start downloading version 1.0.0', 'git checkout failed: error', ]; diff --git a/tests/Pipelines/SeedersPipeTest.php b/tests/Pipelines/SeedersPipeTest.php index 0c7cfc9..e0300d0 100644 --- a/tests/Pipelines/SeedersPipeTest.php +++ b/tests/Pipelines/SeedersPipeTest.php @@ -10,7 +10,7 @@ class SeedersPipeTest extends TestCase public function test_run_handle() { $messages = [ - 'Seeding...', + 'Start seeding', 'Seeded!', ]; From e164c285470857ee6fda0432b9cca586389637be Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Sat, 10 Feb 2024 12:09:38 +0100 Subject: [PATCH 6/7] wip --- src/Updater.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Updater.php b/src/Updater.php index fafb5f7..50d8fdb 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -43,7 +43,7 @@ private function updateTo($version): string try { if (config('updater.maintenance_mode', false)) { - $this->output('Maintenance mode is on, turning it on...'); + $this->output('Maintenance mode is on, turning it on'); Artisan::call( 'down', @@ -119,7 +119,7 @@ function ($content) { ); if (config('updater.maintenance_mode', false)) { - $this->output('Maintenance mode is on, turning it off...'); + $this->output('Maintenance mode is on, turning it off'); Artisan::call('up'); } @@ -128,7 +128,7 @@ function ($content) { return 'Updated to version '.$version; } catch (\Throwable $th) { if (config('updater.maintenance_mode', false)) { - $this->output('Maintenance mode is on, turning it off...'); + $this->output('Maintenance mode is on, turning it off'); Artisan::call('up'); } From 0907f956c465509590aab689ffeb4416e91862ac Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Sat, 10 Feb 2024 12:15:47 +0100 Subject: [PATCH 7/7] WIP --- src/Commands/UpdaterCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/UpdaterCommand.php b/src/Commands/UpdaterCommand.php index ae0aecb..325a22e 100644 --- a/src/Commands/UpdaterCommand.php +++ b/src/Commands/UpdaterCommand.php @@ -26,7 +26,7 @@ public function handle(): int $this->components->task($message); }); - $this->components->twoColumnDetail('Application updated', 'You are now on version '.Updater::getCurrentVersion()); + $this->components->twoColumnDetail('Application updated', Updater::getCurrentVersion()); return self::SUCCESS; }