Add composer release type field

Created on 24 September 2024, 3 months ago

Problem/Motivation

In order to browse recipes, we’ll need to be able to index what projects are recipes.

Recipes on Drupal.org are general projects with a release that has a composer.json containing "type": "drupal-recipe" like https://git.drupalcode.org/project/events/-/blob/1.0.0-alpha3/composer.json

This will allow indexing general projects that have recipe releases. We could do additional indexing, like whether the recipes are on supported or unsupported release series, according to the needs of #3447063: [Meta] Plan for recipe findability on Drupal.org and Project Browser β†’ . That can happen later as the recipe browsing is designed.

Remaining tasks

  • Add the field, storing the type from composer.json as a string.
  • Add automation to fill the field.
  • Backfill the field for existing releases.
  • Consider showing the field on release pages, so maintainers can see if the release was picked up as a specific type.
✨ Feature request
Status

Active

Version

3.0

Component

User interface

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
    • drumm β†’ committed fe9fdc17 on remove-org-credits-view-access-control
      Issue #3476486: Add composer release type field
      
    • drumm β†’ committed 3af03b46 on 7.x-3.x
      Issue #3476486: Parse composer release type during packaging
      
  • πŸ‡ΊπŸ‡ΈUnited States drumm NY, US

    This is now deployed and back-filled for general projects. According to their composer.json files, the recipes on Drupal.org are:

    MariaDB [drupal]> SELECT DISTINCT n.nid, n.title FROM field_data_field_composer_type fdf_ct INNER JOIN field_data_field_release_project fdf_rp ON fdf_rp.entity_id = fdf_ct.entity_id INNER JOIN node n ON n.nid = fdf_rp.field_release_project_target_id WHERE fdf_ct.field_composer_type_value = 'drupal-recipe';
    +---------+-------------------------+
    | nid     | title                   |
    +---------+-------------------------+
    | 3452316 | Velir Base              |
    | 3453366 | Locations               |
    | 1934532 | Events                  |
    | 3463672 | Events Calendar         |
    | 3463674 | Events Locations        |
    | 3463675 | Events Registration     |
    | 3476826 | Tour Core               |
    | 3477215 | Test JSON:API Reference |
    | 3478282 | Tour Core Language      |
    +---------+-------------------------+

    In case we need to do more back-filling, it was done with

    $client = new GuzzleHttp\Client([
      'base_uri' => 'https://git.drupalcode.org',
    ]);
    
    $result = db_query("SELECT fdf_rvl.entity_id release_nid, fdf_pmn.field_project_machine_name_value project, fdf_rvl.field_release_vcs_label_value label FROM {field_data_field_release_vcs_label} fdf_rvl INNER JOIN {field_data_field_release_project} fdf_rp ON fdf_rp.entity_id = fdf_rvl.entity_id INNER JOIN {node} n ON n.nid = fdf_rp.field_release_project_target_id AND n.type = 'project_general' INNER JOIN {field_data_field_project_machine_name} fdf_pmn ON fdf_pmn.entity_id = n.nid");
    foreach ($result as $row) {
      try {
        print $row->release_nid . ' ' . $row->project . ' ' . $row->label . PHP_EOL;
        $composer_json = json_decode($client->request('GET', '/project/' . $row->project . '/-/raw/' . $row->label . '/composer.json')->getBody());
        if (!empty($composer_json->type)) {
          $release_node = node_load($row->release_nid);
          $release_node_wrapper = entity_metadata_wrapper('node', $release_node);
          $release_node_wrapper->field_composer_type = $composer_json->type;
          node_save($release_node);
        }
      }
      catch (Exception $e) {
        print $e->getResponse()->getStatusCode() . PHP_EOL;
      }
    }
    

    If we do this again, we should set the flag on $release_node to signal that it is β€œin packaging,” so packaging is not triggered.

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

Production build 0.71.5 2024