Skip to content
Snippets Groups Projects

Issue #3344127: Composer validate all fixture manipulation changes

Merged Issue #3344127: Composer validate all fixture manipulation changes
8 unresolved threads
8 unresolved threads
Compare and Show latest version
1 file
+ 10
11
Compare changes
  • Side-by-side
  • Inline
@@ -6,7 +6,6 @@ use Composer\Semver\VersionParser;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Serialization\Yaml;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
/**
* It manipulates.
@@ -45,18 +44,18 @@ class FixtureManipulator {
* Validate the fixtures still passes `composer validate`.
*/
private function validateComposer(): void {
$process = new Process([
'composer',
/** @var \PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface $runner */
$runner = \Drupal::service('PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface');
$runner->run([
'validate',
// @todo Check the lock file in https://drupal.org/i/3343827.
'--no-check-lock',
'--no-check-publish',
'--with-dependencies',
'--no-interaction',
'--ansi',
'--no-cache',
], $this->dir);
$process->mustRun();
'--working-dir=' . $this->dir,
]);
}
/**
@@ -79,7 +78,11 @@ class FixtureManipulator {
*/
public function addPackage(array $package, bool $is_dev_requirement = FALSE, bool $create_project = TRUE): self {
if (!$this->committingChanges) {
$this->queueManipulation('addPackage', func_get_args());
// To pass Composer validation all packages must have a version specified.
if (!isset($package['version'])) {
$package['version'] = '1.2.3';
}
$this->queueManipulation('addPackage', [$package, $is_dev_requirement, $create_project]);
return $this;
}
foreach (['name', 'type'] as $required_key) {
@@ -182,10 +185,6 @@ class FixtureManipulator {
if ($should_exist && isset($is_dev_requirement)) {
throw new \LogicException('Changing an existing project to a dev requirement is not supported');
}
// To pass Composer validation all packages must have a version specified.
if (!$should_exist && $package && !isset($package['version'])) {
$package['version'] = '1.2.3';
}
$composer_folder = $this->dir . '/vendor/composer';
$file = $composer_folder . '/installed.json';
Loading