piotrpress/private-composer

此 Composer 插件为 Composer 添加了对 github 和 bitbucket 协议的支持,以便简化私有仓库的管理。

安装: 418

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 1

类型:composer-plugin

v2.0.1 2024-02-20 14:34 UTC

This package is auto-updated.

Last update: 2024-09-20 15:53:40 UTC


README

此 Composer 插件为 Composer 添加了对 githubbitbucket 协议的支持,以便简化私有仓库的管理。

私有 Composer 使用 GitHubBitBucket API 在线构建 packages.json 虚拟文件,包含所有所有者仓库中的所有包,这些包可用于 composer.json 文件中 composer 类型的仓库。

示例

无需手动将每个仓库单独添加到 composer.json 文件中,例如

{
  "repositories": [
    {
      "type": "vcs",
      "url":  "https://github.com/PiotrPress/private-repo-1.git"
    },
    {
      "type": "vcs",
      "url":  "https://github.com/PiotrPress/private-repo-2.git"
    }
  ],
  "require": {
    "piotrpress/private-repo-1": "dev-master",
    "piotrpress/private-repo-2": "*"
  }
}

使用(在本示例中)github 协议

{
  "repositories": [
    {
      "type": "composer",
      "url":  "github://PiotrPress"
    }
  ],
  "require": {
    "piotrpress/private-repo-1": "dev-master",
    "piotrpress/private-repo-2": "*"
  }
}

安装

  1. 将插件作为全局 Composer 要求添加
$ composer global require piotrpress/private-composer
  1. 允许插件执行
$ composer config -g allow-plugins.piotrpress/private-composer true

身份验证

添加 GitHub/BitBucket API 认证凭据

$ composer config [--global] http-basic.<host> <username> <password>

注意:建议使用 --global 选项以将凭据保存在项目文件之外。

GitHub

  1. github.com 示例
$ composer config --global http-basic.github.com x-oauth-basic token
  1. 自定义域名示例
$ composer config --global http-basic.example.com x-oauth-basic token
  • host - GitHub 的域名,如果为空则等价于: github.com
  • username - 总是 x-oauth-basic
  • password - GitHub 的 token(使用此 链接 生成新的)

BitBucket

  1. bitbucket.org 示例
$ composer config --global http-basic.bitbucket.org username app_password
  1. 自定义域名示例
$ composer config --global http-basic.example.com username app_password
  • host - BitBucket 的域名,如果为空则等价于: bitbucket.org
  • username - BitBucket 的 username
  • password - BitBucket 的 app_password(使用此 链接 生成新的)

composer.json 文件中的使用

{
  "repositories": [
    {
      "type": "composer",
      "url":  "<github|bitbucket>://<owner>[@<host>]"
    }
  ]
}

GitHub

  1. github.com 示例
{
  "repositories": [
    {
      "type": "composer",
      "url":  "github://PiotrPress"
    }
  ]
}
  1. 自定义域名示例
{
  "repositories": [
    {
      "type": "composer",
      "url":  "github://PiotrPress@example.com"
    }
  ]
}
  • owner - GitHub 的仓库 owner
  • host - API 端点域名,如果为空则等价于: github.com

BitBucket

  1. bitbucket.org 示例
{
  "repositories": [
    {
      "type": "composer",
      "url":  "bitbucket://PiotrPress"
    }
  ]
}
  1. 自定义域名示例
{
  "repositories": [
    {
      "type": "composer",
      "url":  "bitbucket://PiotrPress@example.com"
    }
  ]
}
  • owner - BitBucket 的 workspace
  • host - API 端点域名,如果为空则等价于: bitbucket.org

作为 命令 使用

$ composer packages <github|bitbucket>://<owner>[@<host>]

命令的输出是有效的 packages.json 文件内容。

示例

$ composer packages github://PiotrPress > packages.json

注意

如果有许多仓库要扫描,可能需要增加进程 超时

需求

  • PHP >= 7.4 版本。
  • Composer ^2.0 版本。

许可证

MIT