Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dedicated bundler classes, always bundle complete package #92

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
"psr-0": {"Clue": "src/"}
},
"bin": ["bin/phar-composer"],
"extra": {
"phar": {
"bundler": "composer"
}
},
"config": {
"platform": {
"php": "5.3.6"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 0 additions & 114 deletions src/Clue/PharComposer/Package/Autoload.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/Clue/PharComposer/Package/Bundler/BundlerInterface.php

This file was deleted.

51 changes: 0 additions & 51 deletions src/Clue/PharComposer/Package/Bundler/Complete.php

This file was deleted.

95 changes: 0 additions & 95 deletions src/Clue/PharComposer/Package/Bundler/Explicit.php

This file was deleted.

47 changes: 13 additions & 34 deletions src/Clue/PharComposer/Package/Package.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php

namespace Clue\PharComposer\Package;;
namespace Clue\PharComposer\Package;

use Clue\PharComposer\Package\Bundler\BundlerInterface;
use Clue\PharComposer\Package\Bundler\Complete as CompleteBundler;
use Clue\PharComposer\Package\Bundler\Explicit as ExplicitBundler;
use Clue\PharComposer\Logger;
use Symfony\Component\Finder\Finder;

/**
* The package represents either the main/root package or one of the vendor packages.
Expand Down Expand Up @@ -78,38 +75,20 @@ public function getDirectory()
}

/**
* Get Bundler instance to bundle this package
*
* @param Logger $logger
* @return BundlerInterface
* @return \Clue\PharComposer\Package\Bundle
*/
public function getBundler(Logger $logger)
public function bundle()
{
$bundlerName = 'complete';
if (isset($this->package['extra']['phar']['bundler'])) {
$bundlerName = $this->package['extra']['phar']['bundler'];
}

if ($bundlerName === 'composer') {
return new ExplicitBundler($this, $logger);
} elseif ($bundlerName === 'complete') {
return new CompleteBundler($this, $logger);
} else {
$logger->log('Invalid bundler "' . $bundlerName . '" specified in package "' . $this->getName() . '", will fall back to "complete" bundler');
return new CompleteBundler($this, $logger);
}
}
$bundle = new Bundle();
$iterator = Finder::create()
->files()
->ignoreVCS(true)
->exclude(rtrim($this->getPathVendor(), '/'))
->notPath('/^composer\.phar/')
->notPath('/^phar-composer\.phar/')
->in($this->getDirectory());

/**
* Get Autoload instance containing all autoloading information
*
* Only used for ExplicitBundler at the moment.
*
* @return Autoload
*/
public function getAutoload()
{
return new Autoload(isset($this->package['autoload']) ? $this->package['autoload'] : array());
return $bundle->addDir($iterator);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Clue/PharComposer/Phar/PharComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function build()

$targetPhar = new TargetPhar(new \Phar($target), $this);
$this->log(' - Adding main package "' . $this->package->getName() . '"');
$targetPhar->addBundle($this->package->getBundler($this->logger)->bundle());
$targetPhar->addBundle($this->package->bundle());

$this->log(' - Adding composer base files');
// explicitly add composer autoloader
Expand All @@ -173,7 +173,7 @@ public function build()

foreach ($this->getPackagesDependencies() as $package) {
$this->log(' - Adding dependency "' . $package->getName() . '" from "' . $this->getPathLocalToBase($package->getDirectory()) . '"');
$targetPhar->addBundle($package->getBundler($this->logger)->bundle());
$targetPhar->addBundle($package->bundle());
}

$this->log(' - Setting main/stub');
Expand Down
Loading