Как перечислить все модули композитора и URL-адреса GitHub, установленные в проекте Laravel? - PullRequest
3 голосов
/ 11 ноября 2019

Я строил своего рода аналитическое программное обеспечение.

Как мне найти Github Urls установленных модулей composer / PHP в проекте Laravel?

Я бы хотел увидеть всеэти 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" },

1 Ответ

1 голос
/ 11 ноября 2019

composer info не предоставит вам эту информацию.

Самый простой способ - получить ее непосредственно из composer.lock. Вместо того, чтобы писать свой собственный анализатор, вы можете использовать готовый инструмент, такой как jq .

После загрузки вы можете написать выражение, подобное этому:

jq -c ".packages[]|{url:.source.url, type: .source.type}" composer.lock

Это отфильтровывает свойство packages 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"}

Это другое выражение создаст массив объектов, уже разделенных запятой, как в вашем примере (но менее компактный):

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"
  }
[...]
]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...