From e27ab3e93cf18d56010f051f7e6c15b22081a938 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 29 Jun 2022 19:09:15 +0100 Subject: [PATCH 001/101] Improves console output --- composer.json | 1 + .../Console/Concerns/CreatesMatchingTest.php | 8 +- .../Console/Concerns/InteractsWithIO.php | 100 +++++++++++++++--- src/Illuminate/Console/ConfirmableTrait.php | 4 +- .../Console/ConsoleServiceProvider.php | 36 +++++++ src/Illuminate/Console/GeneratorCommand.php | 8 +- .../Scheduling/ScheduleListCommand.php | 2 +- .../Console/View/Components/LineComponent.php | 62 +++++++++++ src/Illuminate/Console/composer.json | 2 + .../Console/resources/views/alert.blade.php | 3 + .../resources/views/lines/error.blade.php | 3 + .../resources/views/lines/info.blade.php | 3 + .../resources/views/lines/warning.blade.php | 3 + .../views/tasks/description.blade.php | 1 + .../resources/views/tasks/title.blade.php | 3 + .../Database/Console/DumpCommand.php | 6 +- .../Console/Migrations/ResetCommand.php | 2 +- src/Illuminate/Foundation/Application.php | 2 + .../Foundation/Console/ConfigCacheCommand.php | 2 +- .../Foundation/Console/DownCommand.php | 11 +- .../Foundation/Console/EnvironmentCommand.php | 5 +- .../Foundation/Console/EventCacheCommand.php | 2 +- .../Console/OptimizeClearCommand.php | 16 +-- .../Foundation/Console/OptimizeCommand.php | 8 +- .../Console/PackageDiscoverCommand.php | 7 +- .../Foundation/Console/RouteCacheCommand.php | 2 +- .../Foundation/Console/StorageLinkCommand.php | 7 +- .../Foundation/Console/UpCommand.php | 9 +- .../Console/VendorPublishCommand.php | 37 +++++-- .../Foundation/Console/ViewCacheCommand.php | 2 +- src/Illuminate/Queue/Console/ClearCommand.php | 4 +- .../Queue/Console/ListFailedCommand.php | 2 +- .../Queue/Console/PruneBatchesCommand.php | 4 +- .../Queue/Console/PruneFailedJobsCommand.php | 2 +- .../Queue/Console/RetryBatchCommand.php | 6 +- src/Illuminate/Queue/Console/RetryCommand.php | 14 ++- 36 files changed, 307 insertions(+), 82 deletions(-) create mode 100644 src/Illuminate/Console/ConsoleServiceProvider.php create mode 100644 src/Illuminate/Console/View/Components/LineComponent.php create mode 100644 src/Illuminate/Console/resources/views/alert.blade.php create mode 100644 src/Illuminate/Console/resources/views/lines/error.blade.php create mode 100644 src/Illuminate/Console/resources/views/lines/info.blade.php create mode 100644 src/Illuminate/Console/resources/views/lines/warning.blade.php create mode 100644 src/Illuminate/Console/resources/views/tasks/description.blade.php create mode 100644 src/Illuminate/Console/resources/views/tasks/title.blade.php diff --git a/composer.json b/composer.json index 74f27ac25ba7..13488dc56881 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "league/flysystem": "^3.0.16", "monolog/monolog": "^2.0", "nesbot/carbon": "^2.53.1", + "nunomaduro/termwind": "^1.12", "psr/container": "^1.1.1|^2.0.1", "psr/log": "^1.0|^2.0|^3.0", "psr/simple-cache": "^1.0|^2.0|^3.0", diff --git a/src/Illuminate/Console/Concerns/CreatesMatchingTest.php b/src/Illuminate/Console/Concerns/CreatesMatchingTest.php index a360c281a98a..4182a007ed3a 100644 --- a/src/Illuminate/Console/Concerns/CreatesMatchingTest.php +++ b/src/Illuminate/Console/Concerns/CreatesMatchingTest.php @@ -28,17 +28,17 @@ protected function addTestOptions() * Create the matching test case if requested. * * @param string $path - * @return void + * @return bool */ protected function handleTestCreation($path) { if (! $this->option('test') && ! $this->option('pest')) { - return; + return false; } - $this->call('make:test', [ + return $this->callSilent('make:test', [ 'name' => Str::of($path)->after($this->laravel['path'])->beforeLast('.php')->append('Test')->replace('\\', '/'), '--pest' => $this->option('pest'), - ]); + ]) == 0; } } diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index bdb594b0781f..3adda5dd5c98 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -12,6 +12,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; +use function Termwind\{terminal, render, renderUsing}; trait InteractsWithIO { @@ -193,6 +194,61 @@ public function secret($question, $fallback = true) return $this->output->askQuestion($question); } + /** + * Perform the given tasks. + * + * @param string $title + * @param iterable $tasks + * @param int|string|null $verbosity + * @return void + */ + public function tasks($title, $tasks, $verbosity = null) + { + $this->info($title, $verbosity); + + collect($tasks)->each( + fn ($task, $description) => $this->task($description, $task, $verbosity), + ); + + $this->newLine(); + } + + /** + * Perform the given task. + * + * @param string $description + * @param (callable(): bool)|null $task + * @param int|string|null $verbosity + * @return void + */ + public function task($description, $task = null, $verbosity = null) + { + if (!$this->output->isDecorated()) { + $this->output->write($description); + + if ($task) { + $this->output->writeln(': ' . ($task() ? 'DONE' : 'FAIL')); + } + + return; + } + + $descriptionWidth = mb_strlen($description); + $description = $this->highlightDynamicContent($description); + $this->output->write(" $description ", false, $this->parseVerbosity($verbosity)); + $dots = max(terminal()->width() - $descriptionWidth - 10, 0); + $this->output->write(str_repeat('.', $dots), false, $this->parseVerbosity($verbosity)); + + if ($task) { + $this->output->writeln( + $task() !== false ? ' DONE' : ' FAIL', + $this->parseVerbosity($verbosity), + ); + } else { + $this->output->writeln(str_repeat('.', 5)); + } + } + /** * Give the user a single choice from an array of answers. * @@ -292,9 +348,15 @@ public function info($string, $verbosity = null) */ public function line($string, $style = null, $verbosity = null) { - $styled = $style ? "<$style>$string" : $string; + if ($this->output->isDecorated() == false || is_null($style)) { + return $this->output->writeln($string, $this->parseVerbosity($verbosity)); + } - $this->output->writeln($styled, $this->parseVerbosity($verbosity)); + renderUsing($this->output); + + render(view('illuminate.console::lines.'. $style, [ + 'content' => $this->highlightDynamicContent($string), + ]), $this->parseVerbosity($verbosity)); } /** @@ -306,7 +368,12 @@ public function line($string, $style = null, $verbosity = null) */ public function comment($string, $verbosity = null) { - $this->line($string, 'comment', $verbosity); + $string = $this->highlightDynamicContent($string); + + $this->output->writeln( + "$string", + $this->parseVerbosity($verbosity) + ); } /** @@ -342,12 +409,6 @@ public function error($string, $verbosity = null) */ public function warn($string, $verbosity = null) { - if (! $this->output->getFormatter()->hasStyle('warning')) { - $style = new OutputFormatterStyle('yellow'); - - $this->output->getFormatter()->setStyle('warning', $style); - } - $this->line($string, 'warning', $verbosity); } @@ -359,13 +420,9 @@ public function warn($string, $verbosity = null) */ public function alert($string) { - $length = Str::length(strip_tags($string)) + 12; - - $this->comment(str_repeat('*', $length)); - $this->comment('* '.$string.' *'); - $this->comment(str_repeat('*', $length)); - - $this->newLine(); + render(view('illuminate.console::alert', [ + 'content' => $string, + ])); } /** @@ -431,6 +488,17 @@ protected function parseVerbosity($level = null) return $level; } + /** + * Highligths dynamic content within the given string. + * + * @param string $string + * @return string + */ + protected function highlightDynamicContent($string) + { + return preg_replace('/\[([^\]]+)\]/', "[$1]", $string); + } + /** * Get the output implementation. * diff --git a/src/Illuminate/Console/ConfirmableTrait.php b/src/Illuminate/Console/ConfirmableTrait.php index 8d0d6df77808..ff836b86712b 100644 --- a/src/Illuminate/Console/ConfirmableTrait.php +++ b/src/Illuminate/Console/ConfirmableTrait.php @@ -13,7 +13,7 @@ trait ConfirmableTrait * @param \Closure|bool|null $callback * @return bool */ - public function confirmToProceed($warning = 'Application In Production!', $callback = null) + public function confirmToProceed($warning = 'Application In Production', $callback = null) { $callback = is_null($callback) ? $this->getDefaultConfirmCallback() : $callback; @@ -29,7 +29,7 @@ public function confirmToProceed($warning = 'Application In Production!', $callb $confirmed = $this->confirm('Do you really wish to run this command?'); if (! $confirmed) { - $this->comment('Command Canceled!'); + $this->warn('Command Canceled!'); return false; } diff --git a/src/Illuminate/Console/ConsoleServiceProvider.php b/src/Illuminate/Console/ConsoleServiceProvider.php new file mode 100644 index 000000000000..97c69eeb6912 --- /dev/null +++ b/src/Illuminate/Console/ConsoleServiceProvider.php @@ -0,0 +1,36 @@ +app->runningInConsole()) { + Blade::component('line', Components\LineComponent::class); + } + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + if ($this->app->runningInConsole()) { + $this->loadViewsFrom( + __DIR__.'/resources/views', 'illuminate.console' + ); + } + } +} diff --git a/src/Illuminate/Console/GeneratorCommand.php b/src/Illuminate/Console/GeneratorCommand.php index a9129da7af5d..42b5db2dd5ba 100644 --- a/src/Illuminate/Console/GeneratorCommand.php +++ b/src/Illuminate/Console/GeneratorCommand.php @@ -174,11 +174,15 @@ public function handle() $this->files->put($path, $this->sortImports($this->buildClass($name))); - $this->info($this->type.' created successfully.'); + $info = $this->type; if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { - $this->handleTestCreation($path); + if ($this->handleTestCreation($path)) { + $info .= ' and test'; + } } + + $this->info($info.' created successfully.'); } /** diff --git a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php index 16b9bf46dda3..1b2a7776c501 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php @@ -61,7 +61,7 @@ public function handle(Schedule $schedule) $events = collect($schedule->events()); if ($events->isEmpty()) { - $this->comment('No scheduled tasks have been defined.'); + $this->info('No scheduled tasks have been defined.'); return; } diff --git a/src/Illuminate/Console/View/Components/LineComponent.php b/src/Illuminate/Console/View/Components/LineComponent.php new file mode 100644 index 000000000000..16ab267aad91 --- /dev/null +++ b/src/Illuminate/Console/View/Components/LineComponent.php @@ -0,0 +1,62 @@ +bgColor = $bgColor; + $this->fgColor = $fgColor; + $this->title = $title; + } + + /** + * Get the view / view contents that represent the component. + * + * @return void + */ + public function render() + { + return <<<'blade' +
+ {{ $title }} + + {{ $slot }} + +
+ blade; + } +} \ No newline at end of file diff --git a/src/Illuminate/Console/composer.json b/src/Illuminate/Console/composer.json index 5a768863bc01..a535fb7fc6cc 100755 --- a/src/Illuminate/Console/composer.json +++ b/src/Illuminate/Console/composer.json @@ -19,6 +19,8 @@ "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", "illuminate/support": "^9.0", + "illuminate/view": "^9.0", + "nunomaduro/termwind": "^1.12", "symfony/console": "^6.0", "symfony/process": "^6.0" }, diff --git a/src/Illuminate/Console/resources/views/alert.blade.php b/src/Illuminate/Console/resources/views/alert.blade.php new file mode 100644 index 000000000000..ada9a83bf55f --- /dev/null +++ b/src/Illuminate/Console/resources/views/alert.blade.php @@ -0,0 +1,3 @@ +
+ {{ $content }} +
\ No newline at end of file diff --git a/src/Illuminate/Console/resources/views/lines/error.blade.php b/src/Illuminate/Console/resources/views/lines/error.blade.php new file mode 100644 index 000000000000..b0056077358c --- /dev/null +++ b/src/Illuminate/Console/resources/views/lines/error.blade.php @@ -0,0 +1,3 @@ + + {{ $content }} + diff --git a/src/Illuminate/Console/resources/views/lines/info.blade.php b/src/Illuminate/Console/resources/views/lines/info.blade.php new file mode 100644 index 000000000000..6c738e66f51e --- /dev/null +++ b/src/Illuminate/Console/resources/views/lines/info.blade.php @@ -0,0 +1,3 @@ + + {{ $content }} + diff --git a/src/Illuminate/Console/resources/views/lines/warning.blade.php b/src/Illuminate/Console/resources/views/lines/warning.blade.php new file mode 100644 index 000000000000..b727aec94a89 --- /dev/null +++ b/src/Illuminate/Console/resources/views/lines/warning.blade.php @@ -0,0 +1,3 @@ + + {{ $content }} + diff --git a/src/Illuminate/Console/resources/views/tasks/description.blade.php b/src/Illuminate/Console/resources/views/tasks/description.blade.php new file mode 100644 index 000000000000..8520957c7412 --- /dev/null +++ b/src/Illuminate/Console/resources/views/tasks/description.blade.php @@ -0,0 +1 @@ +{{ $description }} diff --git a/src/Illuminate/Console/resources/views/tasks/title.blade.php b/src/Illuminate/Console/resources/views/tasks/title.blade.php new file mode 100644 index 000000000000..a3b4c2ae09c1 --- /dev/null +++ b/src/Illuminate/Console/resources/views/tasks/title.blade.php @@ -0,0 +1,3 @@ +
+ {{ $title }} +
diff --git a/src/Illuminate/Database/Console/DumpCommand.php b/src/Illuminate/Database/Console/DumpCommand.php index 71171f32b744..eaa3961a51fd 100644 --- a/src/Illuminate/Database/Console/DumpCommand.php +++ b/src/Illuminate/Database/Console/DumpCommand.php @@ -59,15 +59,17 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $dispatcher->dispatch(new SchemaDumped($connection, $path)); - $this->info('Database schema dumped successfully.'); + $info = 'Database schema dumped'; if ($this->option('prune')) { (new Filesystem)->deleteDirectory( database_path('migrations'), $preserve = false ); - $this->info('Migrations pruned successfully.'); + $info .= ' and pruned'; } + + $this->info($info . ' successfully.'); } /** diff --git a/src/Illuminate/Database/Console/Migrations/ResetCommand.php b/src/Illuminate/Database/Console/Migrations/ResetCommand.php index 1f2babbc8d08..83f19deccb98 100755 --- a/src/Illuminate/Database/Console/Migrations/ResetCommand.php +++ b/src/Illuminate/Database/Console/Migrations/ResetCommand.php @@ -60,7 +60,7 @@ public function handle() // start trying to rollback and re-run all of the migrations. If it's not // present we'll just bail out with an info message for the developers. if (! $this->migrator->repositoryExists()) { - return $this->comment('Migration table not found.'); + return $this->warn('Migration table not found.'); } $this->migrator->setOutput($this->output)->reset( diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index fde8e91af68d..538733f43131 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation; use Closure; +use Illuminate\Console\ConsoleServiceProvider; use Illuminate\Container\Container; use Illuminate\Contracts\Foundation\Application as ApplicationContract; use Illuminate\Contracts\Foundation\CachesConfiguration; @@ -218,6 +219,7 @@ protected function registerBaseBindings() */ protected function registerBaseServiceProviders() { + $this->register(new ConsoleServiceProvider($this)); $this->register(new EventServiceProvider($this)); $this->register(new LogServiceProvider($this)); $this->register(new RoutingServiceProvider($this)); diff --git a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php index 17545b41448e..4c23b8e16be4 100644 --- a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php @@ -66,7 +66,7 @@ public function __construct(Filesystem $files) */ public function handle() { - $this->call('config:clear'); + $this->callSilent('config:clear'); $config = $this->getFreshConfiguration(); diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 3777ae6a6131..ff3ec9d8e86b 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -52,7 +52,7 @@ public function handle() { try { if ($this->laravel->maintenanceMode()->active()) { - $this->comment('Application is already down.'); + $this->info('Application is already down.'); return 0; } @@ -66,11 +66,12 @@ public function handle() $this->laravel->get('events')->dispatch(MaintenanceModeEnabled::class); - $this->comment('Application is now in maintenance mode.'); + $this->info('Application is now in maintenance mode.'); } catch (Exception $e) { - $this->error('Failed to enter maintenance mode.'); - - $this->error($e->getMessage()); + $this->error(sprintf( + 'Failed to enter maintenance mode: %s.', + $e->getMessage(), + )); return 1; } diff --git a/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/src/Illuminate/Foundation/Console/EnvironmentCommand.php index 32e99ad8a74d..73d1ffd0b540 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -40,6 +40,9 @@ class EnvironmentCommand extends Command */ public function handle() { - $this->line('Current application environment: '.$this->laravel['env'].''); + $this->info(sprintf( + 'The application is on [%s] environment.', + $this->laravel['env'], + )); } } diff --git a/src/Illuminate/Foundation/Console/EventCacheCommand.php b/src/Illuminate/Foundation/Console/EventCacheCommand.php index 9590e5b57155..299a7bfc1694 100644 --- a/src/Illuminate/Foundation/Console/EventCacheCommand.php +++ b/src/Illuminate/Foundation/Console/EventCacheCommand.php @@ -41,7 +41,7 @@ class EventCacheCommand extends Command */ public function handle() { - $this->call('event:clear'); + $this->callSilent('event:clear'); file_put_contents( $this->laravel->getCachedEventsPath(), diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index 1e12960c10d6..012db8c879cf 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -40,13 +40,13 @@ class OptimizeClearCommand extends Command */ public function handle() { - $this->call('event:clear'); - $this->call('view:clear'); - $this->call('cache:clear'); - $this->call('route:clear'); - $this->call('config:clear'); - $this->call('clear-compiled'); - - $this->info('Caches cleared successfully.'); + $this->tasks('Removing cached bootstrap files', [ + 'events' => fn () => $this->callSilent('event:clear'), + 'views' => fn () => $this->callSilent('view:clear'), + 'cache' => fn () => $this->callSilent('cache:clear'), + 'route' => fn () => $this->callSilent('route:clear'), + 'config' => fn () => $this->callSilent('config:clear'), + 'compiled' => fn () => $this->callSilent('clear-compiled'), + ]); } } diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 619c2733bc8b..802099b0203c 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -40,9 +40,9 @@ class OptimizeCommand extends Command */ public function handle() { - $this->call('config:cache'); - $this->call('route:cache'); - - $this->info('Files cached successfully.'); + $this->tasks('Caching the framework bootstrap files', [ + 'config' => fn () => $this->callSilent('config:cache') == 0, + 'routes' => fn () => $this->callSilent('route:cache') == 0, + ]); } } diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index 674c579aa5a2..dc8209f92116 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -44,10 +44,9 @@ public function handle(PackageManifest $manifest) { $manifest->build(); - foreach (array_keys($manifest->manifest) as $package) { - $this->line("Discovered Package: {$package}"); - } + $tasks = collect($manifest->manifest) + ->map(fn () => fn () => true); - $this->info('Package manifest generated successfully.'); + $this->tasks('Discovering packages', $tasks); } } diff --git a/src/Illuminate/Foundation/Console/RouteCacheCommand.php b/src/Illuminate/Foundation/Console/RouteCacheCommand.php index 67a1dbde4b8d..5a5c9329df7b 100644 --- a/src/Illuminate/Foundation/Console/RouteCacheCommand.php +++ b/src/Illuminate/Foundation/Console/RouteCacheCommand.php @@ -63,7 +63,7 @@ public function __construct(Filesystem $files) */ public function handle() { - $this->call('route:clear'); + $this->callSilent('route:clear'); $routes = $this->getFreshApplicationRoutes(); diff --git a/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/src/Illuminate/Foundation/Console/StorageLinkCommand.php index f5decaf044fa..bee4f6e3c587 100644 --- a/src/Illuminate/Foundation/Console/StorageLinkCommand.php +++ b/src/Illuminate/Foundation/Console/StorageLinkCommand.php @@ -46,6 +46,8 @@ public function handle() foreach ($this->links() as $link => $target) { if (file_exists($link) && ! $this->isRemovableSymlink($link, $this->option('force'))) { + $link = str_replace(base_path() . '/', '', $link); + $this->error("The [$link] link already exists."); continue; } @@ -60,10 +62,11 @@ public function handle() $this->laravel->make('files')->link($target, $link); } + $link = str_replace(base_path() . '/', '', $link); + $target = str_replace(base_path() . '/', '', $target); + $this->info("The [$link] link has been connected to [$target]."); } - - $this->info('The links have been created.'); } /** diff --git a/src/Illuminate/Foundation/Console/UpCommand.php b/src/Illuminate/Foundation/Console/UpCommand.php index 86adaed46154..e01f96755281 100644 --- a/src/Illuminate/Foundation/Console/UpCommand.php +++ b/src/Illuminate/Foundation/Console/UpCommand.php @@ -44,7 +44,7 @@ public function handle() { try { if (! $this->laravel->maintenanceMode()->active()) { - $this->comment('Application is already up.'); + $this->info('Application is already up.'); return 0; } @@ -59,9 +59,10 @@ public function handle() $this->info('Application is now live.'); } catch (Exception $e) { - $this->error('Failed to disable maintenance mode.'); - - $this->error($e->getMessage()); + $this->error(sprintf( + 'Failed to disable maintenance mode: %s.', + $e->getMessage(), + )); return 1; } diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 69020fba7188..33b68f70b3d9 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -92,8 +92,6 @@ public function handle() foreach ($this->tags ?: [null] as $tag) { $this->publishTag($tag); } - - $this->info('Publishing complete.'); } /** @@ -178,16 +176,23 @@ protected function publishTag($tag) $pathsToPublish = $this->pathsToPublish($tag); + if ($publishing = count($pathsToPublish) > 0) { + $this->info(sprintf( + 'Publishing %sassets', + $tag ? "[$tag] " : '', + )); + } + foreach ($pathsToPublish as $from => $to) { $this->publishItem($from, $to); - - $published = true; } - if ($published === false) { - $this->comment('No publishable resources for tag ['.$tag.'].'); + if ($publishing === false) { + $this->info('No publishable resources for tag ['.$tag.'].'); } else { $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); + + $this->newLine(); } } @@ -236,7 +241,12 @@ protected function publishFile($from, $to) $this->files->copy($from, $to); - $this->status($from, $to, 'File'); + $this->status($from, $to, 'file'); + } else { + $this->task(sprintf( + 'File [%s] already exist', + str_replace(base_path() . '/', '', realpath($to)), + )); } } @@ -256,7 +266,7 @@ protected function publishDirectory($from, $to) 'to' => new Flysystem(new LocalAdapter($to, $visibility)), ])); - $this->status($from, $to, 'Directory'); + $this->status($from, $to, 'directory'); } /** @@ -299,10 +309,15 @@ protected function createParentDirectory($directory) */ protected function status($from, $to, $type) { - $from = str_replace(base_path(), '', realpath($from)); + $from = str_replace(base_path(). '/', '', realpath($from)); - $to = str_replace(base_path(), '', realpath($to)); + $to = str_replace(base_path(). '/', '', realpath($to)); - $this->line('Copied '.$type.' ['.$from.'] To ['.$to.']'); + $this->task(sprintf( + 'Copying %s [%s] to [%s]', + $type, + $from, + $to, + ), fn () => true); } } diff --git a/src/Illuminate/Foundation/Console/ViewCacheCommand.php b/src/Illuminate/Foundation/Console/ViewCacheCommand.php index 468d92b9b08b..c0661a762317 100644 --- a/src/Illuminate/Foundation/Console/ViewCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ViewCacheCommand.php @@ -43,7 +43,7 @@ class ViewCacheCommand extends Command */ public function handle() { - $this->call('view:clear'); + $this->callSilent('view:clear'); $this->paths()->each(function ($path) { $this->compileViews($this->bladeFilesIn([$path])); diff --git a/src/Illuminate/Queue/Console/ClearCommand.php b/src/Illuminate/Queue/Console/ClearCommand.php index 5729eb8bd4b0..030646609f90 100644 --- a/src/Illuminate/Queue/Console/ClearCommand.php +++ b/src/Illuminate/Queue/Console/ClearCommand.php @@ -64,9 +64,9 @@ public function handle() if ($queue instanceof ClearableQueue) { $count = $queue->clear($queueName); - $this->line('Cleared '.$count.' jobs from the ['.$queueName.'] queue '); + $this->info('Cleared '.$count.' jobs from the ['.$queueName.'] queue'); } else { - $this->line('Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().'] '); + $this->error('Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().']'); } return 0; diff --git a/src/Illuminate/Queue/Console/ListFailedCommand.php b/src/Illuminate/Queue/Console/ListFailedCommand.php index e74f55afe9be..656ea96d8fbc 100644 --- a/src/Illuminate/Queue/Console/ListFailedCommand.php +++ b/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -49,7 +49,7 @@ class ListFailedCommand extends Command public function handle() { if (count($jobs = $this->getFailedJobs()) === 0) { - return $this->comment('No failed jobs found.'); + return $this->info('No failed jobs found.'); } $this->displayFailedJobs($jobs); diff --git a/src/Illuminate/Queue/Console/PruneBatchesCommand.php b/src/Illuminate/Queue/Console/PruneBatchesCommand.php index 0feb5040702f..5c13dd23d209 100644 --- a/src/Illuminate/Queue/Console/PruneBatchesCommand.php +++ b/src/Illuminate/Queue/Console/PruneBatchesCommand.php @@ -54,7 +54,7 @@ public function handle() $count = $repository->prune(Carbon::now()->subHours($this->option('hours'))); } - $this->info("{$count} entries deleted!"); + $this->info("{$count} entries deleted."); if ($this->option('unfinished')) { $count = 0; @@ -63,7 +63,7 @@ public function handle() $count = $repository->pruneUnfinished(Carbon::now()->subHours($this->option('unfinished'))); } - $this->info("{$count} unfinished entries deleted!"); + $this->info("{$count} unfinished entries deleted."); } } } diff --git a/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php b/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php index f6760b193bb7..644a1f280ede 100644 --- a/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php +++ b/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php @@ -53,6 +53,6 @@ public function handle() return 1; } - $this->info("{$count} entries deleted!"); + $this->info("{$count} entries deleted."); } } diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index 1ab74fac0ae3..d094e5655764 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -53,8 +53,12 @@ public function handle() return 1; } + $this->info("Retrying the failed jobs for a batch [$id]."); + foreach ($batch->failedJobIds as $failedJobId) { - $this->call('queue:retry', ['id' => $failedJobId]); + $this->task($failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); } + + $this->newLine(); } } diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index c9640f0b0e9e..ad568d70f924 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -48,7 +48,13 @@ class RetryCommand extends Command */ public function handle() { - foreach ($this->getJobIds() as $id) { + $jobsFound = count($ids = $this->getJobIds()) > 0; + + if ($jobsFound) { + $this->info('Retrying failed queue jobs.'); + } + + foreach ($ids as $id) { $job = $this->laravel['queue.failer']->find($id); if (is_null($job)) { @@ -56,13 +62,13 @@ public function handle() } else { $this->laravel['events']->dispatch(new JobRetryRequested($job)); - $this->retryJob($job); - - $this->info("The failed job [{$id}] has been pushed back onto the queue!"); + $this->task($id, fn () => $this->retryJob($job)); $this->laravel['queue.failer']->forget($id); } } + + $jobsFound ? $this->newLine() : $this->info('No retryable jobs found.'); } /** From 01f8e99570fcd0f672c0af81d8529445782c6c29 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 29 Jun 2022 18:10:01 +0000 Subject: [PATCH 002/101] Apply fixes from StyleCI --- .../Console/Concerns/InteractsWithIO.php | 14 +++++++------- .../Console/View/Components/LineComponent.php | 3 +-- src/Illuminate/Database/Console/DumpCommand.php | 2 +- .../Foundation/Console/StorageLinkCommand.php | 6 +++--- .../Foundation/Console/VendorPublishCommand.php | 6 +++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 3adda5dd5c98..9a266464976d 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -5,14 +5,14 @@ use Closure; use Illuminate\Console\OutputStyle; use Illuminate\Contracts\Support\Arrayable; -use Illuminate\Support\Str; -use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; -use function Termwind\{terminal, render, renderUsing}; +use function Termwind\render; +use function Termwind\renderUsing; +use function Termwind\terminal; trait InteractsWithIO { @@ -223,11 +223,11 @@ public function tasks($title, $tasks, $verbosity = null) */ public function task($description, $task = null, $verbosity = null) { - if (!$this->output->isDecorated()) { + if (! $this->output->isDecorated()) { $this->output->write($description); if ($task) { - $this->output->writeln(': ' . ($task() ? 'DONE' : 'FAIL')); + $this->output->writeln(': '.($task() ? 'DONE' : 'FAIL')); } return; @@ -354,7 +354,7 @@ public function line($string, $style = null, $verbosity = null) renderUsing($this->output); - render(view('illuminate.console::lines.'. $style, [ + render(view('illuminate.console::lines.'.$style, [ 'content' => $this->highlightDynamicContent($string), ]), $this->parseVerbosity($verbosity)); } @@ -496,7 +496,7 @@ protected function parseVerbosity($level = null) */ protected function highlightDynamicContent($string) { - return preg_replace('/\[([^\]]+)\]/', "[$1]", $string); + return preg_replace('/\[([^\]]+)\]/', '[$1]', $string); } /** diff --git a/src/Illuminate/Console/View/Components/LineComponent.php b/src/Illuminate/Console/View/Components/LineComponent.php index 16ab267aad91..aa0fd2e35c66 100644 --- a/src/Illuminate/Console/View/Components/LineComponent.php +++ b/src/Illuminate/Console/View/Components/LineComponent.php @@ -3,7 +3,6 @@ namespace Illuminate\Console\View\Components; use Illuminate\View\Component; -use function Termwind\{render, renderUsing}; class LineComponent extends Component { @@ -59,4 +58,4 @@ public function render() blade; } -} \ No newline at end of file +} diff --git a/src/Illuminate/Database/Console/DumpCommand.php b/src/Illuminate/Database/Console/DumpCommand.php index eaa3961a51fd..d13887e0d299 100644 --- a/src/Illuminate/Database/Console/DumpCommand.php +++ b/src/Illuminate/Database/Console/DumpCommand.php @@ -69,7 +69,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $info .= ' and pruned'; } - $this->info($info . ' successfully.'); + $this->info($info.' successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/src/Illuminate/Foundation/Console/StorageLinkCommand.php index bee4f6e3c587..b07458a0cc5a 100644 --- a/src/Illuminate/Foundation/Console/StorageLinkCommand.php +++ b/src/Illuminate/Foundation/Console/StorageLinkCommand.php @@ -46,7 +46,7 @@ public function handle() foreach ($this->links() as $link => $target) { if (file_exists($link) && ! $this->isRemovableSymlink($link, $this->option('force'))) { - $link = str_replace(base_path() . '/', '', $link); + $link = str_replace(base_path().'/', '', $link); $this->error("The [$link] link already exists."); continue; @@ -62,8 +62,8 @@ public function handle() $this->laravel->make('files')->link($target, $link); } - $link = str_replace(base_path() . '/', '', $link); - $target = str_replace(base_path() . '/', '', $target); + $link = str_replace(base_path().'/', '', $link); + $target = str_replace(base_path().'/', '', $target); $this->info("The [$link] link has been connected to [$target]."); } diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 33b68f70b3d9..8ccfa2dddc3b 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -245,7 +245,7 @@ protected function publishFile($from, $to) } else { $this->task(sprintf( 'File [%s] already exist', - str_replace(base_path() . '/', '', realpath($to)), + str_replace(base_path().'/', '', realpath($to)), )); } } @@ -309,9 +309,9 @@ protected function createParentDirectory($directory) */ protected function status($from, $to, $type) { - $from = str_replace(base_path(). '/', '', realpath($from)); + $from = str_replace(base_path().'/', '', realpath($from)); - $to = str_replace(base_path(). '/', '', realpath($to)); + $to = str_replace(base_path().'/', '', realpath($to)); $this->task(sprintf( 'Copying %s [%s] to [%s]', From ab0bd25ab2d6867ae74d88e4d7ea9d9318d8f036 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Jun 2022 18:16:48 +0100 Subject: [PATCH 003/101] Improves confirmable trait wording --- src/Illuminate/Console/ConfirmableTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/ConfirmableTrait.php b/src/Illuminate/Console/ConfirmableTrait.php index ff836b86712b..8c46a4789a28 100644 --- a/src/Illuminate/Console/ConfirmableTrait.php +++ b/src/Illuminate/Console/ConfirmableTrait.php @@ -29,7 +29,7 @@ public function confirmToProceed($warning = 'Application In Production', $callba $confirmed = $this->confirm('Do you really wish to run this command?'); if (! $confirmed) { - $this->warn('Command Canceled!'); + $this->warn('Command canceled.'); return false; } From f04e52986e03553de6442d2c243e956a8364f80a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Jun 2022 18:33:45 +0100 Subject: [PATCH 004/101] Refactors to components --- .../Console/Concerns/InteractsWithIO.php | 55 ++-------- .../Console/ConsoleServiceProvider.php | 2 +- .../Console/Contracts/NewLineAware.php | 8 ++ src/Illuminate/Console/OutputStyle.php | 44 +++++++- src/Illuminate/Console/QuestionHelper.php | 92 ++++++++++++++++ .../Components/Concerns/Highlightable.php | 17 +++ .../Console/View/Components/Detail.php | 38 +++++++ .../Console/View/Components/Line.php | 100 ++++++++++++++++++ .../Console/View/Components/LineComponent.php | 61 ----------- .../Console/View/Components/Task.php | 47 ++++++++ .../Console/resources/views/detail.blade.php | 9 ++ .../resources/views/lines/error.blade.php | 2 +- .../resources/views/lines/info.blade.php | 2 +- .../resources/views/lines/warning.blade.php | 2 +- .../views/tasks/description.blade.php | 1 - .../resources/views/tasks/title.blade.php | 3 - 16 files changed, 366 insertions(+), 117 deletions(-) create mode 100644 src/Illuminate/Console/Contracts/NewLineAware.php create mode 100644 src/Illuminate/Console/QuestionHelper.php create mode 100644 src/Illuminate/Console/View/Components/Concerns/Highlightable.php create mode 100644 src/Illuminate/Console/View/Components/Detail.php create mode 100644 src/Illuminate/Console/View/Components/Line.php delete mode 100644 src/Illuminate/Console/View/Components/LineComponent.php create mode 100644 src/Illuminate/Console/View/Components/Task.php create mode 100644 src/Illuminate/Console/resources/views/detail.blade.php delete mode 100644 src/Illuminate/Console/resources/views/tasks/description.blade.php delete mode 100644 src/Illuminate/Console/resources/views/tasks/title.blade.php diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 9a266464976d..52ce387fbcbd 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -4,6 +4,7 @@ use Closure; use Illuminate\Console\OutputStyle; +use Illuminate\Console\View\Components; use Illuminate\Contracts\Support\Arrayable; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; @@ -207,7 +208,9 @@ public function tasks($title, $tasks, $verbosity = null) $this->info($title, $verbosity); collect($tasks)->each( - fn ($task, $description) => $this->task($description, $task, $verbosity), + fn ($task, $description) => Components\Task::renderUsing( + $this->output, $description, $task, $this->parseVerbosity($verbosity), + ), ); $this->newLine(); @@ -223,30 +226,9 @@ public function tasks($title, $tasks, $verbosity = null) */ public function task($description, $task = null, $verbosity = null) { - if (! $this->output->isDecorated()) { - $this->output->write($description); - - if ($task) { - $this->output->writeln(': '.($task() ? 'DONE' : 'FAIL')); - } - - return; - } - - $descriptionWidth = mb_strlen($description); - $description = $this->highlightDynamicContent($description); - $this->output->write(" $description ", false, $this->parseVerbosity($verbosity)); - $dots = max(terminal()->width() - $descriptionWidth - 10, 0); - $this->output->write(str_repeat('.', $dots), false, $this->parseVerbosity($verbosity)); - - if ($task) { - $this->output->writeln( - $task() !== false ? ' DONE' : ' FAIL', - $this->parseVerbosity($verbosity), - ); - } else { - $this->output->writeln(str_repeat('.', 5)); - } + Components\Task::renderUsing( + $this->output, $description, $task, $this->parseVerbosity($verbosity), + ); } /** @@ -348,15 +330,7 @@ public function info($string, $verbosity = null) */ public function line($string, $style = null, $verbosity = null) { - if ($this->output->isDecorated() == false || is_null($style)) { - return $this->output->writeln($string, $this->parseVerbosity($verbosity)); - } - - renderUsing($this->output); - - render(view('illuminate.console::lines.'.$style, [ - 'content' => $this->highlightDynamicContent($string), - ]), $this->parseVerbosity($verbosity)); + Components\Line::renderUsing($this->output, $string, $style, $this->parseVerbosity($verbosity)); } /** @@ -368,8 +342,6 @@ public function line($string, $style = null, $verbosity = null) */ public function comment($string, $verbosity = null) { - $string = $this->highlightDynamicContent($string); - $this->output->writeln( "$string", $this->parseVerbosity($verbosity) @@ -488,17 +460,6 @@ protected function parseVerbosity($level = null) return $level; } - /** - * Highligths dynamic content within the given string. - * - * @param string $string - * @return string - */ - protected function highlightDynamicContent($string) - { - return preg_replace('/\[([^\]]+)\]/', '[$1]', $string); - } - /** * Get the output implementation. * diff --git a/src/Illuminate/Console/ConsoleServiceProvider.php b/src/Illuminate/Console/ConsoleServiceProvider.php index 97c69eeb6912..3c32e5deeb4d 100644 --- a/src/Illuminate/Console/ConsoleServiceProvider.php +++ b/src/Illuminate/Console/ConsoleServiceProvider.php @@ -16,7 +16,7 @@ class ConsoleServiceProvider extends ServiceProvider public function boot() { if ($this->app->runningInConsole()) { - Blade::component('line', Components\LineComponent::class); + Blade::component('line', Components\Line::class); } } diff --git a/src/Illuminate/Console/Contracts/NewLineAware.php b/src/Illuminate/Console/Contracts/NewLineAware.php new file mode 100644 index 000000000000..eb1726531e87 --- /dev/null +++ b/src/Illuminate/Console/Contracts/NewLineAware.php @@ -0,0 +1,8 @@ +output = $output; parent::__construct($input, $output); + + with(new ReflectionClass($this)) + ->getParentClass() + ->getProperty('questionHelper') + ->setValue($this, new QuestionHelper()); } /** @@ -78,4 +92,32 @@ public function getOutput() { return $this->output; } + + /** + * {@inheritdoc} + */ + public function write(string|iterable $messages, bool $newline = false, int $options = 0) + { + $this->newLineWritten = $newline; + + parent::write($messages, $newline, $options); + } + + /** + * {@inheritdoc} + */ + public function newLine(int $count = 1) + { + $this->newLineWritten = $count > 0; + + parent::newLine($count); + } + + /** + * {@inheritdoc} + */ + public function newLineWritten() + { + return $this->newLineWritten; + } } diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php new file mode 100644 index 000000000000..50a3623790d3 --- /dev/null +++ b/src/Illuminate/Console/QuestionHelper.php @@ -0,0 +1,92 @@ +getQuestion()); + + $text = $this->ensureEndsWithPunctuation($text); + + $text = " $text"; + + $default = $question->getDefault(); + + if ($question->isMultiline()) { + $text .= sprintf(' (press %s to continue)', $this->getEofShortcut()); + } + + switch (true) { + case null === $default: + $text = sprintf('%s', $text); + + break; + + case $question instanceof ConfirmationQuestion: + $text = sprintf('%s (yes/no) [%s]', $text, $default ? 'yes' : 'no'); + + break; + + case $question instanceof ChoiceQuestion && $question->isMultiselect(): + $choices = $question->getChoices(); + $default = explode(',', $default); + + foreach ($default as $key => $value) { + $default[$key] = $choices[trim($value)]; + } + + $text = sprintf('%s [%s]', $text, OutputFormatter::escape(implode(', ', $default))); + + break; + + case $question instanceof ChoiceQuestion: + $choices = $question->getChoices(); + $text = sprintf('%s [%s]', $text, OutputFormatter::escape($choices[$default] ?? $default)); + + break; + + default: + $text = sprintf('%s [%s]', $text, OutputFormatter::escape($default)); + } + + $output->writeln($text); + + if ($question instanceof ChoiceQuestion) { + foreach ($question->getChoices() as $key => $value) { + Detail::renderUsing($output, $key, $value); + } + } + + $output->write('❯ '); + } + + /** + * Ensures the given string ends with punctuation. + * + * @param string $string + * @return string + */ + protected function ensureEndsWithPunctuation($string) + { + if (! str($string)->endsWith(['?', ':', '!', '.'])) { + return "$string:"; + } + + return $string; + } +} diff --git a/src/Illuminate/Console/View/Components/Concerns/Highlightable.php b/src/Illuminate/Console/View/Components/Concerns/Highlightable.php new file mode 100644 index 000000000000..09a5f0cd6921 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Concerns/Highlightable.php @@ -0,0 +1,17 @@ +[$1]', $string); + } +} \ No newline at end of file diff --git a/src/Illuminate/Console/View/Components/Detail.php b/src/Illuminate/Console/View/Components/Detail.php new file mode 100644 index 000000000000..2e781db37ee8 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Detail.php @@ -0,0 +1,38 @@ +isDecorated() == false || is_null($style)) { + // return $output->writeln($string, $verbosity); + // } + + renderUsing($output); + + $left = static::highlightDynamicContent($left); + $right = static::highlightDynamicContent($right); + + render(view('illuminate.console::detail', [ + 'left' => static::highlightDynamicContent($left), + 'right' => static::highlightDynamicContent($right), + ]), $verbosity); + } +} diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php new file mode 100644 index 000000000000..a2c543e23fcc --- /dev/null +++ b/src/Illuminate/Console/View/Components/Line.php @@ -0,0 +1,100 @@ +marginTop = $newLine ? 1 : 0; + $this->bgColor = $bgColor; + $this->fgColor = $fgColor; + $this->title = $title; + } + + /** + * Renders the component using the given arguments. + * + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param string $string + * @param string|null $style + * @param int $verbosity + * @return void + */ + public static function renderUsing($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) + { + // if ($output->isDecorated() == false || is_null($style)) { + // return $output->writeln($string, $verbosity); + // } + + renderUsing($output); + + render(view('illuminate.console::lines.'.$style, [ + 'content' => static::highlightDynamicContent($string), + 'newLine' => $output instanceof NewLineAware + ? $output->newLineWritten() == false + : true, + ]), $verbosity); + } + + /** + * Get the view / view contents that represent the component. + * + * @return void + */ + public function render() + { + return <<<'blade' +
+ {{ $title }} + + {{ $slot }} + +
+ blade; + } +} diff --git a/src/Illuminate/Console/View/Components/LineComponent.php b/src/Illuminate/Console/View/Components/LineComponent.php deleted file mode 100644 index aa0fd2e35c66..000000000000 --- a/src/Illuminate/Console/View/Components/LineComponent.php +++ /dev/null @@ -1,61 +0,0 @@ -bgColor = $bgColor; - $this->fgColor = $fgColor; - $this->title = $title; - } - - /** - * Get the view / view contents that represent the component. - * - * @return void - */ - public function render() - { - return <<<'blade' -
- {{ $title }} - - {{ $slot }} - -
- blade; - } -} diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php new file mode 100644 index 000000000000..e1731b8e1884 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Task.php @@ -0,0 +1,47 @@ +isDecorated()) { + // $output->write($description); + + // if ($task) { + // $output->writeln(': '.($task() ? 'DONE' : 'FAIL')); + // } + + // return; + // } + + $descriptionWidth = mb_strlen($description); + $description = static::highlightDynamicContent($description); + $output->write(" $description ", false, $verbosity); + $dots = max(terminal()->width() - $descriptionWidth - 10, 0); + $output->write(str_repeat('.', $dots), false, $verbosity); + + if (is_null($task)) { + return $output->writeln(str_repeat('.', 5), $verbosity); + } + + $output->writeln( + $task() !== false ? ' DONE' : ' FAIL', + $verbosity, + ); + } +} diff --git a/src/Illuminate/Console/resources/views/detail.blade.php b/src/Illuminate/Console/resources/views/detail.blade.php new file mode 100644 index 000000000000..bcd5edd3f122 --- /dev/null +++ b/src/Illuminate/Console/resources/views/detail.blade.php @@ -0,0 +1,9 @@ +
+ + {{ $left }} + + + + {{ $right }} + +
diff --git a/src/Illuminate/Console/resources/views/lines/error.blade.php b/src/Illuminate/Console/resources/views/lines/error.blade.php index b0056077358c..72088e56a3d8 100644 --- a/src/Illuminate/Console/resources/views/lines/error.blade.php +++ b/src/Illuminate/Console/resources/views/lines/error.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} diff --git a/src/Illuminate/Console/resources/views/lines/info.blade.php b/src/Illuminate/Console/resources/views/lines/info.blade.php index 6c738e66f51e..c9132afde16f 100644 --- a/src/Illuminate/Console/resources/views/lines/info.blade.php +++ b/src/Illuminate/Console/resources/views/lines/info.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} diff --git a/src/Illuminate/Console/resources/views/lines/warning.blade.php b/src/Illuminate/Console/resources/views/lines/warning.blade.php index b727aec94a89..715bd7fcbe19 100644 --- a/src/Illuminate/Console/resources/views/lines/warning.blade.php +++ b/src/Illuminate/Console/resources/views/lines/warning.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} diff --git a/src/Illuminate/Console/resources/views/tasks/description.blade.php b/src/Illuminate/Console/resources/views/tasks/description.blade.php deleted file mode 100644 index 8520957c7412..000000000000 --- a/src/Illuminate/Console/resources/views/tasks/description.blade.php +++ /dev/null @@ -1 +0,0 @@ -{{ $description }} diff --git a/src/Illuminate/Console/resources/views/tasks/title.blade.php b/src/Illuminate/Console/resources/views/tasks/title.blade.php deleted file mode 100644 index a3b4c2ae09c1..000000000000 --- a/src/Illuminate/Console/resources/views/tasks/title.blade.php +++ /dev/null @@ -1,3 +0,0 @@ -
- {{ $title }} -
From c87ffeabf9c98112cd7f3cfad14447d355b9a34f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Jun 2022 18:34:00 +0100 Subject: [PATCH 005/101] Improves vendor publish --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 8ccfa2dddc3b..6ca053fa0769 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -142,8 +142,8 @@ protected function publishableChoices() { return array_merge( ['Publish files from all providers and tags listed below'], - preg_filter('/^/', 'Provider: ', Arr::sort(ServiceProvider::publishableProviders())), - preg_filter('/^/', 'Tag: ', Arr::sort(ServiceProvider::publishableGroups())) + preg_filter('/^/', 'Provider: ', Arr::sort(ServiceProvider::publishableProviders())), + preg_filter('/^/', 'Tag: ', Arr::sort(ServiceProvider::publishableGroups())) ); } From 46b5e489dd29fc6f4a651f631abb3b13da9b08c0 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 30 Jun 2022 17:34:31 +0000 Subject: [PATCH 006/101] Apply fixes from StyleCI --- src/Illuminate/Console/Concerns/InteractsWithIO.php | 2 -- src/Illuminate/Console/Contracts/NewLineAware.php | 3 +-- src/Illuminate/Console/QuestionHelper.php | 4 +--- .../Console/View/Components/Concerns/Highlightable.php | 2 +- src/Illuminate/Console/View/Components/Detail.php | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 52ce387fbcbd..13e0bb2a66b3 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -12,8 +12,6 @@ use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; use function Termwind\render; -use function Termwind\renderUsing; -use function Termwind\terminal; trait InteractsWithIO { diff --git a/src/Illuminate/Console/Contracts/NewLineAware.php b/src/Illuminate/Console/Contracts/NewLineAware.php index eb1726531e87..56d046bb106c 100644 --- a/src/Illuminate/Console/Contracts/NewLineAware.php +++ b/src/Illuminate/Console/Contracts/NewLineAware.php @@ -4,5 +4,4 @@ interface NewLineAware { - -} \ No newline at end of file +} diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php index 50a3623790d3..45ec1f82878b 100644 --- a/src/Illuminate/Console/QuestionHelper.php +++ b/src/Illuminate/Console/QuestionHelper.php @@ -3,14 +3,12 @@ namespace Illuminate\Console; use Illuminate\Console\View\Components\Detail; -use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; -use function Termwind\renderUsing; -use function Termwind\render; class QuestionHelper extends SymfonyQuestionHelper { diff --git a/src/Illuminate/Console/View/Components/Concerns/Highlightable.php b/src/Illuminate/Console/View/Components/Concerns/Highlightable.php index 09a5f0cd6921..7ee153d8bcaf 100644 --- a/src/Illuminate/Console/View/Components/Concerns/Highlightable.php +++ b/src/Illuminate/Console/View/Components/Concerns/Highlightable.php @@ -14,4 +14,4 @@ protected static function highlightDynamicContent($string) { return preg_replace('/\[([^\]]+)\]/', '[$1]', $string); } -} \ No newline at end of file +} diff --git a/src/Illuminate/Console/View/Components/Detail.php b/src/Illuminate/Console/View/Components/Detail.php index 2e781db37ee8..e000ea61db82 100644 --- a/src/Illuminate/Console/View/Components/Detail.php +++ b/src/Illuminate/Console/View/Components/Detail.php @@ -2,9 +2,9 @@ namespace Illuminate\Console\View\Components; +use Symfony\Component\Console\Output\OutputInterface; use function Termwind\render; use function Termwind\renderUsing; -use Symfony\Component\Console\Output\OutputInterface; class Detail { From e71d6b7e8c8b9f414f079bb88839b8217abf43d4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Jun 2022 19:02:24 +0100 Subject: [PATCH 007/101] Fixes displaying line without style --- src/Illuminate/Console/View/Components/Line.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index a2c543e23fcc..af453586b15a 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -68,8 +68,9 @@ public function __construct($newLine, $bgColor, $fgColor, $title) public static function renderUsing($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) { // if ($output->isDecorated() == false || is_null($style)) { - // return $output->writeln($string, $verbosity); - // } + if (is_null($style)) { + return $output->writeln($string, $verbosity); + } renderUsing($output); From 00a585441fc629b03d01d9e1c25511f3f80344ee Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:08:25 +0100 Subject: [PATCH 008/101] Adds Bullet List componenent --- .../Console/View/Components/BulletList.php | 37 +++++++++++++++++++ .../resources/views/bullet-list.blade.php | 5 +++ 2 files changed, 42 insertions(+) create mode 100644 src/Illuminate/Console/View/Components/BulletList.php create mode 100644 src/Illuminate/Console/resources/views/bullet-list.blade.php diff --git a/src/Illuminate/Console/View/Components/BulletList.php b/src/Illuminate/Console/View/Components/BulletList.php new file mode 100644 index 000000000000..7d18e2730c16 --- /dev/null +++ b/src/Illuminate/Console/View/Components/BulletList.php @@ -0,0 +1,37 @@ + $elements + * @param int $verbosity + * @return void + */ + public static function renderUsing($output, $elements, $verbosity = OutputInterface::VERBOSITY_NORMAL) + { + renderUsing($output); + + render(view('illuminate.console::bullet-list', [ + 'elements' => collect($elements)->map(function ($string) { + $string = self::highlightDynamicContent($string); + $string = self::ensureNoPunctuation($string); + $string = self::ensureRelativePaths($string); + + return $string; + }), + ]), $verbosity); + } +} diff --git a/src/Illuminate/Console/resources/views/bullet-list.blade.php b/src/Illuminate/Console/resources/views/bullet-list.blade.php new file mode 100644 index 000000000000..b79d588d12d5 --- /dev/null +++ b/src/Illuminate/Console/resources/views/bullet-list.blade.php @@ -0,0 +1,5 @@ +@foreach($elements as $element) +
+ ⇂ {{ $element }} +
+@endforeach From 9adaa23b382257ff527d770c16e12c8d8e74d78a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:08:41 +0100 Subject: [PATCH 009/101] Adds Alert component --- .../Console/View/Components/Alert.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Illuminate/Console/View/Components/Alert.php diff --git a/src/Illuminate/Console/View/Components/Alert.php b/src/Illuminate/Console/View/Components/Alert.php new file mode 100644 index 000000000000..fcdd53f40e3d --- /dev/null +++ b/src/Illuminate/Console/View/Components/Alert.php @@ -0,0 +1,27 @@ + $string, + ]), $verbosity); + } +} From 28c829023df49dd38b608c363d9790e6b2eae31b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:08:57 +0100 Subject: [PATCH 010/101] Gives access to bullet list and detail on the command --- .../Console/Concerns/InteractsWithIO.php | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 13e0bb2a66b3..3fb26f390bbd 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -318,6 +318,31 @@ public function info($string, $verbosity = null) $this->line($string, 'info', $verbosity); } + /** + * Write a list of strings as bullet list output. + * + * @param array $strings + * @param int|string|null $verbosity + * @return void + */ + public function bulletList($strings, $verbosity = null) + { + Components\BulletList::renderUsing($this->output, $strings, $this->parseVerbosity($verbosity)); + } + + /** + * Write a string as detail output. + * + * @param string $left + * @param string|null $right + * @param int|string|null $verbosity + * @return void + */ + public function detail($left, $right = null, $verbosity = null) + { + Components\Detail::renderUsing($this->output, $left, $right, $this->parseVerbosity($verbosity)); + } + /** * Write a string as standard output. * @@ -390,9 +415,7 @@ public function warn($string, $verbosity = null) */ public function alert($string) { - render(view('illuminate.console::alert', [ - 'content' => $string, - ])); + Components\Alert::renderUsing($this->output, $string); } /** From 3a1259d0df3fc0629f658a277fa872dbecdb3228 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:09:09 +0100 Subject: [PATCH 011/101] Improves Detail output --- .../Console/resources/views/detail.blade.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Console/resources/views/detail.blade.php b/src/Illuminate/Console/resources/views/detail.blade.php index bcd5edd3f122..63210f35c7f7 100644 --- a/src/Illuminate/Console/resources/views/detail.blade.php +++ b/src/Illuminate/Console/resources/views/detail.blade.php @@ -1,9 +1,11 @@ -
- - {{ $left }} - - +
- {{ $right }} + {{ $left }} + + @if ($right !== '') + + {{ $right }} + + @endif
From d3e96cda0417f234ef2ffc68bd3c1ca1bd8ad014 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:09:21 +0100 Subject: [PATCH 012/101] Fixes Line info output --- src/Illuminate/Console/resources/views/lines/info.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/resources/views/lines/info.blade.php b/src/Illuminate/Console/resources/views/lines/info.blade.php index c9132afde16f..417737419b61 100644 --- a/src/Illuminate/Console/resources/views/lines/info.blade.php +++ b/src/Illuminate/Console/resources/views/lines/info.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} From ab1f208587a732084dc42633c7aa8127ab82e414 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:09:59 +0100 Subject: [PATCH 013/101] Truncates given information to componenents --- .../Concerns/EnsureNoPunctuation.php | 21 ++++++++ .../Components/Concerns/EnsurePunctuation.php | 22 +++++++++ .../Concerns/EnsureRelativePaths.php | 19 +++++++ .../Console/View/Components/Detail.php | 23 +++++---- .../Console/View/Components/Line.php | 28 ++++++----- .../Console/View/Components/Task.php | 49 ++++++++++++------- .../resources/views/lines/raw.blade.php | 3 ++ 7 files changed, 127 insertions(+), 38 deletions(-) create mode 100644 src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php create mode 100644 src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php create mode 100644 src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php create mode 100644 src/Illuminate/Console/resources/views/lines/raw.blade.php diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php b/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php new file mode 100644 index 000000000000..eeefca1d5c3d --- /dev/null +++ b/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php @@ -0,0 +1,21 @@ +endsWith(['.', '?', '!', ':'])) { + return substr_replace($string ,"", -1); + } + + return $string; + } +} diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php b/src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php new file mode 100644 index 000000000000..f4c8f4578e7f --- /dev/null +++ b/src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php @@ -0,0 +1,22 @@ +endsWith(['.', '?', '!', ':'])) { + return "$string$default"; + } + + return $string; + } +} diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php b/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php new file mode 100644 index 000000000000..555c32b36f56 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php @@ -0,0 +1,19 @@ +isDecorated() == false || is_null($style)) { - // return $output->writeln($string, $verbosity); - // } - renderUsing($output); - $left = static::highlightDynamicContent($left); - $right = static::highlightDynamicContent($right); + $left = self::highlightDynamicContent($left); + $left = self::ensureNoPunctuation($left); + $left = self::ensureRelativePaths($left); + + $right = self::highlightDynamicContent($right); + $right = self::ensureNoPunctuation($right); + $right = self::ensureRelativePaths($right); render(view('illuminate.console::detail', [ - 'left' => static::highlightDynamicContent($left), - 'right' => static::highlightDynamicContent($right), + 'left' => $left, + 'right' => $right, ]), $verbosity); } } diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index af453586b15a..1768a9b86c41 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -4,12 +4,15 @@ use Illuminate\Console\Contracts\NewLineAware; use Illuminate\View\Component; +use Symfony\Component\Console\Output\OutputInterface; use function Termwind\render; use function Termwind\renderUsing; class Line extends Component { - use Concerns\Highlightable; + use Concerns\EnsurePunctuation, + Concerns\EnsureRelativePaths, + Concerns\Highlightable; /** * The margin top that should be applied. @@ -35,7 +38,7 @@ class Line extends Component /** * The line title. * - * @var string + * @var string|null */ public $title; @@ -45,10 +48,10 @@ class Line extends Component * @param bool $newLine * @param string $bgColor * @param string $fgColor - * @param string $title + * @param string|null $title * @return void */ - public function __construct($newLine, $bgColor, $fgColor, $title) + public function __construct($newLine, $bgColor, $fgColor, $title = null) { $this->marginTop = $newLine ? 1 : 0; $this->bgColor = $bgColor; @@ -67,15 +70,16 @@ public function __construct($newLine, $bgColor, $fgColor, $title) */ public static function renderUsing($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - // if ($output->isDecorated() == false || is_null($style)) { - if (is_null($style)) { - return $output->writeln($string, $verbosity); - } + $style = $style ?: 'raw'; renderUsing($output); + $string = self::highlightDynamicContent($string); + $string = self::ensurePunctuation($string); + $string = self::ensureRelativePaths($string); + render(view('illuminate.console::lines.'.$style, [ - 'content' => static::highlightDynamicContent($string), + 'content' => $string, 'newLine' => $output instanceof NewLineAware ? $output->newLineWritten() == false : true, @@ -91,8 +95,10 @@ public function render() { return <<<'blade'
- {{ $title }} - + @if ($title) + {{ $title }} + @endif + {{ $slot }}
diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index e1731b8e1884..1ba1b7399258 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -3,10 +3,14 @@ namespace Illuminate\Console\View\Components; use function Termwind\terminal; +use Throwable; +use Symfony\Component\Console\Output\OutputInterface; class Task { - use Concerns\Highlightable; + use Concerns\EnsureNoPunctuation, + Concerns\EnsureRelativePaths, + Concerns\Highlightable; /** * Renders the component using the given arguments. @@ -19,29 +23,40 @@ class Task */ public static function renderUsing($output, $description, $task, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - // if (! $output->isDecorated()) { - // $output->write($description); - - // if ($task) { - // $output->writeln(': '.($task() ? 'DONE' : 'FAIL')); - // } - - // return; - // } + $description = self::ensureRelativePaths($description); + $description = self::ensureNoPunctuation($description); $descriptionWidth = mb_strlen($description); $description = static::highlightDynamicContent($description); $output->write(" $description ", false, $verbosity); - $dots = max(terminal()->width() - $descriptionWidth - 10, 0); - $output->write(str_repeat('.', $dots), false, $verbosity); if (is_null($task)) { - return $output->writeln(str_repeat('.', 5), $verbosity); + $dots = max(terminal()->width() - $descriptionWidth - 5, 0); + return $output->write(str_repeat('.', $dots), false, $verbosity); } - $output->writeln( - $task() !== false ? ' DONE' : ' FAIL', - $verbosity, - ); + $startTime = microtime(true); + + $result = false; + + try { + $result = $task(); + } catch (Throwable $e) { + throw $e; + } finally { + $runTime = (microtime(true) - $startTime) > 0.05 + ? (' ' . number_format((microtime(true) - $startTime) * 1000, 2) . 'ms') + : ''; + + $runTimeWidth = mb_strlen($runTime); + $dots = max(terminal()->width() - $descriptionWidth - $runTimeWidth - 10, 0); + $output->write(str_repeat('.', $dots), false, $verbosity); + $output->write("$runTime", false, $verbosity); + + $output->writeln( + $result !== false ? ' DONE' : ' FAIL', + $verbosity, + ); + } } } diff --git a/src/Illuminate/Console/resources/views/lines/raw.blade.php b/src/Illuminate/Console/resources/views/lines/raw.blade.php new file mode 100644 index 000000000000..8cec83e5b501 --- /dev/null +++ b/src/Illuminate/Console/resources/views/lines/raw.blade.php @@ -0,0 +1,3 @@ + + {{ $content }} + From 2628ae12540bd200f9e58229b5fb37904ccdb55e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:10 +0100 Subject: [PATCH 014/101] Improves `migrate:fresh` output --- .../Database/Console/Migrations/FreshCommand.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 7bfba0d78821..dc0ebbe68856 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Database\Console\Migrations; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Task; use Illuminate\Console\ConfirmableTrait; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\DatabaseRefreshed; @@ -39,12 +40,14 @@ public function handle() $database = $this->input->getOption('database'); - $this->call('db:wipe', array_filter([ + $this->newLine(); + + $this->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ '--database' => $database, '--drop-views' => $this->option('drop-views'), '--drop-types' => $this->option('drop-types'), '--force' => true, - ])); + ])) == 0); $this->call('migrate', array_filter([ '--database' => $database, From 8556a2e3ae0596a042b4eed9c7e64ff6835e379b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:19 +0100 Subject: [PATCH 015/101] Improves `migrate` output --- .../Console/Migrations/MigrateCommand.php | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index ea379e3f6d28..a37d5ec458dd 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -2,6 +2,8 @@ namespace Illuminate\Database\Console\Migrations; +use Illuminate\Console\View\Components\Line; +use Illuminate\Console\View\Components\Task; use Illuminate\Console\ConfirmableTrait; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\SchemaLoaded; @@ -108,9 +110,13 @@ public function handle() protected function prepareDatabase() { if (! $this->migrator->repositoryExists()) { - $this->call('migrate:install', array_filter([ - '--database' => $this->option('database'), - ])); + $this->info('Preparing database.'); + + Task::renderUsing($this->output, 'Creating migration table', function () { + return $this->callSilent('migrate:install', array_filter([ + '--database' => $this->option('database'), + ])) == 0; + }); } if (! $this->migrator->hasRunAnyMigrations() && ! $this->option('pretend')) { @@ -135,20 +141,18 @@ protected function loadSchemaState() return; } - $this->line('Loading stored database schema: '.$path); - - $startTime = microtime(true); - - // Since the schema file will create the "migrations" table and reload it to its - // proper state, we need to delete it here so we don't get an error that this - // table already exists when the stored database schema file gets executed. - $this->migrator->deleteRepository(); + $this->info('Preparing database.'); - $connection->getSchemaState()->handleOutputUsing(function ($type, $buffer) { - $this->output->write($buffer); - })->load($path); + Task::renderUsing($this->output, "Loading stored database schema [$path].", function () use ($connection, $path) { + // Since the schema file will create the "migrations" table and reload it to its + // proper state, we need to delete it here so we don't get an error that this + // table already exists when the stored database schema file gets executed. + $this->migrator->deleteRepository(); - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + $connection->getSchemaState()->handleOutputUsing(function ($type, $buffer) { + $this->output->write($buffer); + })->load($path); + }); // Finally, we will fire an event that this schema has been loaded so developers // can perform any post schema load tasks that are necessary in listeners for @@ -156,8 +160,6 @@ protected function loadSchemaState() $this->dispatcher->dispatch( new SchemaLoaded($connection, $path) ); - - $this->line('Loaded stored database schema. ('.$runTime.'ms)'); } /** From 62941b5dbdbb8b7ee54dd92e4934eefbfc0dc628 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:24 +0100 Subject: [PATCH 016/101] Improves `make:migrate` output --- .../Database/Console/Migrations/MigrateMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php index 95c3a206e54a..5d4aa6352df1 100644 --- a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php @@ -114,7 +114,7 @@ protected function writeMigration($name, $table, $create) $file = pathinfo($file, PATHINFO_FILENAME); } - $this->line("Created Migration: {$file}"); + $this->info(sprintf('Created migration [%s].', $file)); } /** From e30fec551f46196d47ebffcbbee6f7711490b227 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:30 +0100 Subject: [PATCH 017/101] Improves `migrate:status` output --- .../Console/Migrations/StatusCommand.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index f57fe53a507f..7ce0a1c6d410 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -61,9 +61,13 @@ public function handle() $batches = $this->migrator->getRepository()->getMigrationBatches(); if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { - $this->table(['Ran?', 'Migration', 'Batch'], $migrations); + $this->info('Migration status:'); + $migrations->each( + fn ($migration) => $this->detail($migration[0], $migration[1]) + ); + $this->newLine(); } else { - $this->error('No migrations found'); + $this->info('No migrations found'); } }); } @@ -81,9 +85,15 @@ protected function getStatusFor(array $ran, array $batches) ->map(function ($migration) use ($ran, $batches) { $migrationName = $this->migrator->getMigrationName($migration); - return in_array($migrationName, $ran) - ? ['Yes', $migrationName, $batches[$migrationName]] - : ['No', $migrationName]; + $status = in_array($migrationName, $ran) + ? 'Ran' + : 'Pending'; + + if (in_array($migrationName, $ran)) { + $status .= ' [' . $batches[$migrationName] . ']'; + } + + return [$migrationName, $status]; }); } From 57c31bb78f09abbc450a119c19ee0e36eb7ac8f6 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:35 +0100 Subject: [PATCH 018/101] Improves `migrate` output --- .../Database/Migrations/Migrator.php | 67 +++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 361747c6e85d..144a1713776b 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -3,6 +3,10 @@ namespace Illuminate\Database\Migrations; use Doctrine\DBAL\Schema\SchemaException; +use Illuminate\Console\View\Components\BulletList; +use Illuminate\Console\View\Components\Detail; +use Illuminate\Console\View\Components\Line; +use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\ConnectionResolverInterface as Resolver; use Illuminate\Database\Events\MigrationEnded; @@ -144,7 +148,7 @@ public function runPending(array $migrations, array $options = []) if (count($migrations) === 0) { $this->fireMigrationEvent(new NoPendingMigrations('up')); - $this->note('Nothing to migrate.'); + $this->write(Line::class, 'Nothing to migrate', 'info'); return; } @@ -160,6 +164,8 @@ public function runPending(array $migrations, array $options = []) $this->fireMigrationEvent(new MigrationsStarted('up')); + $this->write(Line::class, 'Running migrations.', 'info'); + // Once we have the array of migrations, we will spin through them and run the // migrations "up" so the changes are made to the databases. We'll then log // that the migration was run so we don't repeat it next time we execute. @@ -195,20 +201,12 @@ protected function runUp($file, $batch, $pretend) return $this->pretendToRun($migration, 'up'); } - $this->note("Migrating: {$name}"); - - $startTime = microtime(true); - - $this->runMigration($migration, 'up'); - - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + $this->write(Task::class, $name, fn () => $this->runMigration($migration, 'up')); // Once we have run a migrations class, we will log that it was run in this // repository so that we don't try to run it next time we do a migration // in the application. A migration repository keeps the migrate order. $this->repository->log($name, $batch); - - $this->note("Migrated: {$name} ({$runTime}ms)"); } /** @@ -228,7 +226,7 @@ public function rollback($paths = [], array $options = []) if (count($migrations) === 0) { $this->fireMigrationEvent(new NoPendingMigrations('down')); - $this->note('Nothing to rollback.'); + $this->write(Line::class, 'Nothing to rollback.', 'info'); return []; } @@ -267,6 +265,8 @@ protected function rollbackMigrations(array $migrations, $paths, array $options) $this->fireMigrationEvent(new MigrationsStarted('down')); + $this->write(Line::class, 'Rollbacking migrations.', 'info'); + // Next we will run through all of the migrations and call the "down" method // which will reverse each migration in order. This getLast method on the // repository already returns these migration's names in reverse order. @@ -274,7 +274,7 @@ protected function rollbackMigrations(array $migrations, $paths, array $options) $migration = (object) $migration; if (! $file = Arr::get($files, $migration->migration)) { - $this->note("Migration not found: {$migration->migration}"); + $this->write(Detail::class, $migration->migration, 'Migration not found'); continue; } @@ -307,7 +307,7 @@ public function reset($paths = [], $pretend = false) $migrations = array_reverse($this->repository->getRan()); if (count($migrations) === 0) { - $this->note('Nothing to rollback.'); + $this->write(Line::class, 'Nothing to rollback.', 'info'); return []; } @@ -354,24 +354,16 @@ protected function runDown($file, $migration, $pretend) $name = $this->getMigrationName($file); - $this->note("Rolling back: {$name}"); - if ($pretend) { return $this->pretendToRun($instance, 'down'); } - $startTime = microtime(true); - - $this->runMigration($instance, 'down'); - - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + $this->write(Task::class, $name, fn () => $this->runMigration($instance, 'down')); // Once we have successfully run the migration "down" we will remove it from // the migration repository so it will be considered to have not been run // by the application then will be able to fire by any later operation. $this->repository->delete($migration); - - $this->note("Rolled back: {$name} ({$runTime}ms)"); } /** @@ -413,21 +405,25 @@ protected function runMigration($migration, $method) protected function pretendToRun($migration, $method) { try { - foreach ($this->getQueries($migration, $method) as $query) { - $name = get_class($migration); - - $reflectionClass = new ReflectionClass($migration); + $name = get_class($migration); - if ($reflectionClass->isAnonymous()) { - $name = $this->getMigrationName($reflectionClass->getFileName()); - } + $reflectionClass = new ReflectionClass($migration); - $this->note("{$name}: {$query['query']}"); + if ($reflectionClass->isAnonymous()) { + $name = $this->getMigrationName($reflectionClass->getFileName()); } + + $this->write(Detail::class, $name); + $this->write(BulletList::class, $name, collect($this->getQueries($migration, $method))->map(function ($query) { + return $query['query']; + })); } catch (SchemaException $e) { $name = get_class($migration); - $this->note("{$name}: failed to dump queries. This may be due to changing database columns using Doctrine, which is not supported while pretending to run migrations."); + $this->write(Line::class, sprintf( + '[%s] failed to dump queries. This may be due to changing database columns using Doctrine, which is not supported while pretending to run migrations.', + $name, + ), 'error'); } } @@ -717,15 +713,16 @@ public function setOutput(OutputInterface $output) } /** - * Write a note to the console's output. + * Write to the console's output. * - * @param string $message + * @param string $component + * @param array|string $arguments * @return void */ - protected function note($message) + protected function write($component, ...$arguments) { if ($this->output) { - $this->output->writeln($message); + $component::renderUsing($this->output, ...$arguments); } } From 5e8f7032288516961205b28185b458711b57d7fe Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:45 +0100 Subject: [PATCH 019/101] Refactors `event:list` output --- .../Foundation/Console/EventListCommand.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index 8fb109bb1b54..290d7c4bb14e 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -59,12 +59,14 @@ public function handle() return; } - $this->line( - $events->map(fn ($listeners, $event) => [ - sprintf(' %s', $this->appendEventInterfaces($event)), - collect($listeners)->map(fn ($listener) => sprintf(' ⇂ %s', $listener)), - ])->flatten()->filter()->prepend('')->push('')->toArray() - ); + $this->newLine(); + + $events->each(function ($listeners, $event) { + $this->detail($this->appendEventInterfaces($event)); + $this->bulletList($listeners); + }); + + $this->newLine(); } /** From 7242fa3c64122c7b430818132e55a42d02146afb Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 12:10:51 +0100 Subject: [PATCH 020/101] Improves `queue:work` output --- src/Illuminate/Queue/Console/WorkCommand.php | 43 +++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 66847a5d81e0..1d4ceea1ddeb 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -12,6 +12,7 @@ use Illuminate\Queue\WorkerOptions; use Illuminate\Support\Carbon; use Symfony\Component\Console\Attribute\AsCommand; +use function Termwind\terminal; #[AsCommand(name: 'queue:work')] class WorkCommand extends Command @@ -71,6 +72,13 @@ class WorkCommand extends Command */ protected $cache; + /** + * Holds the start time of the last processed job, if any. + * + * @var float|null + */ + protected $latestStartedAt; + /** * Create a new queue work command. * @@ -110,6 +118,8 @@ public function handle() // connection being run for the queue operation currently being executed. $queue = $this->getQueue($connection); + $this->info(sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue)))); + return $this->runWorker( $connection, $queue ); @@ -184,32 +194,17 @@ protected function listenForEvents() */ protected function writeOutput(Job $job, $status) { - switch ($status) { - case 'starting': - return $this->writeStatus($job, 'Processing', 'comment'); - case 'success': - return $this->writeStatus($job, 'Processed', 'info'); - case 'failed': - return $this->writeStatus($job, 'Failed', 'error'); + if ($status == 'starting') { + $this->latestStartedAt = microtime(true); + $formattedStartedAt = Carbon::now()->format('Y-m-d H:i:s'); + return $this->output->write(" {$formattedStartedAt} {$job->resolveName()}"); } - } - /** - * Format the status output for the queue worker. - * - * @param \Illuminate\Contracts\Queue\Job $job - * @param string $status - * @param string $type - * @return void - */ - protected function writeStatus(Job $job, $status, $type) - { - $this->output->writeln(sprintf( - "<{$type}>[%s][%s] %s %s", - Carbon::now()->format('Y-m-d H:i:s'), - $job->getJobId(), - str_pad("{$status}:", 11), $job->resolveName() - )); + $runTime = number_format((microtime(true) - $this->latestStartedAt) * 1000, 2) . 'ms'; + $dots = max(terminal()->width() - mb_strlen($job->resolveName()) - mb_strlen($runTime) - 32, 0); + $this->output->write(' ' . str_repeat('.', $dots)); + $this->output->write(" $runTime"); + $this->output->writeln($status == 'success' ? ' DONE' : ' FAIL'); } /** From df80ff7f0908fb2ac71915f54a77adb357938fb6 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 4 Jul 2022 11:11:28 +0000 Subject: [PATCH 021/101] Apply fixes from StyleCI --- src/Illuminate/Console/Concerns/InteractsWithIO.php | 1 - .../Console/View/Components/Concerns/EnsureNoPunctuation.php | 2 +- .../Console/View/Components/Concerns/EnsureRelativePaths.php | 2 +- src/Illuminate/Console/View/Components/Task.php | 5 +++-- src/Illuminate/Database/Console/Migrations/FreshCommand.php | 1 - .../Database/Console/Migrations/MigrateCommand.php | 3 +-- src/Illuminate/Database/Console/Migrations/StatusCommand.php | 2 +- src/Illuminate/Queue/Console/WorkCommand.php | 5 +++-- 8 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 3fb26f390bbd..7e3b554bda34 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -11,7 +11,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; -use function Termwind\render; trait InteractsWithIO { diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php b/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php index eeefca1d5c3d..4af8f373e199 100644 --- a/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php +++ b/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php @@ -13,7 +13,7 @@ trait EnsureNoPunctuation protected static function ensureNoPunctuation($string) { if (str($string)->endsWith(['.', '?', '!', ':'])) { - return substr_replace($string ,"", -1); + return substr_replace($string, '', -1); } return $string; diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php b/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php index 555c32b36f56..f0f839276e7d 100644 --- a/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php +++ b/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php @@ -12,7 +12,7 @@ trait EnsureRelativePaths */ protected static function ensureRelativePaths($string) { - $string = str_replace(base_path() . '/', '', $string); + $string = str_replace(base_path().'/', '', $string); return $string; } diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index 1ba1b7399258..7c4e574167f2 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -2,9 +2,9 @@ namespace Illuminate\Console\View\Components; +use Symfony\Component\Console\Output\OutputInterface; use function Termwind\terminal; use Throwable; -use Symfony\Component\Console\Output\OutputInterface; class Task { @@ -32,6 +32,7 @@ public static function renderUsing($output, $description, $task, $verbosity = Ou if (is_null($task)) { $dots = max(terminal()->width() - $descriptionWidth - 5, 0); + return $output->write(str_repeat('.', $dots), false, $verbosity); } @@ -45,7 +46,7 @@ public static function renderUsing($output, $description, $task, $verbosity = Ou throw $e; } finally { $runTime = (microtime(true) - $startTime) > 0.05 - ? (' ' . number_format((microtime(true) - $startTime) * 1000, 2) . 'ms') + ? (' '.number_format((microtime(true) - $startTime) * 1000, 2).'ms') : ''; $runTimeWidth = mb_strlen($runTime); diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index dc0ebbe68856..0564c18e2c79 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -3,7 +3,6 @@ namespace Illuminate\Database\Console\Migrations; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Illuminate\Console\ConfirmableTrait; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\DatabaseRefreshed; diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index a37d5ec458dd..88f9aa944875 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -2,9 +2,8 @@ namespace Illuminate\Database\Console\Migrations; -use Illuminate\Console\View\Components\Line; -use Illuminate\Console\View\Components\Task; use Illuminate\Console\ConfirmableTrait; +use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\SchemaLoaded; use Illuminate\Database\Migrations\Migrator; diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 7ce0a1c6d410..7156c59ee037 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -90,7 +90,7 @@ protected function getStatusFor(array $ran, array $batches) : 'Pending'; if (in_array($migrationName, $ran)) { - $status .= ' [' . $batches[$migrationName] . ']'; + $status .= ' ['.$batches[$migrationName].']'; } return [$migrationName, $status]; diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 1d4ceea1ddeb..8fa4d7d03574 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -197,12 +197,13 @@ protected function writeOutput(Job $job, $status) if ($status == 'starting') { $this->latestStartedAt = microtime(true); $formattedStartedAt = Carbon::now()->format('Y-m-d H:i:s'); + return $this->output->write(" {$formattedStartedAt} {$job->resolveName()}"); } - $runTime = number_format((microtime(true) - $this->latestStartedAt) * 1000, 2) . 'ms'; + $runTime = number_format((microtime(true) - $this->latestStartedAt) * 1000, 2).'ms'; $dots = max(terminal()->width() - mb_strlen($job->resolveName()) - mb_strlen($runTime) - 32, 0); - $this->output->write(' ' . str_repeat('.', $dots)); + $this->output->write(' '.str_repeat('.', $dots)); $this->output->write(" $runTime"); $this->output->writeln($status == 'success' ? ' DONE' : ' FAIL'); } From 8bb7eb73ba724942dfbe73baff9dc4afa5b11a22 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 15:53:33 +0100 Subject: [PATCH 022/101] Fixes static analysis --- src/Illuminate/Console/QuestionHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php index 45ec1f82878b..f804ecd67aa1 100644 --- a/src/Illuminate/Console/QuestionHelper.php +++ b/src/Illuminate/Console/QuestionHelper.php @@ -26,7 +26,9 @@ protected function writePrompt(OutputInterface $output, Question $question) $default = $question->getDefault(); if ($question->isMultiline()) { - $text .= sprintf(' (press %s to continue)', $this->getEofShortcut()); + $text .= sprintf(' (press %s to continue)', 'Windows' == PHP_OS_FAMILY + ? 'Ctrl+Z then Enter' + : 'Ctrl+D'); } switch (true) { From 22a431d626e470ec48d8b0876af58232a17ff621 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 17:37:31 +0100 Subject: [PATCH 023/101] Improves `queue:listen` output --- src/Illuminate/Queue/Console/ListenCommand.php | 2 ++ src/Illuminate/Queue/Listener.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/ListenCommand.php b/src/Illuminate/Queue/Console/ListenCommand.php index 57a6f874123f..247533dc939b 100755 --- a/src/Illuminate/Queue/Console/ListenCommand.php +++ b/src/Illuminate/Queue/Console/ListenCommand.php @@ -79,6 +79,8 @@ public function handle() $connection = $this->input->getArgument('connection') ); + $this->info(sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue)))); + $this->listener->listen( $connection, $queue, $this->gatherOptions() ); diff --git a/src/Illuminate/Queue/Listener.php b/src/Illuminate/Queue/Listener.php index 513f75d60c55..d57c209f667b 100755 --- a/src/Illuminate/Queue/Listener.php +++ b/src/Illuminate/Queue/Listener.php @@ -172,7 +172,9 @@ protected function createCommand($connection, $queue, ListenerOptions $options) public function runProcess(Process $process, $memory) { $process->run(function ($type, $line) { - $this->handleWorkerOutput($type, $line); + if (! str($line)->contains('Processing jobs from the')) { + $this->handleWorkerOutput($type, $line); + } }); // Once we have run the job we'll go check if the memory limit has been exceeded From f4b4eccd6c6d3c73a5c5291da0f2aba4968db91d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 17:44:54 +0100 Subject: [PATCH 024/101] Swaps dynamic part of the detail to the left. --- src/Illuminate/Database/Console/Migrations/StatusCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 7156c59ee037..740245e21350 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -90,7 +90,7 @@ protected function getStatusFor(array $ran, array $batches) : 'Pending'; if (in_array($migrationName, $ran)) { - $status .= ' ['.$batches[$migrationName].']'; + $status = '['.$batches[$migrationName].'] ' . $status; } return [$migrationName, $status]; From 77cf4d6585560b05eb1ebf7562c8091da850f549 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 4 Jul 2022 16:45:07 +0000 Subject: [PATCH 025/101] Apply fixes from StyleCI --- src/Illuminate/Database/Console/Migrations/StatusCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 740245e21350..072fbf7a953a 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -90,7 +90,7 @@ protected function getStatusFor(array $ran, array $batches) : 'Pending'; if (in_array($migrationName, $ran)) { - $status = '['.$batches[$migrationName].'] ' . $status; + $status = '['.$batches[$migrationName].'] '.$status; } return [$migrationName, $status]; From fe096cbab90d6b08be7bec4986690f9fa325295b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 17:56:20 +0100 Subject: [PATCH 026/101] Improves `queue:monitor` output --- src/Illuminate/Queue/Console/MonitorCommand.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index d9d3d007452f..d9aca6afa4ff 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -109,7 +109,7 @@ protected function parseQueues($queues) 'connection' => $connection, 'queue' => $queue, 'size' => $size = $this->manager->connection($connection)->size($queue), - 'status' => $size >= $this->option('max') ? 'ALERT' : 'OK', + 'status' => $size >= $this->option('max') ? 'ALERT' : 'OK', ]; }); } @@ -122,7 +122,17 @@ protected function parseQueues($queues) */ protected function displaySizes(Collection $queues) { - $this->table($this->headers, $queues); + $this->newLine(); + + $this->detail('Queue name', 'Size / Status'); + + $queues->each(function ($queue) { + $status = '['.$queue['size'].'] ' . $queue['status']; + + $this->detail($queue['queue'], $status); + }); + + $this->newLine(); } /** From 3818e793d8018a5126fca782f3a1f8f0a75c7600 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 17:56:29 +0100 Subject: [PATCH 027/101] Adds title to migrate status command --- src/Illuminate/Database/Console/Migrations/StatusCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 072fbf7a953a..3fd4b731c6c2 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -61,7 +61,8 @@ public function handle() $batches = $this->migrator->getRepository()->getMigrationBatches(); if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { - $this->info('Migration status:'); + $this->newLine(); + $this->detail('Migration name', 'Batch / Status'); $migrations->each( fn ($migration) => $this->detail($migration[0], $migration[1]) ); From 2b79f229309059a05bd0dd67004eb77965d5c888 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 4 Jul 2022 17:34:21 +0000 Subject: [PATCH 028/101] Apply fixes from StyleCI --- src/Illuminate/Queue/Console/MonitorCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index d9aca6afa4ff..a1ea7246c8b6 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -127,7 +127,7 @@ protected function displaySizes(Collection $queues) $this->detail('Queue name', 'Size / Status'); $queues->each(function ($queue) { - $status = '['.$queue['size'].'] ' . $queue['status']; + $status = '['.$queue['size'].'] '.$queue['status']; $this->detail($queue['queue'], $status); }); From 94b7d0668a0a752945e7a4131f9df99b16eaae14 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 18:34:55 +0100 Subject: [PATCH 029/101] Improves `schedule:test` output --- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 2ad1c88676c8..666d8f4f1299 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -52,7 +52,7 @@ public function handle(Schedule $schedule) } if (empty($commandNames)) { - return $this->comment('No scheduled commands have been defined.'); + return $this->info('No scheduled commands have been defined.'); } if (! empty($name = $this->option('name'))) { @@ -73,8 +73,10 @@ public function handle(Schedule $schedule) $event = $commands[$index]; - $this->line('['.Carbon::now()->format('c').'] Running scheduled command: '.$event->getSummaryForDisplay()); + $this->task(sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { + $event->run($this->laravel); + }); - $event->run($this->laravel); + $this->newLine(); } } From 509ceca092e847ea2de2f075c3d9990206073a20 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 4 Jul 2022 17:45:31 +0000 Subject: [PATCH 030/101] Apply fixes from StyleCI --- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 666d8f4f1299..2d73c4c3c345 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -4,7 +4,6 @@ use Illuminate\Console\Application; use Illuminate\Console\Command; -use Illuminate\Support\Carbon; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'schedule:test')] From 667529057344939c51d809d5d105d1ed11d6d240 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 19:11:56 +0100 Subject: [PATCH 031/101] Fixes length of dots --- src/Illuminate/Console/View/Components/Task.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index 7c4e574167f2..d9764056ed89 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -25,9 +25,10 @@ public static function renderUsing($output, $description, $task, $verbosity = Ou { $description = self::ensureRelativePaths($description); $description = self::ensureNoPunctuation($description); - - $descriptionWidth = mb_strlen($description); $description = static::highlightDynamicContent($description); + + $descriptionWidth = mb_strlen(preg_replace("/\<[\w=#\/\;,:.&,%?]+\>|\\e\[\d+m/", '$1', $description) ?? ''); + $output->write(" $description ", false, $verbosity); if (is_null($task)) { From 218872b983b7cd9c1fe1304890e3c8091fd8fd1f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 19:12:04 +0100 Subject: [PATCH 032/101] Fixes extra style --- src/Illuminate/Queue/Console/WorkCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 8fa4d7d03574..19595e5cc035 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -202,7 +202,7 @@ protected function writeOutput(Job $job, $status) } $runTime = number_format((microtime(true) - $this->latestStartedAt) * 1000, 2).'ms'; - $dots = max(terminal()->width() - mb_strlen($job->resolveName()) - mb_strlen($runTime) - 32, 0); + $dots = max(terminal()->width() - mb_strlen($job->resolveName()) - mb_strlen($runTime) - 31, 0); $this->output->write(' '.str_repeat('.', $dots)); $this->output->write(" $runTime"); $this->output->writeln($status == 'success' ? ' DONE' : ' FAIL'); From ddfdc1c0917522afac2d41138fd44bbabe0320d0 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 19:12:16 +0100 Subject: [PATCH 033/101] Improves `schedule:run` output --- .../Console/Scheduling/ScheduleRunCommand.php | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index 680c0e107b8d..43228b551f03 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -9,6 +9,7 @@ use Illuminate\Console\Events\ScheduledTaskStarting; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Date; use Symfony\Component\Console\Attribute\AsCommand; use Throwable; @@ -102,6 +103,8 @@ public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHand $this->dispatcher = $dispatcher; $this->handler = $handler; + $this->newLine(); + foreach ($this->schedule->dueEvents($this->laravel) as $event) { if (! $event->filtersPass($this->laravel)) { $this->dispatcher->dispatch(new ScheduledTaskSkipped($event)); @@ -120,6 +123,8 @@ public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHand if (! $this->eventsRan) { $this->info('No scheduled commands are ready to run.'); + } else { + $this->newLine(); } } @@ -146,25 +151,31 @@ protected function runSingleServerEvent($event) */ protected function runEvent($event) { - $this->line('['.date('c').'] Running scheduled command: '.$event->getSummaryForDisplay()); + $description = sprintf( + '%s Running [%s]', + Carbon::now()->format('Y-m-d H:i:s'), + $event->getSummaryForDisplay() + ); - $this->dispatcher->dispatch(new ScheduledTaskStarting($event)); + $this->task($description, function () use ($event) { + $this->dispatcher->dispatch(new ScheduledTaskStarting($event)); - $start = microtime(true); + $start = microtime(true); - try { - $event->run($this->laravel); + try { + $event->run($this->laravel); - $this->dispatcher->dispatch(new ScheduledTaskFinished( - $event, - round(microtime(true) - $start, 2) - )); + $this->dispatcher->dispatch(new ScheduledTaskFinished( + $event, + round(microtime(true) - $start, 2) + )); - $this->eventsRan = true; - } catch (Throwable $e) { - $this->dispatcher->dispatch(new ScheduledTaskFailed($event, $e)); + $this->eventsRan = true; + } catch (Throwable $e) { + $this->dispatcher->dispatch(new ScheduledTaskFailed($event, $e)); - $this->handler->report($e); - } + $this->handler->report($e); + } + }); } } From 7dcb5cdedc58509ba9a08bf4f86ce3e2feb98fde Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 4 Jul 2022 19:20:09 +0100 Subject: [PATCH 034/101] Fixes missing style --- src/Illuminate/Console/Scheduling/ScheduleRunCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index 43228b551f03..acb85265cd68 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -139,7 +139,9 @@ protected function runSingleServerEvent($event) if ($this->schedule->serverShouldRun($event, $this->startedAt)) { $this->runEvent($event); } else { - $this->line('Skipping command (has already run on another server): '.$event->getSummaryForDisplay()); + $this->info(sprintf( + 'Skipping [%s], as command already run on another server.', $event->getSummaryForDisplay() + )); } } From 28ca6111a3880b9fbe9b8bce127ff32095d6d853 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 09:21:11 +0100 Subject: [PATCH 035/101] Improves `schedule:work` output --- .../Console/Scheduling/ScheduleWorkCommand.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php b/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php index 78d2411dcfdb..1b7c6942c39f 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php @@ -42,7 +42,7 @@ class ScheduleWorkCommand extends Command */ public function handle() { - $this->info('Schedule worker started successfully.'); + $this->info('Running schedule tasks every minute.'); [$lastExecutionStartedAt, $keyOfLastExecutionWithOutput, $executions] = [null, null, []]; @@ -63,18 +63,10 @@ public function handle() } foreach ($executions as $key => $execution) { - $output = trim($execution->getIncrementalOutput()). - trim($execution->getIncrementalErrorOutput()); + $output = $execution->getIncrementalOutput(). + $execution->getIncrementalErrorOutput(); - if (! empty($output)) { - if ($key !== $keyOfLastExecutionWithOutput) { - $this->info(PHP_EOL.'['.date('c').'] Execution #'.($key + 1).' output:'); - - $keyOfLastExecutionWithOutput = $key; - } - - $this->output->writeln($output); - } + $this->output->write(ltrim($output, "\n")); if (! $execution->isRunning()) { unset($executions[$key]); From 83dfcf724cfe6fdb6a2d0ab9c857c495715a95cf Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 12:22:33 +0100 Subject: [PATCH 036/101] Improve "inspire" command --- src/Illuminate/Foundation/Inspiring.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Inspiring.php b/src/Illuminate/Foundation/Inspiring.php index d7d3acf98308..680d34935df6 100644 --- a/src/Illuminate/Foundation/Inspiring.php +++ b/src/Illuminate/Foundation/Inspiring.php @@ -93,6 +93,14 @@ public static function quote() 'The best way to take care of the future is to take care of the present moment. - Thich Nhat Hanh', 'Nothing in life is to be feared, it is only to be understood. Now is the time to understand more, so that we may fear less. - Marie Curie', 'The biggest battle is the war against ignorance. - Mustafa Kemal Atatürk', - ])->random(); + ])->map(function ($quote) { + [$text, $author] = str($quote)->explode('-'); + + return sprintf( + "\n “ %s ”\n — %s\n", + trim($text), + trim($author), + ); + })->random(); } } From aafccde0d16f188233d8cdd648885b6f610a87d4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 15:45:45 +0100 Subject: [PATCH 037/101] Refactors inspiring --- src/Illuminate/Foundation/Inspiring.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Foundation/Inspiring.php b/src/Illuminate/Foundation/Inspiring.php index 680d34935df6..40298bb42b26 100644 --- a/src/Illuminate/Foundation/Inspiring.php +++ b/src/Illuminate/Foundation/Inspiring.php @@ -93,14 +93,23 @@ public static function quote() 'The best way to take care of the future is to take care of the present moment. - Thich Nhat Hanh', 'Nothing in life is to be feared, it is only to be understood. Now is the time to understand more, so that we may fear less. - Marie Curie', 'The biggest battle is the war against ignorance. - Mustafa Kemal Atatürk', - ])->map(function ($quote) { - [$text, $author] = str($quote)->explode('-'); + ])->map(fn ($quote) => static::formatForConsole($quote))->random(); + } + + /** + * Formats the given quote for a pretty console output. + * + * @param string $quote + * @return string + */ + protected static function formatForConsole($quote) + { + [$text, $author] = str($quote)->explode('-'); - return sprintf( - "\n “ %s ”\n — %s\n", - trim($text), - trim($author), - ); - })->random(); + return sprintf( + "\n “ %s ”\n — %s\n", + trim($text), + trim($author), + ); } } From b83a532f4f859c13c1eba999b732354163383d78 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 15:46:44 +0100 Subject: [PATCH 038/101] Refactors line --- src/Illuminate/Console/View/Components/Line.php | 16 ++++++---------- .../Console/resources/views/lines/line.blade.php | 8 ++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 src/Illuminate/Console/resources/views/lines/line.blade.php diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index 1768a9b86c41..99cc2406f902 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -93,15 +93,11 @@ public static function renderUsing($output, $string, $style, $verbosity = Output */ public function render() { - return <<<'blade' -
- @if ($title) - {{ $title }} - @endif - - {{ $slot }} - -
- blade; + return view('illuminate.console::lines.line', [ + 'marginTop' => $this->marginTop, + 'title' => $this->title, + 'bgColor' => $this->bgColor, + 'fgColor' => $this->fgColor, + ]); } } diff --git a/src/Illuminate/Console/resources/views/lines/line.blade.php b/src/Illuminate/Console/resources/views/lines/line.blade.php new file mode 100644 index 000000000000..dbd1ebdf807e --- /dev/null +++ b/src/Illuminate/Console/resources/views/lines/line.blade.php @@ -0,0 +1,8 @@ +
+ @if ($title) + {{ $title }} + @endif + + {{ $slot }} + +
From 145ea48d354c831888343963cb6e5fe41fb5f2a9 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 16:11:10 +0100 Subject: [PATCH 039/101] Avoids conflicts by naming "x-line" to "x-illuminate-console-line" --- src/Illuminate/Console/ConsoleServiceProvider.php | 2 +- src/Illuminate/Console/View/Components/Line.php | 3 +-- src/Illuminate/Console/resources/views/alert.blade.php | 2 +- src/Illuminate/Console/resources/views/lines/error.blade.php | 4 ++-- src/Illuminate/Console/resources/views/lines/info.blade.php | 4 ++-- src/Illuminate/Console/resources/views/lines/raw.blade.php | 4 ++-- .../Console/resources/views/lines/warning.blade.php | 4 ++-- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Illuminate/Console/ConsoleServiceProvider.php b/src/Illuminate/Console/ConsoleServiceProvider.php index 3c32e5deeb4d..3929c3ab96a2 100644 --- a/src/Illuminate/Console/ConsoleServiceProvider.php +++ b/src/Illuminate/Console/ConsoleServiceProvider.php @@ -16,7 +16,7 @@ class ConsoleServiceProvider extends ServiceProvider public function boot() { if ($this->app->runningInConsole()) { - Blade::component('line', Components\Line::class); + Blade::component('illuminate-console-line', Components\Line::class); } } diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index 99cc2406f902..92f2f57ef381 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -72,12 +72,11 @@ public static function renderUsing($output, $string, $style, $verbosity = Output { $style = $style ?: 'raw'; - renderUsing($output); - $string = self::highlightDynamicContent($string); $string = self::ensurePunctuation($string); $string = self::ensureRelativePaths($string); + renderUsing($output); render(view('illuminate.console::lines.'.$style, [ 'content' => $string, 'newLine' => $output instanceof NewLineAware diff --git a/src/Illuminate/Console/resources/views/alert.blade.php b/src/Illuminate/Console/resources/views/alert.blade.php index ada9a83bf55f..8dd476c60309 100644 --- a/src/Illuminate/Console/resources/views/alert.blade.php +++ b/src/Illuminate/Console/resources/views/alert.blade.php @@ -1,3 +1,3 @@
{{ $content }} -
\ No newline at end of file +
diff --git a/src/Illuminate/Console/resources/views/lines/error.blade.php b/src/Illuminate/Console/resources/views/lines/error.blade.php index 72088e56a3d8..355c49934479 100644 --- a/src/Illuminate/Console/resources/views/lines/error.blade.php +++ b/src/Illuminate/Console/resources/views/lines/error.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} - + diff --git a/src/Illuminate/Console/resources/views/lines/info.blade.php b/src/Illuminate/Console/resources/views/lines/info.blade.php index 417737419b61..f4d2dd8c556e 100644 --- a/src/Illuminate/Console/resources/views/lines/info.blade.php +++ b/src/Illuminate/Console/resources/views/lines/info.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} - + diff --git a/src/Illuminate/Console/resources/views/lines/raw.blade.php b/src/Illuminate/Console/resources/views/lines/raw.blade.php index 8cec83e5b501..248ba9f30204 100644 --- a/src/Illuminate/Console/resources/views/lines/raw.blade.php +++ b/src/Illuminate/Console/resources/views/lines/raw.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} - + diff --git a/src/Illuminate/Console/resources/views/lines/warning.blade.php b/src/Illuminate/Console/resources/views/lines/warning.blade.php index 715bd7fcbe19..c706f774e402 100644 --- a/src/Illuminate/Console/resources/views/lines/warning.blade.php +++ b/src/Illuminate/Console/resources/views/lines/warning.blade.php @@ -1,3 +1,3 @@ - + {{ $content }} - + From 91b97979a93457d218eb7003efc145ea6265525f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 17:57:14 +0100 Subject: [PATCH 040/101] Avoids `ConsoleServiceProvider` --- .../Console/ConsoleServiceProvider.php | 36 ------ .../Console/View/Components/Alert.php | 16 ++- .../Console/View/Components/BulletList.php | 26 ++--- .../Console/View/Components/Component.php | 95 ++++++++++++++++ .../Console/View/Components/Detail.php | 30 +++-- .../Console/View/Components/Line.php | 103 ++++++------------ .../EnsureDynamicContentIsHighlighted.php} | 6 +- .../EnsureNoPunctuation.php | 6 +- .../EnsurePunctuation.php | 9 +- .../EnsureRelativePaths.php | 6 +- .../Console/View/Components/Task.php | 16 +-- .../views/{lines => }/line.blade.php | 2 +- .../resources/views/lines/error.blade.php | 3 - .../resources/views/lines/info.blade.php | 3 - .../resources/views/lines/raw.blade.php | 3 - .../resources/views/lines/warning.blade.php | 3 - .../Console/Migrations/StatusCommand.php | 4 +- src/Illuminate/Foundation/Application.php | 1 - .../Queue/Console/MonitorCommand.php | 2 +- 19 files changed, 187 insertions(+), 183 deletions(-) delete mode 100644 src/Illuminate/Console/ConsoleServiceProvider.php create mode 100644 src/Illuminate/Console/View/Components/Component.php rename src/Illuminate/Console/View/Components/{Concerns/Highlightable.php => Mutators/EnsureDynamicContentIsHighlighted.php} (63%) rename src/Illuminate/Console/View/Components/{Concerns => Mutators}/EnsureNoPunctuation.php (68%) rename src/Illuminate/Console/View/Components/{Concerns => Mutators}/EnsurePunctuation.php (53%) rename src/Illuminate/Console/View/Components/{Concerns => Mutators}/EnsureRelativePaths.php (63%) rename src/Illuminate/Console/resources/views/{lines => }/line.blade.php (90%) delete mode 100644 src/Illuminate/Console/resources/views/lines/error.blade.php delete mode 100644 src/Illuminate/Console/resources/views/lines/info.blade.php delete mode 100644 src/Illuminate/Console/resources/views/lines/raw.blade.php delete mode 100644 src/Illuminate/Console/resources/views/lines/warning.blade.php diff --git a/src/Illuminate/Console/ConsoleServiceProvider.php b/src/Illuminate/Console/ConsoleServiceProvider.php deleted file mode 100644 index 3929c3ab96a2..000000000000 --- a/src/Illuminate/Console/ConsoleServiceProvider.php +++ /dev/null @@ -1,36 +0,0 @@ -app->runningInConsole()) { - Blade::component('illuminate-console-line', Components\Line::class); - } - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - if ($this->app->runningInConsole()) { - $this->loadViewsFrom( - __DIR__.'/resources/views', 'illuminate.console' - ); - } - } -} diff --git a/src/Illuminate/Console/View/Components/Alert.php b/src/Illuminate/Console/View/Components/Alert.php index fcdd53f40e3d..93d331176669 100644 --- a/src/Illuminate/Console/View/Components/Alert.php +++ b/src/Illuminate/Console/View/Components/Alert.php @@ -3,10 +3,8 @@ namespace Illuminate\Console\View\Components; use Symfony\Component\Console\Output\OutputInterface; -use function Termwind\render; -use function Termwind\renderUsing; -class Alert +class Alert extends Component { /** * Renders the component using the given arguments. @@ -18,10 +16,16 @@ class Alert */ public static function renderUsing($output, $string, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - renderUsing($output); + $component = static::fromOutput($output); - render(view('illuminate.console::alert', [ + $string = $component->mutate($string, [ + Mutators\EnsureDynamicContentIsHighlighted::class, + Mutators\EnsurePunctuation::class, + Mutators\EnsureRelativePaths::class, + ]); + + $component->render('alert', [ 'content' => $string, - ]), $verbosity); + ], $verbosity); } } diff --git a/src/Illuminate/Console/View/Components/BulletList.php b/src/Illuminate/Console/View/Components/BulletList.php index 7d18e2730c16..c03df7bedb3b 100644 --- a/src/Illuminate/Console/View/Components/BulletList.php +++ b/src/Illuminate/Console/View/Components/BulletList.php @@ -3,15 +3,9 @@ namespace Illuminate\Console\View\Components; use Symfony\Component\Console\Output\OutputInterface; -use function Termwind\render; -use function Termwind\renderUsing; -class BulletList +class BulletList extends Component { - use Concerns\EnsureNoPunctuation, - Concerns\EnsureRelativePaths, - Concerns\Highlightable; - /** * Renders the component using the given arguments. * @@ -22,16 +16,16 @@ class BulletList */ public static function renderUsing($output, $elements, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - renderUsing($output); + $component = static::fromOutput($output); - render(view('illuminate.console::bullet-list', [ - 'elements' => collect($elements)->map(function ($string) { - $string = self::highlightDynamicContent($string); - $string = self::ensureNoPunctuation($string); - $string = self::ensureRelativePaths($string); + $elements = $component->mutate($elements, [ + Mutators\EnsureDynamicContentIsHighlighted::class, + Mutators\EnsureNoPunctuation::class, + Mutators\EnsureRelativePaths::class, + ]); - return $string; - }), - ]), $verbosity); + $component->render('bullet-list', [ + 'elements' => $elements, + ], $verbosity); } } diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php new file mode 100644 index 000000000000..7261eabef265 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Component.php @@ -0,0 +1,95 @@ + + */ + protected $mutators; + + /** + * Creates a new component instance. + * + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + protected function __construct($output) + { + $this->output = $output; + } + + /** + * Creates a new component instance from the given output. + * + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return static + */ + public static function fromOutput($output) + { + return new static($output); + } + + /** + * Renders the given view. + * + * @param string $view + * @param \Illuminate\Contracts\Support\Arrayable|array $data + * @param int $verbosity + * @return void + */ + public function render($view, $data, $verbosity) + { + $this->ensureViewRequirements(); + + renderUsing($this->output); + + render(view('illuminate.console::'.$view, $data), $verbosity); + } + + /** + * Ensure with view requirements, such as the namespace, are loaded. + * + * @return void + */ + protected function ensureViewRequirements() + { + View::replaceNamespace('illuminate.console', __DIR__.'/../../resources/views'); + } + + /** + * Mutates the given data with the given set of mutators. + * + * @param array|string $data + * @param array $mutators + * @return array|string + */ + public function mutate($data, $mutators) + { + foreach ($mutators as $mutator) { + if (is_iterable($data)) { + foreach ($data as $key => $value) { + $data[$key] = resolve($mutator)->__invoke($value); + } + } else { + $data = resolve($mutator)->__invoke($data); + } + } + + return $data; + } +} diff --git a/src/Illuminate/Console/View/Components/Detail.php b/src/Illuminate/Console/View/Components/Detail.php index 09b6977e6f10..3fdc3bffc1e7 100644 --- a/src/Illuminate/Console/View/Components/Detail.php +++ b/src/Illuminate/Console/View/Components/Detail.php @@ -3,15 +3,9 @@ namespace Illuminate\Console\View\Components; use Symfony\Component\Console\Output\OutputInterface; -use function Termwind\render; -use function Termwind\renderUsing; -class Detail +class Detail extends Component { - use Concerns\EnsureNoPunctuation, - Concerns\EnsureRelativePaths, - Concerns\Highlightable; - /** * Renders the component using the given arguments. * @@ -23,19 +17,23 @@ class Detail */ public static function renderUsing($output, $left, $right = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - renderUsing($output); + $component = static::fromOutput($output); - $left = self::highlightDynamicContent($left); - $left = self::ensureNoPunctuation($left); - $left = self::ensureRelativePaths($left); + $left = $component->mutate($left, [ + Mutators\EnsureDynamicContentIsHighlighted::class, + Mutators\EnsureNoPunctuation::class, + Mutators\EnsureRelativePaths::class, + ]); - $right = self::highlightDynamicContent($right); - $right = self::ensureNoPunctuation($right); - $right = self::ensureRelativePaths($right); + $right = $component->mutate($right, [ + Mutators\EnsureDynamicContentIsHighlighted::class, + Mutators\EnsureNoPunctuation::class, + Mutators\EnsureRelativePaths::class, + ]); - render(view('illuminate.console::detail', [ + $component->render('detail', [ 'left' => $left, 'right' => $right, - ]), $verbosity); + ], $verbosity); } } diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index 92f2f57ef381..25fe04dca537 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -3,61 +3,36 @@ namespace Illuminate\Console\View\Components; use Illuminate\Console\Contracts\NewLineAware; -use Illuminate\View\Component; use Symfony\Component\Console\Output\OutputInterface; -use function Termwind\render; -use function Termwind\renderUsing; class Line extends Component { - use Concerns\EnsurePunctuation, - Concerns\EnsureRelativePaths, - Concerns\Highlightable; - - /** - * The margin top that should be applied. - * - * @var int - */ - public $marginTop; - - /** - * The line background color. - * - * @var string - */ - public $bgColor; - - /** - * The line foreground color. - * - * @var string - */ - public $fgColor; - - /** - * The line title. - * - * @var string|null - */ - public $title; - /** - * Create a new component instance. + * The possible line styles. * - * @param bool $newLine - * @param string $bgColor - * @param string $fgColor - * @param string|null $title - * @return void + * @var array> */ - public function __construct($newLine, $bgColor, $fgColor, $title = null) - { - $this->marginTop = $newLine ? 1 : 0; - $this->bgColor = $bgColor; - $this->fgColor = $fgColor; - $this->title = $title; - } + protected static $styles = [ + 'info' => [ + 'bgColor' => 'blue', + 'fgColor' => 'white', + 'title' => 'info', + ], + 'warning' => [ + 'bgColor' => 'yellow', + 'fgColor' => 'black', + 'title' => 'warn', + ], + 'error' => [ + 'bgColor' => 'red', + 'fgColor' => 'white', + 'title' => 'error', + ], + 'raw' => [ + 'bgColor' => 'default', + 'fgColor' => 'default', + ], + ]; /** * Renders the component using the given arguments. @@ -70,33 +45,21 @@ public function __construct($newLine, $bgColor, $fgColor, $title = null) */ public static function renderUsing($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) { + $component = static::fromOutput($output); + $style = $style ?: 'raw'; - $string = self::highlightDynamicContent($string); - $string = self::ensurePunctuation($string); - $string = self::ensureRelativePaths($string); + $string = $component->mutate($string, [ + Mutators\EnsureDynamicContentIsHighlighted::class, + Mutators\EnsurePunctuation::class, + Mutators\EnsureRelativePaths::class, + ]); - renderUsing($output); - render(view('illuminate.console::lines.'.$style, [ - 'content' => $string, - 'newLine' => $output instanceof NewLineAware + $component->render('line', array_merge(static::$styles[$style], [ + 'marginTop' => $output instanceof NewLineAware ? $output->newLineWritten() == false : true, + 'content' => $string, ]), $verbosity); } - - /** - * Get the view / view contents that represent the component. - * - * @return void - */ - public function render() - { - return view('illuminate.console::lines.line', [ - 'marginTop' => $this->marginTop, - 'title' => $this->title, - 'bgColor' => $this->bgColor, - 'fgColor' => $this->fgColor, - ]); - } } diff --git a/src/Illuminate/Console/View/Components/Concerns/Highlightable.php b/src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php similarity index 63% rename from src/Illuminate/Console/View/Components/Concerns/Highlightable.php rename to src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php index 7ee153d8bcaf..4a3b82bda202 100644 --- a/src/Illuminate/Console/View/Components/Concerns/Highlightable.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php @@ -1,8 +1,8 @@ [$1]', $string); } diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php b/src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php similarity index 68% rename from src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php rename to src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php index 4af8f373e199..89622b8a7688 100644 --- a/src/Illuminate/Console/View/Components/Concerns/EnsureNoPunctuation.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php @@ -1,8 +1,8 @@ endsWith(['.', '?', '!', ':'])) { return substr_replace($string, '', -1); diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php b/src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php similarity index 53% rename from src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php rename to src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php index f4c8f4578e7f..a7e8053f91e5 100644 --- a/src/Illuminate/Console/View/Components/Concerns/EnsurePunctuation.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php @@ -1,20 +1,19 @@ endsWith(['.', '?', '!', ':'])) { - return "$string$default"; + return "$string."; } return $string; diff --git a/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php b/src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php similarity index 63% rename from src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php rename to src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php index f0f839276e7d..2d865af6096d 100644 --- a/src/Illuminate/Console/View/Components/Concerns/EnsureRelativePaths.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php @@ -1,8 +1,8 @@ mutate($description, [ + Mutators\EnsureDynamicContentIsHighlighted::class, + Mutators\EnsureNoPunctuation::class, + Mutators\EnsureRelativePaths::class, + ]); $descriptionWidth = mb_strlen(preg_replace("/\<[\w=#\/\;,:.&,%?]+\>|\\e\[\d+m/", '$1', $description) ?? ''); diff --git a/src/Illuminate/Console/resources/views/lines/line.blade.php b/src/Illuminate/Console/resources/views/line.blade.php similarity index 90% rename from src/Illuminate/Console/resources/views/lines/line.blade.php rename to src/Illuminate/Console/resources/views/line.blade.php index dbd1ebdf807e..5a2b04f89c04 100644 --- a/src/Illuminate/Console/resources/views/lines/line.blade.php +++ b/src/Illuminate/Console/resources/views/line.blade.php @@ -3,6 +3,6 @@ {{ $title }} @endif - {{ $slot }} + {{ $content }} diff --git a/src/Illuminate/Console/resources/views/lines/error.blade.php b/src/Illuminate/Console/resources/views/lines/error.blade.php deleted file mode 100644 index 355c49934479..000000000000 --- a/src/Illuminate/Console/resources/views/lines/error.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - - {{ $content }} - diff --git a/src/Illuminate/Console/resources/views/lines/info.blade.php b/src/Illuminate/Console/resources/views/lines/info.blade.php deleted file mode 100644 index f4d2dd8c556e..000000000000 --- a/src/Illuminate/Console/resources/views/lines/info.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - - {{ $content }} - diff --git a/src/Illuminate/Console/resources/views/lines/raw.blade.php b/src/Illuminate/Console/resources/views/lines/raw.blade.php deleted file mode 100644 index 248ba9f30204..000000000000 --- a/src/Illuminate/Console/resources/views/lines/raw.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - - {{ $content }} - diff --git a/src/Illuminate/Console/resources/views/lines/warning.blade.php b/src/Illuminate/Console/resources/views/lines/warning.blade.php deleted file mode 100644 index c706f774e402..000000000000 --- a/src/Illuminate/Console/resources/views/lines/warning.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - - {{ $content }} - diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 3fd4b731c6c2..1372b6715733 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -87,8 +87,8 @@ protected function getStatusFor(array $ran, array $batches) $migrationName = $this->migrator->getMigrationName($migration); $status = in_array($migrationName, $ran) - ? 'Ran' - : 'Pending'; + ? 'Ran' + : 'Pending'; if (in_array($migrationName, $ran)) { $status = '['.$batches[$migrationName].'] '.$status; diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 538733f43131..8666f5f2a13e 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -219,7 +219,6 @@ protected function registerBaseBindings() */ protected function registerBaseServiceProviders() { - $this->register(new ConsoleServiceProvider($this)); $this->register(new EventServiceProvider($this)); $this->register(new LogServiceProvider($this)); $this->register(new RoutingServiceProvider($this)); diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index a1ea7246c8b6..dbcabde5364e 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -109,7 +109,7 @@ protected function parseQueues($queues) 'connection' => $connection, 'queue' => $queue, 'size' => $size = $this->manager->connection($connection)->size($queue), - 'status' => $size >= $this->option('max') ? 'ALERT' : 'OK', + 'status' => $size >= $this->option('max') ? 'ALERT' : 'OK', ]; }); } From d6747c03498d4d4cca168cf956d9a447ae5131cb Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 5 Jul 2022 16:57:27 +0000 Subject: [PATCH 041/101] Apply fixes from StyleCI --- src/Illuminate/Foundation/Application.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 8666f5f2a13e..fde8e91af68d 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -3,7 +3,6 @@ namespace Illuminate\Foundation; use Closure; -use Illuminate\Console\ConsoleServiceProvider; use Illuminate\Container\Container; use Illuminate\Contracts\Foundation\Application as ApplicationContract; use Illuminate\Contracts\Foundation\CachesConfiguration; From 5df59b843cf4702d5864782d5a03c38e740055d0 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 18:02:38 +0100 Subject: [PATCH 042/101] Adds space to breath --- src/Illuminate/Console/Contracts/NewLineAware.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Console/Contracts/NewLineAware.php b/src/Illuminate/Console/Contracts/NewLineAware.php index 56d046bb106c..49d598b3e482 100644 --- a/src/Illuminate/Console/Contracts/NewLineAware.php +++ b/src/Illuminate/Console/Contracts/NewLineAware.php @@ -4,4 +4,5 @@ interface NewLineAware { + // ... } From 47a9f2663e179e647ce23e35105f7793536c8501 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 19:05:57 +0100 Subject: [PATCH 043/101] Fixes margin top --- src/Illuminate/Console/View/Components/Line.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index 25fe04dca537..4c125e99672c 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -56,9 +56,7 @@ public static function renderUsing($output, $string, $style, $verbosity = Output ]); $component->render('line', array_merge(static::$styles[$style], [ - 'marginTop' => $output instanceof NewLineAware - ? $output->newLineWritten() == false - : true, + 'marginTop' => ($output instanceof NewLineAware && $output->newLineWritten()) ? 0 : 1, 'content' => $string, ]), $verbosity); } From 0cdb51983e51bca0826b79f2d384f5150d3ddbae Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 5 Jul 2022 19:06:12 +0100 Subject: [PATCH 044/101] Removes `tasks` and `task` from the public api --- .../Console/Concerns/InteractsWithIO.php | 36 ------------------- .../Console/Scheduling/ScheduleRunCommand.php | 3 +- .../Scheduling/ScheduleTestCommand.php | 3 +- .../Console/View/Components/Task.php | 2 +- .../Console/Migrations/FreshCommand.php | 3 +- .../Console/OptimizeClearCommand.php | 23 +++++++----- .../Foundation/Console/OptimizeCommand.php | 11 ++++-- .../Console/PackageDiscoverCommand.php | 12 +++++-- .../Console/VendorPublishCommand.php | 5 +-- .../Queue/Console/RetryBatchCommand.php | 3 +- src/Illuminate/Queue/Console/RetryCommand.php | 3 +- 11 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 7e3b554bda34..9e4d7470b075 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -192,42 +192,6 @@ public function secret($question, $fallback = true) return $this->output->askQuestion($question); } - /** - * Perform the given tasks. - * - * @param string $title - * @param iterable $tasks - * @param int|string|null $verbosity - * @return void - */ - public function tasks($title, $tasks, $verbosity = null) - { - $this->info($title, $verbosity); - - collect($tasks)->each( - fn ($task, $description) => Components\Task::renderUsing( - $this->output, $description, $task, $this->parseVerbosity($verbosity), - ), - ); - - $this->newLine(); - } - - /** - * Perform the given task. - * - * @param string $description - * @param (callable(): bool)|null $task - * @param int|string|null $verbosity - * @return void - */ - public function task($description, $task = null, $verbosity = null) - { - Components\Task::renderUsing( - $this->output, $description, $task, $this->parseVerbosity($verbosity), - ); - } - /** * Give the user a single choice from an array of answers. * diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index acb85265cd68..c94c5e78edff 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Console\Scheduling; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Task; use Illuminate\Console\Events\ScheduledTaskFailed; use Illuminate\Console\Events\ScheduledTaskFinished; use Illuminate\Console\Events\ScheduledTaskSkipped; @@ -159,7 +160,7 @@ protected function runEvent($event) $event->getSummaryForDisplay() ); - $this->task($description, function () use ($event) { + Task::renderUsing($this->output, $description, function () use ($event) { $this->dispatcher->dispatch(new ScheduledTaskStarting($event)); $start = microtime(true); diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 2d73c4c3c345..a5c6727670f7 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Application; use Illuminate\Console\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'schedule:test')] class ScheduleTestCommand extends Command @@ -72,7 +73,7 @@ public function handle(Schedule $schedule) $event = $commands[$index]; - $this->task(sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { + Task::renderUsing($this->output, sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { $event->run($this->laravel); }); diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index b7557b691886..4fd55f220286 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -17,7 +17,7 @@ class Task extends Component * @param int $verbosity * @return void */ - public static function renderUsing($output, $description, $task, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public static function renderUsing($output, $description, $task = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) { $component = static::fromOutput($output); diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 0564c18e2c79..0b9551771940 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\DatabaseRefreshed; use Symfony\Component\Console\Input\InputOption; +use Illuminate\Console\View\Components\Task; class FreshCommand extends Command { @@ -41,7 +42,7 @@ public function handle() $this->newLine(); - $this->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ + Task::renderUsing($this->output, 'Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ '--database' => $database, '--drop-views' => $this->option('drop-views'), '--drop-types' => $this->option('drop-types'), diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index 012db8c879cf..8f2cd62689dd 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'optimize:clear')] class OptimizeClearCommand extends Command @@ -40,13 +41,19 @@ class OptimizeClearCommand extends Command */ public function handle() { - $this->tasks('Removing cached bootstrap files', [ - 'events' => fn () => $this->callSilent('event:clear'), - 'views' => fn () => $this->callSilent('view:clear'), - 'cache' => fn () => $this->callSilent('cache:clear'), - 'route' => fn () => $this->callSilent('route:clear'), - 'config' => fn () => $this->callSilent('config:clear'), - 'compiled' => fn () => $this->callSilent('clear-compiled'), - ]); + $this->info('Removing cached bootstrap files'); + + collect([ + 'events' => fn () => $this->callSilent('event:clear') == 0, + 'views' => fn () => $this->callSilent('view:clear') == 0, + 'cache' => fn () => $this->callSilent('cache:clear') == 0, + 'route' => fn () => $this->callSilent('route:clear') == 0, + 'config' => fn () => $this->callSilent('config:clear') == 0, + 'compiled' => fn () => $this->callSilent('clear-compiled') == 0, + ])->each(fn ($task, $description) => Task::renderUsing( + $this->output, $description, $task, + )); + + $this->newLine(); } } diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 802099b0203c..6cd7aae159cc 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'optimize')] class OptimizeCommand extends Command @@ -40,9 +41,15 @@ class OptimizeCommand extends Command */ public function handle() { - $this->tasks('Caching the framework bootstrap files', [ + $this->info('Caching the framework bootstrap files'); + + collect([ 'config' => fn () => $this->callSilent('config:cache') == 0, 'routes' => fn () => $this->callSilent('route:cache') == 0, - ]); + ])->each(fn ($task, $description) => Task::renderUsing( + $this->output, $description, $task, + )); + + $this->newLine(); } } diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index dc8209f92116..6221353e3443 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Illuminate\Foundation\PackageManifest; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'package:discover')] class PackageDiscoverCommand extends Command @@ -42,11 +43,16 @@ class PackageDiscoverCommand extends Command */ public function handle(PackageManifest $manifest) { + $this->info('Discovering packages'); + $manifest->build(); - $tasks = collect($manifest->manifest) - ->map(fn () => fn () => true); + collect($manifest->manifest) + ->map(fn () => fn () => true) + ->each(fn ($task, $description) => Task::renderUsing( + $this->output, $description, $task, + )); - $this->tasks('Discovering packages', $tasks); + $this->newLine(); } } diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 6ca053fa0769..4c0c8ebde89a 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -14,6 +14,7 @@ use League\Flysystem\UnixVisibility\PortableVisibilityConverter; use League\Flysystem\Visibility; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'vendor:publish')] class VendorPublishCommand extends Command @@ -243,7 +244,7 @@ protected function publishFile($from, $to) $this->status($from, $to, 'file'); } else { - $this->task(sprintf( + Task::renderUsing($this->output, sprintf( 'File [%s] already exist', str_replace(base_path().'/', '', realpath($to)), )); @@ -313,7 +314,7 @@ protected function status($from, $to, $type) $to = str_replace(base_path().'/', '', realpath($to)); - $this->task(sprintf( + Task::renderUsing($this->output, sprintf( 'Copying %s [%s] to [%s]', $type, $from, diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index d094e5655764..bc223b1d1f01 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -5,6 +5,7 @@ use Illuminate\Bus\BatchRepository; use Illuminate\Console\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'queue:retry-batch')] class RetryBatchCommand extends Command @@ -56,7 +57,7 @@ public function handle() $this->info("Retrying the failed jobs for a batch [$id]."); foreach ($batch->failedJobIds as $failedJobId) { - $this->task($failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); + Task::renderUsing($this->output, $failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); } $this->newLine(); diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index ad568d70f924..ad0fb16773e6 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -9,6 +9,7 @@ use Illuminate\Support\Arr; use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; +use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'queue:retry')] class RetryCommand extends Command @@ -62,7 +63,7 @@ public function handle() } else { $this->laravel['events']->dispatch(new JobRetryRequested($job)); - $this->task($id, fn () => $this->retryJob($job)); + Task::renderUsing($this->output, $id, fn () => $this->retryJob($job)); $this->laravel['queue.failer']->forget($id); } From 38c15ac51b887e7a16bdedd1420f3bca557ac2c4 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 5 Jul 2022 18:06:30 +0000 Subject: [PATCH 045/101] Apply fixes from StyleCI --- src/Illuminate/Console/Scheduling/ScheduleRunCommand.php | 2 +- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 2 +- src/Illuminate/Database/Console/Migrations/FreshCommand.php | 2 +- src/Illuminate/Foundation/Console/OptimizeClearCommand.php | 2 +- src/Illuminate/Foundation/Console/OptimizeCommand.php | 2 +- src/Illuminate/Foundation/Console/PackageDiscoverCommand.php | 2 +- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 2 +- src/Illuminate/Queue/Console/RetryBatchCommand.php | 2 +- src/Illuminate/Queue/Console/RetryCommand.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index c94c5e78edff..83e3f06e8721 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -3,11 +3,11 @@ namespace Illuminate\Console\Scheduling; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Illuminate\Console\Events\ScheduledTaskFailed; use Illuminate\Console\Events\ScheduledTaskFinished; use Illuminate\Console\Events\ScheduledTaskSkipped; use Illuminate\Console\Events\ScheduledTaskStarting; +use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Carbon; diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index a5c6727670f7..faa212719e7b 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -4,8 +4,8 @@ use Illuminate\Console\Application; use Illuminate\Console\Command; -use Symfony\Component\Console\Attribute\AsCommand; use Illuminate\Console\View\Components\Task; +use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'schedule:test')] class ScheduleTestCommand extends Command diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 0b9551771940..73778a718eaf 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -4,10 +4,10 @@ use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; +use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\DatabaseRefreshed; use Symfony\Component\Console\Input\InputOption; -use Illuminate\Console\View\Components\Task; class FreshCommand extends Command { diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index 8f2cd62689dd..da384a2ab27c 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -3,8 +3,8 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Symfony\Component\Console\Attribute\AsCommand; use Illuminate\Console\View\Components\Task; +use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'optimize:clear')] class OptimizeClearCommand extends Command diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 6cd7aae159cc..44f4efc3fa5b 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -3,8 +3,8 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Symfony\Component\Console\Attribute\AsCommand; use Illuminate\Console\View\Components\Task; +use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'optimize')] class OptimizeCommand extends Command diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index 6221353e3443..a3702f7372d3 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -3,9 +3,9 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Task; use Illuminate\Foundation\PackageManifest; use Symfony\Component\Console\Attribute\AsCommand; -use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'package:discover')] class PackageDiscoverCommand extends Command diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 4c0c8ebde89a..9ba454a6fee9 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Task; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Support\Arr; @@ -14,7 +15,6 @@ use League\Flysystem\UnixVisibility\PortableVisibilityConverter; use League\Flysystem\Visibility; use Symfony\Component\Console\Attribute\AsCommand; -use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'vendor:publish')] class VendorPublishCommand extends Command diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index bc223b1d1f01..1bd5544282eb 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -4,8 +4,8 @@ use Illuminate\Bus\BatchRepository; use Illuminate\Console\Command; -use Symfony\Component\Console\Attribute\AsCommand; use Illuminate\Console\View\Components\Task; +use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'queue:retry-batch')] class RetryBatchCommand extends Command diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index ad0fb16773e6..96a608669520 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -4,12 +4,12 @@ use DateTimeInterface; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Queue\Events\JobRetryRequested; use Illuminate\Support\Arr; use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; -use Illuminate\Console\View\Components\Task; #[AsCommand(name: 'queue:retry')] class RetryCommand extends Command From 4e02dbc7c8f2058d6dfaf4bb792c1522b774f1f5 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 10:09:10 +0100 Subject: [PATCH 046/101] Fixes new line written --- src/Illuminate/Console/OutputStyle.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Illuminate/Console/OutputStyle.php b/src/Illuminate/Console/OutputStyle.php index 7cb344ae12ee..ccb2251ec9aa 100644 --- a/src/Illuminate/Console/OutputStyle.php +++ b/src/Illuminate/Console/OutputStyle.php @@ -103,6 +103,16 @@ public function write(string|iterable $messages, bool $newline = false, int $opt parent::write($messages, $newline, $options); } + /** + * {@inheritdoc} + */ + public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL) + { + $this->newLineWritten = true; + + parent::writeln($messages, $type); + } + /** * {@inheritdoc} */ From b79d8f97091ca72d2ced4c75c986d420ef90f808 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 10:40:45 +0100 Subject: [PATCH 047/101] Remove `bulletList` and `detail` --- .../Console/Concerns/InteractsWithIO.php | 25 ------------------- .../Console/Migrations/StatusCommand.php | 7 ++++-- .../Foundation/Console/EventListCommand.php | 6 +++-- .../Queue/Console/MonitorCommand.php | 5 ++-- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 9e4d7470b075..11148ef908bf 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -281,31 +281,6 @@ public function info($string, $verbosity = null) $this->line($string, 'info', $verbosity); } - /** - * Write a list of strings as bullet list output. - * - * @param array $strings - * @param int|string|null $verbosity - * @return void - */ - public function bulletList($strings, $verbosity = null) - { - Components\BulletList::renderUsing($this->output, $strings, $this->parseVerbosity($verbosity)); - } - - /** - * Write a string as detail output. - * - * @param string $left - * @param string|null $right - * @param int|string|null $verbosity - * @return void - */ - public function detail($left, $right = null, $verbosity = null) - { - Components\Detail::renderUsing($this->output, $left, $right, $this->parseVerbosity($verbosity)); - } - /** * Write a string as standard output. * diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 1372b6715733..2eeb531b4d54 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -2,6 +2,7 @@ namespace Illuminate\Database\Console\Migrations; +use Illuminate\Console\View\Components\Detail; use Illuminate\Database\Migrations\Migrator; use Illuminate\Support\Collection; use Symfony\Component\Console\Input\InputOption; @@ -62,9 +63,11 @@ public function handle() if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { $this->newLine(); - $this->detail('Migration name', 'Batch / Status'); + + Detail::renderUsing($this->output, 'Migration name', 'Batch / Status'); + $migrations->each( - fn ($migration) => $this->detail($migration[0], $migration[1]) + fn ($migration) => Detail::renderUsing($this->output, $migration[0], $migration[1]) ); $this->newLine(); } else { diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index 290d7c4bb14e..272dcdcf25dd 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -4,6 +4,8 @@ use Closure; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\BulletList; +use Illuminate\Console\View\Components\Detail; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Contracts\Queue\ShouldQueue; use ReflectionFunction; @@ -62,8 +64,8 @@ public function handle() $this->newLine(); $events->each(function ($listeners, $event) { - $this->detail($this->appendEventInterfaces($event)); - $this->bulletList($listeners); + Detail::renderUsing($this->output, $this->appendEventInterfaces($event)); + BulletList::renderUsing($this->output, $listeners); }); $this->newLine(); diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index dbcabde5364e..e89e6a5bcaeb 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Queue\Console; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Detail; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Queue\Factory; use Illuminate\Queue\Events\QueueBusy; @@ -124,12 +125,12 @@ protected function displaySizes(Collection $queues) { $this->newLine(); - $this->detail('Queue name', 'Size / Status'); + Detail::renderUsing($this->output, 'Queue name', 'Size / Status'); $queues->each(function ($queue) { $status = '['.$queue['size'].'] '.$queue['status']; - $this->detail($queue['queue'], $status); + Detail::renderUsing($this->output, $queue['queue'], $status); }); $this->newLine(); From 9b595cd93f73f1f921f00ad1e78ed1ca8fc22295 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 10:46:07 +0100 Subject: [PATCH 048/101] Renames `Detail` to `TwoColumnDetail` --- src/Illuminate/Console/QuestionHelper.php | 4 ++-- .../View/Components/{Detail.php => TwoColumnDetail.php} | 2 +- .../views/{detail.blade.php => two-column-detail.blade.php} | 0 .../Database/Console/Migrations/StatusCommand.php | 6 +++--- src/Illuminate/Database/Migrations/Migrator.php | 6 +++--- src/Illuminate/Foundation/Console/EventListCommand.php | 4 ++-- src/Illuminate/Queue/Console/MonitorCommand.php | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) rename src/Illuminate/Console/View/Components/{Detail.php => TwoColumnDetail.php} (96%) rename src/Illuminate/Console/resources/views/{detail.blade.php => two-column-detail.blade.php} (100%) diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php index f804ecd67aa1..0a15afd64cb8 100644 --- a/src/Illuminate/Console/QuestionHelper.php +++ b/src/Illuminate/Console/QuestionHelper.php @@ -2,7 +2,7 @@ namespace Illuminate\Console; -use Illuminate\Console\View\Components\Detail; +use Illuminate\Console\View\Components\TwoColumnDetail; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use Symfony\Component\Console\Output\OutputInterface; @@ -68,7 +68,7 @@ protected function writePrompt(OutputInterface $output, Question $question) if ($question instanceof ChoiceQuestion) { foreach ($question->getChoices() as $key => $value) { - Detail::renderUsing($output, $key, $value); + TwoColumnDetail::renderUsing($output, $key, $value); } } diff --git a/src/Illuminate/Console/View/Components/Detail.php b/src/Illuminate/Console/View/Components/TwoColumnDetail.php similarity index 96% rename from src/Illuminate/Console/View/Components/Detail.php rename to src/Illuminate/Console/View/Components/TwoColumnDetail.php index 3fdc3bffc1e7..0cdddca5f792 100644 --- a/src/Illuminate/Console/View/Components/Detail.php +++ b/src/Illuminate/Console/View/Components/TwoColumnDetail.php @@ -4,7 +4,7 @@ use Symfony\Component\Console\Output\OutputInterface; -class Detail extends Component +class TwoColumnDetail extends Component { /** * Renders the component using the given arguments. diff --git a/src/Illuminate/Console/resources/views/detail.blade.php b/src/Illuminate/Console/resources/views/two-column-detail.blade.php similarity index 100% rename from src/Illuminate/Console/resources/views/detail.blade.php rename to src/Illuminate/Console/resources/views/two-column-detail.blade.php diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 2eeb531b4d54..8ec029a273db 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -2,7 +2,7 @@ namespace Illuminate\Database\Console\Migrations; -use Illuminate\Console\View\Components\Detail; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Database\Migrations\Migrator; use Illuminate\Support\Collection; use Symfony\Component\Console\Input\InputOption; @@ -64,10 +64,10 @@ public function handle() if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { $this->newLine(); - Detail::renderUsing($this->output, 'Migration name', 'Batch / Status'); + TwoColumnDetail::renderUsing($this->output, 'Migration name', 'Batch / Status'); $migrations->each( - fn ($migration) => Detail::renderUsing($this->output, $migration[0], $migration[1]) + fn ($migration) => TwoColumnDetail::renderUsing($this->output, $migration[0], $migration[1]) ); $this->newLine(); } else { diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 144a1713776b..3129816479c9 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Schema\SchemaException; use Illuminate\Console\View\Components\BulletList; -use Illuminate\Console\View\Components\Detail; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Console\View\Components\Line; use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Events\Dispatcher; @@ -274,7 +274,7 @@ protected function rollbackMigrations(array $migrations, $paths, array $options) $migration = (object) $migration; if (! $file = Arr::get($files, $migration->migration)) { - $this->write(Detail::class, $migration->migration, 'Migration not found'); + $this->write(TwoColumnDetail::class, $migration->migration, 'Migration not found'); continue; } @@ -413,7 +413,7 @@ protected function pretendToRun($migration, $method) $name = $this->getMigrationName($reflectionClass->getFileName()); } - $this->write(Detail::class, $name); + $this->write(TwoColumnDetail::class, $name); $this->write(BulletList::class, $name, collect($this->getQueries($migration, $method))->map(function ($query) { return $query['query']; })); diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index 272dcdcf25dd..34ac13c9b167 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -5,7 +5,7 @@ use Closure; use Illuminate\Console\Command; use Illuminate\Console\View\Components\BulletList; -use Illuminate\Console\View\Components\Detail; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Contracts\Queue\ShouldQueue; use ReflectionFunction; @@ -64,7 +64,7 @@ public function handle() $this->newLine(); $events->each(function ($listeners, $event) { - Detail::renderUsing($this->output, $this->appendEventInterfaces($event)); + TwoColumnDetail::renderUsing($this->output, $this->appendEventInterfaces($event)); BulletList::renderUsing($this->output, $listeners); }); diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index e89e6a5bcaeb..730f4b2165c8 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -3,7 +3,7 @@ namespace Illuminate\Queue\Console; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Detail; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Queue\Factory; use Illuminate\Queue\Events\QueueBusy; @@ -125,12 +125,12 @@ protected function displaySizes(Collection $queues) { $this->newLine(); - Detail::renderUsing($this->output, 'Queue name', 'Size / Status'); + TwoColumnDetail::renderUsing($this->output, 'Queue name', 'Size / Status'); $queues->each(function ($queue) { $status = '['.$queue['size'].'] '.$queue['status']; - Detail::renderUsing($this->output, $queue['queue'], $status); + TwoColumnDetail::renderUsing($this->output, $queue['queue'], $status); }); $this->newLine(); From f58dc13b7c63dc9ab6739c19d7c640b87d3ec83f Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 6 Jul 2022 09:46:34 +0000 Subject: [PATCH 049/101] Apply fixes from StyleCI --- src/Illuminate/Database/Migrations/Migrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 3129816479c9..7fc2e7a8ab6d 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -4,9 +4,9 @@ use Doctrine\DBAL\Schema\SchemaException; use Illuminate\Console\View\Components\BulletList; -use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Console\View\Components\Line; use Illuminate\Console\View\Components\Task; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\ConnectionResolverInterface as Resolver; use Illuminate\Database\Events\MigrationEnded; From 66eb52237e78fea03c99e829e34ed1804e340300 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 10:54:58 +0100 Subject: [PATCH 050/101] Removes unused code --- src/Illuminate/Foundation/Console/StorageLinkCommand.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/src/Illuminate/Foundation/Console/StorageLinkCommand.php index b07458a0cc5a..a23e8d6c0942 100644 --- a/src/Illuminate/Foundation/Console/StorageLinkCommand.php +++ b/src/Illuminate/Foundation/Console/StorageLinkCommand.php @@ -46,8 +46,6 @@ public function handle() foreach ($this->links() as $link => $target) { if (file_exists($link) && ! $this->isRemovableSymlink($link, $this->option('force'))) { - $link = str_replace(base_path().'/', '', $link); - $this->error("The [$link] link already exists."); continue; } @@ -62,9 +60,6 @@ public function handle() $this->laravel->make('files')->link($target, $link); } - $link = str_replace(base_path().'/', '', $link); - $target = str_replace(base_path().'/', '', $target); - $this->info("The [$link] link has been connected to [$target]."); } } From 8f315613bb78e1224fc735c39d11b7f467a4ca91 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 11:08:34 +0100 Subject: [PATCH 051/101] Fixes two columns view --- src/Illuminate/Console/View/Components/TwoColumnDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/View/Components/TwoColumnDetail.php b/src/Illuminate/Console/View/Components/TwoColumnDetail.php index 0cdddca5f792..d6bef74c834c 100644 --- a/src/Illuminate/Console/View/Components/TwoColumnDetail.php +++ b/src/Illuminate/Console/View/Components/TwoColumnDetail.php @@ -31,7 +31,7 @@ public static function renderUsing($output, $left, $right = null, $verbosity = O Mutators\EnsureRelativePaths::class, ]); - $component->render('detail', [ + $component->render('two-column-detail', [ 'left' => $left, 'right' => $right, ], $verbosity); From d621715e312fe94c56e5a877670bdd35aa542986 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 11:14:27 +0100 Subject: [PATCH 052/101] Reverts changes on `$this->alert` --- src/Illuminate/Console/Concerns/InteractsWithIO.php | 9 ++++++++- src/Illuminate/Console/ConfirmableTrait.php | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 11148ef908bf..a2f75912da9c 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -6,6 +6,7 @@ use Illuminate\Console\OutputStyle; use Illuminate\Console\View\Components; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Support\Str; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -353,7 +354,13 @@ public function warn($string, $verbosity = null) */ public function alert($string) { - Components\Alert::renderUsing($this->output, $string); + $length = Str::length(strip_tags($string)) + 12; + + $this->comment(str_repeat('*', $length)); + $this->comment('* '.$string.' *'); + $this->comment(str_repeat('*', $length)); + + $this->newLine(); } /** diff --git a/src/Illuminate/Console/ConfirmableTrait.php b/src/Illuminate/Console/ConfirmableTrait.php index 8c46a4789a28..39c95947dcaf 100644 --- a/src/Illuminate/Console/ConfirmableTrait.php +++ b/src/Illuminate/Console/ConfirmableTrait.php @@ -2,6 +2,8 @@ namespace Illuminate\Console; +use Illuminate\Console\View\Components\Alert; + trait ConfirmableTrait { /** @@ -24,7 +26,7 @@ public function confirmToProceed($warning = 'Application In Production', $callba return true; } - $this->alert($warning); + Alert::renderUsing($this->output, $warning); $confirmed = $this->confirm('Do you really wish to run this command?'); From 365138e3c3885ba1d0f1cfd87ed7d6df7a5af85a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 11:28:14 +0100 Subject: [PATCH 053/101] Always finishes with a dot --- src/Illuminate/Console/GeneratorCommand.php | 2 +- src/Illuminate/Foundation/Console/ComponentMakeCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/GeneratorCommand.php b/src/Illuminate/Console/GeneratorCommand.php index 42b5db2dd5ba..7ebd3cd58837 100644 --- a/src/Illuminate/Console/GeneratorCommand.php +++ b/src/Illuminate/Console/GeneratorCommand.php @@ -162,7 +162,7 @@ public function handle() if ((! $this->hasOption('force') || ! $this->option('force')) && $this->alreadyExists($this->getNameInput())) { - $this->error($this->type.' already exists!'); + $this->error($this->type.' already exists.'); return false; } diff --git a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php index 00bb517d1eeb..49dd9294ec9e 100644 --- a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php @@ -84,7 +84,7 @@ protected function writeView($onSuccess = null) } if ($this->files->exists($path) && ! $this->option('force')) { - $this->error('View already exists!'); + $this->error('View already exists.'); return; } From 8bca9a5f01a019890247aad7dd1752df7cd7ffe9 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 11:48:08 +0100 Subject: [PATCH 054/101] Uses task component only when is a task --- src/Illuminate/Console/View/Components/Task.php | 8 ++------ .../Foundation/Console/VendorPublishCommand.php | 5 +++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index 4fd55f220286..d7b9aa19576e 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -27,16 +27,12 @@ public static function renderUsing($output, $description, $task = null, $verbosi Mutators\EnsureRelativePaths::class, ]); + $task = $task ?: fn () => true; + $descriptionWidth = mb_strlen(preg_replace("/\<[\w=#\/\;,:.&,%?]+\>|\\e\[\d+m/", '$1', $description) ?? ''); $output->write(" $description ", false, $verbosity); - if (is_null($task)) { - $dots = max(terminal()->width() - $descriptionWidth - 5, 0); - - return $output->write(str_repeat('.', $dots), false, $verbosity); - } - $startTime = microtime(true); $result = false; diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 9ba454a6fee9..d8cbc9a998d1 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Command; use Illuminate\Console\View\Components\Task; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Support\Arr; @@ -244,7 +245,7 @@ protected function publishFile($from, $to) $this->status($from, $to, 'file'); } else { - Task::renderUsing($this->output, sprintf( + TwoColumnDetail::renderUsing($this->output, sprintf( 'File [%s] already exist', str_replace(base_path().'/', '', realpath($to)), )); @@ -319,6 +320,6 @@ protected function status($from, $to, $type) $type, $from, $to, - ), fn () => true); + )); } } From 98a2b32b1824ef8070bddac7f1e940ed30ecf885 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 12:32:03 +0100 Subject: [PATCH 055/101] Fixes access to parent question helper --- src/Illuminate/Console/OutputStyle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/OutputStyle.php b/src/Illuminate/Console/OutputStyle.php index ccb2251ec9aa..32e930334e17 100644 --- a/src/Illuminate/Console/OutputStyle.php +++ b/src/Illuminate/Console/OutputStyle.php @@ -37,7 +37,7 @@ public function __construct(InputInterface $input, OutputInterface $output) parent::__construct($input, $output); - with(new ReflectionClass($this)) + with(new ReflectionClass(self::class)) ->getParentClass() ->getProperty('questionHelper') ->setValue($this, new QuestionHelper()); From bc2ab37b322788296c20ce8df08dabed2abdbc89 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 6 Jul 2022 14:42:18 +0100 Subject: [PATCH 056/101] Fixes missing new line --- src/Illuminate/Database/Console/Migrations/MigrateCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 88f9aa944875..0e31f6f4eb9a 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -116,6 +116,8 @@ protected function prepareDatabase() '--database' => $this->option('database'), ])) == 0; }); + + $this->newLine(); } if (! $this->migrator->hasRunAnyMigrations() && ! $this->option('pretend')) { From c3bd3f632f1ad66dc5e9cddaf46d9b8681ac663f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 7 Jul 2022 11:21:01 +0100 Subject: [PATCH 057/101] Renames `renderUsing` to `render` --- src/Illuminate/Console/Concerns/InteractsWithIO.php | 2 +- src/Illuminate/Console/ConfirmableTrait.php | 2 +- src/Illuminate/Console/QuestionHelper.php | 2 +- src/Illuminate/Console/Scheduling/ScheduleRunCommand.php | 2 +- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 2 +- src/Illuminate/Console/View/Components/Alert.php | 4 ++-- src/Illuminate/Console/View/Components/BulletList.php | 4 ++-- src/Illuminate/Console/View/Components/Component.php | 2 +- src/Illuminate/Console/View/Components/Line.php | 4 ++-- src/Illuminate/Console/View/Components/Task.php | 2 +- src/Illuminate/Console/View/Components/TwoColumnDetail.php | 4 ++-- src/Illuminate/Database/Console/Migrations/FreshCommand.php | 2 +- src/Illuminate/Database/Console/Migrations/MigrateCommand.php | 4 ++-- src/Illuminate/Database/Console/Migrations/StatusCommand.php | 4 ++-- src/Illuminate/Database/Migrations/Migrator.php | 2 +- src/Illuminate/Foundation/Console/EventListCommand.php | 4 ++-- src/Illuminate/Foundation/Console/OptimizeClearCommand.php | 2 +- src/Illuminate/Foundation/Console/OptimizeCommand.php | 2 +- src/Illuminate/Foundation/Console/PackageDiscoverCommand.php | 2 +- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 4 ++-- src/Illuminate/Queue/Console/MonitorCommand.php | 4 ++-- src/Illuminate/Queue/Console/RetryBatchCommand.php | 2 +- src/Illuminate/Queue/Console/RetryCommand.php | 2 +- 23 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index a2f75912da9c..0594915473fe 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -292,7 +292,7 @@ public function info($string, $verbosity = null) */ public function line($string, $style = null, $verbosity = null) { - Components\Line::renderUsing($this->output, $string, $style, $this->parseVerbosity($verbosity)); + Components\Line::render($this->output, $string, $style, $this->parseVerbosity($verbosity)); } /** diff --git a/src/Illuminate/Console/ConfirmableTrait.php b/src/Illuminate/Console/ConfirmableTrait.php index 39c95947dcaf..41f81a07675f 100644 --- a/src/Illuminate/Console/ConfirmableTrait.php +++ b/src/Illuminate/Console/ConfirmableTrait.php @@ -26,7 +26,7 @@ public function confirmToProceed($warning = 'Application In Production', $callba return true; } - Alert::renderUsing($this->output, $warning); + Alert::render($this->output, $warning); $confirmed = $this->confirm('Do you really wish to run this command?'); diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php index 0a15afd64cb8..95a5aead8bd4 100644 --- a/src/Illuminate/Console/QuestionHelper.php +++ b/src/Illuminate/Console/QuestionHelper.php @@ -68,7 +68,7 @@ protected function writePrompt(OutputInterface $output, Question $question) if ($question instanceof ChoiceQuestion) { foreach ($question->getChoices() as $key => $value) { - TwoColumnDetail::renderUsing($output, $key, $value); + TwoColumnDetail::render($output, $key, $value); } } diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index 83e3f06e8721..832d14632e83 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -160,7 +160,7 @@ protected function runEvent($event) $event->getSummaryForDisplay() ); - Task::renderUsing($this->output, $description, function () use ($event) { + Task::render($this->output, $description, function () use ($event) { $this->dispatcher->dispatch(new ScheduledTaskStarting($event)); $start = microtime(true); diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index faa212719e7b..357d2eacf506 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -73,7 +73,7 @@ public function handle(Schedule $schedule) $event = $commands[$index]; - Task::renderUsing($this->output, sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { + Task::render($this->output, sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { $event->run($this->laravel); }); diff --git a/src/Illuminate/Console/View/Components/Alert.php b/src/Illuminate/Console/View/Components/Alert.php index 93d331176669..813a7c3f10cd 100644 --- a/src/Illuminate/Console/View/Components/Alert.php +++ b/src/Illuminate/Console/View/Components/Alert.php @@ -14,7 +14,7 @@ class Alert extends Component * @param int $verbosity * @return void */ - public static function renderUsing($output, $string, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public static function render($output, $string, $verbosity = OutputInterface::VERBOSITY_NORMAL) { $component = static::fromOutput($output); @@ -24,7 +24,7 @@ public static function renderUsing($output, $string, $verbosity = OutputInterfac Mutators\EnsureRelativePaths::class, ]); - $component->render('alert', [ + $component->renderView('alert', [ 'content' => $string, ], $verbosity); } diff --git a/src/Illuminate/Console/View/Components/BulletList.php b/src/Illuminate/Console/View/Components/BulletList.php index c03df7bedb3b..99c9de9b0fd0 100644 --- a/src/Illuminate/Console/View/Components/BulletList.php +++ b/src/Illuminate/Console/View/Components/BulletList.php @@ -14,7 +14,7 @@ class BulletList extends Component * @param int $verbosity * @return void */ - public static function renderUsing($output, $elements, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public static function render($output, $elements, $verbosity = OutputInterface::VERBOSITY_NORMAL) { $component = static::fromOutput($output); @@ -24,7 +24,7 @@ public static function renderUsing($output, $elements, $verbosity = OutputInterf Mutators\EnsureRelativePaths::class, ]); - $component->render('bullet-list', [ + $component->renderView('bullet-list', [ 'elements' => $elements, ], $verbosity); } diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php index 7261eabef265..5ec91e76b566 100644 --- a/src/Illuminate/Console/View/Components/Component.php +++ b/src/Illuminate/Console/View/Components/Component.php @@ -52,7 +52,7 @@ public static function fromOutput($output) * @param int $verbosity * @return void */ - public function render($view, $data, $verbosity) + public function renderView($view, $data, $verbosity) { $this->ensureViewRequirements(); diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index 4c125e99672c..abb297276d7d 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -43,7 +43,7 @@ class Line extends Component * @param int $verbosity * @return void */ - public static function renderUsing($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public static function render($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) { $component = static::fromOutput($output); @@ -55,7 +55,7 @@ public static function renderUsing($output, $string, $style, $verbosity = Output Mutators\EnsureRelativePaths::class, ]); - $component->render('line', array_merge(static::$styles[$style], [ + $component->renderView('line', array_merge(static::$styles[$style], [ 'marginTop' => ($output instanceof NewLineAware && $output->newLineWritten()) ? 0 : 1, 'content' => $string, ]), $verbosity); diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index d7b9aa19576e..2ab17454c687 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -17,7 +17,7 @@ class Task extends Component * @param int $verbosity * @return void */ - public static function renderUsing($output, $description, $task = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public static function render($output, $description, $task = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) { $component = static::fromOutput($output); diff --git a/src/Illuminate/Console/View/Components/TwoColumnDetail.php b/src/Illuminate/Console/View/Components/TwoColumnDetail.php index d6bef74c834c..6ae46f9e19f5 100644 --- a/src/Illuminate/Console/View/Components/TwoColumnDetail.php +++ b/src/Illuminate/Console/View/Components/TwoColumnDetail.php @@ -15,7 +15,7 @@ class TwoColumnDetail extends Component * @param int $verbosity * @return void */ - public static function renderUsing($output, $left, $right = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public static function render($output, $left, $right = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) { $component = static::fromOutput($output); @@ -31,7 +31,7 @@ public static function renderUsing($output, $left, $right = null, $verbosity = O Mutators\EnsureRelativePaths::class, ]); - $component->render('two-column-detail', [ + $component->renderView('two-column-detail', [ 'left' => $left, 'right' => $right, ], $verbosity); diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 73778a718eaf..fd88f6b4a727 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -42,7 +42,7 @@ public function handle() $this->newLine(); - Task::renderUsing($this->output, 'Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ + Task::render($this->output, 'Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ '--database' => $database, '--drop-views' => $this->option('drop-views'), '--drop-types' => $this->option('drop-types'), diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 0e31f6f4eb9a..13709ec5afa1 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -111,7 +111,7 @@ protected function prepareDatabase() if (! $this->migrator->repositoryExists()) { $this->info('Preparing database.'); - Task::renderUsing($this->output, 'Creating migration table', function () { + Task::render($this->output, 'Creating migration table', function () { return $this->callSilent('migrate:install', array_filter([ '--database' => $this->option('database'), ])) == 0; @@ -144,7 +144,7 @@ protected function loadSchemaState() $this->info('Preparing database.'); - Task::renderUsing($this->output, "Loading stored database schema [$path].", function () use ($connection, $path) { + Task::render($this->output, "Loading stored database schema [$path].", function () use ($connection, $path) { // Since the schema file will create the "migrations" table and reload it to its // proper state, we need to delete it here so we don't get an error that this // table already exists when the stored database schema file gets executed. diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 8ec029a273db..dcd917074937 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -64,10 +64,10 @@ public function handle() if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { $this->newLine(); - TwoColumnDetail::renderUsing($this->output, 'Migration name', 'Batch / Status'); + TwoColumnDetail::render($this->output, 'Migration name', 'Batch / Status'); $migrations->each( - fn ($migration) => TwoColumnDetail::renderUsing($this->output, $migration[0], $migration[1]) + fn ($migration) => TwoColumnDetail::render($this->output, $migration[0], $migration[1]) ); $this->newLine(); } else { diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 7fc2e7a8ab6d..5b10386f5532 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -722,7 +722,7 @@ public function setOutput(OutputInterface $output) protected function write($component, ...$arguments) { if ($this->output) { - $component::renderUsing($this->output, ...$arguments); + $component::render($this->output, ...$arguments); } } diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index 34ac13c9b167..4ac83df03282 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -64,8 +64,8 @@ public function handle() $this->newLine(); $events->each(function ($listeners, $event) { - TwoColumnDetail::renderUsing($this->output, $this->appendEventInterfaces($event)); - BulletList::renderUsing($this->output, $listeners); + TwoColumnDetail::render($this->output, $this->appendEventInterfaces($event)); + BulletList::render($this->output, $listeners); }); $this->newLine(); diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index da384a2ab27c..e8aa5a7c4adf 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -50,7 +50,7 @@ public function handle() 'route' => fn () => $this->callSilent('route:clear') == 0, 'config' => fn () => $this->callSilent('config:clear') == 0, 'compiled' => fn () => $this->callSilent('clear-compiled') == 0, - ])->each(fn ($task, $description) => Task::renderUsing( + ])->each(fn ($task, $description) => Task::render( $this->output, $description, $task, )); diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 44f4efc3fa5b..75cc02ca87f2 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -46,7 +46,7 @@ public function handle() collect([ 'config' => fn () => $this->callSilent('config:cache') == 0, 'routes' => fn () => $this->callSilent('route:cache') == 0, - ])->each(fn ($task, $description) => Task::renderUsing( + ])->each(fn ($task, $description) => Task::render( $this->output, $description, $task, )); diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index a3702f7372d3..c7d9e8e67d13 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -49,7 +49,7 @@ public function handle(PackageManifest $manifest) collect($manifest->manifest) ->map(fn () => fn () => true) - ->each(fn ($task, $description) => Task::renderUsing( + ->each(fn ($task, $description) => Task::render( $this->output, $description, $task, )); diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index d8cbc9a998d1..621a75f28826 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -245,7 +245,7 @@ protected function publishFile($from, $to) $this->status($from, $to, 'file'); } else { - TwoColumnDetail::renderUsing($this->output, sprintf( + TwoColumnDetail::render($this->output, sprintf( 'File [%s] already exist', str_replace(base_path().'/', '', realpath($to)), )); @@ -315,7 +315,7 @@ protected function status($from, $to, $type) $to = str_replace(base_path().'/', '', realpath($to)); - Task::renderUsing($this->output, sprintf( + Task::render($this->output, sprintf( 'Copying %s [%s] to [%s]', $type, $from, diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index 730f4b2165c8..34189760eb95 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -125,12 +125,12 @@ protected function displaySizes(Collection $queues) { $this->newLine(); - TwoColumnDetail::renderUsing($this->output, 'Queue name', 'Size / Status'); + TwoColumnDetail::render($this->output, 'Queue name', 'Size / Status'); $queues->each(function ($queue) { $status = '['.$queue['size'].'] '.$queue['status']; - TwoColumnDetail::renderUsing($this->output, $queue['queue'], $status); + TwoColumnDetail::render($this->output, $queue['queue'], $status); }); $this->newLine(); diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index 1bd5544282eb..f966b1a8830e 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -57,7 +57,7 @@ public function handle() $this->info("Retrying the failed jobs for a batch [$id]."); foreach ($batch->failedJobIds as $failedJobId) { - Task::renderUsing($this->output, $failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); + Task::render($this->output, $failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); } $this->newLine(); diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 96a608669520..85b14a7b3ac3 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -63,7 +63,7 @@ public function handle() } else { $this->laravel['events']->dispatch(new JobRetryRequested($job)); - Task::renderUsing($this->output, $id, fn () => $this->retryJob($job)); + Task::render($this->output, $id, fn () => $this->retryJob($job)); $this->laravel['queue.failer']->forget($id); } From 29d6e99e8ab4e856ff2040bfafca9e5ac7bcc529 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 7 Jul 2022 11:47:15 +0100 Subject: [PATCH 058/101] Moves components resources directory --- src/Illuminate/Console/View/Components/Component.php | 2 +- .../Console/resources/views/{ => components}/alert.blade.php | 0 .../resources/views/{ => components}/bullet-list.blade.php | 0 .../Console/resources/views/{ => components}/line.blade.php | 0 .../views/{ => components}/two-column-detail.blade.php | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename src/Illuminate/Console/resources/views/{ => components}/alert.blade.php (100%) rename src/Illuminate/Console/resources/views/{ => components}/bullet-list.blade.php (100%) rename src/Illuminate/Console/resources/views/{ => components}/line.blade.php (100%) rename src/Illuminate/Console/resources/views/{ => components}/two-column-detail.blade.php (100%) diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php index 5ec91e76b566..aab0490d141f 100644 --- a/src/Illuminate/Console/View/Components/Component.php +++ b/src/Illuminate/Console/View/Components/Component.php @@ -58,7 +58,7 @@ public function renderView($view, $data, $verbosity) renderUsing($this->output); - render(view('illuminate.console::'.$view, $data), $verbosity); + render(view('illuminate.console::components.'.$view, $data), $verbosity); } /** diff --git a/src/Illuminate/Console/resources/views/alert.blade.php b/src/Illuminate/Console/resources/views/components/alert.blade.php similarity index 100% rename from src/Illuminate/Console/resources/views/alert.blade.php rename to src/Illuminate/Console/resources/views/components/alert.blade.php diff --git a/src/Illuminate/Console/resources/views/bullet-list.blade.php b/src/Illuminate/Console/resources/views/components/bullet-list.blade.php similarity index 100% rename from src/Illuminate/Console/resources/views/bullet-list.blade.php rename to src/Illuminate/Console/resources/views/components/bullet-list.blade.php diff --git a/src/Illuminate/Console/resources/views/line.blade.php b/src/Illuminate/Console/resources/views/components/line.blade.php similarity index 100% rename from src/Illuminate/Console/resources/views/line.blade.php rename to src/Illuminate/Console/resources/views/components/line.blade.php diff --git a/src/Illuminate/Console/resources/views/two-column-detail.blade.php b/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php similarity index 100% rename from src/Illuminate/Console/resources/views/two-column-detail.blade.php rename to src/Illuminate/Console/resources/views/components/two-column-detail.blade.php From 17f9aaf5763435f91f1bca816ed07fad54b16dc1 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 7 Jul 2022 12:29:28 +0100 Subject: [PATCH 059/101] Fixes multiple listeners on `event:list` --- .../resources/views/components/bullet-list.blade.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Console/resources/views/components/bullet-list.blade.php b/src/Illuminate/Console/resources/views/components/bullet-list.blade.php index b79d588d12d5..45f57708f5bb 100644 --- a/src/Illuminate/Console/resources/views/components/bullet-list.blade.php +++ b/src/Illuminate/Console/resources/views/components/bullet-list.blade.php @@ -1,5 +1,7 @@ -@foreach($elements as $element) -
- ⇂ {{ $element }} -
-@endforeach +
+ @foreach($elements as $element) +
+ ⇂ {{ $element }} +
+ @endforeach +
From 27b344a3518a16d8a8ff38e12095d421c7e5aa02 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 7 Jul 2022 18:38:06 +0100 Subject: [PATCH 060/101] Uses `$this->components` to print output --- .../Auth/Console/ClearResetsCommand.php | 2 +- .../Cache/Console/CacheTableCommand.php | 2 +- src/Illuminate/Cache/Console/ClearCommand.php | 4 +- .../Cache/Console/ForgetCommand.php | 2 +- src/Illuminate/Console/Command.php | 3 + .../Console/Concerns/InteractsWithIO.php | 26 +++++-- src/Illuminate/Console/ConfirmableTrait.php | 8 +-- src/Illuminate/Console/GeneratorCommand.php | 6 +- src/Illuminate/Console/OutputStyle.php | 6 -- src/Illuminate/Console/QuestionHelper.php | 17 +---- .../Console/Scheduling/Schedule.php | 6 ++ .../Scheduling/ScheduleClearCacheCommand.php | 4 +- .../Scheduling/ScheduleListCommand.php | 2 +- .../Console/Scheduling/ScheduleRunCommand.php | 7 +- .../Scheduling/ScheduleTestCommand.php | 11 +-- .../Scheduling/ScheduleWorkCommand.php | 2 +- .../Console/View/Components/Alert.php | 9 +-- .../Console/View/Components/BulletList.php | 9 +-- .../Console/View/Components/Choice.php | 25 +++++++ .../Console/View/Components/Component.php | 71 +++++++++++-------- .../Console/View/Components/Confirm.php | 20 ++++++ .../Console/View/Components/Error.php | 20 ++++++ .../Console/View/Components/Factory.php | 46 ++++++++++++ .../Console/View/Components/Info.php | 20 ++++++ .../Console/View/Components/Line.php | 21 ++---- .../Console/View/Components/Question.php | 1 + .../Console/View/Components/Task.php | 15 ++-- .../View/Components/TwoColumnDetail.php | 19 +++-- .../Console/View/Components/Warn.php | 21 ++++++ .../components/two-column-detail.blade.php | 6 +- .../Database/Console/DumpCommand.php | 2 +- .../Console/Migrations/FreshCommand.php | 2 +- .../Console/Migrations/InstallCommand.php | 2 +- .../Console/Migrations/MigrateCommand.php | 8 +-- .../Console/Migrations/MigrateMakeCommand.php | 2 +- .../Console/Migrations/ResetCommand.php | 2 +- .../Console/Migrations/StatusCommand.php | 9 +-- .../Database/Console/PruneCommand.php | 10 +-- .../Database/Console/Seeds/SeedCommand.php | 2 +- .../Database/Console/WipeCommand.php | 6 +- .../Database/Migrations/Migrator.php | 20 +++--- .../Console/ClearCompiledCommand.php | 2 +- .../Console/ComponentMakeCommand.php | 4 +- .../Foundation/Console/ConfigCacheCommand.php | 2 +- .../Foundation/Console/ConfigClearCommand.php | 2 +- .../Foundation/Console/DownCommand.php | 6 +- .../Foundation/Console/EnvironmentCommand.php | 2 +- .../Foundation/Console/EventCacheCommand.php | 2 +- .../Foundation/Console/EventClearCommand.php | 2 +- .../Console/EventGenerateCommand.php | 2 +- .../Foundation/Console/EventListCommand.php | 6 +- .../Foundation/Console/KeyGenerateCommand.php | 2 +- .../Console/OptimizeClearCommand.php | 6 +- .../Foundation/Console/OptimizeCommand.php | 6 +- .../Console/PackageDiscoverCommand.php | 6 +- .../Foundation/Console/RouteCacheCommand.php | 4 +- .../Foundation/Console/RouteClearCommand.php | 2 +- .../Foundation/Console/RouteListCommand.php | 4 +- .../Foundation/Console/StorageLinkCommand.php | 4 +- .../Foundation/Console/StubPublishCommand.php | 2 +- .../Foundation/Console/UpCommand.php | 6 +- .../Console/VendorPublishCommand.php | 12 ++-- .../Foundation/Console/ViewCacheCommand.php | 2 +- .../Foundation/Console/ViewClearCommand.php | 2 +- .../Console/NotificationTableCommand.php | 2 +- .../Queue/Console/BatchesTableCommand.php | 2 +- src/Illuminate/Queue/Console/ClearCommand.php | 4 +- .../Queue/Console/FailedTableCommand.php | 2 +- .../Queue/Console/FlushFailedCommand.php | 4 +- .../Queue/Console/ForgetFailedCommand.php | 4 +- .../Queue/Console/ListFailedCommand.php | 2 +- .../Queue/Console/ListenCommand.php | 2 +- .../Queue/Console/MonitorCommand.php | 4 +- .../Queue/Console/PruneBatchesCommand.php | 4 +- .../Queue/Console/PruneFailedJobsCommand.php | 4 +- .../Queue/Console/RestartCommand.php | 2 +- .../Queue/Console/RetryBatchCommand.php | 8 +-- src/Illuminate/Queue/Console/RetryCommand.php | 10 +-- src/Illuminate/Queue/Console/TableCommand.php | 2 +- src/Illuminate/Queue/Console/WorkCommand.php | 4 +- .../Routing/Console/ControllerMakeCommand.php | 4 +- .../Session/Console/SessionTableCommand.php | 2 +- 82 files changed, 385 insertions(+), 245 deletions(-) create mode 100644 src/Illuminate/Console/View/Components/Choice.php create mode 100644 src/Illuminate/Console/View/Components/Confirm.php create mode 100644 src/Illuminate/Console/View/Components/Error.php create mode 100644 src/Illuminate/Console/View/Components/Factory.php create mode 100644 src/Illuminate/Console/View/Components/Info.php create mode 100644 src/Illuminate/Console/View/Components/Question.php create mode 100644 src/Illuminate/Console/View/Components/Warn.php diff --git a/src/Illuminate/Auth/Console/ClearResetsCommand.php b/src/Illuminate/Auth/Console/ClearResetsCommand.php index 9c3d9e033987..2ea96681f8e7 100644 --- a/src/Illuminate/Auth/Console/ClearResetsCommand.php +++ b/src/Illuminate/Auth/Console/ClearResetsCommand.php @@ -42,6 +42,6 @@ public function handle() { $this->laravel['auth.password']->broker($this->argument('name'))->getRepository()->deleteExpired(); - $this->info('Expired reset tokens cleared successfully.'); + $this->components->info('Expired reset tokens cleared successfully.'); } } diff --git a/src/Illuminate/Cache/Console/CacheTableCommand.php b/src/Illuminate/Cache/Console/CacheTableCommand.php index ea18d4f20812..19b591bdda36 100644 --- a/src/Illuminate/Cache/Console/CacheTableCommand.php +++ b/src/Illuminate/Cache/Console/CacheTableCommand.php @@ -73,7 +73,7 @@ public function handle() $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/cache.stub')); - $this->info('Migration created successfully.'); + $this->components->info('Migration created successfully.'); $this->composer->dumpAutoloads(); } diff --git a/src/Illuminate/Cache/Console/ClearCommand.php b/src/Illuminate/Cache/Console/ClearCommand.php index ca8d2a27bdb6..7d3336c712a9 100755 --- a/src/Illuminate/Cache/Console/ClearCommand.php +++ b/src/Illuminate/Cache/Console/ClearCommand.php @@ -82,14 +82,14 @@ public function handle() $this->flushFacades(); if (! $successful) { - return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.'); + return $this->components->error('Failed to clear cache. Make sure you have the appropriate permissions.'); } $this->laravel['events']->dispatch( 'cache:cleared', [$this->argument('store'), $this->tags()] ); - $this->info('Application cache cleared successfully.'); + $this->components->info('Application cache cleared successfully.'); } /** diff --git a/src/Illuminate/Cache/Console/ForgetCommand.php b/src/Illuminate/Cache/Console/ForgetCommand.php index 41e7adbdee14..c7fc830cd999 100755 --- a/src/Illuminate/Cache/Console/ForgetCommand.php +++ b/src/Illuminate/Cache/Console/ForgetCommand.php @@ -65,6 +65,6 @@ public function handle() $this->argument('key') ); - $this->info('The ['.$this->argument('key').'] key has been removed from the cache.'); + $this->components->info('The ['.$this->argument('key').'] key has been removed from the cache.'); } } diff --git a/src/Illuminate/Console/Command.php b/src/Illuminate/Console/Command.php index 6d9ae8c89381..0b5242658892 100755 --- a/src/Illuminate/Console/Command.php +++ b/src/Illuminate/Console/Command.php @@ -2,6 +2,7 @@ namespace Illuminate\Console; +use Illuminate\Console\View\Components\Factory; use Illuminate\Support\Traits\Macroable; use Symfony\Component\Console\Command\Command as SymfonyCommand; use Symfony\Component\Console\Input\InputInterface; @@ -117,6 +118,8 @@ public function run(InputInterface $input, OutputInterface $output): int OutputStyle::class, ['input' => $input, 'output' => $output] ); + $this->components = new Factory($this->output); + return parent::run( $this->input = $input, $this->output ); diff --git a/src/Illuminate/Console/Concerns/InteractsWithIO.php b/src/Illuminate/Console/Concerns/InteractsWithIO.php index 0594915473fe..6a7be40c54cf 100644 --- a/src/Illuminate/Console/Concerns/InteractsWithIO.php +++ b/src/Illuminate/Console/Concerns/InteractsWithIO.php @@ -4,9 +4,9 @@ use Closure; use Illuminate\Console\OutputStyle; -use Illuminate\Console\View\Components; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Support\Str; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,6 +15,15 @@ trait InteractsWithIO { + /** + * The console components factory. + * + * @var \Illuminate\Console\View\Components\Factory + * + * @internal This property is not meant to be used or overwritten outside the framework. + */ + protected $components; + /** * The input interface implementation. * @@ -292,7 +301,9 @@ public function info($string, $verbosity = null) */ public function line($string, $style = null, $verbosity = null) { - Components\Line::render($this->output, $string, $style, $this->parseVerbosity($verbosity)); + $styled = $style ? "<$style>$string" : $string; + + $this->output->writeln($styled, $this->parseVerbosity($verbosity)); } /** @@ -304,10 +315,7 @@ public function line($string, $style = null, $verbosity = null) */ public function comment($string, $verbosity = null) { - $this->output->writeln( - "$string", - $this->parseVerbosity($verbosity) - ); + $this->line($string, 'comment', $verbosity); } /** @@ -343,6 +351,12 @@ public function error($string, $verbosity = null) */ public function warn($string, $verbosity = null) { + if (! $this->output->getFormatter()->hasStyle('warning')) { + $style = new OutputFormatterStyle('yellow'); + + $this->output->getFormatter()->setStyle('warning', $style); + } + $this->line($string, 'warning', $verbosity); } diff --git a/src/Illuminate/Console/ConfirmableTrait.php b/src/Illuminate/Console/ConfirmableTrait.php index 41f81a07675f..c575dbe23d71 100644 --- a/src/Illuminate/Console/ConfirmableTrait.php +++ b/src/Illuminate/Console/ConfirmableTrait.php @@ -2,8 +2,6 @@ namespace Illuminate\Console; -use Illuminate\Console\View\Components\Alert; - trait ConfirmableTrait { /** @@ -26,12 +24,12 @@ public function confirmToProceed($warning = 'Application In Production', $callba return true; } - Alert::render($this->output, $warning); + $this->components->alert($warning); - $confirmed = $this->confirm('Do you really wish to run this command?'); + $confirmed = $this->components->confirm('Do you really wish to run this command?'); if (! $confirmed) { - $this->warn('Command canceled.'); + $this->components->warn('Command canceled.'); return false; } diff --git a/src/Illuminate/Console/GeneratorCommand.php b/src/Illuminate/Console/GeneratorCommand.php index 7ebd3cd58837..a5683e0bd2ec 100644 --- a/src/Illuminate/Console/GeneratorCommand.php +++ b/src/Illuminate/Console/GeneratorCommand.php @@ -147,7 +147,7 @@ public function handle() // language and that the class name will actually be valid. If it is not valid we // can error now and prevent from polluting the filesystem using invalid files. if ($this->isReservedName($this->getNameInput())) { - $this->error('The name "'.$this->getNameInput().'" is reserved by PHP.'); + $this->components->error('The name "'.$this->getNameInput().'" is reserved by PHP.'); return false; } @@ -162,7 +162,7 @@ public function handle() if ((! $this->hasOption('force') || ! $this->option('force')) && $this->alreadyExists($this->getNameInput())) { - $this->error($this->type.' already exists.'); + $this->components->error($this->type.' already exists.'); return false; } @@ -182,7 +182,7 @@ public function handle() } } - $this->info($info.' created successfully.'); + $this->components->info($info.' created successfully.'); } /** diff --git a/src/Illuminate/Console/OutputStyle.php b/src/Illuminate/Console/OutputStyle.php index 32e930334e17..4861ff14fc9e 100644 --- a/src/Illuminate/Console/OutputStyle.php +++ b/src/Illuminate/Console/OutputStyle.php @@ -3,7 +3,6 @@ namespace Illuminate\Console; use Illuminate\Console\Contracts\NewLineAware; -use ReflectionClass; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; @@ -36,11 +35,6 @@ public function __construct(InputInterface $input, OutputInterface $output) $this->output = $output; parent::__construct($input, $output); - - with(new ReflectionClass(self::class)) - ->getParentClass() - ->getProperty('questionHelper') - ->setValue($this, new QuestionHelper()); } /** diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php index 95a5aead8bd4..6ae991f2ec38 100644 --- a/src/Illuminate/Console/QuestionHelper.php +++ b/src/Illuminate/Console/QuestionHelper.php @@ -42,33 +42,18 @@ protected function writePrompt(OutputInterface $output, Question $question) break; - case $question instanceof ChoiceQuestion && $question->isMultiselect(): - $choices = $question->getChoices(); - $default = explode(',', $default); - - foreach ($default as $key => $value) { - $default[$key] = $choices[trim($value)]; - } - - $text = sprintf('%s [%s]', $text, OutputFormatter::escape(implode(', ', $default))); - - break; - case $question instanceof ChoiceQuestion: $choices = $question->getChoices(); $text = sprintf('%s [%s]', $text, OutputFormatter::escape($choices[$default] ?? $default)); break; - - default: - $text = sprintf('%s [%s]', $text, OutputFormatter::escape($default)); } $output->writeln($text); if ($question instanceof ChoiceQuestion) { foreach ($question->getChoices() as $key => $value) { - TwoColumnDetail::render($output, $key, $value); + with(new TwoColumnDetail($output))->render($key, $value); } } diff --git a/src/Illuminate/Console/Scheduling/Schedule.php b/src/Illuminate/Console/Scheduling/Schedule.php index cda3d5d1c28a..2f62bf9e81d9 100644 --- a/src/Illuminate/Console/Scheduling/Schedule.php +++ b/src/Illuminate/Console/Scheduling/Schedule.php @@ -22,11 +22,17 @@ class Schedule use Macroable; const SUNDAY = 0; + const MONDAY = 1; + const TUESDAY = 2; + const WEDNESDAY = 3; + const THURSDAY = 4; + const FRIDAY = 5; + const SATURDAY = 6; /** diff --git a/src/Illuminate/Console/Scheduling/ScheduleClearCacheCommand.php b/src/Illuminate/Console/Scheduling/ScheduleClearCacheCommand.php index 0dd9424c4bd3..3deb1c6bcfda 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleClearCacheCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleClearCacheCommand.php @@ -32,7 +32,7 @@ public function handle(Schedule $schedule) foreach ($schedule->events($this->laravel) as $event) { if ($event->mutex->exists($event)) { - $this->line('Deleting mutex for: '.$event->command); + $this->components->info(sprintf('Deleting mutex for [%s]', $event->command)); $event->mutex->forget($event); @@ -41,7 +41,7 @@ public function handle(Schedule $schedule) } if (! $mutexCleared) { - $this->info('No mutex files were found.'); + $this->components->info('No mutex files were found.'); } } } diff --git a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php index 1b2a7776c501..cb4236a9dd10 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php @@ -61,7 +61,7 @@ public function handle(Schedule $schedule) $events = collect($schedule->events()); if ($events->isEmpty()) { - $this->info('No scheduled tasks have been defined.'); + $this->components->info('No scheduled tasks have been defined.'); return; } diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index 832d14632e83..b25fbba48dff 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -7,7 +7,6 @@ use Illuminate\Console\Events\ScheduledTaskFinished; use Illuminate\Console\Events\ScheduledTaskSkipped; use Illuminate\Console\Events\ScheduledTaskStarting; -use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Carbon; @@ -123,7 +122,7 @@ public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHand } if (! $this->eventsRan) { - $this->info('No scheduled commands are ready to run.'); + $this->components->info('No scheduled commands are ready to run.'); } else { $this->newLine(); } @@ -140,7 +139,7 @@ protected function runSingleServerEvent($event) if ($this->schedule->serverShouldRun($event, $this->startedAt)) { $this->runEvent($event); } else { - $this->info(sprintf( + $this->components->info(sprintf( 'Skipping [%s], as command already run on another server.', $event->getSummaryForDisplay() )); } @@ -160,7 +159,7 @@ protected function runEvent($event) $event->getSummaryForDisplay() ); - Task::render($this->output, $description, function () use ($event) { + $this->components->task($description, function () use ($event) { $this->dispatcher->dispatch(new ScheduledTaskStarting($event)); $start = microtime(true); diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 357d2eacf506..008f87e2b7b7 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -4,7 +4,6 @@ use Illuminate\Console\Application; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'schedule:test')] @@ -52,7 +51,7 @@ public function handle(Schedule $schedule) } if (empty($commandNames)) { - return $this->info('No scheduled commands have been defined.'); + return $this->components->info('No scheduled commands have been defined.'); } if (! empty($name = $this->option('name'))) { @@ -63,17 +62,19 @@ public function handle(Schedule $schedule) }); if (count($matches) !== 1) { - return $this->error('No matching scheduled command found.'); + $this->components->info('No matching scheduled command found.'); + + return; } $index = key($matches); } else { - $index = array_search($this->choice('Which command would you like to run?', $commandNames), $commandNames); + $index = array_search($this->components->choice('Which command would you like to run?', $commandNames), $commandNames); } $event = $commands[$index]; - Task::render($this->output, sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { + $this->components->task(sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { $event->run($this->laravel); }); diff --git a/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php b/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php index 1b7c6942c39f..67c8a5c4fe19 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php @@ -42,7 +42,7 @@ class ScheduleWorkCommand extends Command */ public function handle() { - $this->info('Running schedule tasks every minute.'); + $this->components->info('Running schedule tasks every minute.'); [$lastExecutionStartedAt, $keyOfLastExecutionWithOutput, $executions] = [null, null, []]; diff --git a/src/Illuminate/Console/View/Components/Alert.php b/src/Illuminate/Console/View/Components/Alert.php index 813a7c3f10cd..a975aaf8346c 100644 --- a/src/Illuminate/Console/View/Components/Alert.php +++ b/src/Illuminate/Console/View/Components/Alert.php @@ -9,22 +9,19 @@ class Alert extends Component /** * Renders the component using the given arguments. * - * @param \Symfony\Component\Console\Output\OutputInterface $output * @param string $string * @param int $verbosity * @return void */ - public static function render($output, $string, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public function render($string, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - $component = static::fromOutput($output); - - $string = $component->mutate($string, [ + $string = $this->mutate($string, [ Mutators\EnsureDynamicContentIsHighlighted::class, Mutators\EnsurePunctuation::class, Mutators\EnsureRelativePaths::class, ]); - $component->renderView('alert', [ + $this->renderView('alert', [ 'content' => $string, ], $verbosity); } diff --git a/src/Illuminate/Console/View/Components/BulletList.php b/src/Illuminate/Console/View/Components/BulletList.php index 99c9de9b0fd0..da3d8817960e 100644 --- a/src/Illuminate/Console/View/Components/BulletList.php +++ b/src/Illuminate/Console/View/Components/BulletList.php @@ -9,22 +9,19 @@ class BulletList extends Component /** * Renders the component using the given arguments. * - * @param \Symfony\Component\Console\Output\OutputInterface $output * @param array $elements * @param int $verbosity * @return void */ - public static function render($output, $elements, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public function render($elements, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - $component = static::fromOutput($output); - - $elements = $component->mutate($elements, [ + $elements = $this->mutate($elements, [ Mutators\EnsureDynamicContentIsHighlighted::class, Mutators\EnsureNoPunctuation::class, Mutators\EnsureRelativePaths::class, ]); - $component->renderView('bullet-list', [ + $this->renderView('bullet-list', [ 'elements' => $elements, ], $verbosity); } diff --git a/src/Illuminate/Console/View/Components/Choice.php b/src/Illuminate/Console/View/Components/Choice.php new file mode 100644 index 000000000000..6a669b946e45 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Choice.php @@ -0,0 +1,25 @@ + $choices + * @param mixed $default + * @return mixed + */ + public function render($question, $choices, $default = null) + { + return $this->usingQuestionHelper( + fn () => $this->output->askQuestion( + new ChoiceQuestion($question, $choices, $default) + ), + ); + } +} diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php index aab0490d141f..32ef4270a091 100644 --- a/src/Illuminate/Console/View/Components/Component.php +++ b/src/Illuminate/Console/View/Components/Component.php @@ -2,16 +2,20 @@ namespace Illuminate\Console\View\Components; -use Illuminate\Support\Facades\View; +use Illuminate\Console\OutputStyle; +use Illuminate\Console\QuestionHelper; +use Illuminate\Support\Facades\Blade; +use ReflectionClass; +use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use function Termwind\render; use function Termwind\renderUsing; abstract class Component { /** - * The output instance. + * The output style implementation. * - * @var \Symfony\Component\Console\Output\OutputInterface + * @var \Illuminate\Console\OutputStyle */ protected $output; @@ -25,25 +29,14 @@ abstract class Component /** * Creates a new component instance. * - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param \Illuminate\Console\OutputStyle $output * @return void */ - protected function __construct($output) + public function __construct($output) { $this->output = $output; } - /** - * Creates a new component instance from the given output. - * - * @param \Symfony\Component\Console\Output\OutputInterface $output - * @return static - */ - public static function fromOutput($output) - { - return new static($output); - } - /** * Renders the given view. * @@ -52,23 +45,14 @@ public static function fromOutput($output) * @param int $verbosity * @return void */ - public function renderView($view, $data, $verbosity) + protected function renderView($view, $data, $verbosity) { - $this->ensureViewRequirements(); + $view = file_get_contents( + __DIR__."/../../resources/views/components/$view.blade.php" + ); renderUsing($this->output); - - render(view('illuminate.console::components.'.$view, $data), $verbosity); - } - - /** - * Ensure with view requirements, such as the namespace, are loaded. - * - * @return void - */ - protected function ensureViewRequirements() - { - View::replaceNamespace('illuminate.console', __DIR__.'/../../resources/views'); + render((string) Blade::render($view, $data), $verbosity); } /** @@ -78,7 +62,7 @@ protected function ensureViewRequirements() * @param array $mutators * @return array|string */ - public function mutate($data, $mutators) + protected function mutate($data, $mutators) { foreach ($mutators as $mutator) { if (is_iterable($data)) { @@ -92,4 +76,29 @@ public function mutate($data, $mutators) return $data; } + + /** + * Eventually performs a question using the component's question helper. + * + * @param callable $callable + * @return mixed + */ + protected function usingQuestionHelper($callable) + { + $property = with(new ReflectionClass(OutputStyle::class)) + ->getParentClass() + ->getProperty('questionHelper'); + + $currentHelper = $property->isInitialized($this->output) + ? $property->getValue($this->output) + : new SymfonyQuestionHelper(); + + $property->setValue($this->output, new QuestionHelper); + + try { + return $callable(); + } finally { + $property->setValue($this->output, $currentHelper); + } + } } diff --git a/src/Illuminate/Console/View/Components/Confirm.php b/src/Illuminate/Console/View/Components/Confirm.php new file mode 100644 index 000000000000..1d51832e557c --- /dev/null +++ b/src/Illuminate/Console/View/Components/Confirm.php @@ -0,0 +1,20 @@ +usingQuestionHelper( + fn () => $this->output->confirm($question, $default), + ); + } +} diff --git a/src/Illuminate/Console/View/Components/Error.php b/src/Illuminate/Console/View/Components/Error.php new file mode 100644 index 000000000000..73196cc8440e --- /dev/null +++ b/src/Illuminate/Console/View/Components/Error.php @@ -0,0 +1,20 @@ +output))->render('error', $string, $verbosity); + } +} diff --git a/src/Illuminate/Console/View/Components/Factory.php b/src/Illuminate/Console/View/Components/Factory.php new file mode 100644 index 000000000000..54cacba15791 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Factory.php @@ -0,0 +1,46 @@ +output = $output; + } + + /** + * Dynamically handle calls into the component instance. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \InvalidArgumentException + */ + public function __call($method, $parameters) + { + $component = '\Illuminate\Console\View\Components\\'.ucfirst($method); + + throw_unless(class_exists($component), new InvalidArgumentException(sprintf( + 'Console component [%s] not found.', $method + ))); + + return with(new $component($this->output))->render(...$parameters); + } +} diff --git a/src/Illuminate/Console/View/Components/Info.php b/src/Illuminate/Console/View/Components/Info.php new file mode 100644 index 000000000000..765142246fed --- /dev/null +++ b/src/Illuminate/Console/View/Components/Info.php @@ -0,0 +1,20 @@ +output))->render('info', $string, $verbosity); + } +} diff --git a/src/Illuminate/Console/View/Components/Line.php b/src/Illuminate/Console/View/Components/Line.php index abb297276d7d..5c701ee5aa51 100644 --- a/src/Illuminate/Console/View/Components/Line.php +++ b/src/Illuminate/Console/View/Components/Line.php @@ -18,7 +18,7 @@ class Line extends Component 'fgColor' => 'white', 'title' => 'info', ], - 'warning' => [ + 'warn' => [ 'bgColor' => 'yellow', 'fgColor' => 'black', 'title' => 'warn', @@ -28,35 +28,26 @@ class Line extends Component 'fgColor' => 'white', 'title' => 'error', ], - 'raw' => [ - 'bgColor' => 'default', - 'fgColor' => 'default', - ], ]; /** * Renders the component using the given arguments. * - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param string $style * @param string $string - * @param string|null $style * @param int $verbosity * @return void */ - public static function render($output, $string, $style, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public function render($style, $string, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - $component = static::fromOutput($output); - - $style = $style ?: 'raw'; - - $string = $component->mutate($string, [ + $string = $this->mutate($string, [ Mutators\EnsureDynamicContentIsHighlighted::class, Mutators\EnsurePunctuation::class, Mutators\EnsureRelativePaths::class, ]); - $component->renderView('line', array_merge(static::$styles[$style], [ - 'marginTop' => ($output instanceof NewLineAware && $output->newLineWritten()) ? 0 : 1, + $this->renderView('line', array_merge(static::$styles[$style], [ + 'marginTop' => ($this->output instanceof NewLineAware && $this->output->newLineWritten()) ? 0 : 1, 'content' => $string, ]), $verbosity); } diff --git a/src/Illuminate/Console/View/Components/Question.php b/src/Illuminate/Console/View/Components/Question.php new file mode 100644 index 000000000000..468c2e63224a --- /dev/null +++ b/src/Illuminate/Console/View/Components/Question.php @@ -0,0 +1 @@ +Confirm.php \ No newline at end of file diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index 2ab17454c687..33750bbef46b 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -11,17 +11,14 @@ class Task extends Component /** * Renders the component using the given arguments. * - * @param \Symfony\Component\Console\Output\OutputInterface $output * @param string $description * @param (callable(): bool)|null $task * @param int $verbosity * @return void */ - public static function render($output, $description, $task = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public function render($description, $task = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - $component = static::fromOutput($output); - - $description = $component->mutate($description, [ + $description = $this->mutate($description, [ Mutators\EnsureDynamicContentIsHighlighted::class, Mutators\EnsureNoPunctuation::class, Mutators\EnsureRelativePaths::class, @@ -31,7 +28,7 @@ public static function render($output, $description, $task = null, $verbosity = $descriptionWidth = mb_strlen(preg_replace("/\<[\w=#\/\;,:.&,%?]+\>|\\e\[\d+m/", '$1', $description) ?? ''); - $output->write(" $description ", false, $verbosity); + $this->output->write(" $description ", false, $verbosity); $startTime = microtime(true); @@ -48,10 +45,10 @@ public static function render($output, $description, $task = null, $verbosity = $runTimeWidth = mb_strlen($runTime); $dots = max(terminal()->width() - $descriptionWidth - $runTimeWidth - 10, 0); - $output->write(str_repeat('.', $dots), false, $verbosity); - $output->write("$runTime", false, $verbosity); + $this->output->write(str_repeat('.', $dots), false, $verbosity); + $this->output->write("$runTime", false, $verbosity); - $output->writeln( + $this->output->writeln( $result !== false ? ' DONE' : ' FAIL', $verbosity, ); diff --git a/src/Illuminate/Console/View/Components/TwoColumnDetail.php b/src/Illuminate/Console/View/Components/TwoColumnDetail.php index 6ae46f9e19f5..1ffa089373ed 100644 --- a/src/Illuminate/Console/View/Components/TwoColumnDetail.php +++ b/src/Illuminate/Console/View/Components/TwoColumnDetail.php @@ -9,31 +9,28 @@ class TwoColumnDetail extends Component /** * Renders the component using the given arguments. * - * @param \Symfony\Component\Console\Output\OutputInterface $output - * @param string $left - * @param string|null $right + * @param string $first + * @param string|null $second * @param int $verbosity * @return void */ - public static function render($output, $left, $right = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) + public function render($first, $second = null, $verbosity = OutputInterface::VERBOSITY_NORMAL) { - $component = static::fromOutput($output); - - $left = $component->mutate($left, [ + $first = $this->mutate($first, [ Mutators\EnsureDynamicContentIsHighlighted::class, Mutators\EnsureNoPunctuation::class, Mutators\EnsureRelativePaths::class, ]); - $right = $component->mutate($right, [ + $second = $this->mutate($second, [ Mutators\EnsureDynamicContentIsHighlighted::class, Mutators\EnsureNoPunctuation::class, Mutators\EnsureRelativePaths::class, ]); - $component->renderView('two-column-detail', [ - 'left' => $left, - 'right' => $right, + $this->renderView('two-column-detail', [ + 'first' => $first, + 'second' => $second, ], $verbosity); } } diff --git a/src/Illuminate/Console/View/Components/Warn.php b/src/Illuminate/Console/View/Components/Warn.php new file mode 100644 index 000000000000..20adb1f272b7 --- /dev/null +++ b/src/Illuminate/Console/View/Components/Warn.php @@ -0,0 +1,21 @@ +output)) + ->render('warn', $string, $verbosity); + } +} diff --git a/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php b/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php index 63210f35c7f7..a61a7534240d 100644 --- a/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php +++ b/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php @@ -1,11 +1,11 @@
- {{ $left }} + {{ $first }} - @if ($right !== '') + @if ($second !== '') - {{ $right }} + {{ $second }} @endif
diff --git a/src/Illuminate/Database/Console/DumpCommand.php b/src/Illuminate/Database/Console/DumpCommand.php index d13887e0d299..50a6ad076454 100644 --- a/src/Illuminate/Database/Console/DumpCommand.php +++ b/src/Illuminate/Database/Console/DumpCommand.php @@ -69,7 +69,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis $info .= ' and pruned'; } - $this->info($info.' successfully.'); + $this->components->info($info.' successfully.'); } /** diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index fd88f6b4a727..46e5b22ed8dc 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -42,7 +42,7 @@ public function handle() $this->newLine(); - Task::render($this->output, 'Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ + $this->components->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ '--database' => $database, '--drop-views' => $this->option('drop-views'), '--drop-types' => $this->option('drop-types'), diff --git a/src/Illuminate/Database/Console/Migrations/InstallCommand.php b/src/Illuminate/Database/Console/Migrations/InstallCommand.php index d69c2ab6b5aa..901a83babb30 100755 --- a/src/Illuminate/Database/Console/Migrations/InstallCommand.php +++ b/src/Illuminate/Database/Console/Migrations/InstallCommand.php @@ -53,7 +53,7 @@ public function handle() $this->repository->createRepository(); - $this->info('Migration table created successfully.'); + $this->components->info('Migration table created successfully.'); } /** diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 13709ec5afa1..6c813397001e 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -109,9 +109,9 @@ public function handle() protected function prepareDatabase() { if (! $this->migrator->repositoryExists()) { - $this->info('Preparing database.'); + $this->components->info('Preparing database.'); - Task::render($this->output, 'Creating migration table', function () { + $this->components->task('Creating migration table', function () { return $this->callSilent('migrate:install', array_filter([ '--database' => $this->option('database'), ])) == 0; @@ -142,9 +142,9 @@ protected function loadSchemaState() return; } - $this->info('Preparing database.'); + $this->components->info('Preparing database.'); - Task::render($this->output, "Loading stored database schema [$path].", function () use ($connection, $path) { + $this->components->task("Loading stored database schema [$path].", function () use ($connection, $path) { // Since the schema file will create the "migrations" table and reload it to its // proper state, we need to delete it here so we don't get an error that this // table already exists when the stored database schema file gets executed. diff --git a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php index 5d4aa6352df1..c1f070e7ec85 100644 --- a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php @@ -114,7 +114,7 @@ protected function writeMigration($name, $table, $create) $file = pathinfo($file, PATHINFO_FILENAME); } - $this->info(sprintf('Created migration [%s].', $file)); + $this->components->info(sprintf('Created migration [%s].', $file)); } /** diff --git a/src/Illuminate/Database/Console/Migrations/ResetCommand.php b/src/Illuminate/Database/Console/Migrations/ResetCommand.php index 83f19deccb98..c5952fa0532a 100755 --- a/src/Illuminate/Database/Console/Migrations/ResetCommand.php +++ b/src/Illuminate/Database/Console/Migrations/ResetCommand.php @@ -60,7 +60,7 @@ public function handle() // start trying to rollback and re-run all of the migrations. If it's not // present we'll just bail out with an info message for the developers. if (! $this->migrator->repositoryExists()) { - return $this->warn('Migration table not found.'); + return $this->components->warn('Migration table not found.'); } $this->migrator->setOutput($this->output)->reset( diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index dcd917074937..59c1037b2f0a 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -52,7 +52,7 @@ public function handle() { return $this->migrator->usingConnection($this->option('database'), function () { if (! $this->migrator->repositoryExists()) { - $this->error('Migration table not found.'); + $this->components->error('Migration table not found.'); return 1; } @@ -64,14 +64,15 @@ public function handle() if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { $this->newLine(); - TwoColumnDetail::render($this->output, 'Migration name', 'Batch / Status'); + $this->components->twoColumnDetail('Migration name', 'Batch / Status'); $migrations->each( - fn ($migration) => TwoColumnDetail::render($this->output, $migration[0], $migration[1]) + fn ($migration) => $this->components->twoColumnDetail($migration[0], $migration[1]) ); + $this->newLine(); } else { - $this->info('No migrations found'); + $this->components->info('No migrations found'); } }); } diff --git a/src/Illuminate/Database/Console/PruneCommand.php b/src/Illuminate/Database/Console/PruneCommand.php index b69aa86849d7..718f09aa7862 100644 --- a/src/Illuminate/Database/Console/PruneCommand.php +++ b/src/Illuminate/Database/Console/PruneCommand.php @@ -43,7 +43,7 @@ public function handle(Dispatcher $events) $models = $this->models(); if ($models->isEmpty()) { - $this->info('No prunable models found.'); + $this->components->info('No prunable models found.'); return; } @@ -57,7 +57,7 @@ public function handle(Dispatcher $events) } $events->listen(ModelsPruned::class, function ($event) { - $this->info("{$event->count} [{$event->model}] records have been pruned."); + $this->components->info("{$event->count} [{$event->model}] records have been pruned."); }); $models->each(function ($model) { @@ -72,7 +72,7 @@ public function handle(Dispatcher $events) : 0; if ($total == 0) { - $this->info("No prunable [$model] records found."); + $this->components->info("No prunable [$model] records found."); } }); @@ -157,9 +157,9 @@ protected function pretendToPrune($model) })->count(); if ($count === 0) { - $this->info("No prunable [$model] records found."); + $this->components->info("No prunable [$model] records found."); } else { - $this->info("{$count} [{$model}] records will be pruned."); + $this->components->info("{$count} [{$model}] records will be pruned."); } } } diff --git a/src/Illuminate/Database/Console/Seeds/SeedCommand.php b/src/Illuminate/Database/Console/Seeds/SeedCommand.php index f64af58354c3..0ebc26f77f78 100644 --- a/src/Illuminate/Database/Console/Seeds/SeedCommand.php +++ b/src/Illuminate/Database/Console/Seeds/SeedCommand.php @@ -83,7 +83,7 @@ public function handle() $this->resolver->setDefaultConnection($previousConnection); } - $this->info('Database seeding completed successfully.'); + $this->components->info('Database seeding completed successfully.'); return 0; } diff --git a/src/Illuminate/Database/Console/WipeCommand.php b/src/Illuminate/Database/Console/WipeCommand.php index 0227782fa0c0..cb269229f9d5 100644 --- a/src/Illuminate/Database/Console/WipeCommand.php +++ b/src/Illuminate/Database/Console/WipeCommand.php @@ -53,17 +53,17 @@ public function handle() if ($this->option('drop-views')) { $this->dropAllViews($database); - $this->info('Dropped all views successfully.'); + $this->components->info('Dropped all views successfully.'); } $this->dropAllTables($database); - $this->info('Dropped all tables successfully.'); + $this->components->info('Dropped all tables successfully.'); if ($this->option('drop-types')) { $this->dropAllTypes($database); - $this->info('Dropped all types successfully.'); + $this->components->info('Dropped all types successfully.'); } return 0; diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 5b10386f5532..2d7f60f91aec 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -4,7 +4,8 @@ use Doctrine\DBAL\Schema\SchemaException; use Illuminate\Console\View\Components\BulletList; -use Illuminate\Console\View\Components\Line; +use Illuminate\Console\View\Components\Info; +use Illuminate\Console\View\Components\Error; use Illuminate\Console\View\Components\Task; use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Events\Dispatcher; @@ -20,6 +21,7 @@ use Illuminate\Support\Str; use ReflectionClass; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\ArrayInput; class Migrator { @@ -148,7 +150,7 @@ public function runPending(array $migrations, array $options = []) if (count($migrations) === 0) { $this->fireMigrationEvent(new NoPendingMigrations('up')); - $this->write(Line::class, 'Nothing to migrate', 'info'); + $this->write(Info::class, 'Nothing to migrate'); return; } @@ -164,7 +166,7 @@ public function runPending(array $migrations, array $options = []) $this->fireMigrationEvent(new MigrationsStarted('up')); - $this->write(Line::class, 'Running migrations.', 'info'); + $this->write(Info::class, 'Running migrations.'); // Once we have the array of migrations, we will spin through them and run the // migrations "up" so the changes are made to the databases. We'll then log @@ -226,7 +228,7 @@ public function rollback($paths = [], array $options = []) if (count($migrations) === 0) { $this->fireMigrationEvent(new NoPendingMigrations('down')); - $this->write(Line::class, 'Nothing to rollback.', 'info'); + $this->write(Info::class, 'Nothing to rollback.'); return []; } @@ -265,7 +267,7 @@ protected function rollbackMigrations(array $migrations, $paths, array $options) $this->fireMigrationEvent(new MigrationsStarted('down')); - $this->write(Line::class, 'Rollbacking migrations.', 'info'); + $this->write(Info::class, 'Rollbacking migrations.'); // Next we will run through all of the migrations and call the "down" method // which will reverse each migration in order. This getLast method on the @@ -307,7 +309,7 @@ public function reset($paths = [], $pretend = false) $migrations = array_reverse($this->repository->getRan()); if (count($migrations) === 0) { - $this->write(Line::class, 'Nothing to rollback.', 'info'); + $this->write(Info::class, 'Nothing to rollback.'); return []; } @@ -420,10 +422,10 @@ protected function pretendToRun($migration, $method) } catch (SchemaException $e) { $name = get_class($migration); - $this->write(Line::class, sprintf( + $this->write(Error::class, sprintf( '[%s] failed to dump queries. This may be due to changing database columns using Doctrine, which is not supported while pretending to run migrations.', $name, - ), 'error'); + )); } } @@ -722,7 +724,7 @@ public function setOutput(OutputInterface $output) protected function write($component, ...$arguments) { if ($this->output) { - $component::render($this->output, ...$arguments); + with(new $component($this->output))->render(...$arguments); } } diff --git a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php b/src/Illuminate/Foundation/Console/ClearCompiledCommand.php index ec355e859d09..20375ded17a6 100644 --- a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php +++ b/src/Illuminate/Foundation/Console/ClearCompiledCommand.php @@ -48,6 +48,6 @@ public function handle() @unlink($packagesPath); } - $this->info('Compiled services and packages files removed successfully.'); + $this->components->info('Compiled services and packages files removed successfully.'); } } diff --git a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php index 49dd9294ec9e..6134d9ae1d13 100644 --- a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php @@ -52,7 +52,7 @@ public function handle() { if ($this->option('view')) { $this->writeView(function () { - $this->info($this->type.' created successfully.'); + $this->components->info($this->type.' created successfully.'); }); return; @@ -84,7 +84,7 @@ protected function writeView($onSuccess = null) } if ($this->files->exists($path) && ! $this->option('force')) { - $this->error('View already exists.'); + $this->components->error('View already exists.'); return; } diff --git a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php index 4c23b8e16be4..18eec46c0f5c 100644 --- a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php @@ -84,7 +84,7 @@ public function handle() throw new LogicException('Your configuration files are not serializable.', 0, $e); } - $this->info('Configuration cached successfully.'); + $this->components->info('Configuration cached successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/ConfigClearCommand.php b/src/Illuminate/Foundation/Console/ConfigClearCommand.php index cb24bac671c8..3e07e9be9a4a 100644 --- a/src/Illuminate/Foundation/Console/ConfigClearCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigClearCommand.php @@ -63,6 +63,6 @@ public function handle() { $this->files->delete($this->laravel->getCachedConfigPath()); - $this->info('Configuration cache cleared successfully.'); + $this->components->info('Configuration cache cleared successfully.'); } } diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index ff3ec9d8e86b..ac7392fee800 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -52,7 +52,7 @@ public function handle() { try { if ($this->laravel->maintenanceMode()->active()) { - $this->info('Application is already down.'); + $this->components->info('Application is already down.'); return 0; } @@ -66,9 +66,9 @@ public function handle() $this->laravel->get('events')->dispatch(MaintenanceModeEnabled::class); - $this->info('Application is now in maintenance mode.'); + $this->components->info('Application is now in maintenance mode.'); } catch (Exception $e) { - $this->error(sprintf( + $this->components->error(sprintf( 'Failed to enter maintenance mode: %s.', $e->getMessage(), )); diff --git a/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/src/Illuminate/Foundation/Console/EnvironmentCommand.php index 73d1ffd0b540..53d66a12ab08 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -40,7 +40,7 @@ class EnvironmentCommand extends Command */ public function handle() { - $this->info(sprintf( + $this->components->info(sprintf( 'The application is on [%s] environment.', $this->laravel['env'], )); diff --git a/src/Illuminate/Foundation/Console/EventCacheCommand.php b/src/Illuminate/Foundation/Console/EventCacheCommand.php index 299a7bfc1694..df42fbfd1d65 100644 --- a/src/Illuminate/Foundation/Console/EventCacheCommand.php +++ b/src/Illuminate/Foundation/Console/EventCacheCommand.php @@ -48,7 +48,7 @@ public function handle() 'getEvents(), true).';' ); - $this->info('Events cached successfully.'); + $this->components->info('Events cached successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/EventClearCommand.php b/src/Illuminate/Foundation/Console/EventClearCommand.php index 83de371b9362..a5c8ed1937bb 100644 --- a/src/Illuminate/Foundation/Console/EventClearCommand.php +++ b/src/Illuminate/Foundation/Console/EventClearCommand.php @@ -65,6 +65,6 @@ public function handle() { $this->files->delete($this->laravel->getCachedEventsPath()); - $this->info('Cached events cleared successfully.'); + $this->components->info('Cached events cleared successfully.'); } } diff --git a/src/Illuminate/Foundation/Console/EventGenerateCommand.php b/src/Illuminate/Foundation/Console/EventGenerateCommand.php index 307141f7d366..b27e9dbb0c82 100644 --- a/src/Illuminate/Foundation/Console/EventGenerateCommand.php +++ b/src/Illuminate/Foundation/Console/EventGenerateCommand.php @@ -49,7 +49,7 @@ public function handle() } } - $this->info('Events and listeners generated successfully.'); + $this->components->info('Events and listeners generated successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index 4ac83df03282..eb06260cef7f 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -56,7 +56,7 @@ public function handle() $events = $this->getEvents()->sortKeys(); if ($events->isEmpty()) { - $this->comment("Your application doesn't have any events matching the given criteria."); + $this->components->info("Your application doesn't have any events matching the given criteria."); return; } @@ -64,8 +64,8 @@ public function handle() $this->newLine(); $events->each(function ($listeners, $event) { - TwoColumnDetail::render($this->output, $this->appendEventInterfaces($event)); - BulletList::render($this->output, $listeners); + $this->components->twoColumnDetail($this->appendEventInterfaces($event)); + $this->components->bulletList($listeners); }); $this->newLine(); diff --git a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php index 48241c4042f1..afd3eebddbcc 100644 --- a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php +++ b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php @@ -61,7 +61,7 @@ public function handle() $this->laravel['config']['app.key'] = $key; - $this->info('Application key set successfully.'); + $this->components->info('Application key set successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index e8aa5a7c4adf..d798576b7afc 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -41,7 +41,7 @@ class OptimizeClearCommand extends Command */ public function handle() { - $this->info('Removing cached bootstrap files'); + $this->components->info('Removing cached bootstrap files'); collect([ 'events' => fn () => $this->callSilent('event:clear') == 0, @@ -50,9 +50,7 @@ public function handle() 'route' => fn () => $this->callSilent('route:clear') == 0, 'config' => fn () => $this->callSilent('config:clear') == 0, 'compiled' => fn () => $this->callSilent('clear-compiled') == 0, - ])->each(fn ($task, $description) => Task::render( - $this->output, $description, $task, - )); + ])->each(fn ($task, $description) => $this->components->task($description, $task)); $this->newLine(); } diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 75cc02ca87f2..b8c3b20816a0 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -41,14 +41,12 @@ class OptimizeCommand extends Command */ public function handle() { - $this->info('Caching the framework bootstrap files'); + $this->components->info('Caching the framework bootstrap files'); collect([ 'config' => fn () => $this->callSilent('config:cache') == 0, 'routes' => fn () => $this->callSilent('route:cache') == 0, - ])->each(fn ($task, $description) => Task::render( - $this->output, $description, $task, - )); + ])->each(fn ($task, $description) => $this->components->task($description, $task)); $this->newLine(); } diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index c7d9e8e67d13..f690823cfc9a 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -43,15 +43,13 @@ class PackageDiscoverCommand extends Command */ public function handle(PackageManifest $manifest) { - $this->info('Discovering packages'); + $this->components->info('Discovering packages'); $manifest->build(); collect($manifest->manifest) ->map(fn () => fn () => true) - ->each(fn ($task, $description) => Task::render( - $this->output, $description, $task, - )); + ->each(fn ($task, $description) => $this->components->task($description, $task)); $this->newLine(); } diff --git a/src/Illuminate/Foundation/Console/RouteCacheCommand.php b/src/Illuminate/Foundation/Console/RouteCacheCommand.php index 5a5c9329df7b..00f4050c4572 100644 --- a/src/Illuminate/Foundation/Console/RouteCacheCommand.php +++ b/src/Illuminate/Foundation/Console/RouteCacheCommand.php @@ -68,7 +68,7 @@ public function handle() $routes = $this->getFreshApplicationRoutes(); if (count($routes) === 0) { - return $this->error("Your application doesn't have any routes."); + return $this->components->error("Your application doesn't have any routes."); } foreach ($routes as $route) { @@ -79,7 +79,7 @@ public function handle() $this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($routes) ); - $this->info('Routes cached successfully.'); + $this->components->info('Routes cached successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/RouteClearCommand.php b/src/Illuminate/Foundation/Console/RouteClearCommand.php index 0892a6686f6f..da45e6d80f1c 100644 --- a/src/Illuminate/Foundation/Console/RouteClearCommand.php +++ b/src/Illuminate/Foundation/Console/RouteClearCommand.php @@ -63,6 +63,6 @@ public function handle() { $this->files->delete($this->laravel->getCachedRoutesPath()); - $this->info('Route cache cleared successfully.'); + $this->components->info('Route cache cleared successfully.'); } } diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index e89cc6645896..caa81652cea9 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -104,11 +104,11 @@ public function handle() $this->router->flushMiddlewareGroups(); if (! $this->router->getRoutes()->count()) { - return $this->error("Your application doesn't have any routes."); + return $this->components->error("Your application doesn't have any routes."); } if (empty($routes = $this->getRoutes())) { - return $this->error("Your application doesn't have any routes matching the given criteria."); + return $this->components->error("Your application doesn't have any routes matching the given criteria."); } $this->displayRoutes($routes); diff --git a/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/src/Illuminate/Foundation/Console/StorageLinkCommand.php index a23e8d6c0942..10427557bff9 100644 --- a/src/Illuminate/Foundation/Console/StorageLinkCommand.php +++ b/src/Illuminate/Foundation/Console/StorageLinkCommand.php @@ -46,7 +46,7 @@ public function handle() foreach ($this->links() as $link => $target) { if (file_exists($link) && ! $this->isRemovableSymlink($link, $this->option('force'))) { - $this->error("The [$link] link already exists."); + $this->components->error("The [$link] link already exists."); continue; } @@ -60,7 +60,7 @@ public function handle() $this->laravel->make('files')->link($target, $link); } - $this->info("The [$link] link has been connected to [$target]."); + $this->components->info("The [$link] link has been connected to [$target]."); } } diff --git a/src/Illuminate/Foundation/Console/StubPublishCommand.php b/src/Illuminate/Foundation/Console/StubPublishCommand.php index ada13946162b..9886e0b3f598 100644 --- a/src/Illuminate/Foundation/Console/StubPublishCommand.php +++ b/src/Illuminate/Foundation/Console/StubPublishCommand.php @@ -93,6 +93,6 @@ public function handle() } } - $this->info('Stubs published successfully.'); + $this->components->info('Stubs published successfully.'); } } diff --git a/src/Illuminate/Foundation/Console/UpCommand.php b/src/Illuminate/Foundation/Console/UpCommand.php index e01f96755281..1562cbfea535 100644 --- a/src/Illuminate/Foundation/Console/UpCommand.php +++ b/src/Illuminate/Foundation/Console/UpCommand.php @@ -44,7 +44,7 @@ public function handle() { try { if (! $this->laravel->maintenanceMode()->active()) { - $this->info('Application is already up.'); + $this->components->info('Application is already up.'); return 0; } @@ -57,9 +57,9 @@ public function handle() $this->laravel->get('events')->dispatch(MaintenanceModeDisabled::class); - $this->info('Application is now live.'); + $this->components->info('Application is now live.'); } catch (Exception $e) { - $this->error(sprintf( + $this->components->error(sprintf( 'Failed to disable maintenance mode: %s.', $e->getMessage(), )); diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 621a75f28826..c1e13076e8e7 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -123,7 +123,7 @@ protected function determineWhatShouldBePublished() */ protected function promptForProviderOrTag() { - $choice = $this->choice( + $choice = $this->components->choice( "Which provider or tag's files would you like to publish?", $choices = $this->publishableChoices() ); @@ -179,7 +179,7 @@ protected function publishTag($tag) $pathsToPublish = $this->pathsToPublish($tag); if ($publishing = count($pathsToPublish) > 0) { - $this->info(sprintf( + $this->components->info(sprintf( 'Publishing %sassets', $tag ? "[$tag] " : '', )); @@ -190,7 +190,7 @@ protected function publishTag($tag) } if ($publishing === false) { - $this->info('No publishable resources for tag ['.$tag.'].'); + $this->components->info('No publishable resources for tag ['.$tag.'].'); } else { $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish)); @@ -226,7 +226,7 @@ protected function publishItem($from, $to) return $this->publishDirectory($from, $to); } - $this->error("Can't locate path: <{$from}>"); + $this->components->error("Can't locate path: <{$from}>"); } /** @@ -245,7 +245,7 @@ protected function publishFile($from, $to) $this->status($from, $to, 'file'); } else { - TwoColumnDetail::render($this->output, sprintf( + $this->components->twoColumnDetail(sprintf( 'File [%s] already exist', str_replace(base_path().'/', '', realpath($to)), )); @@ -315,7 +315,7 @@ protected function status($from, $to, $type) $to = str_replace(base_path().'/', '', realpath($to)); - Task::render($this->output, sprintf( + $this->components->task(sprintf( 'Copying %s [%s] to [%s]', $type, $from, diff --git a/src/Illuminate/Foundation/Console/ViewCacheCommand.php b/src/Illuminate/Foundation/Console/ViewCacheCommand.php index c0661a762317..f3f1282f622e 100644 --- a/src/Illuminate/Foundation/Console/ViewCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ViewCacheCommand.php @@ -49,7 +49,7 @@ public function handle() $this->compileViews($this->bladeFilesIn([$path])); }); - $this->info('Blade templates cached successfully.'); + $this->components->info('Blade templates cached successfully.'); } /** diff --git a/src/Illuminate/Foundation/Console/ViewClearCommand.php b/src/Illuminate/Foundation/Console/ViewClearCommand.php index 9aed80bb75b1..8a96fd8abbff 100644 --- a/src/Illuminate/Foundation/Console/ViewClearCommand.php +++ b/src/Illuminate/Foundation/Console/ViewClearCommand.php @@ -74,6 +74,6 @@ public function handle() $this->files->delete($view); } - $this->info('Compiled views cleared successfully.'); + $this->components->info('Compiled views cleared successfully.'); } } diff --git a/src/Illuminate/Notifications/Console/NotificationTableCommand.php b/src/Illuminate/Notifications/Console/NotificationTableCommand.php index 7dd89d438aa5..a0161ce6b7c9 100644 --- a/src/Illuminate/Notifications/Console/NotificationTableCommand.php +++ b/src/Illuminate/Notifications/Console/NotificationTableCommand.php @@ -73,7 +73,7 @@ public function handle() $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/notifications.stub')); - $this->info('Migration created successfully.'); + $this->components->info('Migration created successfully.'); $this->composer->dumpAutoloads(); } diff --git a/src/Illuminate/Queue/Console/BatchesTableCommand.php b/src/Illuminate/Queue/Console/BatchesTableCommand.php index 8c8708ae3c17..c1ce2d9bb474 100644 --- a/src/Illuminate/Queue/Console/BatchesTableCommand.php +++ b/src/Illuminate/Queue/Console/BatchesTableCommand.php @@ -75,7 +75,7 @@ public function handle() $this->createBaseMigration($table), $table ); - $this->info('Migration created successfully.'); + $this->components->info('Migration created successfully.'); $this->composer->dumpAutoloads(); } diff --git a/src/Illuminate/Queue/Console/ClearCommand.php b/src/Illuminate/Queue/Console/ClearCommand.php index 030646609f90..cd3ebb48bd81 100644 --- a/src/Illuminate/Queue/Console/ClearCommand.php +++ b/src/Illuminate/Queue/Console/ClearCommand.php @@ -64,9 +64,9 @@ public function handle() if ($queue instanceof ClearableQueue) { $count = $queue->clear($queueName); - $this->info('Cleared '.$count.' jobs from the ['.$queueName.'] queue'); + $this->components->info('Cleared '.$count.' jobs from the ['.$queueName.'] queue'); } else { - $this->error('Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().']'); + $this->components->error('Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().']'); } return 0; diff --git a/src/Illuminate/Queue/Console/FailedTableCommand.php b/src/Illuminate/Queue/Console/FailedTableCommand.php index 2996134c6b21..f3f20ccaf19b 100644 --- a/src/Illuminate/Queue/Console/FailedTableCommand.php +++ b/src/Illuminate/Queue/Console/FailedTableCommand.php @@ -75,7 +75,7 @@ public function handle() $this->createBaseMigration($table), $table ); - $this->info('Migration created successfully.'); + $this->components->info('Migration created successfully.'); $this->composer->dumpAutoloads(); } diff --git a/src/Illuminate/Queue/Console/FlushFailedCommand.php b/src/Illuminate/Queue/Console/FlushFailedCommand.php index 085f7734268e..86a5d16c87a5 100644 --- a/src/Illuminate/Queue/Console/FlushFailedCommand.php +++ b/src/Illuminate/Queue/Console/FlushFailedCommand.php @@ -43,11 +43,11 @@ public function handle() $this->laravel['queue.failer']->flush($this->option('hours')); if ($this->option('hours')) { - $this->info("All jobs that failed more than {$this->option('hours')} hours ago have been deleted successfully."); + $this->components->info("All jobs that failed more than {$this->option('hours')} hours ago have been deleted successfully."); return; } - $this->info('All failed jobs deleted successfully.'); + $this->components->info('All failed jobs deleted successfully.'); } } diff --git a/src/Illuminate/Queue/Console/ForgetFailedCommand.php b/src/Illuminate/Queue/Console/ForgetFailedCommand.php index eed4d9ca2e90..f4625e113053 100644 --- a/src/Illuminate/Queue/Console/ForgetFailedCommand.php +++ b/src/Illuminate/Queue/Console/ForgetFailedCommand.php @@ -41,9 +41,9 @@ class ForgetFailedCommand extends Command public function handle() { if ($this->laravel['queue.failer']->forget($this->argument('id'))) { - $this->info('Failed job deleted successfully.'); + $this->components->info('Failed job deleted successfully.'); } else { - $this->error('No failed job matches the given ID.'); + $this->components->error('No failed job matches the given ID.'); } } } diff --git a/src/Illuminate/Queue/Console/ListFailedCommand.php b/src/Illuminate/Queue/Console/ListFailedCommand.php index 656ea96d8fbc..2af383c46963 100644 --- a/src/Illuminate/Queue/Console/ListFailedCommand.php +++ b/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -49,7 +49,7 @@ class ListFailedCommand extends Command public function handle() { if (count($jobs = $this->getFailedJobs()) === 0) { - return $this->info('No failed jobs found.'); + return $this->components->info('No failed jobs found.'); } $this->displayFailedJobs($jobs); diff --git a/src/Illuminate/Queue/Console/ListenCommand.php b/src/Illuminate/Queue/Console/ListenCommand.php index 247533dc939b..275905eb017b 100755 --- a/src/Illuminate/Queue/Console/ListenCommand.php +++ b/src/Illuminate/Queue/Console/ListenCommand.php @@ -79,7 +79,7 @@ public function handle() $connection = $this->input->getArgument('connection') ); - $this->info(sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue)))); + $this->components->info(sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue)))); $this->listener->listen( $connection, $queue, $this->gatherOptions() diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index 34189760eb95..b3f8fc7c6c4a 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -125,12 +125,12 @@ protected function displaySizes(Collection $queues) { $this->newLine(); - TwoColumnDetail::render($this->output, 'Queue name', 'Size / Status'); + $this->components->twoColumnDetail('Queue name', 'Size / Status'); $queues->each(function ($queue) { $status = '['.$queue['size'].'] '.$queue['status']; - TwoColumnDetail::render($this->output, $queue['queue'], $status); + $this->components->twoColumnDetail($queue['queue'], $status); }); $this->newLine(); diff --git a/src/Illuminate/Queue/Console/PruneBatchesCommand.php b/src/Illuminate/Queue/Console/PruneBatchesCommand.php index 5c13dd23d209..e8a292d34aca 100644 --- a/src/Illuminate/Queue/Console/PruneBatchesCommand.php +++ b/src/Illuminate/Queue/Console/PruneBatchesCommand.php @@ -54,7 +54,7 @@ public function handle() $count = $repository->prune(Carbon::now()->subHours($this->option('hours'))); } - $this->info("{$count} entries deleted."); + $this->components->info("{$count} entries deleted."); if ($this->option('unfinished')) { $count = 0; @@ -63,7 +63,7 @@ public function handle() $count = $repository->pruneUnfinished(Carbon::now()->subHours($this->option('unfinished'))); } - $this->info("{$count} unfinished entries deleted."); + $this->components->info("{$count} unfinished entries deleted."); } } } diff --git a/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php b/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php index 644a1f280ede..61f7903b5f11 100644 --- a/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php +++ b/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php @@ -48,11 +48,11 @@ public function handle() if ($failer instanceof PrunableFailedJobProvider) { $count = $failer->prune(Carbon::now()->subHours($this->option('hours'))); } else { - $this->error('The ['.class_basename($failer).'] failed job storage driver does not support pruning.'); + $this->components->error('The ['.class_basename($failer).'] failed job storage driver does not support pruning.'); return 1; } - $this->info("{$count} entries deleted."); + $this->components->info("{$count} entries deleted."); } } diff --git a/src/Illuminate/Queue/Console/RestartCommand.php b/src/Illuminate/Queue/Console/RestartCommand.php index b104931c82f5..6dfbcb1fa69a 100644 --- a/src/Illuminate/Queue/Console/RestartCommand.php +++ b/src/Illuminate/Queue/Console/RestartCommand.php @@ -66,6 +66,6 @@ public function handle() { $this->cache->forever('illuminate:queue:restart', $this->currentTime()); - $this->info('Broadcasting queue restart signal.'); + $this->components->info('Broadcasting queue restart signal.'); } } diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index f966b1a8830e..f1d741a55ce1 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -45,19 +45,19 @@ public function handle() $batch = $this->laravel[BatchRepository::class]->find($id = $this->argument('id')); if (! $batch) { - $this->error("Unable to find a batch with ID [{$id}]."); + $this->components->error("Unable to find a batch with ID [{$id}]."); return 1; } elseif (empty($batch->failedJobIds)) { - $this->error('The given batch does not contain any failed jobs.'); + $this->components->error('The given batch does not contain any failed jobs.'); return 1; } - $this->info("Retrying the failed jobs for a batch [$id]."); + $this->components->info("Retrying the failed jobs for a batch [$id]."); foreach ($batch->failedJobIds as $failedJobId) { - Task::render($this->output, $failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); + $this->components->task($failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); } $this->newLine(); diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 85b14a7b3ac3..3c83c22e37ae 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -52,24 +52,24 @@ public function handle() $jobsFound = count($ids = $this->getJobIds()) > 0; if ($jobsFound) { - $this->info('Retrying failed queue jobs.'); + $this->components->info('Retrying failed queue jobs.'); } foreach ($ids as $id) { $job = $this->laravel['queue.failer']->find($id); if (is_null($job)) { - $this->error("Unable to find failed job with ID [{$id}]."); + $this->components->error("Unable to find failed job with ID [{$id}]."); } else { $this->laravel['events']->dispatch(new JobRetryRequested($job)); - Task::render($this->output, $id, fn () => $this->retryJob($job)); + $this->components->task($id, fn () => $this->retryJob($job)); $this->laravel['queue.failer']->forget($id); } } - $jobsFound ? $this->newLine() : $this->info('No retryable jobs found.'); + $jobsFound ? $this->newLine() : $this->components->info('No retryable jobs found.'); } /** @@ -110,7 +110,7 @@ protected function getJobIdsByQueue($queue) ->toArray(); if (count($ids) === 0) { - $this->error("Unable to find failed jobs for queue [{$queue}]."); + $this->components->error("Unable to find failed jobs for queue [{$queue}]."); } return $ids; diff --git a/src/Illuminate/Queue/Console/TableCommand.php b/src/Illuminate/Queue/Console/TableCommand.php index 8abb1e5d3a86..aa25dafeb448 100644 --- a/src/Illuminate/Queue/Console/TableCommand.php +++ b/src/Illuminate/Queue/Console/TableCommand.php @@ -75,7 +75,7 @@ public function handle() $this->createBaseMigration($table), $table ); - $this->info('Migration created successfully.'); + $this->components->info('Migration created successfully.'); $this->composer->dumpAutoloads(); } diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 19595e5cc035..5c9ae70741e3 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -118,7 +118,9 @@ public function handle() // connection being run for the queue operation currently being executed. $queue = $this->getQueue($connection); - $this->info(sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue)))); + $this->components->info( + sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue))) + ); return $this->runWorker( $connection, $queue diff --git a/src/Illuminate/Routing/Console/ControllerMakeCommand.php b/src/Illuminate/Routing/Console/ControllerMakeCommand.php index 6bec7f4da60e..59dc55fbe5f4 100755 --- a/src/Illuminate/Routing/Console/ControllerMakeCommand.php +++ b/src/Illuminate/Routing/Console/ControllerMakeCommand.php @@ -140,7 +140,7 @@ protected function buildParentReplacements() $parentModelClass = $this->parseModel($this->option('parent')); if (! class_exists($parentModelClass) && - $this->confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", true)) { + $this->components->confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", true)) { $this->call('make:model', ['name' => $parentModelClass]); } @@ -167,7 +167,7 @@ protected function buildModelReplacements(array $replace) { $modelClass = $this->parseModel($this->option('model')); - if (! class_exists($modelClass) && $this->confirm("A {$modelClass} model does not exist. Do you want to generate it?", true)) { + if (! class_exists($modelClass) && $this->components->confirm("A {$modelClass} model does not exist. Do you want to generate it?", true)) { $this->call('make:model', ['name' => $modelClass]); } diff --git a/src/Illuminate/Session/Console/SessionTableCommand.php b/src/Illuminate/Session/Console/SessionTableCommand.php index 04fa8c5fb84a..e44b2da71238 100644 --- a/src/Illuminate/Session/Console/SessionTableCommand.php +++ b/src/Illuminate/Session/Console/SessionTableCommand.php @@ -73,7 +73,7 @@ public function handle() $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/database.stub')); - $this->info('Migration created successfully.'); + $this->components->info('Migration created successfully.'); $this->composer->dumpAutoloads(); } From c3060624f9952281c205c4f117a9e5652ff09812 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 7 Jul 2022 17:38:45 +0000 Subject: [PATCH 061/101] Apply fixes from StyleCI --- src/Illuminate/Database/Console/Migrations/FreshCommand.php | 1 - src/Illuminate/Database/Console/Migrations/StatusCommand.php | 1 - src/Illuminate/Database/Migrations/Migrator.php | 3 +-- src/Illuminate/Foundation/Console/EventListCommand.php | 2 -- src/Illuminate/Foundation/Console/OptimizeClearCommand.php | 1 - src/Illuminate/Foundation/Console/OptimizeCommand.php | 1 - src/Illuminate/Foundation/Console/PackageDiscoverCommand.php | 1 - src/Illuminate/Foundation/Console/VendorPublishCommand.php | 2 -- src/Illuminate/Queue/Console/MonitorCommand.php | 1 - src/Illuminate/Queue/Console/RetryBatchCommand.php | 1 - src/Illuminate/Queue/Console/RetryCommand.php | 1 - 11 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 46e5b22ed8dc..3ea8d3de49d2 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -4,7 +4,6 @@ use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; -use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\DatabaseRefreshed; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 59c1037b2f0a..60ad9dc19a96 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -2,7 +2,6 @@ namespace Illuminate\Database\Console\Migrations; -use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Database\Migrations\Migrator; use Illuminate\Support\Collection; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 2d7f60f91aec..3c8a4775b4aa 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -4,8 +4,8 @@ use Doctrine\DBAL\Schema\SchemaException; use Illuminate\Console\View\Components\BulletList; -use Illuminate\Console\View\Components\Info; use Illuminate\Console\View\Components\Error; +use Illuminate\Console\View\Components\Info; use Illuminate\Console\View\Components\Task; use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Events\Dispatcher; @@ -21,7 +21,6 @@ use Illuminate\Support\Str; use ReflectionClass; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\ArrayInput; class Migrator { diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php index eb06260cef7f..1e0e11b877c8 100644 --- a/src/Illuminate/Foundation/Console/EventListCommand.php +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -4,8 +4,6 @@ use Closure; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\BulletList; -use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Contracts\Queue\ShouldQueue; use ReflectionFunction; diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index d798576b7afc..4e4024714ab7 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -3,7 +3,6 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'optimize:clear')] diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index b8c3b20816a0..b487928d43ba 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -3,7 +3,6 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'optimize')] diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index f690823cfc9a..3e621b42c114 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -3,7 +3,6 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Illuminate\Foundation\PackageManifest; use Symfony\Component\Console\Attribute\AsCommand; diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index c1e13076e8e7..d4eed8338036 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -3,8 +3,6 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; -use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Support\Arr; diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php index b3f8fc7c6c4a..12feda4e11b0 100644 --- a/src/Illuminate/Queue/Console/MonitorCommand.php +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -3,7 +3,6 @@ namespace Illuminate\Queue\Console; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Queue\Factory; use Illuminate\Queue\Events\QueueBusy; diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index f1d741a55ce1..32577e2ce7bf 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -4,7 +4,6 @@ use Illuminate\Bus\BatchRepository; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'queue:retry-batch')] diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 3c83c22e37ae..4bd7f4c81d58 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -4,7 +4,6 @@ use DateTimeInterface; use Illuminate\Console\Command; -use Illuminate\Console\View\Components\Task; use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Queue\Events\JobRetryRequested; use Illuminate\Support\Arr; From 6521918ce9c4cdbfe2a1067cfb427ab6754dc3b3 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 7 Jul 2022 19:42:16 +0100 Subject: [PATCH 062/101] Removes blade dependency --- .../Console/View/Components/Component.php | 28 +++++++++++++++---- .../Mutators/EnsureRelativePaths.php | 4 ++- .../components/{alert.blade.php => alert.php} | 2 +- .../views/components/bullet-list.blade.php | 7 ----- .../views/components/bullet-list.php | 7 +++++ .../resources/views/components/line.blade.php | 8 ------ .../resources/views/components/line.php | 6 ++++ ...detail.blade.php => two-column-detail.php} | 8 +++--- 8 files changed, 43 insertions(+), 27 deletions(-) rename src/Illuminate/Console/resources/views/components/{alert.blade.php => alert.php} (65%) delete mode 100644 src/Illuminate/Console/resources/views/components/bullet-list.blade.php create mode 100644 src/Illuminate/Console/resources/views/components/bullet-list.php delete mode 100644 src/Illuminate/Console/resources/views/components/line.blade.php create mode 100644 src/Illuminate/Console/resources/views/components/line.php rename src/Illuminate/Console/resources/views/components/{two-column-detail.blade.php => two-column-detail.php} (52%) diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php index 32ef4270a091..d7b1d2c30179 100644 --- a/src/Illuminate/Console/View/Components/Component.php +++ b/src/Illuminate/Console/View/Components/Component.php @@ -4,7 +4,6 @@ use Illuminate\Console\OutputStyle; use Illuminate\Console\QuestionHelper; -use Illuminate\Support\Facades\Blade; use ReflectionClass; use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use function Termwind\render; @@ -47,12 +46,29 @@ public function __construct($output) */ protected function renderView($view, $data, $verbosity) { - $view = file_get_contents( - __DIR__."/../../resources/views/components/$view.blade.php" - ); - renderUsing($this->output); - render((string) Blade::render($view, $data), $verbosity); + + render((string) $this->compile($view, $data), $verbosity); + } + + /** + * Compile the given view contents. + * + * @param string $view + * @param array $data + * @return void + */ + protected function compile($view, $data) + { + extract($data); + + ob_start(); + + include(__DIR__."/../../resources/views/components/$view.php"); + + return tap(ob_get_contents(), function () { + ob_end_clean(); + }); } /** diff --git a/src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php b/src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php index 2d865af6096d..50f42c6fffd3 100644 --- a/src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsureRelativePaths.php @@ -12,7 +12,9 @@ class EnsureRelativePaths */ public function __invoke($string) { - $string = str_replace(base_path().'/', '', $string); + if (app()->has('path.base')) { + $string = str_replace(base_path().'/', '', $string); + } return $string; } diff --git a/src/Illuminate/Console/resources/views/components/alert.blade.php b/src/Illuminate/Console/resources/views/components/alert.php similarity index 65% rename from src/Illuminate/Console/resources/views/components/alert.blade.php rename to src/Illuminate/Console/resources/views/components/alert.php index 8dd476c60309..bddcb21306d4 100644 --- a/src/Illuminate/Console/resources/views/components/alert.blade.php +++ b/src/Illuminate/Console/resources/views/components/alert.php @@ -1,3 +1,3 @@
- {{ $content }} +
diff --git a/src/Illuminate/Console/resources/views/components/bullet-list.blade.php b/src/Illuminate/Console/resources/views/components/bullet-list.blade.php deleted file mode 100644 index 45f57708f5bb..000000000000 --- a/src/Illuminate/Console/resources/views/components/bullet-list.blade.php +++ /dev/null @@ -1,7 +0,0 @@ -
- @foreach($elements as $element) -
- ⇂ {{ $element }} -
- @endforeach -
diff --git a/src/Illuminate/Console/resources/views/components/bullet-list.php b/src/Illuminate/Console/resources/views/components/bullet-list.php new file mode 100644 index 000000000000..a016a9108121 --- /dev/null +++ b/src/Illuminate/Console/resources/views/components/bullet-list.php @@ -0,0 +1,7 @@ +
+ +
+ ⇂ +
+ +
diff --git a/src/Illuminate/Console/resources/views/components/line.blade.php b/src/Illuminate/Console/resources/views/components/line.blade.php deleted file mode 100644 index 5a2b04f89c04..000000000000 --- a/src/Illuminate/Console/resources/views/components/line.blade.php +++ /dev/null @@ -1,8 +0,0 @@ -
- @if ($title) - {{ $title }} - @endif - - {{ $content }} - -
diff --git a/src/Illuminate/Console/resources/views/components/line.php b/src/Illuminate/Console/resources/views/components/line.php new file mode 100644 index 000000000000..cad5f24382e6 --- /dev/null +++ b/src/Illuminate/Console/resources/views/components/line.php @@ -0,0 +1,6 @@ +
+ + + + +
diff --git a/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php b/src/Illuminate/Console/resources/views/components/two-column-detail.php similarity index 52% rename from src/Illuminate/Console/resources/views/components/two-column-detail.blade.php rename to src/Illuminate/Console/resources/views/components/two-column-detail.php index a61a7534240d..995ca60115de 100644 --- a/src/Illuminate/Console/resources/views/components/two-column-detail.blade.php +++ b/src/Illuminate/Console/resources/views/components/two-column-detail.php @@ -1,11 +1,11 @@
- {{ $first }} + - @if ($second !== '') + - {{ $second }} + - @endif +
From caded00b9681f24a79c7298f5f98775b234b3ef1 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 7 Jul 2022 18:42:34 +0000 Subject: [PATCH 063/101] Apply fixes from StyleCI --- src/Illuminate/Console/View/Components/Component.php | 2 +- src/Illuminate/Console/resources/views/components/line.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php index d7b1d2c30179..acb91737bab3 100644 --- a/src/Illuminate/Console/View/Components/Component.php +++ b/src/Illuminate/Console/View/Components/Component.php @@ -64,7 +64,7 @@ protected function compile($view, $data) ob_start(); - include(__DIR__."/../../resources/views/components/$view.php"); + include __DIR__."/../../resources/views/components/$view.php"; return tap(ob_get_contents(), function () { ob_end_clean(); diff --git a/src/Illuminate/Console/resources/views/components/line.php b/src/Illuminate/Console/resources/views/components/line.php index cad5f24382e6..a6c38cfab00a 100644 --- a/src/Illuminate/Console/resources/views/components/line.php +++ b/src/Illuminate/Console/resources/views/components/line.php @@ -1,6 +1,8 @@
- +
From f5a72c840946b53ba28ad37b65bfe8dc68d2d29e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 16:35:04 +0100 Subject: [PATCH 064/101] Fixes more tests --- .../Database/Migrations/Migrator.php | 2 +- .../Console/Events/EventListCommandTest.php | 17 ++-- .../Scheduling/ScheduleListCommandTest.php | 2 +- .../Scheduling/ScheduleTestCommandTest.php | 13 ++- tests/Integration/Migration/MigratorTest.php | 86 +++++++++++++++---- 5 files changed, 83 insertions(+), 37 deletions(-) diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 3c8a4775b4aa..74fd3db9e6b6 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -415,7 +415,7 @@ protected function pretendToRun($migration, $method) } $this->write(TwoColumnDetail::class, $name); - $this->write(BulletList::class, $name, collect($this->getQueries($migration, $method))->map(function ($query) { + $this->write(BulletList::class, collect($this->getQueries($migration, $method))->map(function ($query) { return $query['query']; })); } catch (SchemaException $e) { diff --git a/tests/Integration/Console/Events/EventListCommandTest.php b/tests/Integration/Console/Events/EventListCommandTest.php index 8f8cd1e17f4c..3273c7da33c1 100644 --- a/tests/Integration/Console/Events/EventListCommandTest.php +++ b/tests/Integration/Console/Events/EventListCommandTest.php @@ -22,7 +22,7 @@ public function testDisplayEmptyList() { $this->artisan(EventListCommand::class) ->assertSuccessful() - ->expectsOutput("Your application doesn't have any events matching the given criteria."); + ->expectsOutputToContain("Your application doesn't have any events matching the given criteria."); } public function testDisplayEvents() @@ -37,15 +37,12 @@ public function testDisplayEvents() $this->artisan(EventListCommand::class) ->assertSuccessful() - ->expectsOutput(' ExampleSubscriberEventName') - ->expectsOutput(' ⇂ Illuminate\Tests\Integration\Console\Events\ExampleSubscriber@a') - ->expectsOutput(' ⇂ Illuminate\Tests\Integration\Console\Events\ExampleSubscriber@b') - ->expectsOutput(' Illuminate\Tests\Integration\Console\Events\ExampleBroadcastEvent (ShouldBroadcast)') - ->expectsOutput(' ⇂ Illuminate\Tests\Integration\Console\Events\ExampleBroadcastListener') - ->expectsOutput(' Illuminate\Tests\Integration\Console\Events\ExampleEvent') - ->expectsOutput(' ⇂ Illuminate\Tests\Integration\Console\Events\ExampleListener') - ->expectsOutput(' ⇂ Illuminate\Tests\Integration\Console\Events\ExampleQueueListener (ShouldQueue)') - ->expectsOutput(' ⇂ Closure at: '.$unixFilePath.':'.$closureLineNumber); + ->expectsOutputToContain('ExampleSubscriberEventName') + ->expectsOutputToContain('⇂ Illuminate\Tests\Integration\Console\Events\ExampleSubscriber@a') + ->expectsOutputToContain('Illuminate\Tests\Integration\Console\Events\ExampleBroadcastEvent (ShouldBroadcast)') + ->expectsOutputToContain('⇂ Illuminate\Tests\Integration\Console\Events\ExampleBroadcastListener') + ->expectsOutputToContain('Illuminate\Tests\Integration\Console\Events\ExampleEvent') + ->expectsOutputToContain('⇂ Closure at: '.$unixFilePath.':'.$closureLineNumber); } public function testDisplayFilteredEvent() diff --git a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php index 891be7452413..73b8c247e242 100644 --- a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php @@ -25,7 +25,7 @@ public function testDisplayEmptySchedule() { $this->artisan(ScheduleListCommand::class) ->assertSuccessful() - ->expectsOutput('No scheduled tasks have been defined.'); + ->expectsOutputToContain('No scheduled tasks have been defined.'); } public function testDisplaySchedule() diff --git a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php index 74b9170e2014..fb6adebc05cb 100644 --- a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php @@ -17,7 +17,6 @@ protected function setUp(): void Carbon::setTestNow(now()->startOfYear()); - $this->timestamp = now()->startOfYear()->format('c'); $this->schedule = $this->app->make(Schedule::class); } @@ -25,7 +24,7 @@ public function testRunNoDefinedCommands() { $this->artisan(ScheduleTestCommand::class) ->assertSuccessful() - ->expectsOutput('No scheduled commands have been defined.'); + ->expectsOutputToContain('No scheduled commands have been defined.'); } public function testRunNoMatchingCommand() @@ -34,7 +33,7 @@ public function testRunNoMatchingCommand() $this->artisan(ScheduleTestCommand::class, ['--name' => 'missing:command']) ->assertSuccessful() - ->expectsOutput('No matching scheduled command found.'); + ->expectsOutputToContain('No matching scheduled command found.'); } public function testRunUsingNameOption() @@ -45,15 +44,15 @@ public function testRunUsingNameOption() $this->artisan(ScheduleTestCommand::class, ['--name' => 'bar:command']) ->assertSuccessful() - ->expectsOutput(sprintf('[%s] Running scheduled command: bar-command', $this->timestamp)); + ->expectsOutputToContain('Running [bar-command]'); $this->artisan(ScheduleTestCommand::class, ['--name' => BarJobStub::class]) ->assertSuccessful() - ->expectsOutput(sprintf('[%s] Running scheduled command: %s', $this->timestamp, BarJobStub::class)); + ->expectsOutputToContain(sprintf('Running [%s]', BarJobStub::class)); $this->artisan(ScheduleTestCommand::class, ['--name' => 'callback']) ->assertSuccessful() - ->expectsOutput(sprintf('[%s] Running scheduled command: callback', $this->timestamp)); + ->expectsOutputToContain('Running [callback]'); } public function testRunUsingChoices() @@ -70,7 +69,7 @@ public function testRunUsingChoices() [Application::formatCommandString('bar:command'), BarJobStub::class, 'callback'], true ) - ->expectsOutput(sprintf('[%s] Running scheduled command: callback', $this->timestamp)); + ->expectsOutputToContain('Running [callback]'); } protected function tearDown(): void diff --git a/tests/Integration/Migration/MigratorTest.php b/tests/Integration/Migration/MigratorTest.php index 67afc1748eb5..b99d22f54ee4 100644 --- a/tests/Integration/Migration/MigratorTest.php +++ b/tests/Integration/Migration/MigratorTest.php @@ -26,12 +26,11 @@ protected function setUp(): void public function testMigrate() { - $this->expectOutput('Migrating: 2014_10_12_000000_create_people_table'); - $this->expectOutput(m::pattern('#Migrated: 2014_10_12_000000_create_people_table (.*)#')); - $this->expectOutput('Migrating: 2015_10_04_000000_modify_people_table'); - $this->expectOutput(m::pattern('#Migrated: 2015_10_04_000000_modify_people_table (.*)#')); - $this->expectOutput('Migrating: 2016_10_04_000000_modify_people_table'); - $this->expectOutput(m::pattern('#Migrated: 2016_10_04_000000_modify_people_table (.*)#')); + $this->expectInfo('Running migrations.'); + + $this->expectTask('2014_10_12_000000_create_people_table', 'DONE'); + $this->expectTask('2015_10_04_000000_modify_people_table', 'DONE'); + $this->expectTask('2016_10_04_000000_modify_people_table', 'DONE'); $this->subject->run([__DIR__.'/fixtures']); @@ -47,12 +46,11 @@ public function testRollback() $this->subject->getRepository()->log('2015_10_04_000000_modify_people_table', 1); $this->subject->getRepository()->log('2016_10_04_000000_modify_people_table', 1); - $this->expectOutput('Rolling back: 2016_10_04_000000_modify_people_table'); - $this->expectOutput(m::pattern('#Rolled back: 2016_10_04_000000_modify_people_table (.*)#')); - $this->expectOutput('Rolling back: 2015_10_04_000000_modify_people_table'); - $this->expectOutput(m::pattern('#Rolled back: 2015_10_04_000000_modify_people_table (.*)#')); - $this->expectOutput('Rolling back: 2014_10_12_000000_create_people_table'); - $this->expectOutput(m::pattern('#Rolled back: 2014_10_12_000000_create_people_table (.*)#')); + $this->expectInfo('Rollbacking migrations.'); + + $this->expectTask('2016_10_04_000000_modify_people_table', 'DONE'); + $this->expectTask('2015_10_04_000000_modify_people_table', 'DONE'); + $this->expectTask('2014_10_12_000000_create_people_table', 'DONE'); $this->subject->rollback([__DIR__.'/fixtures']); @@ -61,18 +59,70 @@ public function testRollback() public function testPretendMigrate() { - $this->expectOutput('CreatePeopleTable: create table "people" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar, "created_at" datetime, "updated_at" datetime)'); - $this->expectOutput('CreatePeopleTable: create unique index "people_email_unique" on "people" ("email")'); - $this->expectOutput('ModifyPeopleTable: alter table "people" add column "first_name" varchar'); - $this->expectOutput('2016_10_04_000000_modify_people_table: alter table "people" add column "last_name" varchar'); + $this->expectInfo('Running migrations.'); + + $this->expectTwoColumnDetail('CreatePeopleTable'); + $this->expectBulletList([ + 'create table "people" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar, "created_at" datetime, "updated_at" datetime)', + 'create unique index "people_email_unique" on "people" ("email")', + ]); + + $this->expectTwoColumnDetail('ModifyPeopleTable'); + $this->expectBulletList(['alter table "people" add column "first_name" varchar']); + + $this->expectTwoColumnDetail('2016_10_04_000000_modify_people_table'); + $this->expectBulletList(['alter table "people" add column "last_name" varchar']); $this->subject->run([__DIR__.'/fixtures'], ['pretend' => true]); $this->assertFalse(DB::getSchemaBuilder()->hasTable('people')); } - private function expectOutput($argument): void + protected function expectInfo($message): void + { + $this->output->shouldReceive('writeln')->once()->with(m::on( + fn ($argument) => str($argument)->contains($message), + ), m::any()); + } + + protected function expectTwoColumnDetail($first, $second = null) + { + $this->output->shouldReceive('writeln')->with(m::on(function ($argument) use ($first, $second) { + $result = str($argument)->contains($first); + + if ($result && $second) { + $result = str($argument)->contains($second); + } + + return $result; + }), m::any()); + } + + protected function expectBulletList($elements): void { - $this->output->shouldReceive('writeln')->once()->with($argument); + $this->output->shouldReceive('writeln')->once()->with(m::on(function ($argument) use ($elements) { + foreach ($elements as $element) { + if (! str($argument)->contains("⇂ $element")) { + return false; + } + } + + return true; + }), m::any()); + } + + protected function expectTask($description, $result): void + { + $this->output->shouldReceive('write')->with(m::on( + fn ($argument) => str($argument)->contains(['', '.']), + ), m::any(), m::any()); + + $this->output->shouldReceive('write')->once()->with(m::on( + fn ($argument) => str($argument)->contains($description), + ), m::any(), m::any()); + + $this->output->shouldReceive('writeln')->once()->with(m::on( + fn ($argument) => str($argument)->contains($result), + ), m::any()); } } From 414e932529ad56b85c6978e63ff2f43da5d54ef4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 17:12:30 +0100 Subject: [PATCH 065/101] Fixes more tests --- .../EnsureDynamicContentIsHighlighted.php | 2 +- .../DatabaseMigrationMigrateCommandTest.php | 4 +- .../DatabaseMigratorIntegrationTest.php | 2 + tests/Database/PruneCommandTest.php | 62 ++++++++++--------- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php b/src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php index 4a3b82bda202..16575b40c934 100644 --- a/src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsureDynamicContentIsHighlighted.php @@ -12,6 +12,6 @@ class EnsureDynamicContentIsHighlighted */ public function __invoke($string) { - return preg_replace('/\[([^\]]+)\]/', '[$1]', $string); + return preg_replace('/\[([^\]]+)\]/', '[$1]', (string) $string); } } diff --git a/tests/Database/DatabaseMigrationMigrateCommandTest.php b/tests/Database/DatabaseMigrationMigrateCommandTest.php index 2fdffd062bbf..47afe368f291 100755 --- a/tests/Database/DatabaseMigrationMigrateCommandTest.php +++ b/tests/Database/DatabaseMigrationMigrateCommandTest.php @@ -68,7 +68,7 @@ public function testMigrationsCanBeRunWithStoredSchema() public function testMigrationRepositoryCreatedWhenNecessary() { $params = [$migrator = m::mock(Migrator::class), $dispatcher = m::mock(Dispatcher::class)]; - $command = $this->getMockBuilder(MigrateCommand::class)->onlyMethods(['call'])->setConstructorArgs($params)->getMock(); + $command = $this->getMockBuilder(MigrateCommand::class)->onlyMethods(['callSilent'])->setConstructorArgs($params)->getMock(); $app = new ApplicationDatabaseMigrationStub(['path.database' => __DIR__]); $app->useDatabasePath(__DIR__); $command->setLaravel($app); @@ -80,7 +80,7 @@ public function testMigrationRepositoryCreatedWhenNecessary() $migrator->shouldReceive('setOutput')->once()->andReturn($migrator); $migrator->shouldReceive('run')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], ['pretend' => false, 'step' => false]); $migrator->shouldReceive('repositoryExists')->once()->andReturn(false); - $command->expects($this->once())->method('call')->with($this->equalTo('migrate:install'), $this->equalTo([])); + $command->expects($this->once())->method('callSilent')->with($this->equalTo('migrate:install'), $this->equalTo([])); $this->runCommand($command); } diff --git a/tests/Database/DatabaseMigratorIntegrationTest.php b/tests/Database/DatabaseMigratorIntegrationTest.php index f144170da0a1..7870cdb3e9df 100644 --- a/tests/Database/DatabaseMigratorIntegrationTest.php +++ b/tests/Database/DatabaseMigratorIntegrationTest.php @@ -59,7 +59,9 @@ protected function setUp(): void ); $output = m::mock(OutputStyle::class); + $output->shouldReceive('write'); $output->shouldReceive('writeln'); + $output->shouldReceive('newLineWritten'); $this->migrator->setOutput($output); diff --git a/tests/Database/PruneCommandTest.php b/tests/Database/PruneCommandTest.php index 58926b43e42b..b7d9d429c4e5 100644 --- a/tests/Database/PruneCommandTest.php +++ b/tests/Database/PruneCommandTest.php @@ -35,21 +35,27 @@ public function testPrunableModelWithPrunableRecords() { $output = $this->artisan(['--model' => PrunableTestModelWithPrunableRecords::class]); - $this->assertEquals(<<<'EOF' -10 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records have been pruned. -20 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records have been pruned. + $output = $output->fetch(); -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + '10 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records have been pruned.', + $output, + ); + + $this->assertStringContainsString( + '20 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records have been pruned.', + $output, + ); } public function testPrunableTestModelWithoutPrunableRecords() { $output = $this->artisan(['--model' => PrunableTestModelWithoutPrunableRecords::class]); - $this->assertEquals(<<<'EOF' -No prunable [Illuminate\Tests\Database\PrunableTestModelWithoutPrunableRecords] records found. - -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + 'No prunable [Illuminate\Tests\Database\PrunableTestModelWithoutPrunableRecords] records found.', + $output->fetch() + ); } public function testPrunableSoftDeletedModelWithPrunableRecords() @@ -74,10 +80,10 @@ public function testPrunableSoftDeletedModelWithPrunableRecords() $output = $this->artisan(['--model' => PrunableTestSoftDeletedModelWithPrunableRecords::class]); - $this->assertEquals(<<<'EOF' -2 [Illuminate\Tests\Database\PrunableTestSoftDeletedModelWithPrunableRecords] records have been pruned. - -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + '2 [Illuminate\Tests\Database\PrunableTestSoftDeletedModelWithPrunableRecords] records have been pruned.', + $output->fetch(), + ); $this->assertEquals(2, PrunableTestSoftDeletedModelWithPrunableRecords::withTrashed()->count()); } @@ -86,20 +92,20 @@ public function testNonPrunableTest() { $output = $this->artisan(['--model' => NonPrunableTestModel::class]); - $this->assertEquals(<<<'EOF' -No prunable [Illuminate\Tests\Database\NonPrunableTestModel] records found. - -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + 'No prunable [Illuminate\Tests\Database\NonPrunableTestModel] records found.', + $output->fetch(), + ); } public function testNonPrunableTestWithATrait() { $output = $this->artisan(['--model' => NonPrunableTrait::class]); - $this->assertEquals(<<<'EOF' -No prunable models found. - -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + 'No prunable models found.', + $output->fetch(), + ); } public function testTheCommandMayBePretended() @@ -128,10 +134,10 @@ public function testTheCommandMayBePretended() '--pretend' => true, ]); - $this->assertEquals(<<<'EOF' -3 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records will be pruned. - -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + '3 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records will be pruned.', + $output->fetch(), + ); $this->assertEquals(5, PrunableTestModelWithPrunableRecords::count()); } @@ -161,10 +167,10 @@ public function testTheCommandMayBePretendedOnSoftDeletedModel() '--pretend' => true, ]); - $this->assertEquals(<<<'EOF' -2 [Illuminate\Tests\Database\PrunableTestSoftDeletedModelWithPrunableRecords] records will be pruned. - -EOF, str_replace("\r", '', $output->fetch())); + $this->assertStringContainsString( + '2 [Illuminate\Tests\Database\PrunableTestSoftDeletedModelWithPrunableRecords] records will be pruned.', + $output->fetch(), + ); $this->assertEquals(4, PrunableTestSoftDeletedModelWithPrunableRecords::withTrashed()->count()); } From e43ea313f7d8d838c460476e3f229e3b7aa66e67 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 17:21:43 +0100 Subject: [PATCH 066/101] Fixes tests when using PHP 8.0 --- src/Illuminate/Console/View/Components/Component.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Illuminate/Console/View/Components/Component.php b/src/Illuminate/Console/View/Components/Component.php index acb91737bab3..11d95bb8f621 100644 --- a/src/Illuminate/Console/View/Components/Component.php +++ b/src/Illuminate/Console/View/Components/Component.php @@ -105,6 +105,8 @@ protected function usingQuestionHelper($callable) ->getParentClass() ->getProperty('questionHelper'); + $property->setAccessible(true); + $currentHelper = $property->isInitialized($this->output) ? $property->getValue($this->output) : new SymfonyQuestionHelper(); From af31579f5e850aa5389f92aee36e95ebd33e51f7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 18:15:27 +0100 Subject: [PATCH 067/101] Rewords `env` command --- src/Illuminate/Foundation/Console/EnvironmentCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/src/Illuminate/Foundation/Console/EnvironmentCommand.php index 53d66a12ab08..00df1e5c20e3 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -41,7 +41,7 @@ class EnvironmentCommand extends Command public function handle() { $this->components->info(sprintf( - 'The application is on [%s] environment.', + 'The application is in the [%s] environment.', $this->laravel['env'], )); } From 34abe683e722cd0fad0652d3f89c0bf31f5e0197 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 19:12:47 +0100 Subject: [PATCH 068/101] Asks previous output if new line was written --- src/Illuminate/Console/OutputStyle.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Console/OutputStyle.php b/src/Illuminate/Console/OutputStyle.php index 4861ff14fc9e..a61d828806db 100644 --- a/src/Illuminate/Console/OutputStyle.php +++ b/src/Illuminate/Console/OutputStyle.php @@ -122,6 +122,10 @@ public function newLine(int $count = 1) */ public function newLineWritten() { + if ($this->output instanceof static && $this->output->newLineWritten()) { + return true; + } + return $this->newLineWritten; } } From b1a277f94d1adf0b0b525a6cbf627d5813e1e7a3 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 19:12:55 +0100 Subject: [PATCH 069/101] Improves migrate command --- .../Database/Console/Migrations/MigrateCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 6c813397001e..8022f0518177 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -142,9 +142,9 @@ protected function loadSchemaState() return; } - $this->components->info('Preparing database.'); + $this->components->info('Loading stored database schemas.'); - $this->components->task("Loading stored database schema [$path].", function () use ($connection, $path) { + $this->components->task($path, function () use ($connection, $path) { // Since the schema file will create the "migrations" table and reload it to its // proper state, we need to delete it here so we don't get an error that this // table already exists when the stored database schema file gets executed. @@ -155,6 +155,8 @@ protected function loadSchemaState() })->load($path); }); + $this->newLine(); + // Finally, we will fire an event that this schema has been loaded so developers // can perform any post schema load tasks that are necessary in listeners for // this event, which may seed the database tables with some necessary data. From dc0c359391ea6ae83c01a893ed3c66e56c4c062b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 19:53:52 +0100 Subject: [PATCH 070/101] Rewords `optimize:clear` --- src/Illuminate/Foundation/Console/OptimizeClearCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php index 4e4024714ab7..d3b039ebb36b 100644 --- a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -40,7 +40,7 @@ class OptimizeClearCommand extends Command */ public function handle() { - $this->components->info('Removing cached bootstrap files'); + $this->components->info('Clearing cached bootstrap files.'); collect([ 'events' => fn () => $this->callSilent('event:clear') == 0, From 0298ae8cdcfa3920ea4c30b62ecc831785ac00a7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 8 Jul 2022 19:54:04 +0100 Subject: [PATCH 071/101] Fixes new lines on migrations --- src/Illuminate/Database/Console/Migrations/FreshCommand.php | 2 ++ src/Illuminate/Database/Migrations/Migrator.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 3ea8d3de49d2..e319e74bc06a 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -48,6 +48,8 @@ public function handle() '--force' => true, ])) == 0); + $this->newLine(); + $this->call('migrate', array_filter([ '--database' => $database, '--path' => $this->input->getOption('path'), diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 74fd3db9e6b6..bb5861b84580 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -313,7 +313,11 @@ public function reset($paths = [], $pretend = false) return []; } - return $this->resetMigrations($migrations, $paths, $pretend); + return tap($this->resetMigrations($migrations, $paths, $pretend), function () { + if ($this->output) { + $this->output->writeln(""); + } + }); } /** From e85ac0484218dec1a21bebcc5b63eef4d1251e06 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 8 Jul 2022 18:54:33 +0000 Subject: [PATCH 072/101] Apply fixes from StyleCI --- src/Illuminate/Database/Migrations/Migrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index bb5861b84580..e124186bed87 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -315,7 +315,7 @@ public function reset($paths = [], $pretend = false) return tap($this->resetMigrations($migrations, $paths, $pretend), function () { if ($this->output) { - $this->output->writeln(""); + $this->output->writeln(''); } }); } From ea7f369ac98f527c65f593777c7f8e71ced6a439 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 11:00:58 +0100 Subject: [PATCH 073/101] Improves `model:prune` command --- .../Database/Console/PruneCommand.php | 14 +++++++++-- tests/Database/PruneCommandTest.php | 25 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Database/Console/PruneCommand.php b/src/Illuminate/Database/Console/PruneCommand.php index 718f09aa7862..617a184ef142 100644 --- a/src/Illuminate/Database/Console/PruneCommand.php +++ b/src/Illuminate/Database/Console/PruneCommand.php @@ -56,8 +56,18 @@ public function handle(Dispatcher $events) return; } - $events->listen(ModelsPruned::class, function ($event) { - $this->components->info("{$event->count} [{$event->model}] records have been pruned."); + $prunning = []; + + $events->listen(ModelsPruned::class, function ($event) use (&$prunning) { + if (! in_array($event->model, $prunning)) { + $prunning[] = $event->model; + + $this->newLine(); + + $this->components->info(sprintf('Prunning [%s] records.', $event->model)); + } + + $this->components->twoColumnDetail($event->model, "{$event->count} records"); }); $models->each(function ($model) { diff --git a/tests/Database/PruneCommandTest.php b/tests/Database/PruneCommandTest.php index b7d9d429c4e5..cbb38ff1930b 100644 --- a/tests/Database/PruneCommandTest.php +++ b/tests/Database/PruneCommandTest.php @@ -38,12 +38,22 @@ public function testPrunableModelWithPrunableRecords() $output = $output->fetch(); $this->assertStringContainsString( - '10 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records have been pruned.', + 'Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords', $output, ); $this->assertStringContainsString( - '20 [Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords] records have been pruned.', + '10 records', + $output, + ); + + $this->assertStringContainsString( + 'Illuminate\Tests\Database\PrunableTestModelWithPrunableRecords', + $output, + ); + + $this->assertStringContainsString( + '20 records', $output, ); } @@ -80,9 +90,16 @@ public function testPrunableSoftDeletedModelWithPrunableRecords() $output = $this->artisan(['--model' => PrunableTestSoftDeletedModelWithPrunableRecords::class]); + $output = $output->fetch(); + $this->assertStringContainsString( - '2 [Illuminate\Tests\Database\PrunableTestSoftDeletedModelWithPrunableRecords] records have been pruned.', - $output->fetch(), + 'Illuminate\Tests\Database\PrunableTestSoftDeletedModelWithPrunableRecords', + $output, + ); + + $this->assertStringContainsString( + '2 records', + $output, ); $this->assertEquals(2, PrunableTestSoftDeletedModelWithPrunableRecords::withTrashed()->count()); From 16881fbb82d88f2d1318213feb803be0ede59577 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 11:07:45 +0100 Subject: [PATCH 074/101] Only prints new line when packages found --- src/Illuminate/Foundation/Console/PackageDiscoverCommand.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index 3e621b42c114..0effad8261ae 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -48,8 +48,7 @@ public function handle(PackageManifest $manifest) collect($manifest->manifest) ->map(fn () => fn () => true) - ->each(fn ($task, $description) => $this->components->task($description, $task)); - - $this->newLine(); + ->each(fn ($task, $description) => $this->components->task($description, $task)) + ->whenNotEmpty(fn () => $this->newLine()); } } From c0ef63cd7096bf27f775490b11fa31292bfb52a5 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 11:23:26 +0100 Subject: [PATCH 075/101] Improves `list:failed` command --- src/Illuminate/Queue/Console/ListFailedCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/ListFailedCommand.php b/src/Illuminate/Queue/Console/ListFailedCommand.php index 2af383c46963..9194a001d392 100644 --- a/src/Illuminate/Queue/Console/ListFailedCommand.php +++ b/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -52,7 +52,9 @@ public function handle() return $this->components->info('No failed jobs found.'); } + $this->newLine(); $this->displayFailedJobs($jobs); + $this->newLine(); } /** @@ -122,6 +124,11 @@ protected function matchJobName($payload) */ protected function displayFailedJobs(array $jobs) { - $this->table($this->headers, $jobs); + collect($jobs)->each( + fn ($job) => $this->components->twoColumnDetail( + sprintf("%s %s", $job[4], $job[0]), + sprintf("%s@%s %s", $job[1], $job[2], $job[3]) + ), + ); } } From 639819a761dca186c9b4d611f9dd638a571c7d1f Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 11 Jul 2022 10:23:58 +0000 Subject: [PATCH 076/101] Apply fixes from StyleCI --- src/Illuminate/Queue/Console/ListFailedCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/ListFailedCommand.php b/src/Illuminate/Queue/Console/ListFailedCommand.php index 9194a001d392..4ccaf30ea242 100644 --- a/src/Illuminate/Queue/Console/ListFailedCommand.php +++ b/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -126,8 +126,8 @@ protected function displayFailedJobs(array $jobs) { collect($jobs)->each( fn ($job) => $this->components->twoColumnDetail( - sprintf("%s %s", $job[4], $job[0]), - sprintf("%s@%s %s", $job[1], $job[2], $job[3]) + sprintf('%s %s', $job[4], $job[0]), + sprintf('%s@%s %s', $job[1], $job[2], $job[3]) ), ); } From aa9bfcdf15cd3def50701b0e7a7cb56dce508c32 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 11:38:23 +0100 Subject: [PATCH 077/101] Improves `queue:retry` and `queue:retry-batch` wording --- src/Illuminate/Queue/Console/RetryBatchCommand.php | 2 +- src/Illuminate/Queue/Console/RetryCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryBatchCommand.php b/src/Illuminate/Queue/Console/RetryBatchCommand.php index 32577e2ce7bf..b99e00206866 100644 --- a/src/Illuminate/Queue/Console/RetryBatchCommand.php +++ b/src/Illuminate/Queue/Console/RetryBatchCommand.php @@ -53,7 +53,7 @@ public function handle() return 1; } - $this->components->info("Retrying the failed jobs for a batch [$id]."); + $this->components->info("Pushing failed queue jobs of the batch [$id] back onto the queue."); foreach ($batch->failedJobIds as $failedJobId) { $this->components->task($failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0); diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 4bd7f4c81d58..ef6a5ed49de3 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -51,7 +51,7 @@ public function handle() $jobsFound = count($ids = $this->getJobIds()) > 0; if ($jobsFound) { - $this->components->info('Retrying failed queue jobs.'); + $this->components->info('Pushing failed queue jobs back onto the queue.'); } foreach ($ids as $id) { From 56ac3ed7a667d22f6189e86befd4a3a05529dd6f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 14:55:37 +0100 Subject: [PATCH 078/101] Improve `schedule:run` command --- .../Console/Scheduling/ScheduleRunCommand.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index b25fbba48dff..9b3e76e5e067 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -2,6 +2,7 @@ namespace Illuminate\Console\Scheduling; +use Illuminate\Console\Application; use Illuminate\Console\Command; use Illuminate\Console\Events\ScheduledTaskFailed; use Illuminate\Console\Events\ScheduledTaskFinished; @@ -77,6 +78,13 @@ class ScheduleRunCommand extends Command */ protected $handler; + /** + * The PHP Binary used by the command. + * + * @var string + */ + protected $phpBinary; + /** * Create a new command instance. * @@ -102,6 +110,7 @@ public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHand $this->schedule = $schedule; $this->dispatcher = $dispatcher; $this->handler = $handler; + $this->phpBinary = Application::phpBinary(); $this->newLine(); @@ -153,10 +162,17 @@ protected function runSingleServerEvent($event) */ protected function runEvent($event) { + $summary = $event->getSummaryForDisplay(); + + $command = $event instanceof CallbackEvent + ? (class_exists($summary) ? $summary : 'Closure') + : trim(str_replace($this->phpBinary, '', $event->command)); + $description = sprintf( - '%s Running [%s]', + '%s Running [%s]%s', Carbon::now()->format('Y-m-d H:i:s'), - $event->getSummaryForDisplay() + $command, + $event->runInBackground ? ' in background' : '', ); $this->components->task($description, function () use ($event) { @@ -178,6 +194,12 @@ protected function runEvent($event) $this->handler->report($e); } + + return $event->exitCode == 0; }); + + if (! $event instanceof CallbackEvent) { + $this->components->bulletList([$event->getSummaryForDisplay()]); + } } } From f28074fd9de76dca94e2a89798bc4eda93b6c1b2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 15:07:07 +0100 Subject: [PATCH 079/101] Makes `schedule:test` very similar to `schedule:run` --- .../Console/Scheduling/ScheduleRunCommand.php | 6 +++-- .../Scheduling/ScheduleTestCommand.php | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index 9b3e76e5e067..1e25f291e3b6 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -165,7 +165,7 @@ protected function runEvent($event) $summary = $event->getSummaryForDisplay(); $command = $event instanceof CallbackEvent - ? (class_exists($summary) ? $summary : 'Closure') + ? $summary : trim(str_replace($this->phpBinary, '', $event->command)); $description = sprintf( @@ -199,7 +199,9 @@ protected function runEvent($event) }); if (! $event instanceof CallbackEvent) { - $this->components->bulletList([$event->getSummaryForDisplay()]); + $this->components->bulletList([ + $event->getSummaryForDisplay() + ]); } } } diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 008f87e2b7b7..a8a1a596b77c 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -42,6 +42,8 @@ class ScheduleTestCommand extends Command */ public function handle(Schedule $schedule) { + $phpBinary = Application::phpBinary(); + $commands = $schedule->events(); $commandNames = []; @@ -55,7 +57,7 @@ public function handle(Schedule $schedule) } if (! empty($name = $this->option('name'))) { - $commandBinary = Application::phpBinary().' '.Application::artisanBinary(); + $commandBinary = $phpBinary.' '.Application::artisanBinary(); $matches = array_filter($commandNames, function ($commandName) use ($commandBinary, $name) { return trim(str_replace($commandBinary, '', $commandName)) === $name; @@ -74,9 +76,23 @@ public function handle(Schedule $schedule) $event = $commands[$index]; - $this->components->task(sprintf('Running [%s].', $event->getSummaryForDisplay()), function () use ($event) { - $event->run($this->laravel); - }); + $summary = $event->getSummaryForDisplay(); + + $command = $event instanceof CallbackEvent + ? $summary + : trim(str_replace($phpBinary, '', $event->command)); + + $description = sprintf( + 'Running [%s]%s', + $command, + $event->runInBackground ? ' in background' : '', + ); + + $this->components->task($description, fn () => $event->run($this->laravel)); + + if (! $event instanceof CallbackEvent) { + $this->components->bulletList([$event->getSummaryForDisplay()]); + } $this->newLine(); } From f5433bf2afcd43876df054c29f838ff29ff83b91 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 11 Jul 2022 14:07:21 +0000 Subject: [PATCH 080/101] Apply fixes from StyleCI --- src/Illuminate/Console/Scheduling/ScheduleRunCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index 1e25f291e3b6..dca910ce908a 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -200,7 +200,7 @@ protected function runEvent($event) if (! $event instanceof CallbackEvent) { $this->components->bulletList([ - $event->getSummaryForDisplay() + $event->getSummaryForDisplay(), ]); } } From ef9f636a8399de6a2b7c79005781ffaf064ca089 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 15:18:33 +0100 Subject: [PATCH 081/101] Fixes tests --- .../Integration/Console/Scheduling/ScheduleTestCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php index fb6adebc05cb..8cd58c369810 100644 --- a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php @@ -44,7 +44,7 @@ public function testRunUsingNameOption() $this->artisan(ScheduleTestCommand::class, ['--name' => 'bar:command']) ->assertSuccessful() - ->expectsOutputToContain('Running [bar-command]'); + ->expectsOutputToContain('Running [\'artisan\' bar:command]'); $this->artisan(ScheduleTestCommand::class, ['--name' => BarJobStub::class]) ->assertSuccessful() From 41a4560bd926b9736ec9a3fb9b7fb4a547457ea3 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 17:43:19 +0100 Subject: [PATCH 082/101] Improves wording --- .../Console/View/Components/Mutators/EnsureNoPunctuation.php | 2 +- .../Console/View/Components/Mutators/EnsurePunctuation.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php b/src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php index 89622b8a7688..5f349362668e 100644 --- a/src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsureNoPunctuation.php @@ -5,7 +5,7 @@ class EnsureNoPunctuation { /** - * Ensures the given string does not end with a dot. + * Ensures the given string does not end with punctuation. * * @param string $string * @return string diff --git a/src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php b/src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php index a7e8053f91e5..c99fecffa9ec 100644 --- a/src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php +++ b/src/Illuminate/Console/View/Components/Mutators/EnsurePunctuation.php @@ -5,7 +5,7 @@ class EnsurePunctuation { /** - * Ensures the given string ends with a punctuation. + * Ensures the given string ends with punctuation. * * @param string $string * @return string From 5a51f8c1d490a5e1c893109771876b3b5bb594ea Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 17:43:26 +0100 Subject: [PATCH 083/101] Removes non-used file --- src/Illuminate/Console/View/Components/Question.php | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/Illuminate/Console/View/Components/Question.php diff --git a/src/Illuminate/Console/View/Components/Question.php b/src/Illuminate/Console/View/Components/Question.php deleted file mode 100644 index 468c2e63224a..000000000000 --- a/src/Illuminate/Console/View/Components/Question.php +++ /dev/null @@ -1 +0,0 @@ -Confirm.php \ No newline at end of file From c6ed3e17c8a39812376b009a120a1ab30220336f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 17:52:35 +0100 Subject: [PATCH 084/101] Uses latest version of Termwind --- composer.json | 2 +- src/Illuminate/Console/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 13488dc56881..0082c4481806 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "league/flysystem": "^3.0.16", "monolog/monolog": "^2.0", "nesbot/carbon": "^2.53.1", - "nunomaduro/termwind": "^1.12", + "nunomaduro/termwind": "^1.13", "psr/container": "^1.1.1|^2.0.1", "psr/log": "^1.0|^2.0|^3.0", "psr/simple-cache": "^1.0|^2.0|^3.0", diff --git a/src/Illuminate/Console/composer.json b/src/Illuminate/Console/composer.json index a535fb7fc6cc..948a6fc16db4 100755 --- a/src/Illuminate/Console/composer.json +++ b/src/Illuminate/Console/composer.json @@ -20,7 +20,7 @@ "illuminate/macroable": "^9.0", "illuminate/support": "^9.0", "illuminate/view": "^9.0", - "nunomaduro/termwind": "^1.12", + "nunomaduro/termwind": "^1.13", "symfony/console": "^6.0", "symfony/process": "^6.0" }, From 5220ef75f298489b50140d264e34d603f493f8d7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 17:55:37 +0100 Subject: [PATCH 085/101] Fixes tests on windows --- .../Console/Scheduling/ScheduleTestCommandTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php index 8cd58c369810..66e81e74883d 100644 --- a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php @@ -42,9 +42,13 @@ public function testRunUsingNameOption() $this->schedule->job(BarJobStub::class); $this->schedule->call(fn () => true)->name('callback'); + $expectedOutput = windows_os() + ? 'Running ["artisan" bar:command]' + : "Running ['artisan' bar:command]"; + $this->artisan(ScheduleTestCommand::class, ['--name' => 'bar:command']) ->assertSuccessful() - ->expectsOutputToContain('Running [\'artisan\' bar:command]'); + ->expectsOutputToContain($expectedOutput); $this->artisan(ScheduleTestCommand::class, ['--name' => BarJobStub::class]) ->assertSuccessful() From d2aaf696b1f576e97072a5fdb30d468999edeb3a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 11 Jul 2022 18:20:04 +0100 Subject: [PATCH 086/101] Adds tests to components --- tests/Console/View/ComponentsTest.php | 123 ++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 tests/Console/View/ComponentsTest.php diff --git a/tests/Console/View/ComponentsTest.php b/tests/Console/View/ComponentsTest.php new file mode 100644 index 000000000000..f9899e099e40 --- /dev/null +++ b/tests/Console/View/ComponentsTest.php @@ -0,0 +1,123 @@ +render('The application is in the [production] environment'); + + $this->assertStringContainsString( + "THE APPLICATION IS IN THE [PRODUCTION] ENVIRONMENT.", + $output->fetch() + ); + } + + public function testBulletList() + { + $output = new BufferedOutput(); + + with(new Components\BulletList($output))->render([ + 'ls -la', + 'php artisan inspire', + ]); + + $output = $output->fetch(); + + $this->assertStringContainsString('⇂ ls -la', $output); + $this->assertStringContainsString('⇂ php artisan inspire', $output); + } + + public function testError() + { + $output = new BufferedOutput(); + + with(new Components\Error($output))->render('The application is in the [production] environment'); + + $this->assertSame("\n ERROR The application is in the [production] environment. \n\n", $output->fetch()); + } + + public function testInfo() + { + $output = new BufferedOutput(); + + with(new Components\Info($output))->render('The application is in the [production] environment'); + + $this->assertSame("\n INFO The application is in the [production] environment. \n\n", $output->fetch()); + } + + public function testConfirm() + { + $output = m::mock(OutputStyle::class); + + $output->shouldReceive('confirm') + ->with('Question?', true) + ->once() + ->andReturnTrue(); + + $result = with(new Components\Confirm($output))->render('Question?'); + $this->assertTrue($result); + } + + public function testChoice() + { + $output = m::mock(OutputStyle::class); + + $output->shouldReceive('askQuestion') + ->with(m::type(ChoiceQuestion::class)) + ->once() + ->andReturn('a'); + + $result = with(new Components\Choice($output))->render('Question?', ['a', 'b']); + $this->assertSame('a', $result); + } + + public function testTask() + { + $output = new BufferedOutput(); + + with(new Components\Task($output))->render('My task', fn () => true); + $result = $output->fetch(); + $this->assertStringContainsString('My task', $result); + $this->assertStringContainsString('DONE', $result); + + with(new Components\Task($output))->render('My task', fn () => false); + $result = $output->fetch(); + $this->assertStringContainsString('My task', $result); + $this->assertStringContainsString('FAIL', $result); + } + + public function testTwoColumnDetail() + { + $output = new BufferedOutput(); + + with(new Components\TwoColumnDetail($output))->render('First', 'Second'); + $result = $output->fetch(); + $this->assertStringContainsString('First', $result); + $this->assertStringContainsString('Second', $result); + } + + public function testWarn() + { + $output = new BufferedOutput(); + + with(new Components\Warn($output))->render('The application is in the [production] environment'); + + $this->assertSame("\n WARN The application is in the [production] environment. \n\n", $output->fetch()); + } +} From 53a8b3db7f8076e9812956a7f92d99b04a668b9a Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 11 Jul 2022 17:20:18 +0000 Subject: [PATCH 087/101] Apply fixes from StyleCI --- tests/Console/View/ComponentsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Console/View/ComponentsTest.php b/tests/Console/View/ComponentsTest.php index f9899e099e40..c90b90f73d0b 100644 --- a/tests/Console/View/ComponentsTest.php +++ b/tests/Console/View/ComponentsTest.php @@ -2,8 +2,8 @@ namespace Illuminate\Tests\Console\View; -use Illuminate\Console\View\Components; use Illuminate\Console\OutputStyle; +use Illuminate\Console\View\Components; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\BufferedOutput; @@ -23,7 +23,7 @@ public function testAlert() with(new Components\Alert($output))->render('The application is in the [production] environment'); $this->assertStringContainsString( - "THE APPLICATION IS IN THE [PRODUCTION] ENVIRONMENT.", + 'THE APPLICATION IS IN THE [PRODUCTION] ENVIRONMENT.', $output->fetch() ); } From 62b2dce73285595105a80879e45dcb559ca3587b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 10:11:17 +0100 Subject: [PATCH 088/101] Updates `env` wording --- src/Illuminate/Foundation/Console/EnvironmentCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/src/Illuminate/Foundation/Console/EnvironmentCommand.php index 00df1e5c20e3..ba74ed987efc 100644 --- a/src/Illuminate/Foundation/Console/EnvironmentCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -41,7 +41,7 @@ class EnvironmentCommand extends Command public function handle() { $this->components->info(sprintf( - 'The application is in the [%s] environment.', + 'The application environment is [%s].', $this->laravel['env'], )); } From b5439cdcf8f8db7c2dfeed5f658089a0ba8b6861 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 10:12:55 +0100 Subject: [PATCH 089/101] Updates question first and second color --- src/Illuminate/Console/QuestionHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/QuestionHelper.php b/src/Illuminate/Console/QuestionHelper.php index 6ae991f2ec38..06d90b65fd74 100644 --- a/src/Illuminate/Console/QuestionHelper.php +++ b/src/Illuminate/Console/QuestionHelper.php @@ -53,7 +53,7 @@ protected function writePrompt(OutputInterface $output, Question $question) if ($question instanceof ChoiceQuestion) { foreach ($question->getChoices() as $key => $value) { - with(new TwoColumnDetail($output))->render($key, $value); + with(new TwoColumnDetail($output))->render($value, $key); } } From 46b6968e84e043a2ee9abcb4d29051ddd3b7b7ec Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 10:15:50 +0100 Subject: [PATCH 090/101] Adds skipped wording on `vendor:publish` --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index d4eed8338036..fadbba63e462 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -246,7 +246,7 @@ protected function publishFile($from, $to) $this->components->twoColumnDetail(sprintf( 'File [%s] already exist', str_replace(base_path().'/', '', realpath($to)), - )); + ), 'SKIPPED'); } } From 8ce9c30a5ec423ce7d0434cc3609fd0fd27cd77b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 10:44:39 +0100 Subject: [PATCH 091/101] Adds missing method on interface and tests --- .../Console/Contracts/NewLineAware.php | 7 ++- tests/Console/OutputStyleTest.php | 52 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/Console/OutputStyleTest.php diff --git a/src/Illuminate/Console/Contracts/NewLineAware.php b/src/Illuminate/Console/Contracts/NewLineAware.php index 49d598b3e482..135cecba8062 100644 --- a/src/Illuminate/Console/Contracts/NewLineAware.php +++ b/src/Illuminate/Console/Contracts/NewLineAware.php @@ -4,5 +4,10 @@ interface NewLineAware { - // ... + /** + * Whether a newline has already been written. + * + * @return bool + */ + public function newLineWritten(); } diff --git a/tests/Console/OutputStyleTest.php b/tests/Console/OutputStyleTest.php new file mode 100644 index 000000000000..eac60e81d486 --- /dev/null +++ b/tests/Console/OutputStyleTest.php @@ -0,0 +1,52 @@ +assertFalse($style->newLineWritten()); + + $style->newLine(); + $this->assertTrue($style->newLineWritten()); + } + + public function testDetectsNewLineOnWrite() + { + $bufferedOutput = new BufferedOutput(); + + $style = new OutputStyle(new ArrayInput([]), $bufferedOutput); + + $style->write('Foo'); + $this->assertFalse($style->newLineWritten()); + + $style->write('Foo', true); + $this->assertTrue($style->newLineWritten()); + } + + public function testDetectsNewLineOnWriteln() + { + $bufferedOutput = new BufferedOutput(); + + $style = new OutputStyle(new ArrayInput([]), $bufferedOutput); + + $style->writeln('Foo'); + $this->assertTrue($style->newLineWritten()); + } +} From 1ae061031dda25b0101191fde0ecd70319767c99 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 10:46:12 +0100 Subject: [PATCH 092/101] Adds test on underlying output --- tests/Console/OutputStyleTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Console/OutputStyleTest.php b/tests/Console/OutputStyleTest.php index eac60e81d486..ca987bfd7f9c 100644 --- a/tests/Console/OutputStyleTest.php +++ b/tests/Console/OutputStyleTest.php @@ -27,6 +27,17 @@ public function testDetectsNewLine() $this->assertTrue($style->newLineWritten()); } + public function testDetectsNewLineOnUnderlyingOutput() + { + $bufferedOutput = new BufferedOutput(); + + $underlyingStyle = new OutputStyle(new ArrayInput([]), $bufferedOutput); + $style = new OutputStyle(new ArrayInput([]), $underlyingStyle); + + $underlyingStyle->newLine(); + $this->assertTrue($style->newLineWritten()); + } + public function testDetectsNewLineOnWrite() { $bufferedOutput = new BufferedOutput(); From a7b61d7cace48eb454944e5d5e36d3739a3cee09 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 10:57:17 +0100 Subject: [PATCH 093/101] Uses `PHP_EOL` for windows tests --- tests/Console/View/ComponentsTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/Console/View/ComponentsTest.php b/tests/Console/View/ComponentsTest.php index c90b90f73d0b..04ae4304450f 100644 --- a/tests/Console/View/ComponentsTest.php +++ b/tests/Console/View/ComponentsTest.php @@ -11,6 +11,11 @@ class ComponentsTest extends TestCase { + protected function setUp(): void + { + $this->phpEOL = PHP_EOL; + } + protected function tearDown(): void { m::close(); @@ -49,7 +54,7 @@ public function testError() with(new Components\Error($output))->render('The application is in the [production] environment'); - $this->assertSame("\n ERROR The application is in the [production] environment. \n\n", $output->fetch()); + $this->assertSame("{$this->phpEOL} ERROR The application is in the [production] environment. {$this->phpEOL}{$this->phpEOL}", $output->fetch()); } public function testInfo() @@ -58,7 +63,7 @@ public function testInfo() with(new Components\Info($output))->render('The application is in the [production] environment'); - $this->assertSame("\n INFO The application is in the [production] environment. \n\n", $output->fetch()); + $this->assertSame("{$this->phpEOL} INFO The application is in the [production] environment. {$this->phpEOL}{$this->phpEOL}", $output->fetch()); } public function testConfirm() @@ -118,6 +123,6 @@ public function testWarn() with(new Components\Warn($output))->render('The application is in the [production] environment'); - $this->assertSame("\n WARN The application is in the [production] environment. \n\n", $output->fetch()); + $this->assertSame("{$this->phpEOL} WARN The application is in the [production] environment. {$this->phpEOL}{$this->phpEOL}", $output->fetch()); } } From af4626540c177f0819bfdb5fd9192c77f2dbbf5e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 11:15:57 +0100 Subject: [PATCH 094/101] Fixes windows tests --- tests/Console/View/ComponentsTest.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/Console/View/ComponentsTest.php b/tests/Console/View/ComponentsTest.php index 04ae4304450f..8bb84031b688 100644 --- a/tests/Console/View/ComponentsTest.php +++ b/tests/Console/View/ComponentsTest.php @@ -11,11 +11,6 @@ class ComponentsTest extends TestCase { - protected function setUp(): void - { - $this->phpEOL = PHP_EOL; - } - protected function tearDown(): void { m::close(); @@ -54,7 +49,7 @@ public function testError() with(new Components\Error($output))->render('The application is in the [production] environment'); - $this->assertSame("{$this->phpEOL} ERROR The application is in the [production] environment. {$this->phpEOL}{$this->phpEOL}", $output->fetch()); + $this->assertStringContainsString("ERROR The application is in the [production] environment.", $output->fetch()); } public function testInfo() @@ -63,7 +58,7 @@ public function testInfo() with(new Components\Info($output))->render('The application is in the [production] environment'); - $this->assertSame("{$this->phpEOL} INFO The application is in the [production] environment. {$this->phpEOL}{$this->phpEOL}", $output->fetch()); + $this->assertStringContainsString("INFO The application is in the [production] environment.", $output->fetch()); } public function testConfirm() @@ -123,6 +118,6 @@ public function testWarn() with(new Components\Warn($output))->render('The application is in the [production] environment'); - $this->assertSame("{$this->phpEOL} WARN The application is in the [production] environment. {$this->phpEOL}{$this->phpEOL}", $output->fetch()); + $this->assertStringContainsString("WARN The application is in the [production] environment.", $output->fetch()); } } From 5e3e68974f059f946b6bf727770e02fc6eb054a8 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 12 Jul 2022 10:16:36 +0000 Subject: [PATCH 095/101] Apply fixes from StyleCI --- tests/Console/View/ComponentsTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Console/View/ComponentsTest.php b/tests/Console/View/ComponentsTest.php index 8bb84031b688..4bd872f4a6f4 100644 --- a/tests/Console/View/ComponentsTest.php +++ b/tests/Console/View/ComponentsTest.php @@ -49,7 +49,7 @@ public function testError() with(new Components\Error($output))->render('The application is in the [production] environment'); - $this->assertStringContainsString("ERROR The application is in the [production] environment.", $output->fetch()); + $this->assertStringContainsString('ERROR The application is in the [production] environment.', $output->fetch()); } public function testInfo() @@ -58,7 +58,7 @@ public function testInfo() with(new Components\Info($output))->render('The application is in the [production] environment'); - $this->assertStringContainsString("INFO The application is in the [production] environment.", $output->fetch()); + $this->assertStringContainsString('INFO The application is in the [production] environment.', $output->fetch()); } public function testConfirm() @@ -118,6 +118,6 @@ public function testWarn() with(new Components\Warn($output))->render('The application is in the [production] environment'); - $this->assertStringContainsString("WARN The application is in the [production] environment.", $output->fetch()); + $this->assertStringContainsString('WARN The application is in the [production] environment.', $output->fetch()); } } From 3bf2b02ff335ebf7ea52daa3bbd5d9b326342635 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 11:44:21 +0100 Subject: [PATCH 096/101] Displays duration always, except when there is no task at all --- src/Illuminate/Console/View/Components/Task.php | 6 ++---- .../Foundation/Console/PackageDiscoverCommand.php | 4 ++-- tests/Integration/Migration/MigratorTest.php | 6 ++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index 33750bbef46b..0aef986ee42c 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -24,8 +24,6 @@ public function render($description, $task = null, $verbosity = OutputInterface: Mutators\EnsureRelativePaths::class, ]); - $task = $task ?: fn () => true; - $descriptionWidth = mb_strlen(preg_replace("/\<[\w=#\/\;,:.&,%?]+\>|\\e\[\d+m/", '$1', $description) ?? ''); $this->output->write(" $description ", false, $verbosity); @@ -35,11 +33,11 @@ public function render($description, $task = null, $verbosity = OutputInterface: $result = false; try { - $result = $task(); + $result = ($task ?: fn () => true)(); } catch (Throwable $e) { throw $e; } finally { - $runTime = (microtime(true) - $startTime) > 0.05 + $runTime = $task ? (' '.number_format((microtime(true) - $startTime) * 1000, 2).'ms') : ''; diff --git a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php index 0effad8261ae..d9b928f4ad4a 100644 --- a/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php +++ b/src/Illuminate/Foundation/Console/PackageDiscoverCommand.php @@ -47,8 +47,8 @@ public function handle(PackageManifest $manifest) $manifest->build(); collect($manifest->manifest) - ->map(fn () => fn () => true) - ->each(fn ($task, $description) => $this->components->task($description, $task)) + ->keys() + ->each(fn ($description) => $this->components->task($description)) ->whenNotEmpty(fn () => $this->newLine()); } } diff --git a/tests/Integration/Migration/MigratorTest.php b/tests/Integration/Migration/MigratorTest.php index b99d22f54ee4..2168c289ebbf 100644 --- a/tests/Integration/Migration/MigratorTest.php +++ b/tests/Integration/Migration/MigratorTest.php @@ -113,10 +113,16 @@ protected function expectBulletList($elements): void protected function expectTask($description, $result): void { + // Ignore dots... $this->output->shouldReceive('write')->with(m::on( fn ($argument) => str($argument)->contains(['', '.']), ), m::any(), m::any()); + // Ignore duration... + $this->output->shouldReceive('write')->with(m::on( + fn ($argument) => str($argument)->contains(['ms']), + ), m::any(), m::any()); + $this->output->shouldReceive('write')->once()->with(m::on( fn ($argument) => str($argument)->contains($description), ), m::any(), m::any()); From 03b61f1adf6a2b3f28941d25bb45b15e460148a2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 13:23:40 +0100 Subject: [PATCH 097/101] Improves `db:seed` output --- .../Console/Migrations/MigrateCommand.php | 2 ++ .../Console/Migrations/RefreshCommand.php | 2 ++ .../Database/Console/Seeds/SeedCommand.php | 4 ++-- src/Illuminate/Database/Seeder.php | 20 ++++++++----------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 8022f0518177..8e132d1147e1 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -91,6 +91,8 @@ public function handle() // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed') && ! $this->option('pretend')) { + $this->newLine(); + $this->call('db:seed', [ '--class' => $this->option('seeder') ?: 'Database\\Seeders\\DatabaseSeeder', '--force' => true, diff --git a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php b/src/Illuminate/Database/Console/Migrations/RefreshCommand.php index 2073cd9977e6..aff48ace944c 100755 --- a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/RefreshCommand.php @@ -132,6 +132,8 @@ protected function needsSeeding() */ protected function runSeeder($database) { + $this->newLine(); + $this->call('db:seed', array_filter([ '--database' => $database, '--class' => $this->option('seeder') ?: 'Database\\Seeders\\DatabaseSeeder', diff --git a/src/Illuminate/Database/Console/Seeds/SeedCommand.php b/src/Illuminate/Database/Console/Seeds/SeedCommand.php index 0ebc26f77f78..235958648925 100644 --- a/src/Illuminate/Database/Console/Seeds/SeedCommand.php +++ b/src/Illuminate/Database/Console/Seeds/SeedCommand.php @@ -71,6 +71,8 @@ public function handle() return 1; } + $this->components->info('Seeding database.'); + $previousConnection = $this->resolver->getDefaultConnection(); $this->resolver->setDefaultConnection($this->getDatabase()); @@ -83,8 +85,6 @@ public function handle() $this->resolver->setDefaultConnection($previousConnection); } - $this->components->info('Database seeding completed successfully.'); - return 0; } diff --git a/src/Illuminate/Database/Seeder.php b/src/Illuminate/Database/Seeder.php index 1a7a12e1914d..a702609936fd 100755 --- a/src/Illuminate/Database/Seeder.php +++ b/src/Illuminate/Database/Seeder.php @@ -3,6 +3,7 @@ namespace Illuminate\Database; use Illuminate\Console\Command; +use Illuminate\Console\View\Components\Task; use Illuminate\Container\Container; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Support\Arr; @@ -48,18 +49,13 @@ public function call($class, $silent = false, array $parameters = []) $name = get_class($seeder); - if ($silent === false && isset($this->command)) { - $this->command->getOutput()->writeln("Seeding: {$name}"); - } - - $startTime = microtime(true); - - $seeder->__invoke($parameters); - - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); - - if ($silent === false && isset($this->command)) { - $this->command->getOutput()->writeln("Seeded: {$name} ({$runTime}ms)"); + if ($silent || ! isset($this->command)) { + $seeder->__invoke($parameters); + } else { + with(new Task($this->command->getOutput()))->render( + $name, + fn () => $seeder->__invoke($parameters), + ); } static::$called[] = $class; From 537d47f5cec034d708e44b9237ba9ba9fc642585 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 13:37:42 +0100 Subject: [PATCH 098/101] Improves new line on `seed` command --- src/Illuminate/Database/Console/Migrations/FreshCommand.php | 2 ++ .../Database/Console/Migrations/MigrateCommand.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index e319e74bc06a..d3d8bbe534d8 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -90,6 +90,8 @@ protected function needsSeeding() */ protected function runSeeder($database) { + $this->newLine(); + $this->call('db:seed', array_filter([ '--database' => $database, '--class' => $this->option('seeder') ?: 'Database\\Seeders\\DatabaseSeeder', diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 8e132d1147e1..444876d85cc1 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -81,7 +81,7 @@ public function handle() // Next, we will check to see if a path option has been defined. If it has // we will use the path relative to the root of this installation folder // so that migrations may be run for any path within the applications. - $this->migrator->setOutput($this->output) + $migrations = $this->migrator->setOutput($this->output) ->run($this->getMigrationPaths(), [ 'pretend' => $this->option('pretend'), 'step' => $this->option('step'), @@ -91,7 +91,9 @@ public function handle() // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed') && ! $this->option('pretend')) { - $this->newLine(); + if (! empty($migrations)) { + $this->newLine(); + } $this->call('db:seed', [ '--class' => $this->option('seeder') ?: 'Database\\Seeders\\DatabaseSeeder', From e8f405508afcb954f112ff47fddbe508ebaed365 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Jul 2022 13:46:09 +0100 Subject: [PATCH 099/101] Fixes seeding tests --- tests/Database/DatabaseSeederTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Database/DatabaseSeederTest.php b/tests/Database/DatabaseSeederTest.php index 7926a1ff2a27..907f47d7b4ff 100755 --- a/tests/Database/DatabaseSeederTest.php +++ b/tests/Database/DatabaseSeederTest.php @@ -46,8 +46,7 @@ public function testCallResolveTheClassAndCallsRun() $child->shouldReceive('setContainer')->once()->with($container)->andReturn($child); $child->shouldReceive('setCommand')->once()->with($command)->andReturn($child); $child->shouldReceive('__invoke')->once(); - $command->shouldReceive('getOutput')->once()->andReturn($output); - $output->shouldReceive('writeln')->once(); + $output->shouldReceive('write')->times(3); $seeder->call('ClassName'); } From 77fe993fa2f961b3a2f90266d600ee6eb1a67170 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 13 Jul 2022 12:05:34 +0100 Subject: [PATCH 100/101] Ensures max width --- src/Illuminate/Console/View/Components/Task.php | 4 +++- .../Console/resources/views/components/two-column-detail.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/View/Components/Task.php b/src/Illuminate/Console/View/Components/Task.php index 0aef986ee42c..001bbb3a940b 100644 --- a/src/Illuminate/Console/View/Components/Task.php +++ b/src/Illuminate/Console/View/Components/Task.php @@ -42,7 +42,9 @@ public function render($description, $task = null, $verbosity = OutputInterface: : ''; $runTimeWidth = mb_strlen($runTime); - $dots = max(terminal()->width() - $descriptionWidth - $runTimeWidth - 10, 0); + $width = min(terminal()->width(), 150); + $dots = max($width - $descriptionWidth - $runTimeWidth - 10, 0); + $this->output->write(str_repeat('.', $dots), false, $verbosity); $this->output->write("$runTime", false, $verbosity); diff --git a/src/Illuminate/Console/resources/views/components/two-column-detail.php b/src/Illuminate/Console/resources/views/components/two-column-detail.php index 995ca60115de..1aeed496f8ae 100644 --- a/src/Illuminate/Console/resources/views/components/two-column-detail.php +++ b/src/Illuminate/Console/resources/views/components/two-column-detail.php @@ -1,4 +1,4 @@ -
+
From 1d21cbf5a563d7b4057ad55d0ee778ad4f5f1182 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 14 Jul 2022 09:34:30 -0500 Subject: [PATCH 101/101] formatting --- src/Illuminate/Console/OutputStyle.php | 96 +++++++++---------- .../Console/Scheduling/ScheduleRunCommand.php | 2 +- src/Illuminate/Queue/Console/WorkCommand.php | 1 + 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/Illuminate/Console/OutputStyle.php b/src/Illuminate/Console/OutputStyle.php index a61d828806db..06eeef186b14 100644 --- a/src/Illuminate/Console/OutputStyle.php +++ b/src/Illuminate/Console/OutputStyle.php @@ -10,18 +10,18 @@ class OutputStyle extends SymfonyStyle implements NewLineAware { /** - * If the last output wrote a new line. + * The output instance. * - * @var bool + * @var \Symfony\Component\Console\Output\OutputInterface */ - protected $newLineWritten = false; + private $output; /** - * The output instance. + * If the last output written wrote a new line. * - * @var \Symfony\Component\Console\Output\OutputInterface + * @var bool */ - private $output; + protected $newLineWritten = false; /** * Create a new Console OutputStyle instance. @@ -37,6 +37,48 @@ public function __construct(InputInterface $input, OutputInterface $output) parent::__construct($input, $output); } + /** + * {@inheritdoc} + */ + public function write(string|iterable $messages, bool $newline = false, int $options = 0) + { + $this->newLineWritten = $newline; + + parent::write($messages, $newline, $options); + } + + /** + * {@inheritdoc} + */ + public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL) + { + $this->newLineWritten = true; + + parent::writeln($messages, $type); + } + + /** + * {@inheritdoc} + */ + public function newLine(int $count = 1) + { + $this->newLineWritten = $count > 0; + + parent::newLine($count); + } + + /** + * {@inheritdoc} + */ + public function newLineWritten() + { + if ($this->output instanceof static && $this->output->newLineWritten()) { + return true; + } + + return $this->newLineWritten; + } + /** * Returns whether verbosity is quiet (-q). * @@ -86,46 +128,4 @@ public function getOutput() { return $this->output; } - - /** - * {@inheritdoc} - */ - public function write(string|iterable $messages, bool $newline = false, int $options = 0) - { - $this->newLineWritten = $newline; - - parent::write($messages, $newline, $options); - } - - /** - * {@inheritdoc} - */ - public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL) - { - $this->newLineWritten = true; - - parent::writeln($messages, $type); - } - - /** - * {@inheritdoc} - */ - public function newLine(int $count = 1) - { - $this->newLineWritten = $count > 0; - - parent::newLine($count); - } - - /** - * {@inheritdoc} - */ - public function newLineWritten() - { - if ($this->output instanceof static && $this->output->newLineWritten()) { - return true; - } - - return $this->newLineWritten; - } } diff --git a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php index dca910ce908a..067aebd05519 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php @@ -79,7 +79,7 @@ class ScheduleRunCommand extends Command protected $handler; /** - * The PHP Binary used by the command. + * The PHP binary used by the command. * * @var string */ diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 5c9ae70741e3..2ee07ddcb420 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -205,6 +205,7 @@ protected function writeOutput(Job $job, $status) $runTime = number_format((microtime(true) - $this->latestStartedAt) * 1000, 2).'ms'; $dots = max(terminal()->width() - mb_strlen($job->resolveName()) - mb_strlen($runTime) - 31, 0); + $this->output->write(' '.str_repeat('.', $dots)); $this->output->write(" $runTime"); $this->output->writeln($status == 'success' ? ' DONE' : ' FAIL');