Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

For a full diff see [`2.1.0...master`][2.1.0...master].
For a full diff see [`2.1.1...master`][2.1.1...master].

## [`2.1.1`][2.1.1]

For a full diff see [`2.1.0...2.1.1`][2.1.0...2.1.1].

### Fixed

* Actually run `composer validate` to show validation errors when `composer.json` is not valid according to its schema ([#297]), by [@localheinz]

## [`2.1.0`][2.1.0]

Expand Down Expand Up @@ -266,6 +274,7 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0].
[2.0.1]: https://github.com/ergebnis/composer-normalize/releases/tag/2.0.1
[2.0.2]: https://github.com/ergebnis/composer-normalize/releases/tag/2.0.2
[2.1.0]: https://github.com/ergebnis/composer-normalize/releases/tag/2.1.0
[2.1.1]: https://github.com/ergebnis/composer-normalize/releases/tag/2.1.1

[81bc3a8...0.1.0]: https://github.com/ergebnis/composer-normalize/compare/81bc3a8...0.1.0
[0.1.0...0.2.0]: https://github.com/ergebnis/composer-normalize/compare/0.1.0...0.2.0
Expand All @@ -289,7 +298,8 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0].
[2.0.0...2.0.1]: https://github.com/ergebnis/composer-normalize/compare/2.0.0...2.0.1
[2.0.1...2.0.2]: https://github.com/ergebnis/composer-normalize/compare/2.0.1...2.0.2
[2.0.2...2.1.0]: https://github.com/ergebnis/composer-normalize/compare/2.0.2...2.1.0
[2.1.0...master]: https://github.com/ergebnis/composer-normalize/compare/2.1.0...master
[2.1.0...2.1.1]: https://github.com/ergebnis/composer-normalize/compare/2.1.0...2.1.1
[2.1.1...master]: https://github.com/ergebnis/composer-normalize/compare/2.1.1...master

[#1]: https://github.com/ergebnis/composer-normalize/pull/1
[#2]: https://github.com/ergebnis/composer-normalize/pull/2
Expand Down Expand Up @@ -327,6 +337,7 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0].
[#273]: https://github.com/ergebnis/composer-normalize/pull/273
[#280]: https://github.com/ergebnis/composer-normalize/pull/280
[#292]: https://github.com/ergebnis/composer-normalize/pull/292
[#297]: https://github.com/ergebnis/composer-normalize/pull/297

[@ergebnis]: https://github.com/ergebnis
[@localheinz]: https://github.com/localheinz
Expand Down
11 changes: 8 additions & 3 deletions src/Command/NormalizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,16 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O

try {
$normalized = $this->normalizer->normalize($json);
} catch (\InvalidArgumentException $exception) {
} catch (Normalizer\Exception\OriginalInvalidAccordingToSchemaException $exception) {
$io->writeError(\sprintf(
'<error>%s</error>',
$exception->getMessage()
));

return $this->validateComposerFile($output);
return $this->validateComposerFile(
$output,
$composerFile
);
} catch (\RuntimeException $exception) {
$io->writeError(\sprintf(
'<error>%s</error>',
Expand Down Expand Up @@ -347,19 +350,21 @@ private function diff(string $before, string $after): string
* @see https://getcomposer.org/doc/03-cli.md#validate
*
* @param Console\Output\OutputInterface $output
* @param string $composerFile
*
* @throws \Exception
*
* @return int
*/
private function validateComposerFile(Console\Output\OutputInterface $output): int
private function validateComposerFile(Console\Output\OutputInterface $output, string $composerFile): int
{
/** @var Console\Application $application */
$application = $this->getApplication();

return $application->run(
new Console\Input\ArrayInput([
'command' => 'validate',
'file' => $composerFile,
'--no-check-all' => true,
'--no-check-lock' => true,
'--no-check-publish' => true,
Expand Down
7 changes: 6 additions & 1 deletion test/Integration/Command/NormalizeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ public function testFailsWhenComposerJsonIsPresentButNotValid(CommandInvocation
);

self::assertExitCodeSame(1, $exitCode);
self::assertRegExp('/Original JSON is not valid according to schema ".*"/', $output->fetch());

$display = $output->fetch();

self::assertRegExp('/Original JSON is not valid according to schema ".*"/', $display);
self::assertContains('See https://getcomposer.org/doc/04-schema.md for details on the schema', $display);
self::assertContains('No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.', $display);
self::assertEquals($initialState, $scenario->currentState());
}

Expand Down