protected function LocalPackagesTrait::getLocalPackageRepositories in Automatic Updates 8.2
Generates local path repositories for a set of installed packages.
Parameters
string $dir: The directory which contains composer.lock.
Return value
mixed[][] The local path repositories' configuration, for inclusion in a composer.json file.
1 call to LocalPackagesTrait::getLocalPackageRepositories()
- UpdateTestBase::getInitialConfiguration in tests/
src/ Build/ UpdateTestBase.php - Returns the initial data to write to the test site's composer.json.
File
- tests/
src/ Traits/ LocalPackagesTrait.php, line 94
Class
- LocalPackagesTrait
- Provides methods for interacting with installed Composer packages.
Namespace
Drupal\Tests\automatic_updates\TraitsCode
protected function getLocalPackageRepositories(string $dir) : array {
$repositories = [];
foreach ($this
->getPackagesFromLockFile($dir) as $package) {
// Ensure the package directory is writable, since we'll need to make a
// few changes to it.
$path = $dir . DIRECTORY_SEPARATOR . $this
->getPackagePath($package);
Assert::assertIsWritable($path);
$composer = $path . DIRECTORY_SEPARATOR . 'composer.json';
// Overwrite the composer.json with the fully resolved package information
// from the lock file.
// @todo Back up composer.json before overwriting it?
$this
->writeJson($composer, $package);
$name = $package['name'];
$repositories[$name] = $this
->createPathRepository($path);
}
return $repositories;
}