elendev / nexus-composer-push
Provide a Push command to composer to push to repositories
Installs: 91 758
Dependents: 2
Suggesters: 0
Security: 0
Stars: 49
Watchers: 7
Forks: 29
Open Issues: 13
Type:composer-plugin
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.1.0
- 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/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-28 09:46:19 UTC
README
This composer plugin provide a composer push
command that allow to push the current package into a distant composer repository.
Currently supported repositories are:
- JFrog Artifactory
- Nexus, with nexus-repository-composer.
Installation
$ composer require elendev/composer-push
Important note
This plugin is the continuation of elendev/nexus-composer-push
, you have to migrate to this one if you haven't done it yet.
Usage
Many of the options are optional since they can be added directly to the composer.json
file.
# 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=http://localhost: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
Configuration
It's possible to add some configurations inside the composer.json
file
{ "extra": { "push": { "url": "http://localhost:8081/repository/composer", "type": "nexus", "ssl-verify": true, "username": "admin", "password": "admin123", "ignore-by-git-attributes": true, "ignore": [ "test.php", "foo/" ] } } }
Above configuration may be called unique repository configuration format, as you can only configue one repository in composer.json.
In practice, for security reasons, different versions of component code, such as production and development, often apply different deployment policy, such as disable redeploy for the production version and allow redeploy for the development version, so they need to be stored in different repositories. For versions later than 0.1.5, the command-line parameter -- repository is introduced to meet this requirement. To enable the -- repository parameter, the composer.json file needs to be in the following format:
{ "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": "http://localhost:8081/repository/composer-devs", "username": "admin", "password": "admin123", "ignore-by-git-attributes": true, "ignore": [ "test.php", "foo/" ] }] } }
Above configuration may be called multi repository configuration format.
The new version continues to support parsing the unique repository configuration format, but remember that you cannot use the -- repository command line argument in this scenario.
The username
and password
can be specified in the auth.json
file on a per-user basis with the authentication mechanism provided by Composer.
Global configuration
It's also possible to add some configuration inside global composer.json
located at composer home (composer config -g home
).
Following precedence order will be used for each key:
- command-line parameter
- local
composer.json
- global
composer.json
- default
Array values will not be merged.
The command-line parameter -- repository is required if local configuration is multi repository. Global unique repository configuration will be ignored in that case.
Multi repository configuration will be merged by the name
key.
Providers
Specificity for some of the providers.
Nexus
Source type, URL, reference
This is an optional part that can be added to the composer.json file provided for the package which can contain the source reference for this version. This option is useful in case you have a source manager and you would like to have a direct link to the source of an specific version. The example above given will read the last commit ID from git and the remote address from git as well which is quiet simple and useful.
Artifactory
Tokens
Tokens are currently supported when used as password. The username is still required for it to work.
Standalone tokens are currently not supported.
Example of token usage:
{ "extra": { "push": { "url": "https://jfrog-art.com/artifactory/composer-local", "type": "artifactory", "username": "<username>", "password": "<Authentication token for the user username>" } } }