Skip to content

Commit

Permalink
Less dumpy
Browse files Browse the repository at this point in the history
  • Loading branch information
bobdenotter committed Oct 25, 2020
1 parent 5517e40 commit 60aeaa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
20 changes: 7 additions & 13 deletions src/Managers/DownloadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DownloadManager
* @var \Composer\Package\CompletePackage
*/
private $ownerPackage;

/**
* @var \Composer\Downloader\DownloadManager
*/
Expand All @@ -26,7 +26,7 @@ class DownloadManager
* @var \Composer\Installer\InstallationManager
*/
private $installationManager;

/**
* @var \Composer\Cache
*/
Expand All @@ -46,7 +46,7 @@ class DownloadManager
* @var \Vaimo\WebDriverBinaryDownloader\Analysers\PlatformAnalyser
*/
private $platformAnalyser;

/**
* @var \Vaimo\WebDriverBinaryDownloader\Utils\SystemUtils
*/
Expand Down Expand Up @@ -91,13 +91,13 @@ public function __construct(
$this->driverPkgFactory = $driverPkgFactory;
$this->pluginConfig = $pluginConfig;
$this->composer = $composer;

$this->platformAnalyser = new \Vaimo\WebDriverBinaryDownloader\Analysers\PlatformAnalyser();
$this->systemUtils = new \Vaimo\WebDriverBinaryDownloader\Utils\SystemUtils();
$this->dataUtils = new \Vaimo\WebDriverBinaryDownloader\Utils\DataUtils();
$this->stringUtils = new \Vaimo\WebDriverBinaryDownloader\Utils\StringUtils();
}

public function downloadRelease(array $versions)
{
$executableName = $this->dataUtils->extractValue(
Expand All @@ -107,7 +107,7 @@ public function downloadRelease(array $versions)
);

$ownerName = $this->ownerPackage->getName();

if (!$executableName) {
$platformName = $this->platformAnalyser->getPlatformName();

Expand All @@ -117,7 +117,7 @@ public function downloadRelease(array $versions)
}

$name = sprintf('%s-virtual', $ownerName);

$relativePath = $this->systemUtils->composePath(
$this->ownerPackage->getName(),
'downloads'
Expand All @@ -128,13 +128,7 @@ public function downloadRelease(array $versions)
'downloads'
);

echo "== downloadRelease fullpath == \n";
\Symfony\Component\VarDumper\VarDumper::dump($fullPath);

while ($version = array_shift($versions)) {
\Symfony\Component\VarDumper\VarDumper::dump($this->getDownloadUrl($version));
\Symfony\Component\VarDumper\VarDumper::dump($relativePath);

$package = $this->driverPkgFactory->create(
$name,
$this->getDownloadUrl($version),
Expand Down
23 changes: 4 additions & 19 deletions src/Managers/PackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PackageManager
* @var \Composer\Util\Filesystem
*/
private $fileSystem;

/**
* @var \Vaimo\WebDriverBinaryDownloader\Analysers\PlatformAnalyser
*/
Expand Down Expand Up @@ -71,36 +71,23 @@ public function installBinaries(PackageInterface $package, $binDir)
{
$sourceDir = $this->systemUtils->composePath($this->vendorDir, $package->getTargetDir());

echo "\n== installBinaries == \n";

\Symfony\Component\VarDumper\VarDumper::dump($this->vendorDir);
\Symfony\Component\VarDumper\VarDumper::dump($package->getTargetDir());

$matches = [];

$binaries = $package->getBinaries();

\Symfony\Component\VarDumper\VarDumper::dump($binaries);

foreach ($binaries as $binary) {
if (file_exists($this->systemUtils->composePath($sourceDir, $binary))) {
$matches[] = $this->systemUtils->composePath($sourceDir, $binary);
}

$globPattern = $this->systemUtils->composePath($sourceDir, '**', $binary);

\Symfony\Component\VarDumper\VarDumper::dump($globPattern);

$matches = array_merge(
$matches,
$this->systemUtils->recursiveGlob($globPattern)
);
}

echo "\n\n== Matches ==\n\n";
\Symfony\Component\VarDumper\VarDumper::dump($matches);


if (!$matches) {
$errorMessage = sprintf(
'Could not locate binaries (%s) from downloaded source',
Expand All @@ -113,19 +100,17 @@ public function installBinaries(PackageInterface $package, $binDir)
)
)
);

throw new \Exception($errorMessage);
}

echo "\n== end installBinaries == \n";

$fileRenames = $this->pluginConfig->getExecutableFileRenames();

$this->fileSystem->ensureDirectoryExists($binDir);

foreach (array_filter($matches, 'is_executable') as $fromPath) {
$fileName = basename($fromPath);

$toPath = $this->systemUtils->composePath(
$binDir,
$this->dataUtils->extractValue($fileRenames, $fileName, $fileName)
Expand Down

0 comments on commit 60aeaa3

Please sign in to comment.