Improve composer.json matching

Created on 3 May 2023, over 1 year ago
Updated 9 May 2023, over 1 year ago

https://git.drupalcode.org/project/project_composer/-/blob/62ac7f27f70fd... adds information from the project’s composer.json if the component name matches the package name. However, Drupal has no expectation there will be a component name that matches. Examples:

We could do the composer.json processing if either:

  • The component_role is primary, so a component will always match. (The primary component is the one that matches the project name, falling back to the component with the shortest name.)
  • The component at the root of the project, so if a composer.json file exists in the project root, along with a module or other component, that will be picked. It isn't common, but I believe there are projects that put every component in a subdirectory.

I think using the “primary” component is likely the best way to go.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States drumm NY, US

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

Comments & Activities

  • Issue created by @drumm
  • 🇪🇸Spain idiaz.roncero Madrid

    Hello;

    I might be having a related issue

    This module (source code) started a few days/weeks ago to miss the installation of its required dependencies (google/apiclient)

    @fjgarlin has been helping me but we can't make it work.

    There is also here a mismatch between the module machine name (feeds_youtube_api) and the drupal.org project/composer.json name (feeds_youtube_api_parser) .

    I've tried both names on the module's composer.json but the dependency fails to install anyway:

    {
      "name": "drupal/feeds_youtube_api_parser",
      "description": "Fetches YouTube videos from playlists via Google API v3.",
      "type": "drupal-module",
      "minimum-stability": "dev",
      "require": {
        "google/apiclient": "^2.0"
      }
    }
    
    {
      "name": "drupal/feeds_youtube_api",
      "description": "Fetches YouTube videos from playlists via Google API v3.",
      "type": "drupal-module",
      "minimum-stability": "dev",
      "require": {
        "google/apiclient": "^2.0"
      }
    }
    

    ..they both fail to install google/apiclient

    Also tried:

    • Clearing composer cache / removing vendor folder
    • On a Drupal 9 and a Drupal 10 site (both fail)
  • Assigned to drumm
  • 🇺🇸United States drumm NY, US

    Some of the code comments made me unsure if the primary component for everything was found. It looks like it is, edge cases can be found with

    SELECT fdf_rp.field_release_project_target_id, fdf_rc.field_release_category_value category, pcc.release_nid, sum(pcc.component_role = 'primary') c FROM project_composer_component pcc INNER JOIN field_data_field_release_category fdf_rc ON fdf_rc.entity_id = pcc.release_nid AND fdf_rc.field_release_category_value != 'obsolete' INNER JOIN field_data_field_release_project fdf_rp ON fdf_rp.entity_id = pcc.release_nid AND fdf_rp.field_release_project_target_id != '3060' GROUP BY pcc.release_nid HAVING c != 1 ORDER BY NULL;

    The 29 releases without primary components all have other issues which make them uninstallable, so it is fine to rely on the primary component.

    • drumm committed 524832e0 on 7.x-1.x
      Issue #3357952: Use the primary component’s composer.json instead of...
  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States drumm NY, US

    This is deployed and I rebuilt composer data for the 4 projects mentioned. The ones I double checked now install the composer.json dependencies.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024