Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Require localheinz/composer-json-normalizer and remove normalizers #106

Merged
merged 3 commits into from
Nov 17, 2018
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
- xdebug-enable

script:
- vendor/bin/infection --min-covered-msi=80 --min-msi=60
- vendor/bin/infection --min-covered-msi=80 --min-msi=47

notifications:
email: false
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/localheinz/composer-normalize/compare/0.9.0...HEAD) ([`0.9.0...master`](https://github.com/localheinz/composer-normalize/compare/0.9.0...master))
## Unreleased

For a full diff see [`1.0.0...master`](https://github.com/localheinz/composer-normalize/compare/1.0.0...master).

## [`1.0.0`](https://github.com/localheinz/composer-normalize/releases/tag/1.0.0)

For a full diff see [`0.9.0...1.0.0`](https://github.com/localheinz/composer-normalize/compare/0.9.0...1.0.0).

### Added

* Added this changelog ([#94](https://github.com/localheinz/composer-normalize/pull/#94)), by [@localheinz](https://github.com/localheinz)

## [`0.9.0`](https://github.com/localheinz/composer-normalize/releases/tag/0.9.0)
### Removed

* Removed normalizers after extracting package [`localheinz/composer-json-normalizer`](https://github.com/localheinz/composer-json-normalizer) ([#106](https://github.com/localheinz/composer-normalize/pull/#106)), by [@localheinz](https://github.com/localheinz)

## [`0.9.0`](https://github.com/localheinz/composer-normalize/releases/tag/0.9.0)

For a full diff see [`0.8.0...0.9.0`](https://github.com/localheinz/composer-normalize/compare/0.8.0...0.9.0).

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cs: vendor
vendor/bin/php-cs-fixer fix --config=.php_cs --diff --verbose

infection:
vendor/bin/infection --min-covered-msi=80 --min-msi=60
vendor/bin/infection --min-covered-msi=80 --min-msi=47

stan: vendor
vendor/bin/phpstan analyse --configuration=phpstan.neon --level=max src
Expand Down
84 changes: 4 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ The `NormalizeCommand` provided by the `NormalizePlugin` within this package wil

* determine whether a `composer.json` exists
* determine whether a `composer.lock` exists, and if so, whether it is up to date
* use the `ComposerJsonNormalizer` to normalize the content of `composer.json`
* use the `ComposerJsonNormalizer` from [`localheinz/composer-json-normalizer`](https://github.com/localheinz/composer-json-normalizer) to normalize the content of `composer.json`
* format the normalized content (either as sniffed, or as specified using the `--indent-size` and `--indent-style` options)
* write the normalized and formatted content of `composer.json` back to the file
* update the hash in `composer.lock` if it exists and if an update is necessary

:bulb: Interested in what `ComposerJsonNormalizer` does? Head over to
[`localheinz/composer-json-normalizer`](https://github.com/localheinz/composer-json-normalizer#normalizers) for a full explanation.

### Arguments

* `file`: Path to composer.json file (optional, defaults to `composer.json` in working directory)
Expand All @@ -70,77 +73,6 @@ The `NormalizeCommand` provided by the `NormalizePlugin` within this package wil
* `--indent-style`: Indent style (one of "space", "tab"); should be used with the `--indent-size` option
* `--no-update-lock`: Do not update lock file if it exists

## Normalizers

The `ComposerJsonNormalizer` composes normalizers provided by [`localheinz/json-normalizer`](https://github.com/localheinz/json-normalizer):

* [`Localheinz\Json\Normalizer\ChainNormalizer`](https://github.com/localheinz/json-normalizer#chainnormalizer)
* [`Localheinz\Json\Normalizer\SchemaNormalizer`](https://github.com/localheinz/json-normalizer#schemanormalizer)

as well as the following normalizers provided by this package:

* [`Localheinz\Composer\Normalize\Normalizer\BinNormalizer`](#binnormalizer)
* [`Localheinz\Composer\Normalize\Normalizer\ConfigHashNormalizer`](#confighashnormalizer)
* [`Localheinz\Composer\Normalize\Normalizer\PackageHashNormalizer`](#packagehashnormalizer)
* [`Localheinz\Composer\Normalize\Normalizer\VersionConstraintNormalizer`](#versionconstraintnormalizer)

### `BinNormalizer`

If `composer.json` contains an array of scripts in the `bin` section,
the `BinNormalizer` will sort the elements of the `bin` section by value in ascending order.

:bulb: Find out more about the `bin` section at https://getcomposer.org/doc/04-schema.md#bin.

### `ConfigHashNormalizer`

If `composer.json` contains any configuration in the

* `config`
* `extra`
* `scripts-descriptions`

sections, the `ConfigHashNormalizer` will sort the content of these sections
by key in ascending order.

:bulb: Find out more about the `config` section at https://getcomposer.org/doc/06-config.md.

### `PackageHashNormalizer`

If `composer.json` contains any configuration in the

* `conflict`
* `provide`
* `replace`
* `require`
* `require-dev`
* `suggest`

sections, the `PackageHashNormalizer` will sort the content of these sections.

:bulb: This transfers the behaviour from using the `--sort-packages` or
`sort-packages` configuration flag to other sections. Find out more about
the `--sort-packages` flag and configuration at https://getcomposer.org/doc/06-config.md#sort-packages
and https://getcomposer.org/doc/03-cli.md#require.

### `VersionConstraintNormalizer`

If `composer.json` contains version constraints in the

* `conflict`
* `provide`
* `replace`
* `require`
* `require-dev`

sections, the `VersionConstraintNormalizer` will ensure that

* all constraints are trimmed
* *and* constraints are separated by a single space (` `) or a comma (`,`)
* *or* constraints are separated by double-pipe with a single space before and after (` || `)
* *range* constraints are separated by a single space (` `)

:bulb: Find out more about version constraints at https://getcomposer.org/doc/articles/versions.md.

## Changelog

Please have a look at [`CHANGELOG.md`](CHANGELOG.md).
Expand All @@ -157,14 +89,6 @@ Please have a look at [`CODE_OF_CONDUCT.md`](.github/CODE_OF_CONDUCT.md).

This package is licensed using the MIT License.

## Credits

The algorithm for sorting packages in the [`PackageHashNormalizer`](src/Normalizer/PackageHashNormalizer.php) has
been adopted from [`Composer\Json\JsonManipulator::sortPackages()`](https://github.com/composer/composer/blob/1.6.2/src/Composer/Json/JsonManipulator.php#L110-L146)
(originally licensed under MIT by [Nils Adermann](https://github.com/naderman) and [Jordi Boggiano](https://github.com/seldaek)),
which I initially contributed to `composer/composer` with [`composer/composer#3549`](https://github.com/composer/composer/pull/3549)
and [`composer/composer#3872`](https://github.com/composer/composer/pull/3872).

## Services

`localheinz/composer-normalize` is currently in use by [FlintCI](https://flintci.io), see https://flintci.io/docs#composernormalize.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"require": {
"php": "^7.1",
"composer-plugin-api": "^1.1.0",
"localheinz/composer-json-normalizer": "^1.0.1",
"localheinz/json-normalizer": "~0.9.0",
"sebastian/diff": "^2.0.1 || ^3.0.0",
"symfony/console": "^2.5.0 || ^3.0.0 || ^4.0.0"
Expand Down
Loading