ToolCommands
extends AbstractCommands
in package
Generic tools.
Tags
Table of Contents
- composerLockCheck() : int
- Check if 'composer.lock' exists on the project root folder.
- fixPermissions() : mixed
- Run script to fix permissions (experimental).
- formatBytes() : string
- Helper to convert bytes to human-readable unit.
- getCommitTokens() : array<string|int, mixed>
- Check the commit message for SKIPPING tokens.
- getConfigurationFile() : string
- Path to YAML configuration file containing command defaults.
- getDeploymentEnvironment() : string
- Returns the current environment based on env vars.
- getPackagePropertyFromComposer() : false|mixed
- Helper to return a property from a package in the composer.lock file.
- getWorkingDir() : string
- Returns the current working directory.
- initializeRuntimeConfiguration() : mixed
- Command initialization.
- optsReview() : mixed
- Check project's .opts.yml file for forbidden commands.
- parseOptsYml() : array<string|int, mixed>|false
- Returns the .opts.yml file content.
- toolkitCodeReview() : mixed
- This command will execute all the testing tools.
- toolkitInstallDependencies() : mixed
- Install packages present in the opts.yml file under extra_pkgs section.
- toolkitRequirements() : mixed
- Check the Toolkit Requirements.
- toolkitVendorList() : mixed
- Check 'Vendor' packages being monitored.
- toolkitVersion() : mixed
- Check the Toolkit version.
- getBin() : string
- Validate and return the path to given bin.
- getBinPath() : string
- Return the path to given bin.
- getConfigValue() : mixed
- {@inheritdoc}
- getNodeBin() : string
- Validate and return the path to given bin from node packages.
- getNodeBinPath() : string
- Return the path to given bin from node packages.
- isSimulating() : bool
- Check if current command is being executed with option simulate.
- taskExecute() : mixed
- Execute a command.
- taskProcess() : Process|CollectionBuilder
- Process the file.
- taskReplaceBlock() : ReplaceBlock|CollectionBuilder
- Replace block in a file.
Methods
composerLockCheck()
Check if 'composer.lock' exists on the project root folder.
public
composerLockCheck(ConsoleIO $io) : int
Parameters
- $io : ConsoleIO
Tags
Return values
int —fixPermissions()
Run script to fix permissions (experimental).
public
fixPermissions([array<string|int, mixed> $options = ['drupal_path' => InputOption::VALUE_OPTIONAL, 'drupal_user' => InputOption::VALUE_OPTIONAL, 'httpd_group' => InputOption::VALUE_OPTIONAL] ]) : mixed
Parameters
- $options : array<string|int, mixed> = ['drupal_path' => InputOption::VALUE_OPTIONAL, 'drupal_user' => InputOption::VALUE_OPTIONAL, 'httpd_group' => InputOption::VALUE_OPTIONAL]
Tags
Return values
mixed —formatBytes()
Helper to convert bytes to human-readable unit.
public
static formatBytes(int $bytes[, int $precision = 2 ]) : string
Parameters
- $bytes : int
-
The bytes to convert.
- $precision : int = 2
-
The precision for the conversion.
Return values
string —The converted value.
getCommitTokens()
Check the commit message for SKIPPING tokens.
public
static getCommitTokens() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array with tokens present in the commit message.
getConfigurationFile()
Path to YAML configuration file containing command defaults.
public
getConfigurationFile() : string
Return values
string —getDeploymentEnvironment()
Returns the current environment based on env vars.
public
static getDeploymentEnvironment() : string
This command is called during build-dist, the build-dist is called in the create-distribution step during deployments. If CI env var is defined and TAG is available then the environment is 'prod' otherwise is 'acc'. If no CI env var is defined assume 'dev' environment.
Return values
string —The current environment, one of: 'dev', 'acc', 'prod'.
getPackagePropertyFromComposer()
Helper to return a property from a package in the composer.lock file.
public
static getPackagePropertyFromComposer(string $package[, string $prop = 'version' ][, string|null $section = null ]) : false|mixed
Parameters
- $package : string
-
The package name to search.
- $prop : string = 'version'
-
The property to return, default to 'version'.
- $section : string|null = null
-
Set to 'packages' or 'packages-dev' to filter by section.
Tags
Return values
false|mixed —The property value, false if not found.
getWorkingDir()
Returns the current working directory.
public
getWorkingDir() : string
Return values
string —The current working directory.
initializeRuntimeConfiguration()
Command initialization.
public
initializeRuntimeConfiguration() : mixed
Tags
Return values
mixed —optsReview()
Check project's .opts.yml file for forbidden commands.
public
optsReview(ConsoleIO $io) : mixed
Parameters
- $io : ConsoleIO
Tags
Return values
mixed —parseOptsYml()
Returns the .opts.yml file content.
public
static parseOptsYml() : array<string|int, mixed>|false
Tags
Return values
array<string|int, mixed>|false —An array with the content or false if the file do not exist.
toolkitCodeReview()
This command will execute all the testing tools.
public
toolkitCodeReview(ConsoleIO $io[, array<string|int, mixed> $options = ['phpcs' => InputOption::VALUE_NONE, 'opts-review' => InputOption::VALUE_NONE, 'lint-php' => InputOption::VALUE_NONE, 'lint-yaml' => InputOption::VALUE_NONE, 'phpstan' => InputOption::VALUE_NONE] ]) : mixed
If no option is given, all the tests will be executed.
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['phpcs' => InputOption::VALUE_NONE, 'opts-review' => InputOption::VALUE_NONE, 'lint-php' => InputOption::VALUE_NONE, 'lint-yaml' => InputOption::VALUE_NONE, 'phpstan' => InputOption::VALUE_NONE]
Tags
Return values
mixed —toolkitInstallDependencies()
Install packages present in the opts.yml file under extra_pkgs section.
public
toolkitInstallDependencies(ConsoleIO $io[, array<string|int, mixed> $options = ['print' => InputOption::VALUE_NONE] ]) : mixed
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['print' => InputOption::VALUE_NONE]
Tags
Return values
mixed —toolkitRequirements()
Check the Toolkit Requirements.
public
toolkitRequirements(ConsoleIO $io[, array<string|int, mixed> $options = ['endpoint' => InputOption::VALUE_OPTIONAL] ]) : mixed
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['endpoint' => InputOption::VALUE_OPTIONAL]
Tags
Return values
mixed —toolkitVendorList()
Check 'Vendor' packages being monitored.
public
toolkitVendorList(ConsoleIO $io) : mixed
Parameters
- $io : ConsoleIO
Tags
Return values
mixed —toolkitVersion()
Check the Toolkit version.
public
toolkitVersion(ConsoleIO $io) : mixed
Parameters
- $io : ConsoleIO
Tags
Return values
mixed —getBin()
Validate and return the path to given bin.
protected
getBin(string $name) : string
Parameters
- $name : string
-
The bin to look for.
Tags
Return values
string —The bin path.
getBinPath()
Return the path to given bin.
protected
getBinPath(string $name) : string
Parameters
- $name : string
Return values
string —The path to given binary.
getConfigValue()
{@inheritdoc}
protected
getConfigValue(mixed $key[, mixed $default = null ]) : mixed
Parameters
- $key : mixed
- $default : mixed = null
Return values
mixed —getNodeBin()
Validate and return the path to given bin from node packages.
protected
getNodeBin(string $name) : string
Parameters
- $name : string
-
The bin to look for.
Tags
Return values
string —The bin path.
getNodeBinPath()
Return the path to given bin from node packages.
protected
getNodeBinPath(string $name) : string
Parameters
- $name : string
Return values
string —The path to given binary.
isSimulating()
Check if current command is being executed with option simulate.
protected
isSimulating() : bool
Return values
bool —True if using --simulate, false otherwise.
taskExecute()
Execute a command.
protected
taskExecute(array<string|int, mixed> $tasks) : mixed
Parameters
- $tasks : array<string|int, mixed>
-
An array with tasks to execute.
Return values
mixed —taskProcess()
Process the file.
protected
taskProcess(string $source[, string $destination = '' ]) : Process|CollectionBuilder
Parameters
- $source : string
-
The source file to process.
- $destination : string = ''
-
The destination file.
Return values
Process|CollectionBuilder —taskReplaceBlock()
Replace block in a file.
protected
taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
- $filename : string = ''
-
The file to process.