Skip to content

Commit

Permalink
Merge pull request #300 from ergebnis/feature/version
Browse files Browse the repository at this point in the history
Enhancement: Show version of ergebnis/composer-normalize
  • Loading branch information
localheinz authored Dec 27, 2019
2 parents 4be962a + 0baf3c6 commit 5c63fc9
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ jobs:
- name: "Require composer/composer"
run: "composer require composer/composer:1.9.1 --no-interaction --no-progress --no-suggest"

- name: "Remove git placeholder configuration with jq"
run: "echo $(cat box.json | jq 'del(.git)') > box.json"

- name: "Validate configuration for humbug/box"
run: "phar/box.phar validate box.json"

Expand Down
1 change: 1 addition & 0 deletions box.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"files": [
"resource/schema.json"
],
"git": "git",
"main": "phar/composer-normalize.php",
"output": ".build/phar/composer-normalize.phar"
}
1 change: 1 addition & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"void",
"Composer\\Command\\BaseCommand",
"Composer\\Composer",
"Composer\\Console\\Application",
"Composer\\Factory",
"Composer\\IO\\IOInterface",
"Composer\\Json\\JsonFile",
Expand Down
10 changes: 5 additions & 5 deletions phar/composer-normalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* @see https://github.com/ergebnis/composer-normalize
*/

use Composer\Console\Application;
use Ergebnis\Composer\Json\Normalizer\ComposerJsonNormalizer;
use Composer\Factory;
use Ergebnis\Composer\Json;
use Ergebnis\Composer\Normalize;
use Ergebnis\Json\Normalizer;
use Ergebnis\Json\Printer;
Expand All @@ -21,16 +21,16 @@
require_once __DIR__ . '/../vendor/autoload.php';

$command = new Normalize\Command\NormalizeCommand(
new Composer\Factory(),
new ComposerJsonNormalizer(__DIR__ . '/../resource/schema.json'),
new Factory(),
new Json\Normalizer\ComposerJsonNormalizer(__DIR__ . '/../resource/schema.json'),
new Normalizer\Format\Formatter(new Printer\Printer()),
new Diff\Differ(new Diff\Output\StrictUnifiedDiffOutputBuilder([
'fromFile' => 'original',
'toFile' => 'normalized',
]))
);

$application = new Application();
$application = new Normalize\Application();

$application->add($command);
$application->setDefaultCommand($command->getName());
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ parameters:
ergebnis:
classesAllowedToBeExtended:
- Composer\Command\BaseCommand
- Composer\Console\Application
- LogicException
inferPrivatePropertyTypeFromConstructor: true
level: max
Expand Down
31 changes: 31 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2018 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/ergebnis/composer-normalize
*/

namespace Ergebnis\Composer\Normalize;

use Composer\Console;

/**
* @internal
*/
final class Application extends Console\Application
{
public function getLongVersion(): string
{
return \sprintf(
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
$this->getName(),
$this->getVersion()
);
}
}
39 changes: 39 additions & 0 deletions test/Unit/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2018 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/ergebnis/composer-normalize
*/

namespace Ergebnis\Composer\Normalize\Test\Unit;

use Ergebnis\Composer\Normalize\Application;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Composer\Normalize\Application
*/
final class ApplicationTest extends Framework\TestCase
{
public function testGetLongVersionReturnsVersion(): void
{
$composerApplication = new \Composer\Console\Application();
$application = new Application();

$expected = \sprintf(
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
$composerApplication->getName(),
$composerApplication->getVersion()
);

self::assertSame($expected, $application->getLongVersion());
}
}

0 comments on commit 5c63fc9

Please sign in to comment.