Issue #3080205 by greg.1.anderson: Implicitly allow drupal/core and legacy scaffold projects to scaffold files
parent
e70758877b
commit
6340ef5877
|
@ -62,6 +62,10 @@ class AllowedPackages implements PostPackageEventListenerInterface {
|
||||||
/**
|
/**
|
||||||
* Gets a list of all packages that are allowed to copy scaffold files.
|
* Gets a list of all packages that are allowed to copy scaffold files.
|
||||||
*
|
*
|
||||||
|
* We will implicitly allow the projects 'drupal/legacy-scaffold-assets'
|
||||||
|
* and 'drupal/core' to scaffold files, if they are present. Any other
|
||||||
|
* project must be explicitly whitelisted in the top-level composer.json
|
||||||
|
* file in order to be allowed to override scaffold files.
|
||||||
* Configuration for packages specified later will override configuration
|
* Configuration for packages specified later will override configuration
|
||||||
* specified by packages listed earlier. In other words, the last listed
|
* specified by packages listed earlier. In other words, the last listed
|
||||||
* package has the highest priority. The root package will always be returned
|
* package has the highest priority. The root package will always be returned
|
||||||
|
@ -71,12 +75,12 @@ class AllowedPackages implements PostPackageEventListenerInterface {
|
||||||
* An array of allowed Composer packages.
|
* An array of allowed Composer packages.
|
||||||
*/
|
*/
|
||||||
public function getAllowedPackages() {
|
public function getAllowedPackages() {
|
||||||
$options = $this->manageOptions->getOptions();
|
$top_level_packages = $this->getTopLevelAllowedPackages();
|
||||||
$allowed_packages = $this->recursiveGetAllowedPackages($options->allowedPackages());
|
$allowed_packages = $this->recursiveGetAllowedPackages($top_level_packages);
|
||||||
// If the root package defines any file mappings, then implicitly add it
|
// If the root package defines any file mappings, then implicitly add it
|
||||||
// to the list of allowed packages. Add it at the end so that it overrides
|
// to the list of allowed packages. Add it at the end so that it overrides
|
||||||
// all the preceding packages.
|
// all the preceding packages.
|
||||||
if ($options->hasFileMapping()) {
|
if ($this->manageOptions->getOptions()->hasFileMapping()) {
|
||||||
$root_package = $this->composer->getPackage();
|
$root_package = $this->composer->getPackage();
|
||||||
unset($allowed_packages[$root_package->getName()]);
|
unset($allowed_packages[$root_package->getName()]);
|
||||||
$allowed_packages[$root_package->getName()] = $root_package;
|
$allowed_packages[$root_package->getName()] = $root_package;
|
||||||
|
@ -97,6 +101,26 @@ class AllowedPackages implements PostPackageEventListenerInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all packages that are allowed in the top-level composer.json.
|
||||||
|
*
|
||||||
|
* We will implicitly allow the projects 'drupal/legacy-scaffold-assets'
|
||||||
|
* and 'drupal/core' to scaffold files, if they are present. Any other
|
||||||
|
* project must be explicitly whitelisted in the top-level composer.json
|
||||||
|
* file in order to be allowed to override scaffold files.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* An array of allowed Composer package names.
|
||||||
|
*/
|
||||||
|
protected function getTopLevelAllowedPackages() {
|
||||||
|
$implicit_packages = [
|
||||||
|
'drupal/legacy-scaffold-assets',
|
||||||
|
'drupal/core',
|
||||||
|
];
|
||||||
|
$top_level_packages = $this->manageOptions->getOptions()->allowedPackages();
|
||||||
|
return array_merge($implicit_packages, $top_level_packages);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a name-to-package mapping from a list of package names.
|
* Builds a name-to-package mapping from a list of package names.
|
||||||
*
|
*
|
||||||
|
|
|
@ -224,7 +224,10 @@ class Handler {
|
||||||
if ($options->hasFileMapping()) {
|
if ($options->hasFileMapping()) {
|
||||||
return $this->createScaffoldOperations($package, $options->fileMapping());
|
return $this->createScaffoldOperations($package, $options->fileMapping());
|
||||||
}
|
}
|
||||||
if (!$options->hasAllowedPackages()) {
|
// Warn the user if they allow a package that does not have any scaffold
|
||||||
|
// files. We will ignore drupal/core, though, as it is implicitly allowed,
|
||||||
|
// but might not have scaffold files (version 8.7.x and earlier).
|
||||||
|
if (!$options->hasAllowedPackages() && ($package->getName() != 'drupal/core')) {
|
||||||
$this->io->writeError("The allowed package {$package->getName()} does not provide a file mapping for Composer Scaffold.");
|
$this->io->writeError("The allowed package {$package->getName()} does not provide a file mapping for Composer Scaffold.");
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
|
Loading…
Reference in New Issue