Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Update digipolisgent/robo-digipolis-package dependency.
  Fixed code style issues.
  Fixed review remarks.
  Fix phpunit.xml
  Added badges to readme.
  Code style fixes.
  Added codeclimate token to travis config.
  Added tests.
  Added tasks for compiling themes and creating an archive.
  • Loading branch information
Jelle-S committed Feb 14, 2017
2 parents 952c0bc + cc4a073 commit 15f45d1
Show file tree
Hide file tree
Showing 25 changed files with 735 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ install:
- composer install --dev
script:
- vendor/bin/robo test:coverage-codeclimate
#addons:
# code_climate:
# repo_token: ***REMOVED***
#after_success:
# - vendor/bin/test-reporter
addons:
code_climate:
repo_token: ***REMOVED***
after_success:
- vendor/bin/test-reporter
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@

Drupal 8 Packaging/Compile tasks for Robo Task Runner

[![Latest Stable Version](https://poser.pugx.org/digipolisgent/robo-digipolis-package-drupal8/v/stable)](https://packagist.org/packages/digipolisgent/robo-digipolis-package-drupal8)
[![Latest Unstable Version](https://poser.pugx.org/digipolisgent/robo-digipolis-package-drupal8/v/unstable)](https://packagist.org/packages/digipolisgent/robo-digipolis-package-drupal8)
[![Total Downloads](https://poser.pugx.org/digipolisgent/robo-digipolis-package-drupal8/downloads)](https://packagist.org/packages/digipolisgent/robo-digipolis-package-drupal8)
[![PHP 7 ready](http://php7ready.timesplinter.ch/digipolisgent/robo-digipolis-package-drupal8/develop/badge.svg)](https://travis-ci.org/digipolisgent/robo-digipolis-package-drupal8)
[![License](https://poser.pugx.org/digipolisgent/robo-digipolis-package-drupal8/license)](https://packagist.org/packages/digipolisgent/robo-digipolis-package-drupal8)

[![Build Status](https://travis-ci.org/digipolisgent/robo-digipolis-package-drupal8.svg?branch=develop)](https://travis-ci.org/digipolisgent/robo-digipolis-package-drupal8)
[![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)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"require": {
"consolidation/robo": "~1.0",
"php": ">=5.5.0",
"digipolisgent/robo-digipolis-package": "dev-feature/base"
"digipolisgent/robo-digipolis-package": "^0.1.0@alpha"
},
"require-dev": {
"phpunit/phpunit": "~4.4",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
>
<testsuites>
<testsuite name="robo-digipolis-package tests">
<testsuite name="robo-digipolis-package-drupal8 tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
Expand Down
74 changes: 74 additions & 0 deletions src/PackageDrupal8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8;

use DigipolisGent\Robo\Task\Package\PackageProject;
use Symfony\Component\Finder\Finder;

class PackageDrupal8 extends PackageProject
{

/**
* {@inheritdoc}
*/
protected $ignoreFileNames = [
'LICENSE',
'LICENSE.txt',
'README',
'README.txt',
'README.md',
'CHANGELOG.txt',
'COPYRIGHT.txt',
'INSTALL.mysql.txt',
'INSTALL.pgsql.txt',
'INSTALL.sqlite.txt',
'INSTALL.txt',
'MAINTAINERS.txt',
'UPDATE.txt',
];

/**
* {@inheritdoc}
*/
protected function getFiles()
{
$dir = $this->dir;
if (is_null($dir)) {
$projectRoot = $this->getConfig()->get('digipolis.root.project', null);
$dir = is_null($projectRoot)
? getcwd()
: $projectRoot;
}
$finder = new Finder();
$finder->ignoreDotFiles(false);
// Ignore dotfiles except .htaccess.
$finder->notPath('/(^|\/)\.(?!(htaccess$)).+(\/|$)/');

// Ignore other files defined by the dev.
foreach ($this->ignoreFileNames as $fileName) {
$finder->notName($fileName);
}
$dirs = [];
$finderClone = clone $finder;
$finder->in([
$dir . '/vendor',
$dir . '/web',
$dir . '/config',
]);
foreach ($finder as $file) {
$realPath = $file->getRealPath();
if (is_dir($realPath)) {
$subDirFinder = clone $finderClone;
// This is a directory that contains files that will be added.
// So don't add the directory or files will be added twice.
if ($subDirFinder->in($realPath)->files()->count()) {
continue;
}
}

$relative = substr($realPath, strlen($dir) + 1);
$dirs[$relative] = $realPath;
}
return $dirs;
}
}
113 changes: 113 additions & 0 deletions src/ThemesCleanDrupal8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8;

use Robo\Contract\BuilderAwareInterface;
use Robo\Task\BaseTask;
use Symfony\Component\Finder\Finder;

class ThemesCleanDrupal8 extends BaseTask implements BuilderAwareInterface
{
use \Robo\TaskAccessor;
use \DigipolisGent\Robo\Task\Package\loadTasks;
use Utility\ThemeFinder;

/**
* An associative array where the keys are the Drupal theme machine names
* and the values are the respective Grunt/Gulp commands to execute.
*
* @var array
*/
protected $themes = [];

/**
* The directories in which to search for the themes.
*
* @var string
*/
protected $dirs;

/**
* The Symfony finder to use to find the themes.
* @var \Symfony\Component\Finder\Finder
*/
protected $finder;


/**
* Creates a new ThemesCompileDrupal8 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.
*/
public function __construct($themes = [], $dirs = null)
{
$this->themes = $themes;
$this->dirs = $dirs;
$this->finder = new Finder();
}

/**
* Sets the themes to clean.
*
* @param array $themes
* An array of Drupal theme machine names. Defaults to the keys of the
* digipolis.themes.drupal8 config value.
*/
public function themes($themes)
{
$this->themes = $themes;
}

/**
* Sets the directories in which to search for themes.
*
* @param array $dirs
* The directories in which to search for the themes.
*/
public function dirs($dirs)
{
$this->dirs = $dirs;
}

/**
* Sets the finder.
*
* @param \Symfony\Component\Finder\Finder $finder
*
* @return $this
*
* @codeCoverageIgnore
*/
public function finder(Finder $finder)
{
$this->finder = $finder;

return $this;
}

/**
* {@inheritdoc}
*/
public function run()
{
$themesFromConfig = $this->getConfig()->get('digipolis.themes.drupal8', false);
if ($themesFromConfig) {
$themesFromConfig = array_keys((array) $themesFromConfig);
}
$themes = empty($this->themes)
? $themesFromConfig
: $this->themes;

$collection = $this->collectionBuilder();
foreach ($this->getThemePaths($themes) as $path) {
$collection->addTask($this->taskThemeClean($path));
}
return $collection->run();
}
}
111 changes: 111 additions & 0 deletions src/ThemesCompileDrupal8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace DigipolisGent\Robo\Task\Package\Drupal8;

use Robo\Contract\BuilderAwareInterface;
use Robo\Task\BaseTask;
use Symfony\Component\Finder\Finder;

class ThemesCompileDrupal8 extends BaseTask implements BuilderAwareInterface
{
use \Robo\TaskAccessor;
use \DigipolisGent\Robo\Task\Package\loadTasks;
use Utility\ThemeFinder;

/**
* An associative array where the keys are the Drupal theme machine names
* and the values are the respective Grunt/Gulp commands to execute.
*
* @var array
*/
protected $themes = [];

/**
* The directories in which to search for the themes.
*
* @var string
*/
protected $dirs;

/**
* The Symfony finder to use to find the themes.
* @var \Symfony\Component\Finder\Finder
*/
protected $finder;


/**
* Creates a new 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.
*/
public function __construct($themes = [], $dirs = null)
{
$this->themes = $themes;
$this->dirs = $dirs;
$this->finder = new Finder();
}

/**
* Sets the themes to compile.
*
* @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.
*/
public function themes($themes)
{
$this->themes = $themes;
}

/**
* Sets the directories in which to search for themes.
*
* @param array $dirs
* The directories in which to search for the themes.
*/
public function dirs($dirs)
{
$this->dirs = $dirs;
}

/**
* Sets the finder.
*
* @param \Symfony\Component\Finder\Finder $finder
*
* @return $this
*
* @codeCoverageIgnore
*/
public function finder(Finder $finder)
{
$this->finder = $finder;

return $this;
}

/**
* {@inheritdoc}
*/
public function run()
{
$themes = empty($this->themes)
? $this->getConfig()->get('digipolis.themes.drupal8', false)
: $this->themes;
$collection = $this->collectionBuilder();
foreach ($this->getThemePaths(array_keys($themes)) as $themeName => $path) {
$command = $themes[$themeName];
$collection->addTask($this->taskThemeCompile($path, $command));
}
return $collection->run();
}
}
Loading

0 comments on commit 15f45d1

Please sign in to comment.