1
0
Fork 0

Merge pull request #7999 from Seldaek/store_dev

Store dev mode in installed.json, fixes #3008
pull/6942/head^2
Jordi Boggiano 2019-08-01 17:59:09 +02:00 committed by GitHub
commit 3ef27cabd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 13 deletions

View File

@ -64,7 +64,7 @@ script:
- ls -d tests/Composer/Test/* | grep -v TestCase.php | parallel --gnu --keep-order 'echo "Running {} tests"; ./vendor/bin/phpunit -c tests/complete.phpunit.xml --colors=always {} || (echo -e "\e[41mFAILED\e[0m {}" && exit 1);'
# Run PHPStan
- if [[ $PHPSTAN == "1" ]]; then
composer require --dev phpstan/phpstan-shim:^0.11 --ignore-platform-reqs &&
bin/composer require --dev phpstan/phpstan-shim:^0.11 --ignore-platform-reqs &&
vendor/bin/phpstan.phar analyse src tests --configuration=phpstan/config.neon --autoload-file=phpstan/autoload.php;
fi

View File

@ -618,7 +618,7 @@ class Installer
}
if ($this->executeOperations || $this->writeLock) {
$localRepo->write();
$localRepo->write($this->devMode);
}
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($jobType);
@ -630,7 +630,7 @@ class Installer
if ($this->executeOperations) {
// force source/dist urls to be updated for all packages
$this->processPackageUrls($pool, $policy, $localRepo, $repositories);
$localRepo->write();
$localRepo->write($this->devMode);
}
return array(0, $devPackages);

View File

@ -49,7 +49,12 @@ class FilesystemRepository extends WritableArrayRepository
}
try {
$packages = $this->file->read();
$data = $this->file->read();
if (isset($data['packages'])) {
$packages = $data['packages'];
} else {
$packages = $data;
}
// forward compatibility for composer v2 installed.json
if (isset($packages['packages'])) {
@ -79,16 +84,16 @@ class FilesystemRepository extends WritableArrayRepository
/**
* Writes writable repository.
*/
public function write()
public function write($devMode)
{
$data = array();
$data = array('packages' => array(), 'dev' => $devMode);
$dumper = new ArrayDumper();
foreach ($this->getCanonicalPackages() as $package) {
$data[] = $dumper->dump($package);
$data['packages'][] = $dumper->dump($package);
}
usort($data, function ($a, $b) {
usort($data['packages'], function ($a, $b) {
return strcmp($a['name'], $b['name']);
});

View File

@ -24,7 +24,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
/**
* {@inheritDoc}
*/
public function write()
public function write($devMode)
{
}

View File

@ -23,8 +23,10 @@ interface WritableRepositoryInterface extends RepositoryInterface
{
/**
* Writes repository (f.e. to the disc).
*
* @param bool $devMode Whether dev requirements were included or not in this installation
*/
public function write();
public function write($devMode);
/**
* Adds package to the repository.

View File

@ -20,7 +20,7 @@ class InstalledFilesystemRepositoryMock extends InstalledFilesystemRepository
{
}
public function write()
public function write($devMode)
{
}
}

View File

@ -95,11 +95,12 @@ class FilesystemRepositoryTest extends TestCase
->expects($this->once())
->method('write')
->with(array(
array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0'),
'packages' => array(array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0')),
'dev' => true,
));
$repository->addPackage($this->getPackage('mypkg', '0.1.10'));
$repository->write();
$repository->write(true);
}
private function createJsonFileMock()