Skip to content

Commit

Permalink
Merge 7b2ab51 into a995ab9
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsonar-acquia committed Jun 3, 2021
2 parents a995ab9 + 7b2ab51 commit 2333545
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
10 changes: 7 additions & 3 deletions src/Composer/ComposerizeDrupalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,13 @@ protected function mergeTemplateGitignore()
protected function requireDrupalCore($root_composer_json)
{
$version_constraint = DrupalInspector::getVersionConstraint($this->drupalCoreVersion, $this->input->getOption('exact-versions'));
$root_composer_json->require->{'drupal/core'} = $version_constraint;
$root_composer_json->require->{'drupal/core-recommended'} = $version_constraint;
$this->getIO()
->write("<info>Added drupal/core $version_constraint to requirements.</info>");
->write("<info>Added drupal/core-recommended $version_constraint to requirements.</info>");
// Adding drupal/core-composer-scaffold with the same drupal core version.
$root_composer_json->require->{'drupal/core-composer-scaffold'} = $version_constraint;
$this->getIO()
->write("<info>Added drupal/core-composer-scaffold $version_constraint to requirements.</info>");
}

/**
Expand Down Expand Up @@ -329,7 +333,7 @@ protected function removeAllComposerFiles()
$finder = new Finder();
$finder->in($this->baseDir)
->files()
->name('/^composer\.(lock|json)$/');
->name('/(^composer\.(lock|json)$)|autoload.php/');
$files = iterator_to_array($finder);
$this->fs->remove($files);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Utility/ComposerJsonManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public static function processPaths(&$template_composer_json, $drupal_root)
}
}

foreach ($template_composer_json->extra->{'merge-plugin'}->{'include'} as $key => $path) {
$processed_path = str_replace('[drupal-root]/', $replacement, $path);
foreach ($template_composer_json->extra->{'drupal-scaffold'}->{'locations'} as $key => $path) {
$processed_path = str_replace('[drupal-root]', $replacement, $path);
if ($processed_path != $path) {
$template_composer_json->extra->{'merge-plugin'}->{'include'}[$key] = $processed_path;
$template_composer_json->extra->{'drupal-scaffold'}->{'locations'}->{$key} = $processed_path;
}
}
}
Expand Down
25 changes: 8 additions & 17 deletions template.composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,25 @@
"require": {
"php": "^5.5.9|>=7.0.8",
"composer/installers": "^1.2.0",
"cweagans/composer-patches": "^1.6.5",
"grasmash/drupal-security-warning": "^1.0.0",
"oomphinc/composer-installers-extender": "^2.0",
"wikimedia/composer-merge-plugin": "^2.0"
"cweagans/composer-patches": "^1.6.5"
},
"require-dev": {},
"config": {
"sort-packages": true,
"discard-changes": true,
"optimize-autoloader": true
"discard-changes": true
},
"conflict": {
"drupal/drupal": "*"
},
"extra": {
"enable-patching": true,
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"composer-exit-on-patch-failure": false,
"patches": [],
"drupal-scaffold": {
"locations": {
"web-root": "./[drupal-root]"
}
},
"installer-types": ["bower-asset", "npm-asset"],
"installer-paths": {
"[drupal-root]/core": ["type:drupal-core"],
Expand All @@ -54,13 +52,6 @@
"[drupal-root]/themes/custom/{$name}": ["type:drupal-custom-theme"],
"[drupal-root]/libraries/{$name}": ["type:drupal-library", "type:bower-asset", "type:npm-asset"],
"drush/Commands/{$name}": ["type:drupal-drush"]
},
"merge-plugin": {
"include": [
"[drupal-root]/modules/custom/*/composer.json"
],
"replace": false,
"ignore-duplicates": true
}
},
"minimum-stability": "dev",
Expand Down
7 changes: 2 additions & 5 deletions tests/phpunit/ComposerizeDrupalCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ protected function assertCorrectFileGeneration($relative_drupal_root)
$composer_json->require->{'drupal/ctools'}
);
$this->assertObjectHasAttribute(
'drupal/core',
'drupal/core-recommended',
$composer_json->require
);
$this->assertEquals(
"^" . $this->sandboxManager->getDrupalVersion(),
$composer_json->require->{'drupal/core'}
$composer_json->require->{'drupal/core-recommended'}
);

// Assert installer paths.
Expand All @@ -238,8 +238,5 @@ protected function assertCorrectFileGeneration($relative_drupal_root)
$this->assertObjectHasAttribute('drupal/ctools', $composer_json->extra->patches);
$this->assertObjectHasAttribute($patch_relative_path, $composer_json->extra->patches->{"drupal/ctools"});
$this->assertEquals($patch_relative_path, $composer_json->extra->patches->{"drupal/ctools"}->{$patch_relative_path});

// Assert merge-plugin.
$this->assertContains($relative_drupal_root . "modules/custom/*/composer.json", $composer_json->extra->{'merge-plugin'}->include);
}
}

0 comments on commit 2333545

Please sign in to comment.