项目作者: JBZoo

项目描述 :
See what packages have changed after `composer update`
高级语言: PHP
项目地址: git://github.com/JBZoo/Composer-Diff.git
创建时间: 2020-07-03T19:01:26Z
项目社区:https://github.com/JBZoo/Composer-Diff

开源协议:MIT License

下载


JBZoo / Composer-Diff

CI Coverage Status Psalm Coverage Psalm Level CodeFactor
Stable Version Total Downloads Dependents GitHub License

Why?

See what packages have been changed after you run composer update by comparing composer.lock to the git show HEAD:composer.lock.

Installation

  1. composer require jbzoo/composer-diff # For specific project
  2. composer global require jbzoo/composer-diff # As global tool
  3. # OR use phar file.
  4. wget https://github.com/JBZoo/Composer-Diff/releases/latest/download/composer-diff.phar

Usage

  1. composer update
  2. # if it's installed via composer
  3. php ./vendor/bin/composer-diff
  4. # OR (if installed globally)
  5. composer-diff
  6. # OR (if you downloaded phar file)
  7. php composer-diff.phar

Help Description

  1. ./vendor/bin/composer-diff --help
  2. Description:
  3. Show difference between two versions of composer.lock files
  4. Usage:
  5. diff [options]
  6. Options:
  7. --source=SOURCE The file, git ref, or git ref with filename to compare FROM [default: "HEAD:composer.lock"]
  8. --target=TARGET The file, git ref, or git ref with filename to compare TO [default: "./composer.lock"]
  9. --env=ENV Show only selected environment. Available options: both, require, require-dev [default: "both"]
  10. --output=OUTPUT Output format. Available options: console, markdown, json [default: "console"]
  11. --no-links Hide all links in tables
  12. --strict Return exit code if you have any difference
  13. --no-progress Disable progress bar animation for logs. It will be used only for text output format.
  14. --mute-errors Mute any sort of errors. So exit code will be always "0" (if it's possible).
  15. It has major priority then --non-zero-on-error. It's on your own risk!
  16. --stdout-only For any errors messages application will use StdOut instead of StdErr. It's on your own risk!
  17. --non-zero-on-error None-zero exit code on any StdErr message.
  18. --timestamp Show timestamp at the beginning of each message.It will be used only for text output format.
  19. --profile Display timing and memory usage information.
  20. --output-mode=OUTPUT-MODE Output format. Available options:
  21. text - Default text output format, userfriendly and easy to read.
  22. cron - Shortcut for crontab. It's basically focused on human-readable logs output.
  23. It's combination of --timestamp --profile --stdout-only --no-progress -vv.
  24. logstash - Logstash output format, for integration with ELK stack.
  25. [default: "text"]
  26. --cron Alias for --output-mode=cron. Deprecated!
  27. -h, --help Display help for the given command. When no command is given display help for the diff command
  28. -q, --quiet Do not output any message
  29. -V, --version Display this application version
  30. --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
  31. -n, --no-interaction Do not ask any interactive question
  32. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Output Examples

Default view (—output=console)

  1. PHP Production Dependencies (require)
  2. +-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
  3. | Package | Action | Old Version | New Version | Details |
  4. +-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
  5. | vendor/downgraded | Downgraded | 2.0.0 | 1.0.0 | https://gitlab.com/vendor/downgraded/compare/2.0.0...1.0.0 |
  6. | vendor/new | New | - | 1.0.0 | |
  7. | vendor/no-tag | Changed | dev-master@bbc0fba | dev-master@f2f9280 | https://gitlab.com/vendor/package-1/compare/bbc0fba...f2f9280 |
  8. | vendor/no-tag-new | New | - | dev-develop@a999014 | |
  9. | vendor/removed | Removed | 1.0.0 | - | |
  10. | vendor/upgraded | Upgraded | 1.0.0 | 2.0.0 | https://gitlab.com/vendor/upgraded/compare/1.0.0...2.0.0 |
  11. +-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+

Rendered in your terminal:
Dummy example

Also, see colored example in travis-ci
Real project

Markdown Output (—output=markdown)

Source code:

  1. ## PHP Production Dependencies (require)
  2. | Package | Action | Old Version | New Version | |
  3. |:-----------------------------------------------------------|:-----------|-------------------:|--------------------:|:-----------------------------------------------------------------------------|
  4. | [vendor/downgraded](https://gitlab.com/vendor/downgraded) | Downgraded | 2.0.0 | 1.0.0 | [See details](https://gitlab.com/vendor/downgraded/compare/2.0.0...1.0.0) |
  5. | [vendor/new](https://gitlab.com/vendor/new) | New | - | 1.0.0 | |
  6. | [vendor/no-tag](https://gitlab.com/vendor/package-1) | Changed | dev-master@bbc0fba | dev-master@f2f9280 | [See details](https://gitlab.com/vendor/package-1/compare/bbc0fba...f2f9280) |
  7. | [vendor/no-tag-new](https://gitlab.com/vendor-1/package-1) | New | - | dev-develop@a999014 | |
  8. | [vendor/removed](https://gitlab.com/vendor/removed) | Removed | 1.0.0 | - | |
  9. | [vendor/upgraded](https://gitlab.com/vendor/upgraded) | Upgraded | 1.0.0 | 2.0.0 | [See details](https://gitlab.com/vendor/upgraded/compare/1.0.0...2.0.0) |

Rendered in your readme or PR/MR description:

Package Action Old Version New Version
vendor/downgraded Downgraded 2.0.0 1.0.0 See details
vendor/new New - 1.0.0
vendor/no-tag Changed dev-master@bbc0fba dev-master@f2f9280 See details
vendor/no-tag-new New - dev-develop@a999014
vendor/removed Removed 1.0.0 -
vendor/upgraded Upgraded 1.0.0 2.0.0 See details

JSON Output (—output=json)

  1. {
  2. "require": {
  3. "vendor\/downgraded": {
  4. "name": "vendor\/downgraded",
  5. "url": "https:\/\/gitlab.com\/vendor\/downgraded",
  6. "version_from": "2.0.0",
  7. "version_to": "1.0.0",
  8. "mode": "Downgraded",
  9. "compare": "https:\/\/gitlab.com\/vendor\/downgraded\/compare\/2.0.0...1.0.0"
  10. },
  11. "vendor\/new": {
  12. "name": "vendor\/new",
  13. "url": "https:\/\/gitlab.com\/vendor\/new",
  14. "version_from": null,
  15. "version_to": "1.0.0",
  16. "mode": "New",
  17. "compare": null
  18. },
  19. "vendor\/no-tag": {
  20. "name": "vendor\/no-tag",
  21. "url": "https:\/\/gitlab.com\/vendor\/package-1",
  22. "version_from": "dev-master@bbc0fba",
  23. "version_to": "dev-master@f2f9280",
  24. "mode": "Changed",
  25. "compare": "https:\/\/gitlab.com\/vendor\/package-1\/compare\/bbc0fba...f2f9280"
  26. },
  27. "vendor\/no-tag-new": {
  28. "name": "vendor\/no-tag-new",
  29. "url": "https:\/\/gitlab.com\/vendor-1\/package-1",
  30. "version_from": null,
  31. "version_to": "dev-develop@a999014",
  32. "mode": "New",
  33. "compare": null
  34. },
  35. "vendor\/removed": {
  36. "name": "vendor\/removed",
  37. "url": "https:\/\/gitlab.com\/vendor\/removed",
  38. "version_from": "1.0.0",
  39. "version_to": null,
  40. "mode": "Removed",
  41. "compare": null
  42. },
  43. "vendor\/upgraded": {
  44. "name": "vendor\/upgraded",
  45. "url": "https:\/\/gitlab.com\/vendor\/upgraded",
  46. "version_from": "1.0.0",
  47. "version_to": "2.0.0",
  48. "mode": "Upgraded",
  49. "compare": "https:\/\/gitlab.com\/vendor\/upgraded\/compare\/1.0.0...2.0.0"
  50. }
  51. }
  52. }

Roadmap

  • Supporting Drupal repos. For example.
  • Add action in the composer via API like composer lock-diff.
  • Fixes the same issue with complex/custom name of tag.
  • Auto-detecting alias name of branch.
  • No warp links for Markdown format.
  • (?) Support MS Windows…

Unit tests and check code style

  1. make build
  2. make test-all

License

MIT

See Also

  • CI-Report-Converter - Converting different error reports for deep compatibility with popular CI systems.
  • Composer-Graph - Dependency graph visualization of composer.json based on mermaid-js.
  • Mermaid-PHP - Generate diagrams and flowcharts with the help of the mermaid script language.
  • Utils - Collection of useful PHP functions, mini-classes, and snippets for every day.
  • Image - Package provides object-oriented way to manipulate with images as simple as possible.
  • Data - Extended implementation of ArrayObject. Use files as config/array.
  • Retry - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.
  • SimpleTypes - Converting any values and measures - money, weight, exchange rates, length, …

Special thanks to the project davidrjonas/composer-lock-diff which inspired me to make a great utility :)