diff --git a/package_manager/config/install/package_manager.settings.yml b/package_manager/config/install/package_manager.settings.yml index edd2c6ed40a9b610d4a3b36571373880e5e67d48..0ec2dbcf3329499510dcfa2f8bea858f282da8e1 100644 --- a/package_manager/config/install/package_manager.settings.yml +++ b/package_manager/config/install/package_manager.settings.yml @@ -2,4 +2,5 @@ executables: composer: ~ rsync: ~ additional_trusted_composer_plugins: [] +additional_known_files_in_project_root: [] include_unknown_files_in_project_root: false diff --git a/package_manager/config/schema/package_manager.schema.yml b/package_manager/config/schema/package_manager.schema.yml index e048fd67a7387376c1f7210ac0f1f92fe6d866f8..751d004d705a472aab58b99aeaf88ad7765347f6 100644 --- a/package_manager/config/schema/package_manager.schema.yml +++ b/package_manager/config/schema/package_manager.schema.yml @@ -22,6 +22,9 @@ package_manager.settings: sequence: type: package_name label: 'Trusted composer plugin' + additional_known_files_in_project_root: + type: sequence + label: 'Known files that would otherwise be excluded from staging operations' include_unknown_files_in_project_root: type: boolean label: 'Include unrecognized files and directories in the project root in staging operations' diff --git a/package_manager/src/PathExcluder/UnknownPathExcluder.php b/package_manager/src/PathExcluder/UnknownPathExcluder.php index b09a01e0535bdab749010d0a751eebc4a02c0343..bafd8f137d6064cc9722bcfe0da83516fe80158d 100644 --- a/package_manager/src/PathExcluder/UnknownPathExcluder.php +++ b/package_manager/src/PathExcluder/UnknownPathExcluder.php @@ -104,6 +104,8 @@ final class UnknownPathExcluder implements EventSubscriberInterface, LoggerAware $web_root, 'composer.json', 'composer.lock', + ...$this->configFactory->get('package_manager.settings') + ->get('additional_known_files_in_project_root'), ]; foreach ($this->getScaffoldFiles() as $scaffold_file_path) { // The web root is always included in staging operations, so we don't need diff --git a/package_manager/tests/src/Kernel/PathExcluder/UnknownPathExcluderTest.php b/package_manager/tests/src/Kernel/PathExcluder/UnknownPathExcluderTest.php index d68da1cba9aac56db0cf965f9ded0781addd9746..8687fa98852da8f54a6b30792e5164bf4f70372a 100644 --- a/package_manager/tests/src/Kernel/PathExcluder/UnknownPathExcluderTest.php +++ b/package_manager/tests/src/Kernel/PathExcluder/UnknownPathExcluderTest.php @@ -203,6 +203,31 @@ class UnknownPathExcluderTest extends PackageManagerKernelTestBase { } } + /** + * Tests that additional known files can be added in config. + */ + public function testExcluderKnownFilesCanBeAdded(): void { + $this->createTestProjectForTemplate(TRUE); + + $project_root = $this->container->get(PathLocator::class) + ->getProjectRoot(); + mkdir($project_root . '/known'); + touch($project_root . '/known/file.txt'); + + $config = $this->config('package_manager.settings'); + $config->set('additional_known_files_in_project_root', ['known'])->save(); + + $stage = $this->createStage(); + $stage->create(); + $this->assertFileExists($stage->getStageDirectory() . '/known/file.txt'); + $stage->destroy(); + + $config->set('additional_known_files_in_project_root', [])->save(); + $this->assertFileExists($project_root . '/known/file.txt'); + $stage->create(); + $this->assertFileDoesNotExist($stage->getStageDirectory() . '/known/file.txt'); + } + /** * Tests that the excluder can be disabled by a config flag. */