我正在构建一种分析软件。
如何在Laravel项目中找到已安装composer/PHP模块的Github Urls?
我希望看到所有这些URL,而不是一个一个,但作为一个整体,可能在控制台中的列表。
如下所示:
{ "type": "vcs", "url": "https://github.com/twigphp/Twig" },
{ "type": "vcs", "url": "https://github.com/sitepoint/Rauth" },
{ "type": "vcs", "url": "https://github.com/PHP-DI/PHP-DI" },
{ "type": "vcs", "url": "https://github.com/nikic/FastRoute" },
{ "type": "vcs", "url": "https://github.com/guzzle/guzzle" },
{ "type": "vcs", "url": "https://github.com/Respect/Validation" },
{ "type": "vcs", "url": "https://github.com/doctrine/annotations" },
{ "type": "vcs", "url": "https://github.com/thephpleague/glide" },
{ "type": "vcs", "url": "https://github.com/tamtamchik/simple-flash" },
{ "type": "vcs", "url": "https://github.com/Seldaek/monolog" },
{ "type": "vcs", "url": "https://github.com/cakephp/orm" },
{ "type": "vcs", "url": "https://github.com/Bee-Lab/bowerphp" },
{ "type": "vcs", "url": "https://github.com/markstory/mini-asset" },
{ "type": "vcs", "url": "https://github.com/natxet/CssMin" },
{ "type": "vcs", "url": "https://github.com/linkorb/jsmin-php" },
{ "type": "vcs", "url": "https://github.com/consolidation-org/Robo" },
{ "type": "vcs", "url": "https://github.com/symfony/var-dumper" },
{ "type": "vcs", "url": "https://github.com/consolidation-org/Robo" },发布于 2019-11-11 17:17:13
composer info不会给你这些信息的
最简单的方法是直接从composer.lock获取它。您可以使用像jq这样的现成工具,而不是编写自己的解析器。
下载后,您可以编写如下表达式:
jq -c ".packages[]|{url:.source.url, type: .source.type}" composer.lock这将过滤composer.lock的packages属性,并将创建与您想要的输出非常相似的输出。例如:
{"url":"https://github.com/api-platform/api-pack.git","type":"git"}
{"url":"https://github.com/api-platform/core.git","type":"git"}
{"url":"https://github.com/aws/aws-sdk-php.git","type":"git"}
{"url":"https://github.com/aws/aws-sdk-php-symfony.git","type":"git"}
{"url":"https://github.com/beberlei/DoctrineExtensions.git","type":"git"}另一个表达式将创建一个对象数组,在示例中已经用逗号分隔(但不是很紧凑):
jq "[.packages[]|{url:.source.url, type: .source.type}]" composer.lock结果:
[
{
"url": "https://github.com/api-platform/api-pack.git",
"type": "git"
},
{
"url": "https://github.com/api-platform/core.git",
"type": "git"
},
{
"url": "https://github.com/aws/aws-sdk-php.git",
"type": "git"
},
{
"url": "https://github.com/aws/aws-sdk-php-symfony.git",
"type": "git"
},
{
"url": "https://github.com/beberlei/DoctrineExtensions.git",
"type": "git"
}
[...]
]https://stackoverflow.com/questions/58797063
复制相似问题