[CQ] Add Composer abstract task

This commit is contained in:
Andrés Montañez 2017-04-14 15:24:39 -03:00
parent 49b96e00a8
commit 88afbc76f9
5 changed files with 51 additions and 30 deletions

View file

@ -1,6 +1,10 @@
CHANGELOG for 3.X
=================
* 3.2.0 (2017-04-xx)
* Improve code quality, remove duplications on Composer Tasks.
* [PR#364] Allow to define custom timeout to Composer:Install
* 3.1.0 (2017-02-25)
* Add new Exec task to execute arbitrary shell commands
* Add new Composer task, to update phar (composer/self-update)

View file

@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Magallanes package.
*
* (c) Andrés Montañez <andres@andresmontanez.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mage\Task\BuiltIn\Composer;
use Mage\Task\AbstractTask;
/**
* Abstract Composer Task
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
abstract class AbstractComposerTask extends AbstractTask
{
protected function getOptions()
{
$options = array_merge(
['path' => 'composer'],
$this->getComposerOptions(),
$this->runtime->getMergedOption('composer'),
$this->options
);
return $options;
}
protected function getComposerOptions()
{
return [];
}
}

View file

@ -11,14 +11,13 @@
namespace Mage\Task\BuiltIn\Composer;
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
/**
* Composer Task - Generate Autoload
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
class DumpAutoloadTask extends AbstractTask
class DumpAutoloadTask extends AbstractComposerTask
{
public function getName()
{
@ -41,14 +40,8 @@ class DumpAutoloadTask extends AbstractTask
return $process->isSuccessful();
}
protected function getOptions()
protected function getComposerOptions()
{
$options = array_merge(
['path' => 'composer', 'flags' => '--optimize'],
$this->runtime->getMergedOption('composer'),
$this->options
);
return $options;
return ['flags' => '--optimize'];
}
}

View file

@ -11,14 +11,13 @@
namespace Mage\Task\BuiltIn\Composer;
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
/**
* Composer Task - Install Vendors
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
class InstallTask extends AbstractTask
class InstallTask extends AbstractComposerTask
{
public function getName()
{
@ -41,14 +40,8 @@ class InstallTask extends AbstractTask
return $process->isSuccessful();
}
protected function getOptions()
protected function getComposerOptions()
{
$options = array_merge(
['path' => 'composer', 'flags' => '--optimize-autoloader', 'timeout' => 120],
$this->runtime->getMergedOption('composer'),
$this->options
);
return $options;
return ['flags' => '--optimize-autoloader', 'timeout' => 120];
}
}

View file

@ -12,7 +12,6 @@ namespace Mage\Task\BuiltIn\Composer;
use Mage\Task\Exception\SkipException;
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
use DateTime;
/**
@ -20,7 +19,7 @@ use DateTime;
*
* @author Yanick Witschi <https://github.com/Toflar>
*/
class SelfUpdateTask extends AbstractTask
class SelfUpdateTask extends AbstractComposerTask
{
public function getName()
{
@ -80,14 +79,8 @@ class SelfUpdateTask extends AbstractTask
return $compareDate;
}
protected function getOptions()
protected function getComposerOptions()
{
$options = array_merge(
['path' => 'composer', 'days' => 60],
$this->runtime->getMergedOption('composer'),
$this->options
);
return $options;
return ['days' => 60];
}
}