Catégories
Drupal 8

API Packages de Drupal.org

De temps en temps, je décide de répondre à de vieilles interrogations par si prioritaires que cela… donc longtemps laissées de côté.

Aujourd’hui, c’est :

Au fait, comment on fait pour récupérer les méta-données composer des projets publiés sur Drupal.org ?

Commencer par lister les Providers

https://packages.drupal.org/8/packages.json

On obtient une réponse du type :

	
notify-batch	"/8/downloads"
providers-url	"/8/%package%$%hash%.json"
metadata-url	"/files/packages/8/p2/%package%.json"
available-package-patterns	
0	"drupal/*"
search	"/8/search.json?s=%query%"
provider-includes	
drupal/provider-2021-1$%hash%.json	
sha256	"939a261c7f3ee146a49fdccf1309f778be5c777561ee414ae334ba80cef8f3df"
drupal/provider-2020-4$%hash%.json	
sha256	"72a3b55863aefe136e1d43ef1703a5c2074061a468f16c0ed0c6e557428a09cd"
drupal/provider-2020-3$%hash%.json	
sha256	"942b1e135ca9549dcc648fdb1811cc7debea9e23f561ab5a43c86cafe3cbd041"
drupal/provider-2020-2$%hash%.json	
sha256	"d70f0b669b5cca3e56be6da3df2addd65b019847edb58e44f755ac3bf6b99469"
drupal/provider-2020-1$%hash%.json	
sha256	"073583c5541108dd1248f6f32dc2f034f7290fcfae66559868f48023f9472a90"
drupal/provider-2019-4$%hash%.json	
sha256	"1f009f5db0ecc6af07eb0400a5f17b5919539eddcbf8e8d5aeb97df7d8be286d"

Comme on peut l’induire, il existe un Provider par trimestre : tous les modules ne sont pas présents dans chaque Provider.

La dernière fois que j’ai mis à jour mon module xtc, c’était en Mars 2020 : il est présent dans le Provider drupal/provider-2020-1 puisque le mois de mars appartient au premier trimestre…

Requêter un Provider

Donc assez logiquement : le module xtc n’est pas listé par la requête : https://packages.drupal.org/8/drupal/provider-2021-1$939a261c7f3ee146a49fdccf1309f778be5c777561ee414ae334ba80cef8f3df.json.

Mais est listé dans la requête : https://packages.drupal.org/8/drupal/provider-2020-1$073583c5541108dd1248f6f32dc2f034f7290fcfae66559868f48023f9472a90.json.

Où l’on trouve notamment ces lignes (sous une forme brute) :

...
{"sha256":"e29c0eb3997f5e97ec7fae1057decb61f166075be84fc2bb9e373ebbbba9f063"},"drupal\/drupal_gitlabci":{"sha256":"415b28737885fde318f12968f4b175bde3d13cd815e7a9f2752ba5c62215ac0e"},"drupal\/my_d8_theme":{"sha256":"74f07237c30472c6b2ba87efc15e40e2aa88598974320467f2dce01dd9924878"},"drupal\/my_d8_module":{"sha256":"5c326cf06cd8a5d2c2b713e91771a19451611a47e1891e2fff0160e11dc206f5"},"drupal\/commerce_product_reminder":{"sha256":"d2f7c0e3ba63d6bfc6ff9049926bce5b67bd7817eac4e1f865c2f960d3ed01ba"},"drupal\/dark_mode_switch":{"sha256":"617bc5fc031884fc4b88846bd30d53c9795fdb420273f32543186ceda59da665"},"drupal\/tmgmt_morningside":{"sha256":"d658eef5d51d68ca51a4c6fcdca8ccf1581d2318bd507ff9f8f0850c5945cf05"},"drupal\/body_node_id_class":{"sha256":"eb98e0ba54616ad026dd2b11b40da75787682ec51d40ff49015f5c9837e30d41"},"drupal\/xtc":{"sha256":"8e4c117ee700d2748a0a8df4eac8b0a1e714688c179c592099f9230968651a26"},"drupal\/xtcfile":{"sha256":"64697ba1d8aff76da8a255edf36c159b55a42aacaec3a0fe81bcf25891b56508"},"drupal\/xtcguzzle":{"sha256":"5c1df8a7746b4e9e2c780af06ce5f71477657ae80e73a9c3cf4d5a0113159acc"},"drupal\/nova_poshta_field":{"sha256":"8af17b0b96ea0989f43f1744e1b40a415ae579708ba1de3ff5b17cba547ecf67"},"drupal\/entity_unified_access":{"sha256":"dcc76797f1df71125f3d80a6dc494c85061766404032f4d6b04ec2d6f27071b7"},"drupal\/menu_block_settings_override":{"sha256":"5365cac17c871a0c278392dd441157f81b68cadb29952caaefe3916a4d892cd0"},"drupal\/xtclorem":{"sha256":"39fc24b8c20d6c8a2544a8e085c811e6a7bbe020f43f40121f9c8cfc0fb02fcf"},"drupal\/if_then_else_commerce":{"sha256":"ae331bc53d7c63c70b7491bb6a2a9140e09f430bfc3e1b59617e9abc3ced1730"},"drupal\/fieldory":{"sha256":"1cdf83bdab46ebc44dec0147461cd55e3575d1445446db2109d4fd689f7a9bf6"},"drupal\/fieldory_examples":{"sha256":"5682cf8a0e90c40a8d8face84eaa415fa2fcfc0845fcf806ebf854012986e218"},"drupal\/important_information":{"sha256":"da144ec87acba8cf03a9507892f2376cd00ca9dc87a93c0d82d955c7a801cbc0"},"drupal\/stackpath":{"sha256":"12f04dbf4ac04a7a2552d6e031a8faf88f2ce9f96130d2644e841a6f359c3558"},"drupal\/xtcdrupal":{"sha256":"51abb00816689fd48b7d21d17781c6f4a2d0273869e042a76394a2eb1d26887a"},"drupal\/flashpoint_course_media":{"sha256":"c023de5eaeec7f812e98c146e3882322838a2bdd9cc115b33a546d243fce73d7"},"drupal\/fullscreen_modal":{"sha256":"32a9c1468532486e2922633df5784701e7921620ab6f494ef2e5a04e93a2db71"},"drupal\/xtcfield":{"sha256":"02e68b1445be514341927984dbda730fa6215e99ac33a0fb63bfb8fcc9efc73f"},"drupal\/flmngr":{"sha256":"497e95ffbf34449cc24d4e1db8a1c15a31990bf464b5e395cc9d0fb942dd8ac3"},"drupal\/imgpen":{"sha256":"37e88160b070a0f13032ff97deed7c275e22e20dec24678431de516925936faa"},"drupal\/bootstrap_editor":
...

Obtenir les méta-données d’un projet

À partir de là, il est enfin possible d’afficher les méta-données pour composer avec une requête de la forme : https://packages.drupal.org/8/drupal/xtc$8e4c117ee700d2748a0a8df4eac8b0a1e714688c179c592099f9230968651a26.json.

Ce qui nous retourne :

{"packages":{"drupal\/xtc":{"dev-1.x":{"keywords":"Actively maintained,Content","homepage":"https:\/\/www.drupal.org\/project\/xtc","version":"dev-1.x","version_normalized":"dev-1.x","license":"GPL-2.0+","authors":[{"name":"Alexandre Isra\u00ebl","homepage":"https:\/\/www.drupal.org\/u\/sashainparis"}],"support":{"source":"http:\/\/cgit.drupalcode.org\/xtc","issues":"https:\/\/www.drupal.org\/project\/issues\/xtc"},"source":{"type":"git","url":"https:\/\/git.drupalcode.org\/project\/xtc.git","reference":"b4df9f5036dc62354cf76caa7cc1e896276026bc"},"type":"drupal-module","uid":"xtc-3073866","name":"drupal\/xtc","extra":{"branch-alias":{"dev-1.x":"1.x-dev"},"drupal":{"version":"8.x-1.0+16-dev","datestamp":"1594933662","security-coverage":{"status":"not-covered","message":"Dev releases are not covered by Drupal security advisories."}}},"description":"Extended Content provides access to external content from Drupal.","require":{"drupal\/core":"~8.0"}},"0.1.0":{"keywords":"Actively maintained,Content","homepage":"https:\/\/www.drupal.org\/project\/xtc","version":"0.1.0","version_normalized":"0.1.0.0","license":"GPL-2.0+","authors":[{"name":"Alexandre Isra\u00ebl","homepage":"https:\/\/www.drupal.org\/u\/sashainparis"}],"support":{"source":"http:\/\/cgit.drupalcode.org\/xtc","issues":"https:\/\/www.drupal.org\/project\/issues\/xtc"},"source":{"type":"git","url":"https:\/\/git.drupalcode.org\/project\/xtc.git","reference":"8.x-0.1"},"dist":{"type":"zip","url":"https:\/\/ftp.drupal.org\/files\/projects\/xtc-8.x-0.1.zip","reference":"8.x-0.1","shasum":"4bf7c83f2bc95a8ff68bf374db4fb31b7fb92532"},"type":"drupal-module","uid":"xtc-3074985","name":"drupal\/xtc",...