Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[9.x] Introducing a fresh new look for Artisan #43065

Merged
merged 102 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
e27ab3e
Improves console output
nunomaduro Jun 29, 2022
01f8e99
Apply fixes from StyleCI
StyleCIBot Jun 29, 2022
ab0bd25
Improves confirmable trait wording
nunomaduro Jun 30, 2022
f04e529
Refactors to components
nunomaduro Jun 30, 2022
c87ffea
Improves vendor publish
nunomaduro Jun 30, 2022
46b5e48
Apply fixes from StyleCI
StyleCIBot Jun 30, 2022
e71d6b7
Fixes displaying line without style
nunomaduro Jun 30, 2022
00a5854
Adds Bullet List componenent
nunomaduro Jul 4, 2022
9adaa23
Adds Alert component
nunomaduro Jul 4, 2022
28c8290
Gives access to bullet list and detail on the command
nunomaduro Jul 4, 2022
3a1259d
Improves Detail output
nunomaduro Jul 4, 2022
d3e96cd
Fixes Line info output
nunomaduro Jul 4, 2022
ab1f208
Truncates given information to componenents
nunomaduro Jul 4, 2022
2628ae1
Improves `migrate:fresh` output
nunomaduro Jul 4, 2022
8556a2e
Improves `migrate` output
nunomaduro Jul 4, 2022
62941b5
Improves `make:migrate` output
nunomaduro Jul 4, 2022
e30fec5
Improves `migrate:status` output
nunomaduro Jul 4, 2022
57c31bb
Improves `migrate` output
nunomaduro Jul 4, 2022
5e8f703
Refactors `event:list` output
nunomaduro Jul 4, 2022
7242fa3
Improves `queue:work` output
nunomaduro Jul 4, 2022
df80ff7
Apply fixes from StyleCI
StyleCIBot Jul 4, 2022
8bb7eb7
Fixes static analysis
nunomaduro Jul 4, 2022
22a431d
Improves `queue:listen` output
nunomaduro Jul 4, 2022
f4b4ecc
Swaps dynamic part of the detail to the left.
nunomaduro Jul 4, 2022
77cf4d6
Apply fixes from StyleCI
StyleCIBot Jul 4, 2022
fe096cb
Improves `queue:monitor` output
nunomaduro Jul 4, 2022
3818e79
Adds title to migrate status command
nunomaduro Jul 4, 2022
2b79f22
Apply fixes from StyleCI
StyleCIBot Jul 4, 2022
94b7d06
Improves `schedule:test` output
nunomaduro Jul 4, 2022
509ceca
Apply fixes from StyleCI
StyleCIBot Jul 4, 2022
6675290
Fixes length of dots
nunomaduro Jul 4, 2022
218872b
Fixes extra style
nunomaduro Jul 4, 2022
ddfdc1c
Improves `schedule:run` output
nunomaduro Jul 4, 2022
7dcb5cd
Fixes missing style
nunomaduro Jul 4, 2022
28ca611
Improves `schedule:work` output
nunomaduro Jul 5, 2022
83dfcf7
Improve "inspire" command
nunomaduro Jul 5, 2022
aafccde
Refactors inspiring
nunomaduro Jul 5, 2022
b83a532
Refactors line
nunomaduro Jul 5, 2022
145ea48
Avoids conflicts by naming "x-line" to "x-illuminate-console-line"
nunomaduro Jul 5, 2022
91b9797
Avoids `ConsoleServiceProvider`
nunomaduro Jul 5, 2022
d6747c0
Apply fixes from StyleCI
StyleCIBot Jul 5, 2022
5df59b8
Adds space to breath
nunomaduro Jul 5, 2022
47a9f26
Fixes margin top
nunomaduro Jul 5, 2022
0cdb519
Removes `tasks` and `task` from the public api
nunomaduro Jul 5, 2022
38c15ac
Apply fixes from StyleCI
StyleCIBot Jul 5, 2022
4e02dbc
Fixes new line written
nunomaduro Jul 6, 2022
b79d8f9
Remove `bulletList` and `detail`
nunomaduro Jul 6, 2022
9b595cd
Renames `Detail` to `TwoColumnDetail`
nunomaduro Jul 6, 2022
f58dc13
Apply fixes from StyleCI
StyleCIBot Jul 6, 2022
66eb522
Removes unused code
nunomaduro Jul 6, 2022
8f31561
Fixes two columns view
nunomaduro Jul 6, 2022
d621715
Reverts changes on `$this->alert`
nunomaduro Jul 6, 2022
365138e
Always finishes with a dot
nunomaduro Jul 6, 2022
8bca9a5
Uses task component only when is a task
nunomaduro Jul 6, 2022
98a2b32
Fixes access to parent question helper
nunomaduro Jul 6, 2022
bc2ab37
Fixes missing new line
nunomaduro Jul 6, 2022
c3bd3f6
Renames `renderUsing` to `render`
nunomaduro Jul 7, 2022
29d6e99
Moves components resources directory
nunomaduro Jul 7, 2022
17f9aaf
Fixes multiple listeners on `event:list`
nunomaduro Jul 7, 2022
27b344a
Uses `$this->components` to print output
nunomaduro Jul 7, 2022
c306062
Apply fixes from StyleCI
StyleCIBot Jul 7, 2022
6521918
Removes blade dependency
nunomaduro Jul 7, 2022
caded00
Apply fixes from StyleCI
StyleCIBot Jul 7, 2022
f5a72c8
Fixes more tests
nunomaduro Jul 8, 2022
414e932
Fixes more tests
nunomaduro Jul 8, 2022
e43ea31
Fixes tests when using PHP 8.0
nunomaduro Jul 8, 2022
af31579
Rewords `env` command
nunomaduro Jul 8, 2022
34abe68
Asks previous output if new line was written
nunomaduro Jul 8, 2022
b1a277f
Improves migrate command
nunomaduro Jul 8, 2022
dc0c359
Rewords `optimize:clear`
nunomaduro Jul 8, 2022
0298ae8
Fixes new lines on migrations
nunomaduro Jul 8, 2022
e85ac04
Apply fixes from StyleCI
StyleCIBot Jul 8, 2022
ea7f369
Improves `model:prune` command
nunomaduro Jul 11, 2022
16881fb
Only prints new line when packages found
nunomaduro Jul 11, 2022
c0ef63c
Improves `list:failed` command
nunomaduro Jul 11, 2022
639819a
Apply fixes from StyleCI
StyleCIBot Jul 11, 2022
aa9bfcd
Improves `queue:retry` and `queue:retry-batch` wording
nunomaduro Jul 11, 2022
56ac3ed
Improve `schedule:run` command
nunomaduro Jul 11, 2022
f28074f
Makes `schedule:test` very similar to `schedule:run`
nunomaduro Jul 11, 2022
f5433bf
Apply fixes from StyleCI
StyleCIBot Jul 11, 2022
ef9f636
Fixes tests
nunomaduro Jul 11, 2022
41a4560
Improves wording
nunomaduro Jul 11, 2022
5a51f8c
Removes non-used file
nunomaduro Jul 11, 2022
c6ed3e1
Uses latest version of Termwind
nunomaduro Jul 11, 2022
5220ef7
Fixes tests on windows
nunomaduro Jul 11, 2022
d2aaf69
Adds tests to components
nunomaduro Jul 11, 2022
53a8b3d
Apply fixes from StyleCI
StyleCIBot Jul 11, 2022
62b2dce
Updates `env` wording
nunomaduro Jul 12, 2022
b5439cd
Updates question first and second color
nunomaduro Jul 12, 2022
46b6968
Adds skipped wording on `vendor:publish`
nunomaduro Jul 12, 2022
8ce9c30
Adds missing method on interface and tests
nunomaduro Jul 12, 2022
1ae0610
Adds test on underlying output
nunomaduro Jul 12, 2022
a7b61d7
Uses `PHP_EOL` for windows tests
nunomaduro Jul 12, 2022
af46265
Fixes windows tests
nunomaduro Jul 12, 2022
5e3e689
Apply fixes from StyleCI
StyleCIBot Jul 12, 2022
3bf2b02
Displays duration always, except when there is no task at all
nunomaduro Jul 12, 2022
03b61f1
Improves `db:seed` output
nunomaduro Jul 12, 2022
537d47f
Improves new line on `seed` command
nunomaduro Jul 12, 2022
e8f4055
Fixes seeding tests
nunomaduro Jul 12, 2022
77fe993
Ensures max width
nunomaduro Jul 13, 2022
1d21cbf
formatting
taylorotwell Jul 14, 2022
5f7e8dc
Merge branch '9.x' into feat/console-ui-improvements
taylorotwell Jul 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"league/flysystem": "^3.0.16",
"monolog/monolog": "^2.0",
"nesbot/carbon": "^2.53.1",
"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",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Console/ClearResetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/Console/CacheTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cache/Console/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/Console/ForgetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
}
3 changes: 3 additions & 0 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Console/Concerns/CreatesMatchingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
9 changes: 9 additions & 0 deletions src/Illuminate/Console/Concerns/InteractsWithIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Console/ConfirmableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -24,12 +24,12 @@ public function confirmToProceed($warning = 'Application In Production!', $callb
return true;
}

$this->alert($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->comment('Command Canceled!');
$this->components->warn('Command canceled.');

return false;
}
Expand Down
13 changes: 13 additions & 0 deletions src/Illuminate/Console/Contracts/NewLineAware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Illuminate\Console\Contracts;

interface NewLineAware
nunomaduro marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* Whether a newline has already been written.
*
* @return bool
*/
public function newLineWritten();
}
12 changes: 8 additions & 4 deletions src/Illuminate/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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->components->info($info.' created successfully.');
}

/**
Expand Down
52 changes: 51 additions & 1 deletion src/Illuminate/Console/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Illuminate\Console;

use Illuminate\Console\Contracts\NewLineAware;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class OutputStyle extends SymfonyStyle
class OutputStyle extends SymfonyStyle implements NewLineAware
{
/**
* The output instance.
Expand All @@ -15,6 +16,13 @@ class OutputStyle extends SymfonyStyle
*/
private $output;

/**
* If the last output written wrote a new line.
*
* @var bool
*/
protected $newLineWritten = false;

/**
* Create a new Console OutputStyle instance.
*
Expand All @@ -29,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).
*
Expand Down
77 changes: 77 additions & 0 deletions src/Illuminate/Console/QuestionHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Illuminate\Console;

use Illuminate\Console\View\Components\TwoColumnDetail;
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;

class QuestionHelper extends SymfonyQuestionHelper
{
/**
* {@inheritdoc}
*/
protected function writePrompt(OutputInterface $output, Question $question)
{
$text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());

$text = $this->ensureEndsWithPunctuation($text);

$text = " <fg=default;options=bold>$text</></>";

$default = $question->getDefault();

if ($question->isMultiline()) {
$text .= sprintf(' (press %s to continue)', 'Windows' == PHP_OS_FAMILY
nunomaduro marked this conversation as resolved.
Show resolved Hide resolved
? '<comment>Ctrl+Z</comment> then <comment>Enter</comment>'
: '<comment>Ctrl+D</comment>');
}

switch (true) {
case null === $default:
$text = sprintf('<info>%s</info>', $text);

break;

case $question instanceof ConfirmationQuestion:
$text = sprintf('<info>%s (yes/no)</info> [<comment>%s</comment>]', $text, $default ? 'yes' : 'no');

break;

case $question instanceof ChoiceQuestion:
$choices = $question->getChoices();
$text = sprintf('<info>%s</info> [<comment>%s</comment>]', $text, OutputFormatter::escape($choices[$default] ?? $default));

break;
}

$output->writeln($text);

if ($question instanceof ChoiceQuestion) {
foreach ($question->getChoices() as $key => $value) {
with(new TwoColumnDetail($output))->render($value, $key);
}
}

$output->write('<options=bold>❯ </>');
}

/**
* Ensures the given string ends with punctuation.
*
* @param string $string
* @return string
*/
protected function ensureEndsWithPunctuation($string)
{
if (! str($string)->endsWith(['?', ':', '!', '.'])) {
return "$string:";
}

return $string;
}
}
6 changes: 6 additions & 0 deletions src/Illuminate/Console/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function handle(Schedule $schedule)

foreach ($schedule->events($this->laravel) as $event) {
if ($event->mutex->exists($event)) {
$this->line('<info>Deleting mutex for:</info> '.$event->command);
$this->components->info(sprintf('Deleting mutex for [%s]', $event->command));

$event->mutex->forget($event);

Expand All @@ -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.');
}
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->components->info('No scheduled tasks have been defined.');

return;
}
Expand Down
Loading