jbzoo / composer-diff
查看 composer 更新后发生了什么变化。
7.0.3
2024-01-28 12:53 UTC
Requires
- php: ^8.1
- ext-filter: *
- ext-json: *
- composer/semver: >=1.0
- jbzoo/cli: ^7.1.1
- jbzoo/data: ^7.1
- jbzoo/markdown: ^7.0
- symfony/console: >=6.4
- symfony/process: >=6.4
Requires (Dev)
- composer/composer: >=2.0
- jbzoo/toolbox-dev: ^7.1
- roave/security-advisories: dev-master
README
为什么?
通过比较 composer.lock
与 git show HEAD:composer.lock
,在运行 composer update
后查看哪些包发生了变化。
安装
composer require jbzoo/composer-diff # For specific project composer global require jbzoo/composer-diff # As global tool # OR use phar file. wget https://github.com/JBZoo/Composer-Diff/releases/latest/download/composer-diff.phar
用法
composer update # if it's installed via composer php ./vendor/bin/composer-diff # OR (if installed globally) composer-diff # OR (if you downloaded phar file) php composer-diff.phar
帮助描述
./vendor/bin/composer-diff --help
Description:
Show difference between two versions of composer.lock files
Usage:
diff [options]
Options:
--source=SOURCE The file, git ref, or git ref with filename to compare FROM [default: "HEAD:composer.lock"]
--target=TARGET The file, git ref, or git ref with filename to compare TO [default: "./composer.lock"]
--env=ENV Show only selected environment. Available options: both, require, require-dev [default: "both"]
--output=OUTPUT Output format. Available options: console, markdown, json [default: "console"]
--no-links Hide all links in tables
--strict Return exit code if you have any difference
--no-progress Disable progress bar animation for logs. It will be used only for text output format.
--mute-errors Mute any sort of errors. So exit code will be always "0" (if it's possible).
It has major priority then --non-zero-on-error. It's on your own risk!
--stdout-only For any errors messages application will use StdOut instead of StdErr. It's on your own risk!
--non-zero-on-error None-zero exit code on any StdErr message.
--timestamp Show timestamp at the beginning of each message.It will be used only for text output format.
--profile Display timing and memory usage information.
--output-mode=OUTPUT-MODE Output format. Available options:
text - Default text output format, userfriendly and easy to read.
cron - Shortcut for crontab. It's basically focused on human-readable logs output.
It's combination of --timestamp --profile --stdout-only --no-progress -vv.
logstash - Logstash output format, for integration with ELK stack.
[default: "text"]
--cron Alias for --output-mode=cron. Deprecated!
-h, --help Display help for the given command. When no command is given display help for the diff command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
输出示例
默认视图 (--output=console)
PHP Production Dependencies (require)
+-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
| Package | Action | Old Version | New Version | Details |
+-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
| vendor/downgraded | Downgraded | 2.0.0 | 1.0.0 | https://gitlab.com/vendor/downgraded/compare/2.0.0...1.0.0 |
| vendor/new | New | - | 1.0.0 | |
| vendor/no-tag | Changed | dev-master@bbc0fba | dev-master@f2f9280 | https://gitlab.com/vendor/package-1/compare/bbc0fba...f2f9280 |
| vendor/no-tag-new | New | - | dev-develop@a999014 | |
| vendor/removed | Removed | 1.0.0 | - | |
| vendor/upgraded | Upgraded | 1.0.0 | 2.0.0 | https://gitlab.com/vendor/upgraded/compare/1.0.0...2.0.0 |
+-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
另请参阅 travis-ci 中的彩色示例
Markdown 输出 (--output=markdown)
源代码
## PHP Production Dependencies (require) | Package | Action | Old Version | New Version | | |:-----------------------------------------------------------|:-----------|-------------------:|--------------------:|:-----------------------------------------------------------------------------| | [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) | | [vendor/new](https://gitlab.com/vendor/new) | New | - | 1.0.0 | | | [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) | | [vendor/no-tag-new](https://gitlab.com/vendor-1/package-1) | New | - | dev-develop@a999014 | | | [vendor/removed](https://gitlab.com/vendor/removed) | Removed | 1.0.0 | - | | | [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) |
在您的 README 或 PR/MR 描述中渲染
JSON 输出 (--output=json)
{ "require": { "vendor\/downgraded": { "name": "vendor\/downgraded", "url": "https:\/\/gitlab.com\/vendor\/downgraded", "version_from": "2.0.0", "version_to": "1.0.0", "mode": "Downgraded", "compare": "https:\/\/gitlab.com\/vendor\/downgraded\/compare\/2.0.0...1.0.0" }, "vendor\/new": { "name": "vendor\/new", "url": "https:\/\/gitlab.com\/vendor\/new", "version_from": null, "version_to": "1.0.0", "mode": "New", "compare": null }, "vendor\/no-tag": { "name": "vendor\/no-tag", "url": "https:\/\/gitlab.com\/vendor\/package-1", "version_from": "dev-master@bbc0fba", "version_to": "dev-master@f2f9280", "mode": "Changed", "compare": "https:\/\/gitlab.com\/vendor\/package-1\/compare\/bbc0fba...f2f9280" }, "vendor\/no-tag-new": { "name": "vendor\/no-tag-new", "url": "https:\/\/gitlab.com\/vendor-1\/package-1", "version_from": null, "version_to": "dev-develop@a999014", "mode": "New", "compare": null }, "vendor\/removed": { "name": "vendor\/removed", "url": "https:\/\/gitlab.com\/vendor\/removed", "version_from": "1.0.0", "version_to": null, "mode": "Removed", "compare": null }, "vendor\/upgraded": { "name": "vendor\/upgraded", "url": "https:\/\/gitlab.com\/vendor\/upgraded", "version_from": "1.0.0", "version_to": "2.0.0", "mode": "Upgraded", "compare": "https:\/\/gitlab.com\/vendor\/upgraded\/compare\/1.0.0...2.0.0" } } }
路线图
- 支持 Drupal 仓库。例如 fast_404。
- 通过 API 在 composer 中添加操作,如
composer lock-diff
。 - 修复了具有复杂/自定义标签名称的 相同问题。
- 自动检测分支的别名名称。
- Markdown 格式没有 warp 链接。
- (?) 支持 MS Windows...
单元测试和代码风格检查
make build make test-all
许可证
MIT
另请参阅
- CI-Report-Converter - 转换不同的错误报告,以与流行的 CI 系统实现深度兼容。
- Composer-Graph - 基于 mermaid-js 的 composer.json 的依赖关系图可视化。
- Mermaid-PHP - 使用 mermaid 脚本语言生成图表和流程图。
- Utils - 收集有用的 PHP 函数、迷你类和代码片段,供日常使用。
- Image - 包提供面向对象的方式来操作图像,尽可能简单。
- Data - 扩展实现 ArrayObject。使用文件作为配置/数组。
- Retry - 小型 PHP 库,提供具有多种回退策略和抖动支持的重试/回退功能。
- SimpleTypes - 转换任何值和度量 - 货币、重量、汇率、长度等。
特别感谢项目 davidrjonas/composer-lock-diff,它启发我制作了一个出色的实用工具 :)