elendev / composer-push
为 composer 提供一个 Push 命令,用于向仓库推送
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: ^4.0|^5.0|^6.0
- symfony/finder: ^4.0|^5.0|^6.0
Requires (Dev)
- composer/composer: ^1.8 || ^2.0
- friendsofphp/php-cs-fixer: ^2.18|^3.4.0
- phpunit/phpunit: ^8 || ^9 || ^10
Suggests
- elendev/composer-push: Replaces the elendev/nexus-composer-push repository, which is deprecated.
Replaces
- dev-master
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.7
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- v0.1.0
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1-alpha3
- v0.0.1-alpha
- dev-dependabot/composer/phpunit/phpunit-tw-11.3.4
- dev-dependabot/composer/phpunit/phpunit-tw-11.3.3
- dev-dependabot/composer/symfony/finder-tw-7.1.4
- dev-support-symfony7-composer27-php82
- dev-dependabot/composer/symfony/filesystem-tw-7.1.2
- dev-dependabot/composer/friendsofphp/php-cs-fixer-tw-3.0
- dev-firstTests
This package is auto-updated.
Last update: 2024-09-10 04:29:23 UTC
README
此 composer 插件提供了一个 composer push
命令,允许将当前包推送到远程 composer 仓库。
目前支持的仓库有
- JFrog Artifactory
- Nexus,使用 nexus-repository-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 命令行参数。
username
和 password
可以使用 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>" } } }