Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Fix code style issues.
  Document commands.
  Fix loadTasks
  Read properties first if available.
  Add command traits.
  • Loading branch information
Jelle-S committed Feb 15, 2017
2 parents 15f45d1 + 8608966 commit 8a5d741
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ engines:
enabled: true
markdownlint:
enabled: true
checks:
MD024:
enabled: false
ratings:
paths:
- "**.php"
Expand Down
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,74 @@ Drupal 8 Packaging/Compile tasks for Robo Task Runner
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/7520a070-4500-494e-80c8-e0b109fb3db6/mini.png)](https://insight.sensiolabs.com/projects/7520a070-4500-494e-80c8-e0b109fb3db6)
[![Code Climate](https://codeclimate.com/github/digipolisgent/robo-digipolis-package-drupal8/badges/gpa.svg)](https://codeclimate.com/github/digipolisgent/robo-digipolis-package-drupal8)
[![Test Coverage](https://codeclimate.com/github/digipolisgent/robo-digipolis-package-drupal8/badges/coverage.svg)](https://codeclimate.com/github/digipolisgent/robo-digipolis-package-drupal8/coverage)

## Commands

This package provides default commands wich you can use in your `RoboFile.php`
like so:

```php
class RoboFile extends \Robo\Tasks
{
use \DigipolisGent\Robo\Task\Package\Drupal8\Commands\loadCommands;
}
```

### digipolis:package-project

`vendor/bin/robo digipolis:package-drupal8 FILE [DIR] [OPTIONS]`

#### Arguments

##### FILE

The name of the archive file that will be created.

##### DIR

The directory to package. Defaults to the config value `digipolis.root.project`
if it is set (see <https://github.com/digipolisgent/robo-digipolis-general> for
more information), or the current working directory otherwise.

#### Options

##### --ignore, -i

Comma separated list of filenames to ignore, has sensible defaults for Drupal 8
projects

### digipolis:themes-clean-drupal8

`vendor/bin/robo digipolis:themes-clean-drupal8 [THEMES] [DIRS]`

#### Arguments

##### THEMES

Comma-seperated list of Drupal theme machine names. Defaults to the keys of the
digipolis.themes.drupal8 config value.

##### DIRS

Comma-seperated list of directories in which to search for the themes. Defaults
to the digipolis.root.project and digipolis.root.web config values, or the
current working directory if that is not set.

### digipolis:themes-compile-drupal8

`vendor/bin/robo digipolis:themes-compile-drupal8 [THEMES] [DIRS]`

#### Arguments

##### THEMES

Comma-seperated list of Drupal theme machine names, or comma separated list in
the format `themename:command` where `themename` is the name of the theme to
compile and `command` is the name of the grunt/gulp command to execute (defaults
to `compile`). Defaults to the digipolis.themes.drupal8 config value.

##### DIRS

Comma-seperated list of directories in which to search for the themes. Defaults
to the digipolis.root.project and digipolis.root.web config values, or the
current working directory if that is not set.
19 changes: 19 additions & 0 deletions src/Commands/PackageDrupal8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Commands;

trait PackageDrupal8
{

use \DigipolisGent\Robo\Task\Package\Drupal8\Traits\PackageDrupal8Trait;

public function digipolisPackageDrupal8($archiveFile, $dir = null, $opts = ['ignore|i' => ''])
{
if (is_callable([$this, 'readProperties'])) {
$this->readProperties();
}
$this->taskPackageDrupal8($archiveFile, $dir)
->ignoreFileNames(array_map('trim', explode(',', $opts['ignore'])))
->run();
}
}
19 changes: 19 additions & 0 deletions src/Commands/ThemesCleanDrupal8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Commands;

trait ThemesCleanDrupal8
{
use \DigipolisGent\Robo\Task\Package\Drupal8\Traits\ThemesCleanDrupal8Trait;

public function digipolisThemesCleanDrupal8($themes = '', $dirs = '')
{
if (is_callable([$this, 'readProperties'])) {
$this->readProperties();
}
$this->taskThemesCleanDrupal8(
explode(',', $themes),
explode(',', $dirs)
)->run();
}
}
26 changes: 26 additions & 0 deletions src/Commands/ThemesCompileDrupal8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Commands;

trait ThemesCompileDrupal8
{
use \DigipolisGent\Robo\Task\Package\Drupal8\Traits\ThemesCompileDrupal8Trait;

public function digipolisThemesCompileDrupal8($themes = '', $dirs = '')
{
if (is_callable([$this, 'readProperties'])) {
$this->readProperties();
}
$themesWithCommand = [];
foreach (explode(',', $themes) as $theme) {
$parts = explode(':', $theme);
$themesWithCommand[$parts[0]] = isset($parts[1])
? $parts[1]
: 'compile';
}
$this->taskThemesCompileDrupal8(
$themesWithCommand,
explode(',', $dirs)
)->run();
}
}
10 changes: 10 additions & 0 deletions src/Commands/loadCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Commands;

trait loadCommands
{
use PackageDrupal8;
use ThemesCleanDrupal8;
use ThemesCompileDrupal8;
}
25 changes: 25 additions & 0 deletions src/Traits/PackageDrupal8Trait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Traits;

use DigipolisGent\Robo\Task\Package\Drupal8\PackageDrupal8;

trait PackageDrupal8Trait
{
/**
* Creates a PackageDrupal8 task.
*
* @param string $archiveFile
* The full path and name of the archive file to create.
* @param string $dir
* The directory to package. Defaults to digipolis.root.project, or to the
* current working directory if that's not set.
*
* @return \DigipolisGent\Robo\Task\Package\Drupal8\PackageDrupal8
* The package project task.
*/
protected function taskPackageDrupal8($archiveFile, $dir = null)
{
return $this->task(PackageDrupal8::class, $archiveFile, $dir);
}
}
27 changes: 27 additions & 0 deletions src/Traits/ThemesCleanDrupal8Trait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Traits;

use DigipolisGent\Robo\Task\Package\Drupal8\ThemesCleanDrupal8;

trait ThemesCleanDrupal8Trait
{
/**
* Creates a ThemesCleanDrupal8 task.
*
* @param array $themes
* An array of Drupal theme machine names. Defaults to the keys of the
* digipolis.themes.drupal8 config value.
* @param array $dirs
* The directories in which to search for the themes. Defaults to the
* digipolis.root.project and digipolis.root.web config values, or the
* current working directory if that is not set.
*
* @return \DigipolisGent\Robo\Task\Package\Drupal8\ThemesCleanDrupal8
* The theme clean task.
*/
protected function taskThemesCleanDrupal8($themes = [], $dirs = null)
{
return $this->task(ThemesCleanDrupal8::class, $themes, $dirs);
}
}
28 changes: 28 additions & 0 deletions src/Traits/ThemesCompileDrupal8Trait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8\Traits;

use DigipolisGent\Robo\Task\Package\Drupal8\ThemesCompileDrupal8;

trait ThemesCompileDrupal8Trait
{
/**
* Creates a ThemesCompileDrupal8 task.
*
* @param array $themes
* An associative array where the keys are the Drupal theme machine names
* and the values are the respective Grunt/Gulp commands to execute.
* Defaults to the digipolis.themes.drupal8 config value.
* @param array $dirs
* The directories in which to search for the themes. Defaults to the
* digipolis.root.project and digipolis.root.web config values, or the
* current working directory if that is not set.
*
* @return \DigipolisGent\Robo\Task\Package\Drupal8\ThemesCompileDrupal8
* The theme compile task.
*/
protected function taskThemesCompileDrupal8($themes = [], $dirs = null)
{
return $this->task(ThemesCompileDrupal8::class, $themes, $dirs);
}
}
58 changes: 3 additions & 55 deletions src/loadTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,7 @@

trait loadTasks
{
/**
* Creates a PackageDrupal8 task.
*
* @param string $archiveFile
* The full path and name of the archive file to create.
* @param string $dir
* The directory to package. Defaults to digipolis.root.project, or to the
* current working directory if that's not set.
*
* @return \DigipolisGent\Robo\Task\Package\Drupal8\PackageDrupal8
* The package project task.
*/
protected function taskPackageDrupal8($archiveFile, $dir = null)
{
return $this->task(PackageDrupal8::class, $archiveFile, $dir);
}

/**
* Creates a ThemesCompileDrupal8 task.
*
* @param array $themes
* An associative array where the keys are the Drupal theme machine names
* and the values are the respective Grunt/Gulp commands to execute.
* Defaults to the digipolis.themes.drupal8 config value.
* @param array $dirs
* The directories in which to search for the themes. Defaults to the
* digipolis.root.project and digipolis.root.web config values, or the
* current working directory if that is not set.
*
* @return \DigipolisGent\Robo\Task\Package\Drupal8\ThemesCompileDrupal8
* The theme compile task.
*/
protected function taskThemesCompileDrupal8($themes = [], $dirs = null)
{
return $this->task(ThemesCompileDrupal8::class, $themes, $dirs);
}

/**
* Creates a ThemesCleanDrupal8 task.
*
* @param array $themes
* An array of Drupal theme machine names. Defaults to the keys of the
* digipolis.themes.drupal8 config value.
* @param array $dirs
* The directories in which to search for the themes. Defaults to the
* digipolis.root.project and digipolis.root.web config values, or the
* current working directory if that is not set.
*
* @return \DigipolisGent\Robo\Task\Package\Drupal8\ThemesCleanDrupal8
* The theme clean task.
*/
protected function taskThemesCleanDrupal8($themes = [], $dirs = null)
{
return $this->task(ThemesCleanDrupal8::class, $themes, $dirs);
}
use Traits\PackageDrupal8Trait;
use Traits\ThemesCompileDrupal8Trait;
use Traits\ThemesCleanDrupal8Trait;
}

0 comments on commit 8a5d741

Please sign in to comment.