piotrpress/private-composer

This composer plugin adds github and bitbucket protocols support to Composer in order to simplify private repositories handling.

Installs: 438

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Type:composer-plugin

v2.0.1 2024-02-20 14:34 UTC

This package is auto-updated.

Last update: 2024-10-20 15:56:06 UTC


README

This composer plugin adds github and bitbucket protocols support to Composer in order to simplify private repositories handling.

Private Composer uses GitHub and BitBucket APIs to build packages.json virtual file on the fly, with all packages from owner's repositories, which can be used in repository type composer in composer.json file.

Example

Instead of manually adding each one repository separately to composer.json file, e.g.:

{
  "repositories": [
    {
      "type": "vcs",
      "url":  "https://github.com/PiotrPress/private-repo-1.git"
    },
    {
      "type": "vcs",
      "url":  "https://github.com/PiotrPress/private-repo-2.git"
    }
  ],
  "require": {
    "piotrpress/private-repo-1": "dev-master",
    "piotrpress/private-repo-2": "*"
  }
}

use (in this example) github protocol:

{
  "repositories": [
    {
      "type": "composer",
      "url":  "github://PiotrPress"
    }
  ],
  "require": {
    "piotrpress/private-repo-1": "dev-master",
    "piotrpress/private-repo-2": "*"
  }
}

Installation

  1. Add the plugin as a global composer requirement:
$ composer global require piotrpress/private-composer
  1. Allow the plugin execution:
$ composer config -g allow-plugins.piotrpress/private-composer true

Authentication

Add GitHub/BitBucket API authentication credentials:

$ composer config [--global] http-basic.<host> <username> <password>

NOTE: using --global option is recommended to keep credentials outside of project's files.

GitHub

  1. github.com example:
$ composer config --global http-basic.github.com x-oauth-basic token
  1. Custom domain example:
$ composer config --global http-basic.example.com x-oauth-basic token
  • host - GitHub's domain, if empty it's equivalent: github.com
  • username - always x-oauth-basic
  • password - GitHub's token (generate new one using this link)

BitBucket

  1. bitbucket.org example:
$ composer config --global http-basic.bitbucket.org username app_password
  1. Custom domain example:
$ composer config --global http-basic.example.com username app_password
  • host - BitBucket's domain, if empty it's equivalent: bitbucket.org
  • username - BitBucket's username
  • password - BitBucket's app_password (generate new one using this link)

Usage in composer.json file

{
  "repositories": [
    {
      "type": "composer",
      "url":  "<github|bitbucket>://<owner>[@<host>]"
    }
  ]
}

GitHub

  1. github.com example:
{
  "repositories": [
    {
      "type": "composer",
      "url":  "github://PiotrPress"
    }
  ]
}
  1. Custom domain example:
{
  "repositories": [
    {
      "type": "composer",
      "url":  "github://PiotrPress@example.com"
    }
  ]
}
  • owner - GitHub's repository owner
  • host - API endpoint domain, if empty it's equivalent: github.com

BitBucket

  1. bitbucket.org example:
{
  "repositories": [
    {
      "type": "composer",
      "url":  "bitbucket://PiotrPress"
    }
  ]
}
  1. Custom domain example:
{
  "repositories": [
    {
      "type": "composer",
      "url":  "bitbucket://PiotrPress@example.com"
    }
  ]
}
  • owner - BitBucket's workspace
  • host - API endpoint domain, if empty it's equivalent: bitbucket.org

Usage as a command

$ composer packages <github|bitbucket>://<owner>[@<host>]

Command's output is a valid packages.json file content.

Example

$ composer packages github://PiotrPress > packages.json

Note

If there are many repositories to scan, it may be necessary to increase the process timeout.

Requirements

  • PHP >= 7.4 version.
  • Composer ^2.0 version.

License

MIT