Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature-dist
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Jul 3, 2012
2 parents 7ad3185 + 0a55707 commit 926a36d
Show file tree
Hide file tree
Showing 70 changed files with 2,701 additions and 673 deletions.
5 changes: 3 additions & 2 deletions doc/04-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,11 @@ Example:
Lists packages required by this package. The package will not be installed
unless those requirements can be met.

#### require-dev
#### require-dev <span>(root-only)</span>

Lists packages required for developing this package, or running
tests, etc. They are installed if install or update is ran with `--dev`.
tests, etc. The dev requirements of the root package only will be installed
if `install` or `update` is ran with `--dev`.

Packages listed here and their dependencies can not overrule the resolution
found with the packages listed in require. This is even true if a different
Expand Down
38 changes: 37 additions & 1 deletion doc/05-repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ should you need to specify one for whatever reason, you can use `git`, `svn` or

It is possible to install packages from any PEAR channel by using the `pear`
repository. Composer will prefix all package names with `pear-{channelName}/` to
avoid conflicts.
avoid conflicts. All packages are also aliased with prefix `pear-{channelAlias}/`

Example using `pear2.php.net`:

Expand All @@ -214,6 +214,7 @@ Example using `pear2.php.net`:
}
],
"require": {
"pear-pear2.php.net/PEAR2_Text_Markdown": "*",
"pear-pear2/PEAR2_HTTP_Request": "*"
}
}
Expand All @@ -224,6 +225,41 @@ In this case the short name of the channel is `pear2`, so the
> **Note:** The `pear` repository requires doing quite a few requests per
> package, so this may considerably slow down the installation process.
#### Custom channel alias
It is possible to alias all pear channel packages with custom name.

Example:
You own private pear repository and going to use composer abilities to bring dependencies from vcs or transit to composer repository scheme.
Your repository list of packages:
* BasePackage, requires nothing
* IntermediatePackage, depends on BasePackage
* TopLevelPackage1 and TopLevelPackage2 both dependth on IntermediatePackage.

For composer it looks like:
* "pear-pear.foobar.repo/IntermediatePackage" depends on "pear-pear.foobar.repo/BasePackage",
* "pear-pear.foobar.repo/TopLevelPackage1" depends on "pear-pear.foobar.repo/IntermediatePackage",
* "pear-pear.foobar.repo/TopLevelPackage2" depends on "pear-pear.foobar.repo/IntermediatePackage"

When you update one of your packages to composer naming scheme or made it available through vcs, your older dependencies would not see new version, cause it would be named like "foobar/IntermediatePackage". Specifying 'vendor-alias' for pear repository, you will get all its packages aliased with composer-like names. Following example would take BasePackage, TopLevelPackage1 and TopLevelPackage2 packages from pear repository and IntermediatePackage from github repository:

{
"repositories": [
{
"type": "git",
"https://github.com/foobar/intermediate.git"
},
{
"type": "pear",
"url": "http://pear.foobar.repo",
"vendor-alias": "foobar"
}
],
"require": {
"foobar/TopLevelPackage1": "*",
"foobar/TopLevelPackage2": "*"
}
}

### Package

If you want to use a project that does not support composer through any of the
Expand Down
9 changes: 6 additions & 3 deletions src/Composer/Autoload/AutoloadGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Composer\Autoload;

use Composer\Config;
use Composer\Installer\InstallationManager;
use Composer\Package\AliasPackage;
use Composer\Package\PackageInterface;
Expand All @@ -24,12 +25,14 @@
*/
class AutoloadGenerator
{
public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir)
public function dump(Config $config, RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir)
{
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($installationManager->getVendorPath());
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$vendorPath = strtr(realpath($config->get('vendor-dir')), '\\', '/');
$targetDir = $vendorPath.'/'.$targetDir;
$filesystem->ensureDirectoryExists($targetDir);
$vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/');

$relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath, true);
$vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
$vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Command/CreateProjectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public function installProject(IOInterface $io, $packageName, $directory = null,
}
}

$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>', true);
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
$package->setSourceReference(substr($package->getPrettyVersion(), 4));
}

$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>', true);
$projectInstaller = new ProjectInstaller($directory, $dm);
$projectInstaller->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), $package);
if ($package->getRepository() instanceof NotifiableRepositoryInterface) {
Expand Down
13 changes: 10 additions & 3 deletions src/Composer/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Repository\ArrayRepository;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
use Composer\Repository\RepositoryInterface;
Expand All @@ -39,6 +40,7 @@ protected function configure()
new InputArgument('version', InputArgument::OPTIONAL, 'Version to inspect'),
new InputOption('installed', null, InputOption::VALUE_NONE, 'List installed packages only'),
new InputOption('platform', null, InputOption::VALUE_NONE, 'List platform packages only'),
new InputOption('self', null, InputOption::VALUE_NONE, 'Show the root package information'),
))
->setHelp(<<<EOT
The show command displays detailed information about a package, or
Expand All @@ -53,7 +55,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
// init repos
$platformRepo = new PlatformRepository;
if ($input->getOption('platform')) {
if ($input->getOption('self')) {
$package = $this->getComposer(false)->getPackage();
$repos = $installedRepo = new ArrayRepository(array($package));
} elseif ($input->getOption('platform')) {
$repos = $installedRepo = $platformRepo;
} elseif ($input->getOption('installed')) {
$composer = $this->getComposer();
Expand All @@ -70,8 +75,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

// show single package or single version
if ($input->getArgument('package')) {
$package = $this->getPackage($input, $output, $installedRepo, $repos);
if ($input->getArgument('package') || !empty($package)) {
if (empty($package)) {
$package = $this->getPackage($input, $output, $installedRepo, $repos);
}
if (!$package) {
throw new \InvalidArgumentException('Package '.$input->getArgument('package').' not found');
}
Expand Down
1 change: 0 additions & 1 deletion src/Composer/Command/ValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
} catch (\Exception $e) {
$output->writeln('<error>' . $file . ' contains a JSON Syntax Error:</error>');
$output->writeln('<error>' . $e->getMessage() . '</error>');

return 1;
Expand Down
10 changes: 4 additions & 6 deletions src/Composer/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ public function merge(array $config)
}

// disable a repository with an anonymous {"name": false} repo
foreach ($this->repositories as $repoName => $repoSpec) {
if (isset($repository[$repoName]) && false === $repository[$repoName]) {
unset($this->repositories[$repoName]);
continue 2;
}
if (1 === count($repository) && false === current($repository)) {
unset($this->repositories[key($repository)]);
continue;
}

// store repo
Expand Down Expand Up @@ -105,7 +103,7 @@ public function get($key)
// convert foo-bar to COMPOSER_FOO_BAR and check if it exists since it overrides the local config
$env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));

return $this->process(getenv($env) ?: $this->config[$key]);
return rtrim($this->process(getenv($env) ?: $this->config[$key]), '/\\');

case 'home':
return rtrim($this->process($this->config[$key]), '/\\');
Expand Down
4 changes: 4 additions & 0 deletions src/Composer/DependencyResolver/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ protected function findUpdates()
$literal = $decision[Decisions::DECISION_LITERAL];
$package = $this->pool->literalToPackage($literal);

if ($package instanceof AliasPackage) {
continue;
}

// !wanted & installed
if ($literal <= 0 && isset($this->installedMap[$package->getId()])) {
$updates = $this->policy->findUpdatePackages($this->pool, $this->installedMap, $package);
Expand Down
52 changes: 0 additions & 52 deletions src/Composer/Downloader/PearDownloader.php

This file was deleted.

Loading

0 comments on commit 926a36d

Please sign in to comment.