Skip to content

Instantly share code, notes, and snippets.

@kerasai
Last active November 3, 2023 16:59
Show Gist options
  • Save kerasai/cd43af83a1e41ba6191100f0991040c1 to your computer and use it in GitHub Desktop.
Save kerasai/cd43af83a1e41ba6191100f0991040c1 to your computer and use it in GitHub Desktop.
Robo Setup

Robo Setup

Basic installation

Install dependencies:

lando composer require --dev consolidation/robo \
  drupal/coder \
  kerasai/robo-drupal:^1@rc \
  kerasai/robo-phpcs \
  squizlabs/php_codesniffer

Lando tooling:

tooling:
  robo:
    service: appserver
    description: Runs Robo commands
    cmd: /app/vendor/bin/robo

Add RoboFile.php and robo.yml to root of project.

drupal:
files:
public:
path: web/sites/default/files
phpcs:
# Defaults to 'phpcs'.
path: vendor/bin/phpcs
files:
src:
standard: vendor/drupal/coder/coder_sniffer/Drupal
# modules:
# path: web/modules/custom
# standard: vendor/drupal/coder/coder_sniffer/Drupal
# extensions: 'php,module,inc,install,test,profile,theme,css,info,txt,md'
# ignore: 'node_modules,bower_components,vendor'
# modules_practice:
# path: web/modules/custom
# standard: vendor/drupal/coder/coder_sniffer/DrupalPractice
# extensions: 'php,module,inc,install,test,profile,theme,css,info,txt,md'
# ignore: 'node_modules,bower_components,vendor'
# themes:
# path: web/themes/custom
# standard: vendor/drupal/coder/coder_sniffer/Drupal
# extensions: 'php,module,inc,install,test,profile,theme,css,info,txt,md'
# ignore: 'node_modules,bower_components,vendor,dist'
# themes_practice:
# path: web/themes/custom
# standard: vendor/drupal/coder/coder_sniffer/DrupalPractice
# extensions: 'php,module,inc,install,test,profile,theme,css,info,txt,md'
# ignore: 'node_modules,bower_components,vendor,dist'
<?php
use Kerasai\Robo\Phpcs\loadTasks;
use Kerasai\RoboDrupal\DrupalTasks;
use MyProject\Env\Env;
use Robo\Robo;
use Robo\Tasks;
/**
* Robo commands for __my_project__.
*
* @see https://robo.li/
*/
class RoboFile extends Tasks {
use DrupalTasks;
use loadTasks;
protected $env;
/**
* RoboFile constructor.
*/
public function __construct() {
$this->stopOnFail();
$this->env = Env::create();
$config_files = $this->env->getIncludes('.', 'yml', '', 'robo');
$config_files = array_filter(array_map(function ($file) {
return __DIR__ . DIRECTORY_SEPARATOR . 'robo' . DIRECTORY_SEPARATOR . $file;
}, $config_files), 'is_readable');
Robo::loadConfiguration($config_files);
}
/**
* Run PHPCBF file correction
*/
public function devPhpcbf() {
return $this->taskPhpcbf();
}
/**
* Install the application
*/
public function install() {
$collection = $this->collectionBuilder();
$collection->addTask($this->installPrepareFilesDir())
->addTask($this->installExisting());
return $collection;
}
/**
* Run tests
*/
public function test() {
$collection = $this->collectionBuilder();
$collection->addTask($this->testStatic());
return $collection;
}
/**
* Run static tests
*/
public function testStatic() {
$collection = $this->collectionBuilder();
$collection->addTask($this->testPhpcs());
return $collection;
}
/**
* PHPCS code style checks
*/
public function testPhpcs() {
return $this->taskPhpcs();
}
/**
* Display detected environment info
*/
public function envInfo() {
$this->say("Environment info:");
$this->say("-----------------");
foreach ($this->env->getInfo() as $key => $value) {
$this->say("$key: $value");
}
}
/**
* Display detected environment info
*/
public function envIncludes() {
$this->say("Includes:");
$this->say("---------");
foreach ($this->env->getIncludes() as $value) {
$this->say($value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment