From 26042d4a8f4132d05cc8457fc71e1518e3069bc5 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 31 Jul 2024 03:41:22 +0300 Subject: [PATCH] show composer packages version --- src/Entity/Browser/Menu/Help/About.php | 28 +++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Entity/Browser/Menu/Help/About.php b/src/Entity/Browser/Menu/Help/About.php index 2cc8b78b..8ac0eddd 100644 --- a/src/Entity/Browser/Menu/Help/About.php +++ b/src/Entity/Browser/Menu/Help/About.php @@ -15,6 +15,8 @@ use \GtkResponseType; use \Yggverse\Yoda\Entity\Browser\Menu\Help; +use \Composer\InstalledVersions; + class About { // GTK @@ -30,7 +32,7 @@ class About public const DIALOG_FORMAT_SECONDARY_MARKUP_APP_SRC_NAME = 'Yoda'; public const DIALOG_FORMAT_SECONDARY_MARKUP_APP_SRC_INFO = 'Browser for Gemini protocol'; - public const DIALOG_FORMAT_SECONDARY_MARKUP_APP_SRC_META = 'version: %s'; + public const DIALOG_FORMAT_SECONDARY_MARKUP_APP_SRC_META = '%s'; public const DIALOG_FORMAT_SECONDARY_MARKUP_PHP_SRC_NAME = 'PHP'; public const DIALOG_FORMAT_SECONDARY_MARKUP_PHP_SRC_INFO = 'Hypertext Preprocessor'; @@ -44,7 +46,6 @@ class About public const DIALOG_FORMAT_SECONDARY_MARKUP_LIB_GTK_INFO = 'Free and open-source cross-platform widget toolkit'; public const DIALOG_FORMAT_SECONDARY_MARKUP_LIB_GTK_META = 'version: %d.%d.%d'; - public const APP_SRC_VERSION = 'dev'; // @TODO public const PHP_VERSION_GTK_EXTENSION = 'php-gtk3'; public function __construct( @@ -66,6 +67,7 @@ class About 'activate', function() { + // Init application info dialog $dialog = new GtkMessageDialog( $this->help->menu->browser->gtk, GtkDialogFlags::MODAL, @@ -74,6 +76,23 @@ class About _($this::DIALOG_MESSAGE_FORMAT) ); + // Get composer versions installed + $composer = []; + + foreach (InstalledVersions::getInstalledPackages() as $package) + { + $composer[] = sprintf( + '%s %s', + basename( + $package + ), + InstalledVersions::getVersion( + $package + ) + ); + } + + // Build dialog template $dialog->format_secondary_markup( implode( PHP_EOL, @@ -83,7 +102,10 @@ class About _($this::DIALOG_FORMAT_SECONDARY_MARKUP_APP_SRC_INFO), sprintf( _($this::DIALOG_FORMAT_SECONDARY_MARKUP_APP_SRC_META), - $this::APP_SRC_VERSION + implode( + ' / ', + $composer + ) ), null, // PHP