2017 © Pedro PelĂĄez
 

composer-plugin composer-normalize

Provides a composer plugin for normalizing composer.json.

image

localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  • Wednesday, July 25, 2018
  • by localheinz
  • Repository
  • 6 Watchers
  • 75 Stars
  • 11,328 Installations
  • PHP
  • 16 Dependents
  • 1 Suggesters
  • 3 Forks
  • 2 Open issues
  • 24 Versions
  • 57 % Grown

The README.md

composer-normalize

Integrate Merge Release Renew Update, (*1)

Code Coverage, (*2)

Latest Stable Version Total Downloads Monthly Downloads, (*3)

This project provides a composer plugin for normalizing composer.json., (*4)

Hmm, kinda cool I guess, (*5)

Why

When it comes to formatting composer.json, you have the following options:, (*6)

  • you can format it manually (and request changes when contributors format it differently)
  • you can stop caring
  • or you can use ergebnis/composer-normalize

ergebnis/composer-normalize normalizes composer.json, so you don't have to., (*7)

:bulb: If you want to find out more, take a look at the examples and read this blog post., (*8)

Installation

Composer

Run, (*9)

composer require --dev ergebnis/composer-normalize

to install ergebnis/composer-normalize as a composer plugin., (*10)

Run, (*11)

composer config allow-plugins.ergebnis/composer-normalize true

to allow ergebnis/composer-normalize to run as a composer plugin., (*12)

:bulb: The allow-plugins has been added to composer/composer to add an extra layer of security., (*13)

For reference, see, (*14)

  • https://github.com/composer/composer/pull/10314
  • https://getcomposer.org/doc/06-config.md#allow-plugins

Phar

Head over to http://github.com/ergebnis/composer-normalize/releases/latest and download the latest composer-normalize.phar., (*15)

Run, (*16)

chmod +x composer-normalize.phar

to make the downloaded composer-normalize.phar executable., (*17)

Phive

Run, (*18)

phive install ergebnis/composer-normalize

to install ergebnis/composer-normalize with PHIVE., (*19)

Usage

Composer

Run, (*20)

composer normalize

to normalize composer.json in the working directory., (*21)

Phar

Run, (*22)

./composer-normalize.phar

to normalize composer.json in the working directory., (*23)

Phive

Run, (*24)

./tools/composer-normalize

to normalize composer.json in the working directory., (*25)

Details

The NormalizeCommand provided by the NormalizePlugin within this package will, (*26)

  • determine whether a composer.json exists
  • determine whether a composer.lock exists, and if so, whether it is up to date (unless the --no-check-lock option is used)
  • use Ergebnis\Json\Normalizer\Vendor\Composer\ComposerJsonNormalizer 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

Arguments

  • file: Path to composer.json file (optional, defaults to composer.json in working directory)

Options

  • --diff: Show the results of normalizing
  • --dry-run: Show the results of normalizing, but do not modify any files
  • --indent-size: Indent size (an integer greater than 0); should be used with the --indent-style option
  • --indent-style: Indent style (one of "space", "tab"); should be used with the --indent-size option
  • --no-check-lock: Do not check if lock file is up to date
  • --no-update-lock: Do not update lock file if it exists

As an alternative to specifying the --indent-size and --indent-style options, you can also use composer extra to configure these options in composer.json:, (*27)

{
  "extra": {
    "composer-normalize": {
      "indent-size": 2,
      "indent-style": "space"
    }
  }
}

:bulb: The configuration provided in composer extra always overrides the configuration provided via command line options., (*28)

Continuous Integration

If you want to run this in continuous integration services, use the --dry-run option., (*29)

composer normalize --dry-run

In case composer.json is not normalized (or composer.lock is not up-to-date), the command will fail with an exit code of 1 and show a diff., (*30)

Examples

pestphp/pest

Running, (*31)

composer normalize

against https://github.com/pestphp/pest/blob/v0.3.19/composer.json yields the following diff:, (*32)

diff --git a/composer.json b/composer.json
index 1cfbf1e..204f20f 100644
--- a/composer.json
+++ b/composer.json
@@ -25,6 +25,32 @@
         "pestphp/pest-plugin-init": "^0.3",
         "phpunit/phpunit": ">= 9.3.7 <= 9.5.0"
     },
+    "require-dev": {
+        "illuminate/console": "^7.16.1",
+        "illuminate/support": "^7.16.1",
+        "laravel/dusk": "^6.9.1",
+        "mockery/mockery": "^1.4.1",
+        "pestphp/pest-dev-tools": "dev-master"
+    },
+    "config": {
+        "preferred-install": "dist",
+        "sort-packages": true
+    },
+    "extra": {
+        "branch-alias": {
+            "dev-master": "0.3.x-dev"
+        },
+        "laravel": {
+            "providers": [
+                "Pest\\Laravel\\PestServiceProvider"
+            ]
+        },
+        "pest": {
+            "plugins": [
+                "Pest\\Plugins\\Version"
+            ]
+        }
+    },
     "autoload": {
         "psr-4": {
             "Pest\\": "src/"
@@ -42,49 +68,23 @@
             "tests/Autoload.php"
         ]
     },
-    "require-dev": {
-        "illuminate/console": "^7.16.1",
-        "illuminate/support": "^7.16.1",
-        "laravel/dusk": "^6.9.1",
-        "mockery/mockery": "^1.4.1",
-        "pestphp/pest-dev-tools": "dev-master"
-    },
     "minimum-stability": "dev",
     "prefer-stable": true,
-    "config": {
-        "sort-packages": true,
-        "preferred-install": "dist"
-    },
     "bin": [
         "bin/pest"
     ],
     "scripts": {
         "lint": "php-cs-fixer fix -v",
-        "test:lint": "php-cs-fixer fix -v --dry-run",
-        "test:types": "phpstan analyse --ansi --memory-limit=0",
-        "test:unit": "php bin/pest --colors=always --exclude-group=integration",
-        "test:integration": "php bin/pest --colors=always --group=integration",
-        "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
         "test": [
             "@test:lint",
             "@test:types",
             "@test:unit",
             "@test:integration"
-        ]
-    },
-    "extra": {
-        "branch-alias": {
-            "dev-master": "0.3.x-dev"
-        },
-        "pest": {
-            "plugins": [
-                "Pest\\Plugins\\Version"
-            ]
-        },
-        "laravel": {
-            "providers": [
-                "Pest\\Laravel\\PestServiceProvider"
-            ]
-        }
+        ],
+        "test:integration": "php bin/pest --colors=always --group=integration",
+        "test:lint": "php-cs-fixer fix -v --dry-run",
+        "test:types": "phpstan analyse --ansi --memory-limit=0",
+        "test:unit": "php bin/pest --colors=always --exclude-group=integration",
+        "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always"
     }
 }

phpspec/phpspec

Running, (*33)

composer normalize

against https://github.com/phpspec/phpspec/blob/7.0.1/composer.json yields the following diff:, (*34)

diff --git a/composer.json b/composer.json
index 90150a37..276a2ecd 100644
--- a/composer.json
+++ b/composer.json
@@ -1,72 +1,73 @@
 {
-    "name":         "phpspec/phpspec",
-    "description":  "Specification-oriented BDD framework for PHP 7.1+",
-    "keywords":     ["BDD", "SpecBDD", "TDD", "spec", "specification", "tests", "testing"],
-    "homepage":     "http://phpspec.net/",
-    "type":         "library",
-    "license":      "MIT",
-    "authors":      [
+    "name": "phpspec/phpspec",
+    "type": "library",
+    "description": "Specification-oriented BDD framework for PHP 7.1+",
+    "keywords": [
+        "BDD",
+        "SpecBDD",
+        "TDD",
+        "spec",
+        "specification",
+        "tests",
+        "testing"
+    ],
+    "homepage": "http://phpspec.net/",
+    "license": "MIT",
+    "authors": [
         {
-            "name":      "Konstantin Kudryashov",
-            "email":     "ever.zet@gmail.com",
-            "homepage":  "http://everzet.com"
+            "name": "Konstantin Kudryashov",
+            "email": "ever.zet@gmail.com",
+            "homepage": "http://everzet.com"
         },
         {
-            "name":      "Marcello Duarte",
-            "homepage":  "http://marcelloduarte.net/"
+            "name": "Marcello Duarte",
+            "homepage": "http://marcelloduarte.net/"
         },
         {
-            "name":      "Ciaran McNulty",
-            "homepage":  "https://ciaranmcnulty.com/"
+            "name": "Ciaran McNulty",
+            "homepage": "https://ciaranmcnulty.com/"
         }
     ],
-
     "require": {
-        "php":                      "^7.3 || 8.0.*",
-        "phpspec/prophecy":         "^1.9",
-        "phpspec/php-diff":         "^1.0.0",
-        "sebastian/exporter":       "^3.0 || ^4.0",
-        "symfony/console":          "^3.4 || ^4.4 || ^5.0",
+        "php": "^7.3 || 8.0.*",
+        "ext-tokenizer": "*",
+        "doctrine/instantiator": "^1.0.5",
+        "phpspec/php-diff": "^1.0.0",
+        "phpspec/prophecy": "^1.9",
+        "sebastian/exporter": "^3.0 || ^4.0",
+        "symfony/console": "^3.4 || ^4.4 || ^5.0",
         "symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.0",
-        "symfony/process":          "^3.4 || ^4.4 || ^5.0",
-        "symfony/finder":           "^3.4 || ^4.4 || ^5.0",
-        "symfony/yaml":             "^3.4 || ^4.4 || ^5.0",
-        "doctrine/instantiator":    "^1.0.5",
-        "ext-tokenizer":            "*"
+        "symfony/finder": "^3.4 || ^4.4 || ^5.0",
+        "symfony/process": "^3.4 || ^4.4 || ^5.0",
+        "symfony/yaml": "^3.4 || ^4.4 || ^5.0"
+    },
+    "conflict": {
+        "sebastian/comparator": "<1.2.4"
     },
-
     "require-dev": {
-        "behat/behat":           "^3.3",
-        "symfony/filesystem":    "^3.4 || ^4.0 || ^5.0",
-        "phpunit/phpunit":       "^8.0 || ^9.0"
+        "behat/behat": "^3.3",
+        "phpunit/phpunit": "^8.0 || ^9.0",
+        "symfony/filesystem": "^3.4 || ^4.0 || ^5.0"
     },
-
     "suggest": {
         "phpspec/nyan-formatters": "Adds Nyan formatters"
     },
-
-    "conflict": {
-        "sebastian/comparator" : "<1.2.4"
+    "extra": {
+        "branch-alias": {
+            "dev-main": "7.0.x-dev"
+        }
     },
-
     "autoload": {
         "psr-0": {
             "PhpSpec": "src/"
         }
     },
-
     "autoload-dev": {
         "psr-0": {
             "spec\\PhpSpec": "."
         }
     },
-
-    "bin": ["bin/phpspec"],
-
-    "extra": {
-        "branch-alias": {
-            "dev-main": "7.0.x-dev"
-        }
-    }
-
+    "bin": [
+        "bin/phpspec"
+    ]
 }

phpunit/phpunit

Running, (*35)

composer normalize

against https://github.com/sebastianbergmann/phpunit/blob/9.5.0/composer.json yields the following diff:, (*36)

diff --git a/composer.json b/composer.json
index fd6461fc3..23c3a3596 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
 {
     "name": "phpunit/phpunit",
-    "description": "The PHP Unit Testing framework.",
     "type": "library",
+    "description": "The PHP Unit Testing framework.",
     "keywords": [
         "phpunit",
         "xunit",
@@ -16,10 +16,6 @@
             "role": "lead"
         }
     ],
-    "support": {
-        "issues": "https://github.com/sebastianbergmann/phpunit/issues"
-    },
-    "prefer-stable": true,
     "require": {
         "php": ">=7.3",
         "ext-dom": "*",
@@ -54,20 +50,22 @@
         "ext-PDO": "*",
         "phpspec/prophecy-phpunit": "^2.0.1"
     },
+    "suggest": {
+        "ext-soap": "*",
+        "ext-xdebug": "*"
+    },
     "config": {
+        "optimize-autoloader": true,
         "platform": {
             "php": "7.3.0"
         },
-        "optimize-autoloader": true,
         "sort-packages": true
     },
-    "suggest": {
-        "ext-soap": "*",
-        "ext-xdebug": "*"
+    "extra": {
+        "branch-alias": {
+            "dev-master": "9.5-dev"
+        }
     },
-    "bin": [
-        "phpunit"
-    ],
     "autoload": {
         "classmap": [
             "src/"
@@ -86,9 +84,11 @@
             "tests/_files/NamespaceCoveredFunction.php"
         ]
     },
-    "extra": {
-        "branch-alias": {
-            "dev-master": "9.5-dev"
-        }
+    "prefer-stable": true,
+    "bin": [
+        "phpunit"
+    ],
+    "support": {
+        "issues": "https://github.com/sebastianbergmann/phpunit/issues"
     }
 }

Changelog

The maintainers of this project record notable changes to this project in a changelog., (*37)

Contributing

The maintainers of this project suggest following the contribution guide., (*38)

Code of Conduct

The maintainers of this project ask contributors to follow the code of conduct., (*39)

General Support Policy

The maintainers of this project provide limited support., (*40)

You can support the maintenance of this project by sponsoring @localheinz or requesting an invoice for services related to this project., (*41)

PHP Version Support Policy

This project supports PHP versions with active and security support., (*42)

The maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support., (*43)

Security Policy

This project has a security policy., (*44)

License

This project uses the MIT license., (*45)

Social

Follow @localheinz and @ergebnis on Twitter., (*46)

The Versions

25/07 2018

dev-feature/appveyor

dev-feature/appveyor

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

25/07 2018

dev-master

9999999-dev https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

07/05 2018

dev-feature/issue–templates

dev-feature/issue–templates https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

28/04 2018

dev-fix/phpunit

dev-fix/phpunit https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

24/04 2018

0.8.0

0.8.0.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

07/04 2018

0.7.0

0.7.0.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

11/03 2018

dev-feature/infection

dev-feature/infection https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

dev-feature/extra

dev-feature/extra https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

0.6.0

0.6.0.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

dev-fix/new-line

dev-fix/new-line https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

dev-feature/file-argument

dev-feature/file-argument https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

dev-fix/repeat

dev-fix/repeat https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

dev-fix/stages

dev-fix/stages https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

18/02 2018

dev-feature/factory

dev-feature/factory https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

15/02 2018

0.5.0

0.5.0.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

13/02 2018

0.4.1

0.4.1.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

02/02 2018

dev-feature/phpunit

dev-feature/phpunit https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

02/02 2018

dev-feature/diff

dev-feature/diff https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

02/02 2018

dev-fix/infection

dev-fix/infection https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

28/01 2018

0.4.0

0.4.0.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

28/01 2018

0.3.0

0.3.0.0 https://github.com/localheinz/composer-normalize

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

20/01 2018

0.2.0

0.2.0.0

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

14/01 2018

0.1.0

0.1.0.0

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize

14/01 2018

0.1.x-dev

0.1.9999999.9999999-dev

Provides a composer plugin for normalizing composer.json.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

plugin composer normalizer normalize