clearlyip/composer-push

为composer提供推送命令以推送至仓库

安装: 236

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 0

分叉: 29

类型:composer-plugin

v2.0.0 2024-07-25 23:03 UTC

This package is auto-updated.

Last update: 2024-09-25 23:40:55 UTC


README

此composer插件提供了一个 composer push 命令,允许将当前包推送到远程composer仓库。

当前支持的仓库包括

安装

 $ composer require clearlyip/composer-push

用法

许多选项都是可选的,因为它们可以直接添加到 composer.json 文件中。

 # At the root of your directory
 $ composer push [--name=<package name>] \
   [--url=<URL to the composer repository>] \
   [--type=<Type of repository, nexus by default, artifactory available too>]
   [--repository=<the repository you want to save, use this parameter if you want to control which repository to upload to by command-line parameter>] \
   [--username=USERNAME] \
   [--password=PASSWORD] \
   [--ignore=test.php]\
   [--ignore=foo/]\
   [--ignore-by-git-attributes]\
   [--src-type=<The type of repository used for source code: git, svn, ... which will be added to source tag of composer package>]\
   [--src-url=<URL of the source code repository which will be added to source tag of composer package>]\
   [--src-ref=<The reference to the current code version for this package which will be added to source tag of composer package>]\
   [--ssl-verify=true/]\
   [--access-token=<ACCESS_TOKEN added in Bearer>]
   <version>

If <version> is not set, `composer.json` version will be used.

 # Example
 $ composer push --username=admin --password=admin123 --url=https://:8081/repository/composer --ignore=test.php --ignore=foo/ --src-type=git --src-url="$(git remote get-url origin)" --src-ref="$(git rev-parse HEAD)" 0.0.1

 # Example of use --repository
 # you need firstly configure multi repositories in composer.json of the project.
 # Please refer to Configuration below (multi repository configuration format) for configuration method
 # The component will be uploaded to the first repository whose's name value matching -- repository value
 # If there is no matching between the value of repository name and the value of -- repository, the upload will fail with a prompt
 $ composer push --username=admin --password=admin123 --repository=prod --ignore=test.php --ignore=foo/ 0.0.1

配置

可以在 composer.json 文件中添加一些配置

{
    "extra": {
        "push": {
            "url": "https://:8081/repository/composer",
            "type": "nexus",
            "ssl-verify": true,
            "username": "admin",
            "password": "admin123",
            "ignore-by-git-attributes": true,
            "ignore": ["test.php", "foo/"]
        }
    }
}

上述配置可以称为独特的仓库配置格式,因为您只能在 composer.json 中配置一个仓库。

实际上,出于安全考虑,不同的组件代码版本,如生产版本和开发版本,通常应用不同的部署策略,例如禁用生产版本的重部署并允许开发版本的重部署,因此它们需要存储在不同的仓库中。对于0.1.5以后的版本,引入了命令行参数 -- repository 以满足此要求。要启用 -- repository 参数,composer.json 文件需要以下格式

{
    "extra": {
        "push": [
            {
                "name": "prod",
                "type": "artifactory",
                "url": "https://jfrog-art.com/artifactory/composer-local/",
                "username": "admin",
                "password": "admin123",
                "ignore-by-git-attributes": true,
                "ignore": ["test.php", "foo/"]
            },
            {
                "name": "dev",
                "url": "https://:8081/repository/composer-devs",
                "username": "admin",
                "password": "admin123",
                "ignore-by-git-attributes": true,
                "ignore": ["test.php", "foo/"]
            }
        ]
    }
}

上述配置可以称为多仓库配置格式。

新版本继续支持解析独特的仓库配置格式,但请记住,在这种情况下不能使用 -- repository 命令行参数。

可以在 auth.json 文件中为每个用户指定 usernamepassword,该文件位于 Composer 提供的认证机制

提供者

一些提供者的特定要求。

Nexus

源类型、URL、引用

这是可以为包含该版本源引用的包添加到 composer.json 文件的可选部分。此选项在您有源管理器并且希望直接链接到特定版本的源时很有用。上述示例将读取 git 的最后一个提交 ID 和远程地址,这相当简单且有用。

Artifactory

令牌

令牌目前支持作为密码使用时。仍需要用户名才能使其工作。

目前不支持独立令牌。

令牌使用示例

{
    "extra": {
        "push": {
            "url": "https://jfrog-art.com/artifactory/composer-local",
            "type": "artifactory",
            "username": "<username>",
            "password": "<Authentication token for the user username>"
        }
    }
}