Skip to content

Commit

Permalink
Add installer for TastyIgniter extensions and themes (#474)
Browse files Browse the repository at this point in the history
* Add installer for TastyIgniter extensions and themes

* CI fix

* CI fix

* CI fix

* Add support for TastyIgniter themes

* Use appropriate replace regex
  • Loading branch information
sampoyigi committed Jan 12, 2021
1 parent 9d4e028 commit 0d9bf4f
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ is not needed to install packages with these frameworks:
| Sylius | `sylius-theme`
| symfony1 | **`symfony1-plugin`**
| TAO | `tao-extension`
| TastyIgniter | **`igniter-extension`<br>`igniter-theme`**
| Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
| TYPO3 Flow | `typo3-flow-package`<br>`typo3-flow-framework`<br>`typo3-flow-plugin`<br>`typo3-flow-site`<br>`typo3-flow-boilerplate`<br>`typo3-flow-build`
| TYPO3 CMS | `typo3-cms-extension` (Deprecated in this package, use the [TYPO3 CMS Installers](https://packagist.org/packages/typo3/cms-composer-installers) instead)
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"SyDES",
"Sylius",
"symfony",
"TastyIgniter",
"Thelia",
"TYPO3",
"WHMCS",
Expand Down
32 changes: 32 additions & 0 deletions src/Composer/Installers/IgniterInstaller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Composer\Installers;

class IgniterInstaller extends BaseInstaller
{
protected $locations = array(
'extension' => 'extensions/{$vendor}/{$name}/',
'theme' => 'themes/{$name}/',
);

/**
* Format package name.
*
* Cut off leading 'ti-ext-' or 'ti-theme-' if present.
* Strip vendor name of characters that is not alphanumeric or an underscore
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'igniter-extension') {
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
$vars['name'] = preg_replace('/^ti-ext-$/', '', $vars['name']);
}

if ($vars['type'] === 'igniter-theme') {
$vars['name'] = preg_replace('/^ti-theme-$/', '', $vars['name']);
}

return $vars;
}
}
1 change: 1 addition & 0 deletions src/Composer/Installers/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Installer extends LibraryInstaller
'fuelphp' => 'FuelphpInstaller',
'grav' => 'GravInstaller',
'hurad' => 'HuradInstaller',
'igniter' => 'IgniterInstaller',
'imagecms' => 'ImageCMSInstaller',
'itop' => 'ItopInstaller',
'joomla' => 'JoomlaInstaller',
Expand Down
90 changes: 90 additions & 0 deletions tests/Composer/Installers/Test/IgniterInstallerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace Composer\Installers\Test;

use Composer\Composer;
use Composer\Installers\IgniterInstaller;
use Composer\Package\Package;
use PHPUnit\Framework\TestCase as BaseTestCase;

class IgniterInstallerTest extends BaseTestCase
{
/**
* @var IgniterInstaller
*/
private $installer;

/**
* setUp
*
* @return void
*/
public function setUp()
{
$this->installer = new IgniterInstaller(
new Package('NyanCat', '4.2', '4.2'),
new Composer()
);
}

/**
* @dataProvider packageNameInflectionProvider
*
* @return void
*/
public function testInflectPackageVars($type, $vendor, $name, $expectedVendor, $expectedName)
{
$this->assertEquals(
$this->installer->inflectPackageVars(array(
'vendor' => $vendor,
'name' => $name,
'type' => $type,
)),
array('vendor' => $expectedVendor, 'name' => $expectedName, 'type' => $type)
);
}

public function packageNameInflectionProvider()
{
return array(
array(
'igniter-extension',
'acme',
'pages',
'acme',
'pages',
),
array(
'igniter-extension',
'acme',
'ti-ext-pages',
'acme',
'pages',
),
// tests vendor name containing a hyphen
array(
'igniter-extension',
'foo-bar-co',
'blog',
'foobarco',
'blog',
),
// tests that exactly one '-theme' is cut off
array(
'igniter-theme',
'acme',
'ti-theme-theme',
'acme',
'theme',
),
// tests that names without '-theme' suffix stay valid
array(
'igniter-theme',
'acme',
'someothertheme',
'acme',
'someothertheme',
),
);
}
}
4 changes: 4 additions & 0 deletions tests/Composer/Installers/Test/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public function dataForTestSupport()
array('fuelphp-component', true),
array('hurad-plugin', true),
array('hurad-theme', true),
array('igniter-extension', true),
array('igniter-theme', true),
array('imagecms-template', true),
array('imagecms-module', true),
array('imagecms-library', true),
Expand Down Expand Up @@ -344,6 +346,8 @@ public function dataForTestInstallPath()
array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
array('igniter-extension', 'extensions/shama/my_extension/', 'shama/my_extension'),
array('igniter-theme', 'themes/my_theme/', 'shama/my_theme'),
array('imagecms-template', 'templates/my_template/', 'shama/my_template'),
array('imagecms-module', 'application/modules/my_module/', 'shama/my_module'),
array('imagecms-library', 'application/libraries/my_library/', 'shama/my_library'),
Expand Down

0 comments on commit 0d9bf4f

Please sign in to comment.