Permalink
Browse files

initial release

  • Loading branch information...
0 parents commit 612489b1cde8e72f879c1cc198bcf1c2128c9e99 @shama committed Aug 5, 2012
Showing with 279 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +29 −0 README.md
  3. +24 −0 composer.json
  4. +25 −0 phpunit.xml.dist
  5. +52 −0 src/Aura/Installer.php
  6. +13 −0 src/bootstrap.php
  7. +66 −0 tests/Aura/InstallerTest.php
  8. +64 −0 tests/Aura/TestCase.php
  9. +4 −0 tests/bootstrap.php
2 .gitignore
@@ -0,0 +1,2 @@
+vendor/
+composer.lock
29 README.md
@@ -0,0 +1,29 @@
+# Aura System Composer Installer
+
+This is a Composer Installer for the Aura System. It should
+only be used by the aura-system.
+
+```json
+{
+ "name": "hari/aura-system",
+ "minimum-stability": "dev",
+ "require": {
+ "shama/aura-system-installer": "*",
+ "aura/autoload": "1.0.0-beta3",
+ "aura/cli": "1.0.0-beta3",
+ "aura/di": "1.0.0-beta3",
+ "aura/http": "1.0.0-beta3",
+ "aura/marshal": "1.0.0-beta3",
+ "aura/router": "1.0.0-beta3",
+ "aura/signal": "1.0.0-beta3",
+ "aura/sql": "1.0.0-beta3",
+ "aura/uri": "1.0.0-beta3",
+ "aura/view": "1.0.0-beta3",
+ "aura/web": "1.0.0-beta3"
+ },
+ "extra": {
+ "aura-system-install": 1
+ }
+}
+```
+
24 composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "shama/aura-system-installer",
+ "type": "composer-installer",
+ "license": "MIT",
+ "description": "Composer Installer for the Aura System",
+ "keywords": [],
+ "authors": [
+ {
+ "name": "Kyle Robinson Young",
+ "email": "kyle@dontkry.com",
+ "homepage": "https://github.com/shama"
+ }
+ ],
+ "autoload": {
+ "psr-0": { "Aura\\": "src/" }
+ },
+ "extra": {
+ "class": "Aura\\Installer"
+ },
+ "require-dev": {
+ "composer/composer": "1.0.*"
+ },
+ "minimum-stability": "dev"
+}
25 phpunit.xml.dist
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="Aura Installer Test Suite">
+ <directory>tests/Aura</directory>
+ </testsuite>
+ </testsuites>
+
+ <filter>
+ <whitelist>
+ <directory>src/Aura</directory>
+ </whitelist>
+ </filter>
+</phpunit>
52 src/Aura/Installer.php
@@ -0,0 +1,52 @@
+<?php
+namespace Aura;
+
+use Composer\Package\PackageInterface;
+use Composer\Installer\LibraryInstaller;
+
+class Installer extends LibraryInstaller
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function getInstallPath(PackageInterface $package)
+ {
+ $prettyName = $package->getPrettyName();
+ list($vendor, $name) = explode('/', $prettyName);
+
+ if ($this->isAuraSystemInstall() && strtolower($vendor) === 'aura') {
+ $vendor = ucfirst($vendor);
+ $name = ucfirst($name);
+
+ return 'package/' . $vendor . '.' . $name . '/';
+ }
+
+ return parent::getInstallPath($package);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function supports($packageType)
+ {
+ return $this->isAuraSystemInstall();
+ }
+
+ /**
+ * If package is an Aura System Install
+ *
+ * @return boolean
+ */
+ protected function isAuraSystemInstall()
+ {
+ $consumerPackage = $this->composer->getPackage();
+ if ($consumerPackage) {
+ $extra = $consumerPackage->getExtra();
+ if (!empty($extra['aura-system-install'])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
13 src/bootstrap.php
@@ -0,0 +1,13 @@
+<?php
+function includeIfExists($file)
+{
+ if (file_exists($file)) {
+ return include $file;
+ }
+}
+if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
+ die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
+ 'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
+ 'php composer.phar install'.PHP_EOL);
+}
+return $loader;
66 tests/Aura/InstallerTest.php
@@ -0,0 +1,66 @@
+<?php
+namespace Aura;
+
+use Aura\Installer;
+use Composer\Package\MemoryPackage;
+use Composer\Composer;
+use Composer\Config;
+
+class InstallerTest extends TestCase
+{
+ private $composer;
+ private $config;
+ private $dm;
+ private $repository;
+ private $io;
+
+ /**
+ * setUp
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ $this->composer = new Composer();
+ $this->config = new Config();
+ $this->composer->setConfig($this->config);
+
+ $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->composer->setDownloadManager($this->dm);
+
+ $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
+ $this->io = $this->getMock('Composer\IO\IOInterface');
+ }
+
+ /**
+ * testGetAuraSystemInstallPath
+ */
+ public function testGetAuraSystemInstallPath()
+ {
+ $installer = new Installer($this->io, $this->composer);
+ $package = new MemoryPackage('aura/autoload', '1.0.0', '1.0.0');
+
+ $consumerPackage = new MemoryPackage('hari/aura-system', '1.0.0', '1.0.0');
+ $this->composer->setPackage($consumerPackage);
+ $consumerPackage->setExtra(array(
+ 'aura-system-install' => true,
+ ));
+
+ $result = $installer->getInstallPath($package);
+ $this->assertEquals('package/Aura.Autoload/', $result);
+ }
+
+ /**
+ * testNonAuraSystemInstallPath
+ */
+ public function testNonAuraSystemInstallPath()
+ {
+ $installer = new Installer($this->io, $this->composer);
+ $package = new MemoryPackage('aura/autoload', '1.0.0', '1.0.0');
+
+ $result = $installer->getInstallPath($package);
+ $this->assertContains('vendor/aura/autoload', $result);
+ }
+}
64 tests/Aura/TestCase.php
@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ * Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Aura;
+
+use Composer\Package\Version\VersionParser;
+use Composer\Package\MemoryPackage;
+use Composer\Package\AliasPackage;
+use Composer\Package\LinkConstraint\VersionConstraint;
+use Composer\Util\Filesystem;
+
+abstract class TestCase extends \PHPUnit_Framework_TestCase
+{
+ private static $parser;
+
+ protected static function getVersionParser()
+ {
+ if (!self::$parser) {
+ self::$parser = new VersionParser();
+ }
+
+ return self::$parser;
+ }
+
+ protected function getVersionConstraint($operator, $version)
+ {
+ return new VersionConstraint(
+ $operator,
+ self::getVersionParser()->normalize($version)
+ );
+ }
+
+ protected function getPackage($name, $version)
+ {
+ $normVersion = self::getVersionParser()->normalize($version);
+
+ return new MemoryPackage($name, $normVersion, $version);
+ }
+
+ protected function getAliasPackage($package, $version)
+ {
+ $normVersion = self::getVersionParser()->normalize($version);
+
+ return new AliasPackage($package, $normVersion, $version);
+ }
+
+ protected function ensureDirectoryExistsAndClear($directory)
+ {
+ $fs = new Filesystem();
+ if (is_dir($directory)) {
+ $fs->removeDirectory($directory);
+ }
+ mkdir($directory, 0777, true);
+ }
+}
4 tests/bootstrap.php
@@ -0,0 +1,4 @@
+<?php
+
+$loader = require __DIR__ . '/../src/bootstrap.php';
+$loader->add('Aura\Test', __DIR__);

0 comments on commit 612489b

Please sign in to comment.