Skip to content

Commit

Permalink
Merge pull request #37 from salahhusa9/new-ui-output
Browse files Browse the repository at this point in the history
new ui output
  • Loading branch information
salahhusa9 authored Feb 10, 2024
2 parents 767198d + 0907f95 commit 7365406
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/Commands/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));

Expand Down
8 changes: 4 additions & 4 deletions src/Commands/UpdaterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->twoColumnDetail('Application updated', Updater::getCurrentVersion());

return self::SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/ArtisanCallCacheClearPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/ArtisanCallConfigClearPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/ArtisanCallMigratePipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/ArtisanCallOptimizePipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/ArtisanCallRouteClearPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/ArtisanCallViewClearPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/GitPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/SeedersPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
Expand Down
6 changes: 3 additions & 3 deletions src/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Commands/CheckCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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';
Expand Down
8 changes: 5 additions & 3 deletions tests/Commands/UpdaterCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion tests/Pipelines/ArtisanCallCacheClearPipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Clearing cache...',
'Start clearing cache',
'Cache cleared!',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Pipelines/ArtisanCallConfigClearPipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Clearing config cache...',
'Start clearing config cache',
'Config cache cleared!',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Pipelines/ArtisanCallMigratePipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Migrating...',
'Start migrating',
'Migrated!',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Pipelines/ArtisanCallOptimizePipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Optimizing...',
'Start optimizing',
'Optimized!',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Pipelines/ArtisanCallRouteClearPipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Clearing route cache...',
'Start clearing route cache',
'Route cache cleared!',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Pipelines/ArtisanCallViewClearPipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Clearing view cache...',
'Start clearing view cache',
'View cache cleared!',
];

Expand Down
4 changes: 2 additions & 2 deletions tests/Pipelines/GitPipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_run_handle()
]);

$messages = [
'Downloading version 1.0.0 ...',
'Start downloading version 1.0.0',
'Checkout success',
];

Expand All @@ -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',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Pipelines/SeedersPipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SeedersPipeTest extends TestCase
public function test_run_handle()
{
$messages = [
'Seeding...',
'Start seeding',
'Seeded!',
];

Expand Down

0 comments on commit 7365406

Please sign in to comment.