memfinis/nexus-composer-push

此包最新版本(0.4.4)没有可用的许可证信息。

提供Push命令,用于将包推送到Nexus仓库

安装: 7

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 0

分支: 29

类型:composer-plugin

0.4.4 2021-07-05 22:56 UTC

README

此Composer插件提供了一个composer nexus-push命令,允许将当前包推送到由nexus-repository-composer托管的Nexus Composer仓库。

安装

 $ composer require memfinis/nexus-composer-push

使用方法

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

 # At the root of your directory
 $ composer nexus-push [--name=<package name>] \
   [--url=<URL to the composer nexus repository>] \
   [--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>]\
   <version>
   
 # Example 
 $ composer nexus-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 nexus-push --username=admin --password=admin123 --repository=prod --ignore=test.php --ignore=foo/ 0.0.1

配置

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

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

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

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

{
    "extra": {
        "nexus-push": [{
            "name": "prod",
            "url": "https://:8081/repository/composer-releases",
            "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文件中。

源类型、URL、引用

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