Toolkit

ToolCommands extends AbstractCommands
in package

Generic tools.

Tags
SuppressWarnings

(PHPMD.ExcessiveClassComplexity)

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
command

toolkit:complock-check

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
command

toolkit:fix-permissions

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
SuppressWarnings

(PHPMD.CyclomaticComplexity)

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
bool

optsReview()

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
command

toolkit:opts-review

option

endpoint The endpoint to use to connect to QA Website.

option

junit Whether to export results as junit.

aliases

tk-opts-review

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

SuppressWarnings

(PHPMD.ExcessiveMethodLength)

parseOptsYml()

Returns the .opts.yml file content.

public static parseOptsYml() : array<string|int, mixed>|false
Tags
throws
ParseException

If the file could not be read or the YAML is not valid.

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
command

toolkit:code-review

option

phpcs Execute the command toolkit:test-phpcs.

option

opts-review Execute the command toolkit:opts-review.

option

lint-php Execute the command toolkit:lint-php.

option

lint-yaml Execute the command toolkit:lint-yaml.

option

lint-js Execute the command toolkit:lint-js.

option

phpstan Execute the command toolkit:test-phpstan.

option

phpmd Execute the command toolkit:test-phpmd.

option

phpunit Execute the command toolkit:test-phpunit.

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

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
command

toolkit:install-dependencies

option

packages Specify a list of packages to install instead of read from .opts.yml.

option

print Shows output from apt commands.

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

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
command

toolkit:notifications

option

endpoint The endpoint to use to connect to QA Website.

aliases

tk-notifications

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
command

toolkit:requirements

option

endpoint The endpoint to use to connect to QA Website.

option

junit Whether to export results as junit.

aliases

tk-req

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

SuppressWarnings

(PHPMD.ExcessiveMethodLength)

toolkitVendorList()

Check 'Vendor' packages being monitored.

public toolkitVendorList(ConsoleIO $io) : mixed
Parameters
$io : ConsoleIO
Tags
command

toolkit:vendor-list

toolkitVersion()

Check the Toolkit version.

public toolkitVersion(ConsoleIO $io) : mixed
Parameters
$io : ConsoleIO
Tags
command

toolkit:check-version

getBin()

Validate and return the path to given bin.

protected getBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
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
throws
TaskException
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
bool

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.

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.


        
On this page

Search results