Skip to content

Commit 0baf3c6

Browse files
committed
Enhancement: Show version of ergebnis/composer-normalize
1 parent 4be962a commit 0baf3c6

7 files changed

+81
-5
lines changed

.github/workflows/continuous-integration.yml

+3
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ jobs:
285285
- name: "Require composer/composer"
286286
run: "composer require composer/composer:1.9.1 --no-interaction --no-progress --no-suggest"
287287

288+
- name: "Remove git placeholder configuration with jq"
289+
run: "echo $(cat box.json | jq 'del(.git)') > box.json"
290+
288291
- name: "Validate configuration for humbug/box"
289292
run: "phar/box.phar validate box.json"
290293

box.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"files": [
99
"resource/schema.json"
1010
],
11+
"git": "git",
1112
"main": "phar/composer-normalize.php",
1213
"output": ".build/phar/composer-normalize.phar"
1314
}

composer-require-checker.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"void",
1818
"Composer\\Command\\BaseCommand",
1919
"Composer\\Composer",
20+
"Composer\\Console\\Application",
2021
"Composer\\Factory",
2122
"Composer\\IO\\IOInterface",
2223
"Composer\\Json\\JsonFile",

phar/composer-normalize.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
* @see https://github.com/ergebnis/composer-normalize
1212
*/
1313

14-
use Composer\Console\Application;
15-
use Ergebnis\Composer\Json\Normalizer\ComposerJsonNormalizer;
14+
use Composer\Factory;
15+
use Ergebnis\Composer\Json;
1616
use Ergebnis\Composer\Normalize;
1717
use Ergebnis\Json\Normalizer;
1818
use Ergebnis\Json\Printer;
@@ -21,16 +21,16 @@
2121
require_once __DIR__ . '/../vendor/autoload.php';
2222

2323
$command = new Normalize\Command\NormalizeCommand(
24-
new Composer\Factory(),
25-
new ComposerJsonNormalizer(__DIR__ . '/../resource/schema.json'),
24+
new Factory(),
25+
new Json\Normalizer\ComposerJsonNormalizer(__DIR__ . '/../resource/schema.json'),
2626
new Normalizer\Format\Formatter(new Printer\Printer()),
2727
new Diff\Differ(new Diff\Output\StrictUnifiedDiffOutputBuilder([
2828
'fromFile' => 'original',
2929
'toFile' => 'normalized',
3030
]))
3131
);
3232

33-
$application = new Application();
33+
$application = new Normalize\Application();
3434

3535
$application->add($command);
3636
$application->setDefaultCommand($command->getName());

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
ergebnis:
66
classesAllowedToBeExtended:
77
- Composer\Command\BaseCommand
8+
- Composer\Console\Application
89
- LogicException
910
inferPrivatePropertyTypeFromConstructor: true
1011
level: max

src/Application.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2018 Andreas Möller
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/ergebnis/composer-normalize
12+
*/
13+
14+
namespace Ergebnis\Composer\Normalize;
15+
16+
use Composer\Console;
17+
18+
/**
19+
* @internal
20+
*/
21+
final class Application extends Console\Application
22+
{
23+
public function getLongVersion(): string
24+
{
25+
return \sprintf(
26+
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
27+
$this->getName(),
28+
$this->getVersion()
29+
);
30+
}
31+
}

test/Unit/ApplicationTest.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2018 Andreas Möller
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/ergebnis/composer-normalize
12+
*/
13+
14+
namespace Ergebnis\Composer\Normalize\Test\Unit;
15+
16+
use Ergebnis\Composer\Normalize\Application;
17+
use PHPUnit\Framework;
18+
19+
/**
20+
* @internal
21+
*
22+
* @covers \Ergebnis\Composer\Normalize\Application
23+
*/
24+
final class ApplicationTest extends Framework\TestCase
25+
{
26+
public function testGetLongVersionReturnsVersion(): void
27+
{
28+
$composerApplication = new \Composer\Console\Application();
29+
$application = new Application();
30+
31+
$expected = \sprintf(
32+
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
33+
$composerApplication->getName(),
34+
$composerApplication->getVersion()
35+
);
36+
37+
self::assertSame($expected, $application->getLongVersion());
38+
}
39+
}

0 commit comments

Comments
 (0)