Skip to content

Commit c15d69f

Browse files
authored
Merge pull request #120 from context-hub/app-version
Support `ctx --version` command
2 parents 32cfa14 + 0708b3d commit c15d69f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

app.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Prepare Global Environment
1515
// -----------------------------------------------------------------------------
1616
\mb_internal_encoding('UTF-8');
17-
\error_reporting((E_ALL | E_STRICT) ^ E_DEPRECATED);
17+
\error_reporting(E_ALL ^ E_DEPRECATED);
1818

1919

2020
// -----------------------------------------------------------------------------
@@ -64,10 +64,8 @@
6464
$insidePhar = \str_starts_with(__FILE__, 'phar://');
6565
$vendorPath = \dirname($vendorPath) . '/../';
6666
$versionFile = $vendorPath . '/version.json';
67-
$appPath = \realpath($vendorPath);
68-
if ($insidePhar) {
69-
$appPath = \getcwd();
70-
}
67+
$appPath = $insidePhar ? \getcwd() : \realpath($vendorPath);
68+
7169
$version = \file_exists($versionFile)
7270
? \json_decode(\file_get_contents($versionFile), true)
7371
: [

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"spiral/code-style": "^2.2.2",
4646
"phpunit/phpunit": "^10.2",
4747
"rector/rector": "^2.0",
48-
"vimeo/psalm": "^5.8"
48+
"vimeo/psalm": "^6.0"
4949
},
5050
"autoload": {
5151
"psr-4": {

src/Application/Bootloader/ConsoleBootloader.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Butschster\ContextGenerator\Application\Bootloader;
66

7+
use Butschster\ContextGenerator\Application\Application;
78
use Butschster\ContextGenerator\Application\Dispatcher\ConsoleDispatcher;
89
use Spiral\Boot\AbstractKernel;
910
use Spiral\Boot\Bootloader\Bootloader;
@@ -23,7 +24,7 @@ public function __construct(
2324
private readonly ConfiguratorInterface $config,
2425
) {}
2526

26-
public function init(AbstractKernel $kernel, BinderInterface $binder): void
27+
public function init(AbstractKernel $kernel, BinderInterface $binder, Application $app): void
2728
{
2829
$kernel->bootstrapped(static function (AbstractKernel $kernel): void {
2930
$kernel->addDispatcher(ConsoleDispatcher::class);
@@ -41,6 +42,8 @@ public function init(AbstractKernel $kernel, BinderInterface $binder): void
4142
[
4243
'interceptors' => [],
4344
'commands' => [],
45+
'name' => $app->name,
46+
'version' => $app->version,
4447
],
4548
);
4649
}

0 commit comments

Comments
 (0)