Skip to content
Snippets Groups Projects
Commit cdcdf2da authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3339714 by kunal.sachdev, Wim Leers: Dynamically copy scaffold file...

Issue #3339714 by kunal.sachdev, Wim Leers: Dynamically copy scaffold file mapping when create fake_site fixture
parent 81234b32
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@
"phpcs": "Checks code for standards compliance.",
"test": "Runs PHPUnit tests.",
"core-convert": "Converts this module to a core merge request. Excepts 2 arguments. 1) The core clone directory. 2) The core merge request branch.",
"create-site-fixture": "Recreates the 'fake_site' fixture needed for testing"
"create-site-fixture": "Recreates the 'fake_site' fixture needed for testing. Requires 1 argument, the core clone directory."
},
"require-dev": {
"colinodell/psr-testlogger": "^1"
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e9b347834f96b988de85d370a723d3bf",
"content-hash": "93c56705fbb05f1b7438c7b811d1d951",
"packages": [
{
"name": "drupal/core",
......@@ -12,7 +12,7 @@
"dist": {
"type": "path",
"url": "../path_repos/drupal--core",
"reference": "5aeab06c3087477e20e617328f2fa9f3ed18373d"
"reference": "ab929a52b18b5423cc35d14db5cb035c2d2a679c"
},
"type": "drupal-core",
"extra": {
......@@ -20,12 +20,33 @@
"The 'drupal-scaffold' section below is needed because 'Drupal\\automatic_updates\\Validator\\ScaffoldFilePermissionsValidator'",
"uses this section to determine which files to check. The actual composer.json file for drupal/core will have more files listed",
"but this limited list is used in '\\Drupal\\Tests\\automatic_updates\\Kernel\\StatusCheck\\ScaffoldFilePermissionsValidatorTest'",
"to ensure the section is source of the file list."
"to ensure this section determines the file list."
],
"drupal-scaffold": {
"file-mapping": {
"[web-root]/sites/default/default.settings.php": "",
"[web-root]/sites/default/default.services.yml": ""
"[project-root]/.editorconfig": "assets/scaffold/files/editorconfig",
"[project-root]/.gitattributes": "assets/scaffold/files/gitattributes",
"[web-root]/.csslintrc": "assets/scaffold/files/csslintrc",
"[web-root]/.eslintignore": "assets/scaffold/files/eslintignore",
"[web-root]/.eslintrc.json": "assets/scaffold/files/eslintrc.json",
"[web-root]/.ht.router.php": "assets/scaffold/files/ht.router.php",
"[web-root]/.htaccess": "assets/scaffold/files/htaccess",
"[web-root]/example.gitignore": "assets/scaffold/files/example.gitignore",
"[web-root]/index.php": "assets/scaffold/files/index.php",
"[web-root]/INSTALL.txt": "assets/scaffold/files/drupal.INSTALL.txt",
"[web-root]/README.md": "assets/scaffold/files/drupal.README.md",
"[web-root]/robots.txt": "assets/scaffold/files/robots.txt",
"[web-root]/update.php": "assets/scaffold/files/update.php",
"[web-root]/web.config": "assets/scaffold/files/web.config",
"[web-root]/sites/README.txt": "assets/scaffold/files/sites.README.txt",
"[web-root]/sites/development.services.yml": "assets/scaffold/files/development.services.yml",
"[web-root]/sites/example.settings.local.php": "assets/scaffold/files/example.settings.local.php",
"[web-root]/sites/example.sites.php": "assets/scaffold/files/example.sites.php",
"[web-root]/sites/default/default.services.yml": "assets/scaffold/files/default.services.yml",
"[web-root]/sites/default/default.settings.php": "assets/scaffold/files/default.settings.php",
"[web-root]/modules/README.txt": "assets/scaffold/files/modules.README.txt",
"[web-root]/profiles/README.txt": "assets/scaffold/files/profiles.README.txt",
"[web-root]/themes/README.txt": "assets/scaffold/files/themes.README.txt"
}
}
},
......
......@@ -7,7 +7,7 @@
"dist": {
"type": "path",
"url": "../path_repos/drupal--core",
"reference": "5aeab06c3087477e20e617328f2fa9f3ed18373d"
"reference": "ab929a52b18b5423cc35d14db5cb035c2d2a679c"
},
"type": "drupal-core",
"extra": {
......@@ -15,12 +15,33 @@
"The 'drupal-scaffold' section below is needed because 'Drupal\\automatic_updates\\Validator\\ScaffoldFilePermissionsValidator'",
"uses this section to determine which files to check. The actual composer.json file for drupal/core will have more files listed",
"but this limited list is used in '\\Drupal\\Tests\\automatic_updates\\Kernel\\StatusCheck\\ScaffoldFilePermissionsValidatorTest'",
"to ensure the section is source of the file list."
"to ensure this section determines the file list."
],
"drupal-scaffold": {
"file-mapping": {
"[web-root]/sites/default/default.settings.php": "",
"[web-root]/sites/default/default.services.yml": ""
"[project-root]/.editorconfig": "assets/scaffold/files/editorconfig",
"[project-root]/.gitattributes": "assets/scaffold/files/gitattributes",
"[web-root]/.csslintrc": "assets/scaffold/files/csslintrc",
"[web-root]/.eslintignore": "assets/scaffold/files/eslintignore",
"[web-root]/.eslintrc.json": "assets/scaffold/files/eslintrc.json",
"[web-root]/.ht.router.php": "assets/scaffold/files/ht.router.php",
"[web-root]/.htaccess": "assets/scaffold/files/htaccess",
"[web-root]/example.gitignore": "assets/scaffold/files/example.gitignore",
"[web-root]/index.php": "assets/scaffold/files/index.php",
"[web-root]/INSTALL.txt": "assets/scaffold/files/drupal.INSTALL.txt",
"[web-root]/README.md": "assets/scaffold/files/drupal.README.md",
"[web-root]/robots.txt": "assets/scaffold/files/robots.txt",
"[web-root]/update.php": "assets/scaffold/files/update.php",
"[web-root]/web.config": "assets/scaffold/files/web.config",
"[web-root]/sites/README.txt": "assets/scaffold/files/sites.README.txt",
"[web-root]/sites/development.services.yml": "assets/scaffold/files/development.services.yml",
"[web-root]/sites/example.settings.local.php": "assets/scaffold/files/example.settings.local.php",
"[web-root]/sites/example.sites.php": "assets/scaffold/files/example.sites.php",
"[web-root]/sites/default/default.services.yml": "assets/scaffold/files/default.services.yml",
"[web-root]/sites/default/default.settings.php": "assets/scaffold/files/default.settings.php",
"[web-root]/modules/README.txt": "assets/scaffold/files/modules.README.txt",
"[web-root]/profiles/README.txt": "assets/scaffold/files/profiles.README.txt",
"[web-root]/themes/README.txt": "assets/scaffold/files/themes.README.txt"
}
}
},
......
......@@ -28,7 +28,7 @@ return [
'drupal/core' => [
'pretty_version' => '9.8.0',
'version' => '9.8.0.0',
'reference' => '5aeab06c3087477e20e617328f2fa9f3ed18373d',
'reference' => 'ab929a52b18b5423cc35d14db5cb035c2d2a679c',
'type' => 'drupal-core',
'install_path' => __DIR__ . '/../drupal/core',
'aliases' => [],
......
{
"name":"drupal/core",
"type":"drupal-core",
"version":"9.8.0",
"name": "drupal/core",
"type": "drupal-core",
"version": "9.8.0",
"extra": {
"_readme": [
"The 'drupal-scaffold' section below is needed because 'Drupal\\automatic_updates\\Validator\\ScaffoldFilePermissionsValidator'",
"uses this section to determine which files to check. The actual composer.json file for drupal/core will have more files listed",
"but this limited list is used in '\\Drupal\\Tests\\automatic_updates\\Kernel\\StatusCheck\\ScaffoldFilePermissionsValidatorTest'",
"to ensure the section is source of the file list."
"to ensure this section determines the file list."
],
"drupal-scaffold": {
"file-mapping": {
"[web-root]/sites/default/default.settings.php": "",
"[web-root]/sites/default/default.services.yml": ""
"[project-root]/.editorconfig": "assets/scaffold/files/editorconfig",
"[project-root]/.gitattributes": "assets/scaffold/files/gitattributes",
"[web-root]/.csslintrc": "assets/scaffold/files/csslintrc",
"[web-root]/.eslintignore": "assets/scaffold/files/eslintignore",
"[web-root]/.eslintrc.json": "assets/scaffold/files/eslintrc.json",
"[web-root]/.ht.router.php": "assets/scaffold/files/ht.router.php",
"[web-root]/.htaccess": "assets/scaffold/files/htaccess",
"[web-root]/example.gitignore": "assets/scaffold/files/example.gitignore",
"[web-root]/index.php": "assets/scaffold/files/index.php",
"[web-root]/INSTALL.txt": "assets/scaffold/files/drupal.INSTALL.txt",
"[web-root]/README.md": "assets/scaffold/files/drupal.README.md",
"[web-root]/robots.txt": "assets/scaffold/files/robots.txt",
"[web-root]/update.php": "assets/scaffold/files/update.php",
"[web-root]/web.config": "assets/scaffold/files/web.config",
"[web-root]/sites/README.txt": "assets/scaffold/files/sites.README.txt",
"[web-root]/sites/development.services.yml": "assets/scaffold/files/development.services.yml",
"[web-root]/sites/example.settings.local.php": "assets/scaffold/files/example.settings.local.php",
"[web-root]/sites/example.sites.php": "assets/scaffold/files/example.sites.php",
"[web-root]/sites/default/default.services.yml": "assets/scaffold/files/default.services.yml",
"[web-root]/sites/default/default.settings.php": "assets/scaffold/files/default.settings.php",
"[web-root]/modules/README.txt": "assets/scaffold/files/modules.README.txt",
"[web-root]/profiles/README.txt": "assets/scaffold/files/profiles.README.txt",
"[web-root]/themes/README.txt": "assets/scaffold/files/themes.README.txt"
}
}
}
......
{
"name":"drupal/core",
"type":"drupal-core",
"version":"9.8.0",
"name": "drupal/core",
"type": "drupal-core",
"version": "9.8.0",
"extra": {
"_readme": [
"The 'drupal-scaffold' section below is needed because 'Drupal\\automatic_updates\\Validator\\ScaffoldFilePermissionsValidator'",
......@@ -11,8 +11,29 @@
],
"drupal-scaffold": {
"file-mapping": {
"[web-root]/sites/default/default.settings.php": "",
"[web-root]/sites/default/default.services.yml": ""
"[project-root]/.editorconfig": "assets/scaffold/files/editorconfig",
"[project-root]/.gitattributes": "assets/scaffold/files/gitattributes",
"[web-root]/.csslintrc": "assets/scaffold/files/csslintrc",
"[web-root]/.eslintignore": "assets/scaffold/files/eslintignore",
"[web-root]/.eslintrc.json": "assets/scaffold/files/eslintrc.json",
"[web-root]/.ht.router.php": "assets/scaffold/files/ht.router.php",
"[web-root]/.htaccess": "assets/scaffold/files/htaccess",
"[web-root]/example.gitignore": "assets/scaffold/files/example.gitignore",
"[web-root]/index.php": "assets/scaffold/files/index.php",
"[web-root]/INSTALL.txt": "assets/scaffold/files/drupal.INSTALL.txt",
"[web-root]/README.md": "assets/scaffold/files/drupal.README.md",
"[web-root]/robots.txt": "assets/scaffold/files/robots.txt",
"[web-root]/update.php": "assets/scaffold/files/update.php",
"[web-root]/web.config": "assets/scaffold/files/web.config",
"[web-root]/sites/README.txt": "assets/scaffold/files/sites.README.txt",
"[web-root]/sites/development.services.yml": "assets/scaffold/files/development.services.yml",
"[web-root]/sites/example.settings.local.php": "assets/scaffold/files/example.settings.local.php",
"[web-root]/sites/example.sites.php": "assets/scaffold/files/example.sites.php",
"[web-root]/sites/default/default.services.yml": "assets/scaffold/files/default.services.yml",
"[web-root]/sites/default/default.settings.php": "assets/scaffold/files/default.settings.php",
"[web-root]/modules/README.txt": "assets/scaffold/files/modules.README.txt",
"[web-root]/profiles/README.txt": "assets/scaffold/files/profiles.README.txt",
"[web-root]/themes/README.txt": "assets/scaffold/files/themes.README.txt"
}
}
}
......
......@@ -4,6 +4,8 @@ declare(strict_types = 1);
namespace Drupal\automatic_updates\Development;
use Composer\Json\JsonFile;
use Composer\Script\Event;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
......@@ -17,8 +19,27 @@ final class ComposerFixtureCreator {
/**
* Creates the fixture.
*
* @param \Composer\Script\Event $event
* The Composer event.
*/
public static function createFixture(): void {
public static function createFixture(Event $event): void {
$args = $event->getArguments();
if (count($args) !== 1) {
throw new \Exception("This script requires 1 argument: a directory that is a core clone.");
}
$core_dir = $args[0];
if (!is_dir($core_dir)) {
throw new \Exception("$core_dir is not a directory.");
}
// Copy drupal scaffold file mapping from core/composer.json to
// fixtures' core/composer.json.
$core_composer_json = new JsonFile("$core_dir/composer.json");
$core_composer_data = $core_composer_json->read();
$fixture_core_composer_file = new JsonFile(static::FIXTURE_PATH . "/../path_repos/drupal--core/composer.json");
$fixture_core_composer_data = $fixture_core_composer_file->read();
$fixture_core_composer_data['extra']['drupal-scaffold']['file-mapping'] = $core_composer_data['extra']['drupal-scaffold']['file-mapping'];
$fixture_core_composer_file->write($fixture_core_composer_data);
$fs = new Filesystem();
$fs->remove(static::FIXTURE_PATH . "/composer.lock");
// Remove all the vendor folders but leave our 2 test files.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment