1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

Display version and package name correctly

This commit is contained in:
James Titcumb
2024-09-26 08:36:31 +01:00
parent a62f1e291e
commit 120326fef5
4 changed files with 37 additions and 2 deletions

View File

@@ -83,6 +83,8 @@ jobs:
tools: composer, box
php-version: "${{ matrix.php-version }}"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ramsey/composer-install@v3
- name: Build PHAR
run: box compile

View File

@@ -22,6 +22,8 @@ jobs:
tools: composer, box
php-version: "${{ matrix.php-version }}"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ramsey/composer-install@v3
- name: Build PHAR
run: box compile

32
bin/pie
View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Php\Pie;
use Composer\InstalledVersions;
use Php\Pie\Command\BuildCommand;
use Php\Pie\Command\DownloadCommand;
use Php\Pie\Command\InfoCommand;
@@ -20,7 +21,36 @@ include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
$container = Container::factory();
$application = new Application('pie', 'dev-main');
$application = new Application(
'🥧 PHP Installer for Extensions (PIE)',
(static function (): string {
$pieVersion = '@pie_version@';
/**
* @psalm-suppress RedundantCondition
* @noinspection PhpConditionAlreadyCheckedInspection
*/
if ($pieVersion === '@pie_version'.'@') {
if (!class_exists(InstalledVersions::class)) {
/**
* Note: magic constant that causes Symfony Console to not display a version
* {@see Application::getLongVersion()}
*/
return 'UNKNOWN';
}
$installedVersion = InstalledVersions::getVersion(InstalledVersions::getRootPackage()['name']);
if ($installedVersion === null) {
return 'UNKNOWN';
}
return $installedVersion;
}
/** @psalm-suppress NoValue */
return $pieVersion;
})()
);
$application->setCommandLoader(new ContainerCommandLoader(
$container,
[

View File

@@ -1,4 +1,5 @@
{
"alias": "pie.phar",
"output": "pie.phar"
"output": "pie.phar",
"git": "pie_version"
}