Skip to content

Commit

Permalink
Added dev-only packages
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Jan 21, 2014
1 parent a2d0187 commit da0967f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ComposerUpdates/Diagnostics/ComposerUpdatesPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct($rootDir, ComposerUpdates\Service $service, Nette\Ca
$rootDir . '/composer.lock',
),
);
return $service->getPackages();
return array_merge($service->getPackages(), $service->getDevPackages());
});
}

Expand Down
3 changes: 3 additions & 0 deletions src/ComposerUpdates/Diagnostics/templates/panel.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ $classes = array(
<td>
<span class="<?php echo $classes[$package->getStatus()] ?>"></span>
<?php echo str_replace('/', ' / ', $package->getName()) ?>
<?php if ($package->isDevOnly()) { ?>
<em>(dev only)</em>
<?php } ?>
</td>
<td>
<?php echo $package->getInstalledVersion() ?>
Expand Down
7 changes: 1 addition & 6 deletions src/ComposerUpdates/NullVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

namespace ComposerUpdates;

use composer\Package\PackageInterface;

class NullVersion extends Version
{
protected $version;

protected $prettyVersion;

public function __construct()
{
$this->version = -1;
$this->prettyVersion = 'none';
}
}
15 changes: 14 additions & 1 deletion src/ComposerUpdates/PackageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ class PackageInfo
/** @var Version[] */
private $incompatibleUpdates;

/** @var bool */
private $devOnly;

/**
* @param string $name
* @param Version $installedVersion
* @param Version[] $compatibleUpdates
* @param Version[] $incompatibleUpdates
* @param bool $devOnly
*/
public function __construct($name, Version $installedVersion, array $compatibleUpdates, array $incompatibleUpdates)
public function __construct($name, Version $installedVersion, array $compatibleUpdates, array $incompatibleUpdates, $devOnly)
{
$this->name = $name;
$this->installedVersion = $installedVersion;
$this->compatibleUpdates = $compatibleUpdates;
$this->incompatibleUpdates = $incompatibleUpdates;
$this->devOnly = $devOnly;
}

/**
Expand Down Expand Up @@ -64,6 +69,14 @@ public function getStatus()
}
}

/**
* @return bool
*/
public function isDevOnly()
{
return $this->devOnly;
}

/**
* @return bool
*/
Expand Down
6 changes: 3 additions & 3 deletions src/ComposerUpdates/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function getPackages()
public function getDevPackages()
{
$requires = $this->initializer->getDevRequires();
return $this->getPackagesFromRequires($requires);
return $this->getPackagesFromRequires($requires, TRUE);
}

private function getPackagesFromRequires(array $requires)
private function getPackagesFromRequires(array $requires, $devOnly = FALSE)
{
$installedRepo = $this->initializer->getInstalledRepository();

Expand Down Expand Up @@ -62,7 +62,7 @@ private function getPackagesFromRequires(array $requires)
return $version->isGreaterThan($currentVersion);
});

$packages[] = new PackageInfo($name, $installedVersions[$name], $compatibleUpdates, $incompatibleUpdates);
$packages[] = new PackageInfo($name, $currentVersion, $compatibleUpdates, $incompatibleUpdates, $devOnly);
}

return $packages;
Expand Down

0 comments on commit da0967f

Please sign in to comment.