memfinis / nexus-composer-push
此包最新版本(0.4.4)没有可用的许可证信息。
提供Push命令,用于将包推送到Nexus仓库
0.4.4
2021-07-05 22:56 UTC
Requires
- php: >=7.2 || ^8.0
- composer-plugin-api: ^1.1|^2.0
- ext-curl: *
- ext-json: *
- ext-zip: *
- guzzlehttp/guzzle: ^6.0|^7.0
- symfony/filesystem: ^3.0|^4.0|^5.0
- symfony/finder: ^3.0|^4.0|^5.0
Requires (Dev)
- composer/composer: ^1.8 || ^2.0
- friendsofphp/php-cs-fixer: ^2.18
- phpunit/phpunit: ^8 || ^9
This package is auto-updated.
Last update: 2024-09-06 16:19:52 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命令行参数。
username
和password
可以指定在Composer提供的认证机制中,每个用户的auth.json
文件中。
源类型、URL、引用
这是可以添加到composer.json文件的包的附加部分,它可以包含此版本的源引用。此选项在您有源管理器并希望直接链接到特定版本的源时非常有用。上面的示例将读取git的最后提交ID以及git的远程地址,这很简单且很有用。