class DevCommands (View source)

Properties

static protected NodePackageManager|null $packageManager

The resolved NodePackageManager instance.

static protected int $colorCount

Counter to keep track of how many colors have been assigned,.

static protected array $commands

The registered development commands.

static protected array<int,string> $only

The names of commands that should be included when running the "dev" command.

static protected array<int,string> $except

The names of commands that should be excluded when running the "dev" command.

Methods

static void
registerDefaults()

Register the default development commands.

static DevCommand
register(string $command, string|null $name = null)

Register a development command.

static DevCommand
artisan(string $command, string|null $name = null)

Registers an Artisan command, automatically prefixing it with "php artisan".

static DevCommand
node(string $command, string|null $name = null)

Registers a Node command, automatically prefixing it with the detected package manager's run command.

static DevCommand
nodeExec(string $command, string|null $name = null)

Registers a Node command, automatically prefixing it with the detected package manager's exec command.

static array
commands()

Get the registered development commands.

static array
fillInEmptyColors(array $commands)

Fill in any empty colors in the given commands array, ensuring each command has a color assigned.

static string
getColor(array $commands)

Get a color for a command, ensuring that colors are reused only after all available colors have been used at least once.

static void
preventVendorRegistration(string $name)

Prevent automatic registration of DevCommands from within vendor packages.

static void
only(string ...$names)

Set the commands that should be included when running the "dev" command.

static void
except(string ...$names)

Set the commands that should be excluded when running the "dev" command.

static string
nameFromCommand(string $command)

Derive a command name from the given command string by taking the first word.

getPackageManager()

Resolve and return the NodePackageManager instance.

static void
clear()

Clear all registered development commands and reset the state of the DevCommands class.

Details

static void registerDefaults()

Register the default development commands.

Return Value

void

static DevCommand register(string $command, string|null $name = null)

Register a development command.

Parameters

string $command
string|null $name

Return Value

DevCommand

static DevCommand artisan(string $command, string|null $name = null)

Registers an Artisan command, automatically prefixing it with "php artisan".

Parameters

string $command
string|null $name

Return Value

DevCommand

static DevCommand node(string $command, string|null $name = null)

Registers a Node command, automatically prefixing it with the detected package manager's run command.

Parameters

string $command
string|null $name

Return Value

DevCommand

static DevCommand nodeExec(string $command, string|null $name = null)

Registers a Node command, automatically prefixing it with the detected package manager's exec command.

Parameters

string $command
string|null $name

Return Value

DevCommand

static array commands()

Get the registered development commands.

Return Value

array

static protected array fillInEmptyColors(array $commands)

Fill in any empty colors in the given commands array, ensuring each command has a color assigned.

Parameters

array $commands

Return Value

array

static protected string getColor(array $commands)

Get a color for a command, ensuring that colors are reused only after all available colors have been used at least once.

Parameters

array $commands

Return Value

string

static protected void preventVendorRegistration(string $name)

Prevent automatic registration of DevCommands from within vendor packages.

Parameters

string $name

Return Value

void

Exceptions

Exception

static void only(string ...$names)

Set the commands that should be included when running the "dev" command.

Parameters

string ...$names

Return Value

void

static void except(string ...$names)

Set the commands that should be excluded when running the "dev" command.

Parameters

string ...$names

Return Value

void

static protected string nameFromCommand(string $command)

Derive a command name from the given command string by taking the first word.

Parameters

string $command

Return Value

string

static protected NodePackageManager getPackageManager()

Resolve and return the NodePackageManager instance.

Return Value

NodePackageManager

static void clear()

Clear all registered development commands and reset the state of the DevCommands class.

Return Value

void