From f1c22bbe50f19fce89b710ce1256b3709994f01f Mon Sep 17 00:00:00 2001 From: bach Date: Sun, 22 Nov 2026 18:51:29 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20injecte=20project/version=20dans=20les?= =?UTF-8?q?=20.info.yml=20des=20packages=20drupal/*=20installes=20en=20sou?= =?UTF-8?q?rce=20(post-install/update-cmd)=20=E2=80=94=20sinon=20/admin/re?= =?UTF-8?q?ports/updates=20ne=20voit=20que=20le=20core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- composer.json | 8 ++++ scripts/update-project-info.php | 72 +++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 scripts/update-project-info.php diff --git a/composer.json b/composer.json index 0cb9bea..0effa43 100644 --- a/composer.json +++ b/composer.json @@ -159,5 +159,13 @@ "Replace Twitter with X https://www.drupal.org/project/social_media_links/issues/3384469": "https://www.drupal.org/files/issues/2023-09-12/social_media_links-change_twitter_to_x-3384469-7.patch" } } + }, + "scripts": { + "post-install-cmd": [ + "@php scripts/update-project-info.php" + ], + "post-update-cmd": [ + "@php scripts/update-project-info.php" + ] } } diff --git a/scripts/update-project-info.php b/scripts/update-project-info.php new file mode 100644 index 0000000..3a9dba5 --- /dev/null +++ b/scripts/update-project-info.php @@ -0,0 +1,72 @@ +/.info.yml, sinon le 1er trouvé. + $infoFile = $dir . '/' . $short . '.info.yml'; + if (!file_exists($infoFile)) { + $found = glob($dir . '/*.info.yml'); + if (!$found) { + continue; + } + $infoFile = $found[0]; + } + $content = file_get_contents($infoFile); + $original = $content; + // project: en tête si absent. + if (!preg_match('/^project:/mi', $content)) { + $content = "project: '" . $short . "'\n" . $content; + } + // version: à la fin si absent (on retire une éventuelle ligne version existante + // pour rester cohérent avec le lock). + $content = preg_replace('/^version:.*$/mi', '', $content); + $version = $pkg['version'] ?? ''; + if ($version !== '') { + $content = trim($content) . "\n\nversion: '" . $version . "'\n"; + } + if ($content !== $original) { + file_put_contents($infoFile, $content); + $patched++; + } +} +// Invalide le cache des projets update si Drupal est bootstrappable. +if (class_exists('Drupal')) { + try { + \Drupal::keyValue('update')->delete('update_project_projects'); + \Drupal::keyValue('update')->delete('update_project_data'); + } + catch (\Throwable $e) { + } +} +fwrite(STDOUT, "update-project-info: $patched .info.yml patchés\n");