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() : mixed
- 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
- {@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() : mixed
- Process the file.
- taskReplaceBlock() : mixed
- Replace block in a file.
- buildAssetsCompile() : mixed
- Launch task runner(s) to compile assets.
- buildAssetsInstall() : mixed
- Install necessary packages to run toolkit:build-assets.
- getHtaccessBlock() : string
- Returns the block for the .htaccess file.
- getHtaccessTask() : mixed
- 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
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
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
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
Return values
CollectionBuilder —Collection builder.
getConfigurationFile()
Path to YAML configuration file containing command defaults.
public
getConfigurationFile() : mixed
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>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
boolgetBin()
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.
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.
buildAssetsCompile()
Launch task runner(s) to compile assets.
private
buildAssetsCompile(mixed $taskRunners, mixed $options, mixed $themeDir) : mixed
Parameters
- $taskRunners : mixed
- $options : mixed
- $themeDir : mixed
buildAssetsInstall()
Install necessary packages to run toolkit:build-assets.
private
buildAssetsInstall(mixed $themeDir, mixed $allowedTaskRunners, mixed $taskRunners, mixed $files, mixed $options) : mixed
Parameters
- $themeDir : mixed
- $allowedTaskRunners : mixed
- $taskRunners : mixed
- $files : mixed
- $options : mixed
getHtaccessBlock()
Returns the block for the .htaccess file.
private
getHtaccessBlock() : string
Return values
stringgetHtaccessTask()
Returns the task for adding custom block to htaccess file.
private
getHtaccessTask(string $root) : mixed
Parameters
- $root : string
-
The drupal root where the .htaccess file is.