-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Add artisan dev command
#60412
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
Open
joetannenbaum
wants to merge
27
commits into
13.x
Choose a base branch
from
composer-dev-process
base: 13.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add artisan dev command
#60412
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
bbb41b0
scaffolded
joetannenbaum cb4f2eb
default command, except, only
joetannenbaum a1063a4
clear
joetannenbaum f9f957b
Update DevCommands.php
joetannenbaum 0c6fb4b
first real pass at vendor prevention
joetannenbaum b42b98f
Update DevCommands.php
joetannenbaum 8030780
Update DevCommands.php
joetannenbaum 828814a
doc blocks
joetannenbaum 4fdbdf6
Update DevCommands.php
joetannenbaum 960112f
small fixes
joetannenbaum ddd625a
fixes
joetannenbaum a1f54da
better method names
joetannenbaum 3b798a9
Update NodePackageManager.php
joetannenbaum 6f6e47e
tests
joetannenbaum fa562eb
Update DevCommand.php
joetannenbaum 8413dc4
pint
joetannenbaum fb87a90
Update FoundationDevCommandsTest.php
joetannenbaum 1d7f0ad
Update SupportNodePackageManagerTest.php
joetannenbaum 82d888b
colors -> enum
joetannenbaum 437dfd8
Update DevCommand.php
joetannenbaum 60d69e1
strstr instead of collect
joetannenbaum 30e5aa4
Update src/Illuminate/Foundation/DevCommand.php
joetannenbaum dcec89e
Update src/Illuminate/Foundation/DevCommands.php
joetannenbaum 023d952
use new color enum
joetannenbaum bb5bc73
Merge branch 'composer-dev-process' of github.com:laravel/framework i…
joetannenbaum f4b748b
Update DevCommand.php
joetannenbaum 6770f5e
Update DevCommand.php
joetannenbaum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Foundation\Console; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Illuminate\Foundation\DevCommands; | ||
| use Illuminate\Support\NodePackageManager; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
|
|
||
| #[AsCommand(name: 'dev')] | ||
| class DevCommand extends Command | ||
| { | ||
| /** | ||
| * The console command name. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $name = 'dev'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'Run the dev processes'; | ||
|
|
||
| /** | ||
| * Execute the console command. | ||
| * | ||
| * @return int | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function handle(NodePackageManager $packageManager) | ||
| { | ||
| $devCommands = DevCommands::commands(); | ||
|
|
||
| $commands = array_column($devCommands, 'command'); | ||
| $colors = array_column($devCommands, 'color'); | ||
| $names = array_column($devCommands, 'name'); | ||
|
|
||
| $longestName = max(array_map('strlen', $names)); | ||
|
joetannenbaum marked this conversation as resolved.
Outdated
|
||
|
|
||
| $this->line(''); | ||
|
|
||
| foreach ($devCommands as $devCommand) { | ||
| $this->line( | ||
| sprintf( | ||
| '<fg=%s>[%s]</>%s<fg=#888888>%s</>', | ||
| $devCommand['color'], | ||
| $devCommand['name'], | ||
| str_repeat(' ', ($longestName - strlen($devCommand['name'])) + 1), | ||
| $devCommand['command'], | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| $this->line(''); | ||
|
|
||
| $command = $packageManager->getExecCommand(sprintf( | ||
| 'concurrently -c "%s" "%s" --names=%s --kill-others', | ||
| implode(',', $colors), | ||
| implode('" "', $commands), | ||
| implode(',', $names) | ||
| )); | ||
|
|
||
| if (extension_loaded('pcntl')) { | ||
| pcntl_exec('/usr/bin/env', ['sh', '-c', $command]); | ||
| } | ||
|
|
||
| passthru($command, $exitCode); | ||
|
|
||
| return $exitCode; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Foundation; | ||
|
|
||
| class DevCommand | ||
| { | ||
| /** | ||
| * Blue color. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const BLUE = '#93c5fd'; | ||
|
|
||
| /** | ||
| * Purple color. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const PURPLE = '#c4b5fd'; | ||
|
|
||
| /** | ||
| * Pink color. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const PINK = '#fb7185'; | ||
|
|
||
| /** | ||
| * Orange color. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const ORANGE = '#fdba74'; | ||
|
|
||
| /** | ||
| * Green color. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const GREEN = '#86efac'; | ||
|
|
||
| /** | ||
| * Yellow color. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const YELLOW = '#fcd34d'; | ||
|
joetannenbaum marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Color of the command when output to the console. | ||
| * | ||
| * @var string|null | ||
| */ | ||
| protected ?string $color = null; | ||
|
|
||
| /** | ||
| * Create a new DevCommand instance. | ||
| * | ||
| * @param string $command | ||
| * @param string|null $name | ||
| * @return void | ||
| */ | ||
| public function __construct(protected string $command, protected ?string $name = null) | ||
| { | ||
| $this->name ??= collect(explode(' ', $command))->first(); | ||
|
joetannenbaum marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Get the command name. | ||
| * | ||
| * @return string | ||
| */ | ||
| public function name(): string | ||
| { | ||
| return $this->name; | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color. | ||
| * | ||
| * @param string $color | ||
| * @return self | ||
| */ | ||
| public function color(string $color): self | ||
| { | ||
| $this->color = $color; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color to blue. | ||
| * | ||
| * @return self | ||
| */ | ||
| public function blue(): self | ||
| { | ||
| return $this->color(self::BLUE); | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color to purple. | ||
| * | ||
| * @return self | ||
| */ | ||
| public function purple(): self | ||
| { | ||
| return $this->color(self::PURPLE); | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color to pink. | ||
| * | ||
| * @return self | ||
| */ | ||
| public function pink(): self | ||
| { | ||
| return $this->color(self::PINK); | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color to orange. | ||
| * | ||
| * @return self | ||
| */ | ||
| public function orange(): self | ||
| { | ||
| return $this->color(self::ORANGE); | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color to green. | ||
| * | ||
| * @return self | ||
| */ | ||
| public function green(): self | ||
| { | ||
| return $this->color(self::GREEN); | ||
| } | ||
|
|
||
| /** | ||
| * Set the command color to yellow. | ||
| * | ||
| * @return self | ||
| */ | ||
| public function yellow(): self | ||
| { | ||
| return $this->color(self::YELLOW); | ||
| } | ||
|
|
||
| /** | ||
| * Get the command as an array. | ||
| * | ||
| * @return array | ||
|
joetannenbaum marked this conversation as resolved.
Outdated
|
||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'command' => $this->command, | ||
| 'name' => $this->name, | ||
| 'color' => $this->color, | ||
| ]; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.