repman-io / repman

Repman - PHP Repository Manager: packagist proxy and host for private packages
https://repman.io
MIT License
513 stars 106 forks source link

How can we register repman repo in composer.json file via command? #585

Open Calvin495 opened 2 years ago

Calvin495 commented 2 years ago

We are trying to set up private packages in the repman. everything is going normal. we just have one question.

Is there a specific command using which we can register the repman repo and add its entry in the composer.json file automatically? just like https://packagist.com/ as they provide one composer config command that can add a repo in the composer.json file automatically. the command is as below.

composer config repositories.private-packagist composer

Currently, as far as we figured out we need to add the repman's entry in the composer.json file manually. Can anyone help with this?

NOTE: this is just a question/concern. this is not an issue

marmichalski commented 2 years ago

Like this?

$ cat composer.json | jq --arg repo 'https://my.repman' '.repositories += [{"type": "composer", "repo": $repo}] | .repositories += [{"packagist.org": false}]' | tee composer.json

What it does is it reads your current composer.json and adds (or creates) repositories array with 2 objects: one is your repo repman url, the other is somethings that's on Getting started of packagist.org.

Should this command override the repositories with those 2 entries at all times or just append them?

swichers commented 1 year ago

You can use these commands to setup repman authentication globally

composer config --global --auth http-basic.<org name>.repo.repman.io token <token here>
composer config --global repo.<org name> composer 'https://<org name>.repo.repman.io'

And there will be no need to add the information to your composer.json