elendev/nexus-composer-push

此包已被弃用且不再维护。作者建议使用elendev/composer-push包。

为composer提供推送到仓库的命令

安装次数: 90,839

依赖: 2

建议者: 0

安全: 0

星标: 49

关注者: 7

分支: 29

开放问题: 14

类型:composer-plugin

1.0.5 2024-08-15 16:11 UTC

README

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

当前支持的仓库包括

安装

 $ composer require elendev/composer-push

重要提示

此插件是elendev/nexus-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>]\
   [--keep-vendor, Keep vendor directory when creating zip]\
   [--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命令行参数。

usernamepassword可以通过Composer提供的认证机制auth.json文件中以用户为单位指定。

提供者

某些提供者的特定性。

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>"
        }
    }
}