vincentholmblad/bitbucket-packagist

A simple composer plugin that automatically creates a local packagist for private repositories hosted on BitBucket.

1.0 2018-05-13 19:17 UTC

This package is not auto-updated.

Last update: 2024-04-14 03:12:20 UTC


README

A simple library that automatically creates a local packagist for private repositories hosted on BitBucket.

The project has two main functions:

  1. Creates a json file with auto-generated repositories (vcs) from a user or team on BitBucket that can be merged into an existing composer.json file. This is almost like having a local version of a Private Packagist.
  2. Takes the auto-generated json file to also create a static composer repository (through Satis) that can be uploaded to a server and served to other projects.

Installation

composer require vincentholmblad/bitbucket-packagist

Add these lines to composer.json after you've installed the package.

// See https://bitbucket.org/account/user/<team or user>/api
// There you can create an OAuth consumer
// Make sure the consumer has access to read repositories
"config": {
    "bitbucket_consumer_key": "key",
    "bitbucket_consumer_secret": "secret",
    "bitbucket_team": "team or user"
},
// Merges scripts and repositories from the user or team
extra: {
    "merge-plugin": {
        "include": [
            "./vendor/vincentholmblad/bitbucket-packagist/bitbucket_packagist_scripts.json",
            "./vendor/vincentholmblad/bitbucket-packagist/packages.json"
        ],
        "merge-scripts": true
    }
}

Then run composer run-script bb_composer_packages whenver you need to update your local packagist.

NOT RECOMMENDED! If you want to automatically update the local packagist with any changes then also include this to your composer.json. This will make the process of updating and installing new packages very slow as the process has to check load composer.json files from all your private repositories to build the packages.json file.

// Automatically update local private packagist
"scripts": {
    "pre-update-cmd": [
        "@bb_composer_packages"
    ],
    "pre-install-cmd": [
        "@bb_composer_packages"
    ]
}

If you want to upload the result to a server then run composer run-script bb_composer_packages and upload the resulting folder ("./dist/" inside the package directory in vendor) to your hosting-service of choice. You can then include your new private packagist with this code in your composer.json.

// Load repositores from private packagist
"repositories": [
    {
        "type": "composer",
        "url": "link to uploaded position"
    }
]

Sidenote for repositories

Make sure that every repository that you want to include has its own composer.json with at least a name and a version field. This namefield should match the name of the repository.

An example below.

{
    "name": "your-shorthand/repo-name",
    "version": "master"
}