Toolkit

BuildCommands extends AbstractCommands
in package

Provides commands to build a site for development and a production artifact.

Table of Contents

Properties

$blockEnd  : string
Comment ending the Toolkit block.
$blockStart  : string
Comment starting the Toolkit block.

Methods

buildAssets()  : Result|int
Build theme assets (Css and Js).
buildDev()  : CollectionBuilder
Build site for local development.
buildDevReset()  : CollectionBuilder
Build site for local development from scratch with a clean git.
buildDist()  : CollectionBuilder
Build the distribution package.
getConfigurationFile()  : string
Path to YAML configuration file containing command defaults.
getJson()  : array<string|int, mixed>
Returns the JSON parsed content.
getWorkingDir()  : string
Returns the current working directory.
isWebsiteInstalled()  : bool
Check if the website is installed.
getBin()  : string
Validate and return the path to given bin.
getBinPath()  : string
Return the path to given bin.
getConfigValue()  : mixed|null
Return the configuration value.
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()  : CollectionBuilder
Execute a command.
taskProcess()  : ReplaceBlock|CollectionBuilder
Process the file.
taskReplaceBlock()  : ReplaceBlock|CollectionBuilder
Replace block in a file.
buildAssetsCompile()  : int|void
Launch task runner(s) to compile assets.
buildAssetsInstall()  : void
Install necessary packages to run toolkit:build-assets.
getHtaccessBlock()  : string
Returns the block for the .htaccess file.
getHtaccessTask()  : CollectionBuilder
Returns the task for adding custom block to htaccess file.

Properties

$blockEnd

Comment ending the Toolkit block.

protected string $blockEnd = '# End Toolkit block.'

$blockStart

Comment starting the Toolkit block.

protected string $blockStart = '# Start Toolkit block.'

Methods

buildAssets()

Build theme assets (Css and Js).

public buildAssets([array<string|int, mixed> $options = ['default-theme' => InputOption::VALUE_OPTIONAL, 'custom-code-folder' => InputOption::VALUE_REQUIRED, 'build-npm-packages' => InputOption::VALUE_REQUIRED, 'theme-task-runner' => InputOption::VALUE_REQUIRED, 'ecl-command' => InputOption::VALUE_REQUIRED] ]) : Result|int

Install task runner, additional packages and execute.

Parameters
$options : array<string|int, mixed> = ['default-theme' => InputOption::VALUE_OPTIONAL, 'custom-code-folder' => InputOption::VALUE_REQUIRED, 'build-npm-packages' => InputOption::VALUE_REQUIRED, 'theme-task-runner' => InputOption::VALUE_REQUIRED, 'ecl-command' => InputOption::VALUE_REQUIRED]

Additional options for the command.

Tags
command

toolkit:build-assets

option

default-theme The theme where to build assets.

option

custom-code-folder The location of the custom code.

option

build-npm-packages The packages to install.

option

theme-task-runner The task runner to use: 'ecl-builder' or 'gulp' as alternative.

option

ecl-command=[COMMAND] Run 'ecl-builder' with append command(s) (use '--ecl-command=help' to see all options).

aliases

tk-assets, tba

Return values
Result|int

The collection builder.

buildDev()

Build site for local development.

public buildDev([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED] ]) : CollectionBuilder
Parameters
$options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED]

Command options.

Tags
command

toolkit:build-dev

option

root Drupal root.

aliases

tk-bdev

Return values
CollectionBuilder

Collection builder.

buildDevReset()

Build site for local development from scratch with a clean git.

public buildDevReset([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED, 'yes' => InputOption::VALUE_OPTIONAL] ]) : CollectionBuilder
Parameters
$options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED, 'yes' => InputOption::VALUE_OPTIONAL]

Command options.

Tags
command

toolkit:build-dev-reset

option

root Drupal root.

option

yes Skip the question.

aliases

tk-bdev-reset

Return values
CollectionBuilder

Collection builder.

buildDist()

Build the distribution package.

public buildDist([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED, 'dist-root' => InputOption::VALUE_REQUIRED, 'keep' => InputOption::VALUE_REQUIRED, 'remove' => InputOption::VALUE_REQUIRED, 'tag' => InputOption::VALUE_REQUIRED, 'sha' => InputOption::VALUE_REQUIRED] ]) : CollectionBuilder

This will create the distribution package intended to be deployed. The folder structure will match the following:

  • ./dist
  • ./dist/composer.json
  • ./dist/composer.lock
  • ./dist/manifest.json
  • ./dist/config
  • ./dist/vendor
  • ./dist/web
  • ./dist/web/VERSION.txt
Parameters
$options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED, 'dist-root' => InputOption::VALUE_REQUIRED, 'keep' => InputOption::VALUE_REQUIRED, 'remove' => InputOption::VALUE_REQUIRED, 'tag' => InputOption::VALUE_REQUIRED, 'sha' => InputOption::VALUE_REQUIRED]

Command options.

Tags
command

toolkit:build-dist

option

root Drupal root.

option

dist-root Distribution package root.

option

keep Comma separated list of files and folders to keep.

option

remove Comma separated list of files and folders to remove.

option

tag Version tag for manifest.

option

sha Commit hash for manifest.

aliases

tk-bdist

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

Return values
CollectionBuilder

Collection builder.

getConfigurationFile()

Path to YAML configuration file containing command defaults.

public getConfigurationFile() : string
Return values
string

Configuration file path.

getJson()

Returns the JSON parsed content.

public getJson(string $filename[, bool $throwException = true ]) : array<string|int, mixed>
Parameters
$filename : string
$throwException : bool = true

If the file is not found.

Return values
array<string|int, mixed>

Json parsed content.

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string

The current working directory.

isWebsiteInstalled()

Check if the website is installed.

public isWebsiteInstalled() : bool
Return values
bool

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()

Return the configuration value.

protected getConfigValue(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
$key : string

The config item to look up.

$default : mixed|null = null

Default configuration value for the key item if neither has value nor exists.

Return values
mixed|null

The configuration value.

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, string> $tasks) : CollectionBuilder
Parameters
$tasks : array<string|int, string>

An array with tasks to execute.

Return values
CollectionBuilder

The task executed.

taskProcess()

Process the file.

protected taskProcess(string $source[, string $destination = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$source : string

The source file to process.

$destination : string = ''

The destination file.

Return values
ReplaceBlock|CollectionBuilder

The file task processed.

taskReplaceBlock()

Replace block in a file.

protected taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$filename : string = ''

The file to process.

Return values
ReplaceBlock|CollectionBuilder

The file replaced.

buildAssetsCompile()

Launch task runner(s) to compile assets.

private buildAssetsCompile(array<string|int, mixed> $taskRunners, array<string|int, mixed> $options, string $themeDir) : int|void
Parameters
$taskRunners : array<string|int, mixed>

The task runners.

$options : array<string|int, mixed>

The extra options for the command.

$themeDir : string

The theme directory.

Return values
int|void

The build assets compile result.

buildAssetsInstall()

Install necessary packages to run toolkit:build-assets.

private buildAssetsInstall(string $themeDir, array<string|int, string> $allowedTaskRunners, array<string|int, string> $taskRunners, array<string|int, string> $files, array<string|int, mixed> $options) : void
Parameters
$themeDir : string

The theme directory.

$allowedTaskRunners : array<string|int, string>

The tasks runners allowed.

$taskRunners : array<string|int, string>

The task runners.

$files : array<string|int, string>

The files to be used.

$options : array<string|int, mixed>

The extra options for the command.

Return values
void

Tasks are performed.

getHtaccessBlock()

Returns the block for the .htaccess file.

private getHtaccessBlock() : string
Return values
string

The htaccess file block content.

getHtaccessTask()

Returns the task for adding custom block to htaccess file.

private getHtaccessTask(string $root) : CollectionBuilder
Parameters
$root : string

The drupal root where the .htaccess file is.

Return values
CollectionBuilder

The htaccess file status.


        
On this page

Search results