ToolCommands
extends AbstractCommands
in package
Generic tools.
Tags
Table of Contents
Methods
- 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() : mixed
- Path to YAML configuration file containing command defaults.
- getDeploymentEnvironment() : string
- Returns the current environment based on env vars.
- getJson() : array<string|int, mixed>
- Returns the JSON parsed content.
- getPackageLatestVersion() : null|string
- Returns the latest version of given package.
- getPackagePropertyFromComposer() : false|mixed
- Helper to return a property from a package in the composer.lock file.
- getWorkingDir() : string
- Returns the current working directory.
- isPackageInstalled() : bool
- Helper to tell if package is installed.
- isWebsiteInstalled() : bool
- Check if the website is installed.
- 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
- Execute all or specific tools for static testing.
- toolkitInstallDependencies() : mixed
- Install packages present in the .opts.yml file under extra_pkgs section.
- toolkitNotifications() : mixed
- Display Toolkit notifications.
- 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.
- isJunit() : bool
- Check whether Junit option is being used, or env var is set.
- isSimulating() : bool
- Check if current command is being executed with option simulate.
- taskExecute() : mixed
- Execute a command.
- taskProcess() : mixed
- Process the file.
- taskReplaceBlock() : mixed
- 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
intfixPermissions()
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
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() : mixed
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'.
getJson()
Returns the JSON parsed content.
public
getJson(string $filename[, mixed $throwException = true ]) : array<string|int, mixed>
Parameters
- $filename : string
- $throwException : mixed = true
Return values
array<string|int, mixed>getPackageLatestVersion()
Returns the latest version of given package.
public
static getPackageLatestVersion(string $package) : null|string
Parameters
- $package : string
-
The package to get the latest version, i.e: ec-europa/toolkit.
Return values
null|string —Returns the package version, or null if the package is not found.
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.
isPackageInstalled()
Helper to tell if package is installed.
public
static isPackageInstalled(string $package) : bool
Parameters
- $package : string
-
The package name to search.
Return values
bool —True or false if not found.
isWebsiteInstalled()
Check if the website is installed.
public
isWebsiteInstalled() : bool
Return values
booloptsReview()
Check project's .opts.yml file for forbidden commands.
public
optsReview(ConsoleIO $io[, array<string|int, mixed> $options = ['endpoint' => InputOption::VALUE_REQUIRED] ]) : mixed
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['endpoint' => InputOption::VALUE_REQUIRED]
Tags
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()
Execute all or specific tools for static testing.
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, 'lint-js' => InputOption::VALUE_NONE, 'phpstan' => InputOption::VALUE_NONE, 'phpmd' => InputOption::VALUE_NONE, 'phpunit' => 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, 'lint-js' => InputOption::VALUE_NONE, 'phpstan' => InputOption::VALUE_NONE, 'phpmd' => InputOption::VALUE_NONE, 'phpunit' => InputOption::VALUE_NONE]
Tags
toolkitInstallDependencies()
Install packages present in the .opts.yml file under extra_pkgs section.
public
toolkitInstallDependencies(ConsoleIO $io[, array<string|int, mixed> $options = ['packages' => InputOption::VALUE_REQUIRED, 'print' => InputOption::VALUE_NONE] ]) : mixed
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['packages' => InputOption::VALUE_REQUIRED, 'print' => InputOption::VALUE_NONE]
Tags
toolkitNotifications()
Display Toolkit notifications.
public
toolkitNotifications(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
toolkitRequirements()
Check the Toolkit Requirements.
public
toolkitRequirements(ConsoleIO $io[, array<string|int, mixed> $options = ['endpoint' => InputOption::VALUE_REQUIRED] ]) : mixed
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['endpoint' => InputOption::VALUE_REQUIRED]
Tags
toolkitVendorList()
Check 'Vendor' packages being monitored.
public
toolkitVendorList(ConsoleIO $io) : mixed
Parameters
- $io : ConsoleIO
Tags
toolkitVersion()
Check the Toolkit version.
public
toolkitVersion(ConsoleIO $io) : mixed
Parameters
- $io : ConsoleIO
Tags
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
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.
isJunit()
Check whether Junit option is being used, or env var is set.
protected
isJunit() : bool
Return values
boolisSimulating()
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.
taskProcess()
Process the file.
protected
taskProcess(string $source[, string $destination = '' ]) : mixed
Parameters
- $source : string
-
The source file to process.
- $destination : string = ''
-
The destination file.
taskReplaceBlock()
Replace block in a file.
protected
taskReplaceBlock([string $filename = '' ]) : mixed
Parameters
- $filename : string = ''
-
The file to process.