Quantcast
Viewing all articles
Browse latest Browse all 294943

Look for recipes in common locations where site builders might keep them

Problem/Motivation

In that issue, we're making the RecipeDiscovery better by ensuring it always searches core's recipes, rather than just the directory that contains the recipe currently being applied.

Right now, we're hard-coding core/recipes as RecipeDiscovery's sole search path. But this isn't suitable for the real world; site builders will install recipes via Composer, and we need to also search for recipes that they might have made available.

Proposed resolution

Figure out how to determine where to search for recipes, then add that to RecipeDiscovery, with test coverage.

There are a few ways we could determine where recipes are installed, but I think one attractive option is to use Composer's InstalledVersions class. We could simply look for recipes, wherever recipes are already installed. For example:

$installed_recipes = InstalledVersions::getInstalledPackagesByType('drupal-recipe');
$installed_recipe_paths = array_map(InstalledVersions::getInstallPath(...), $installed_recipes);
$installed_recipe_paths = array_map('dirname', $installed_recipe_paths);
$paths_to_search = array_map('realpath', array_unique($installed_recipe_paths));

We could also try parsing composer.json directly and looking for the extra.installer-paths entry that mentions recipes. This can get pretty tricky, though, since a site builder might have named certain recipes to be installed at different paths than others.

API changes

Shouldn't be any. This would be an internal change to the RecipeDiscovery class to make it more useful.


Viewing all articles
Browse latest Browse all 294943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>