Merge pull request #7999 from Seldaek/store_dev
Store dev mode in installed.json, fixes #3008pull/6942/head^2
commit
3ef27cabd6
|
@ -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);'
|
- 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
|
||||||
|
|
||||||
|
|
|
@ -618,7 +618,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);
|
||||||
|
@ -630,7 +630,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);
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
// forward compatibility for composer v2 installed.json
|
// forward compatibility for composer v2 installed.json
|
||||||
if (isset($packages['packages'])) {
|
if (isset($packages['packages'])) {
|
||||||
|
@ -79,16 +84,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']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function write()
|
public function write($devMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -20,7 +20,7 @@ class InstalledFilesystemRepositoryMock extends InstalledFilesystemRepository
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write()
|
public function write($devMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue