1
0
Fork 0

Store dev mode in installed.json, fixes #3008

pull/7999/head
Jordi Boggiano 2019-02-21 12:27:02 +01:00
parent 8fe2b9ec69
commit 60df892517
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
7 changed files with 21 additions and 13 deletions

View File

@ -62,7 +62,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);' - 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 # Run PHPStan
- if [[ $PHPSTAN == "1" ]]; then - 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; vendor/bin/phpstan.phar analyse src tests --configuration=phpstan/config.neon --autoload-file=phpstan/autoload.php;
fi fi

View File

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

View File

@ -49,7 +49,12 @@ class FilesystemRepository extends WritableArrayRepository
} }
try { try {
$packages = $this->file->read(); $data = $this->file->read();
if (isset($data['packages'])) {
$packages = $data['packages'];
} else {
$packages = $data;
}
if (!is_array($packages)) { if (!is_array($packages)) {
throw new \UnexpectedValueException('Could not parse package list from the repository'); throw new \UnexpectedValueException('Could not parse package list from the repository');
@ -74,16 +79,16 @@ class FilesystemRepository extends WritableArrayRepository
/** /**
* Writes writable repository. * Writes writable repository.
*/ */
public function write() public function write($devMode)
{ {
$data = array(); $data = array('packages' => array(), 'dev' => $devMode);
$dumper = new ArrayDumper(); $dumper = new ArrayDumper();
foreach ($this->getCanonicalPackages() as $package) { 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']); return strcmp($a['name'], $b['name']);
}); });

View File

@ -24,7 +24,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
/** /**
* {@inheritDoc} * {@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). * 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. * 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()) ->expects($this->once())
->method('write') ->method('write')
->with(array( ->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->addPackage($this->getPackage('mypkg', '0.1.10'));
$repository->write(); $repository->write(true);
} }
private function createJsonFileMock() private function createJsonFileMock()