Enhance the scope of the recipes plugin

Created on 15 November 2024, about 1 month ago

Problem/Motivation

The current recipes plugin only looks for recipes in the core/recipes/ directory. Therefore, it doesn't allow for non-core recipes (yet.)

Assuming that the drupal/recommended-project Composer template follows the pattern of the other composer/installers settings, I would expect that dependencies of type "drupal-recipe" end up in the project's web/recipe/ directory:

      "web/recipes/{$name}": [
        "type:drupal-recipe"
      ],

Or, better yet:

      "web/recipes/contrib/{$name}": [
        "type:drupal-contrib-recipe"
      ],
      "web/recipes/custom{$name}": [
        "type:drupal-custom-recipe"
      ],

Then it would make sense for Project Browser's recipe plugin to also scan this "web/recipes/" directory.

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ultimike
  • πŸ‡ΊπŸ‡ΈUnited States chrisfromredfin Portland, Maine

    marking as stable blocker for now, though I may change this to beta blocker sooner than later.

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    After discussions with one of the Recipe leads, it was determined that we should be including both /project-root/recipes and /project-root/web/recipes.

    I've updated the issue summary.

    -mike

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    Doh! Never mind - I think the plugin already does this!

    In Drupal 10 and and 11, it searches the project-root's "recipes/" directory.

    From a code comment:

        // The recipe system requires that all non-core recipes be located next to each
        // other, in the same directory.

    So, no "custom" or "contrib" directories allowed.

    When I do a composer require somevendor/somerecipe (where the project's composer.json has "type": "drupal-recipe", where is the Composer configuration that installs this dependency in the project root's "recipes" directory? (using a Drupal 11.0.7 site based on the drupal/recommended-project Composer template.) This is a bit of a mystery.

    Sidenote: I have noticed that the 11.x drupal/recommended-project Composer template includes "recipes/{$name}": ["type:drupal-recipe"].

    Finally, in the Project Browser recipes plugin, there is this bit of code that uses information from Composer to figure out which directories Project Browser searches for recipes:

        // If any recipes have been installed by Composer, also search there. The
        // recipe system requires that all non-core recipes be located next to each
        // other, in the same directory.
        $contrib_recipe_names = InstalledVersions::getInstalledPackagesByType(Recipe::COMPOSER_PROJECT_TYPE);
        if ($contrib_recipe_names) {
          $path = InstalledVersions::getInstallPath($contrib_recipe_names[0]);
          $path = $this->fileSystem->realpath($path);
    
          $search_in[] = dirname($path);
        }

    Bottom line - nothing to see here, closing this issue, leaving this information for those that are curious.

    -mike

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    Regarding

    When I do a composer require somevendor/somerecipe (where the project's composer.json has "type": "drupal-recipe", where is the Composer configuration that installs this dependency in the project root's "recipes" directory? (using a Drupal 11.0.7 site based on the drupal/recommended-project Composer template.) This is a bit of a mystery.

    Credit to @ctrladel for figuring out that recent versions of composer/installers has this gem:

    https://github.com/composer/installers/blob/main/src/Composer/Installers/DrupalInstaller.php

    Mystery solved!

    -mike

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    One other thought on this - as things currently stand, Project Browser will only work with recipes that are installed with Composer. If you download/create a recipe into a project, Project Browser won't find it (unless you've previously used Composer to require an additional recipe to the same directory.)

Production build 0.71.5 2024