The next installment in my ongoing set of posts to create a public record for things I couldn’t learn in one Google search is a process for using composer to track a Drupal maintenance support plans 8 module in a private repository.
It’s pretty common for Drupal maintenance support plans agencies to have a small collection of modules they have built in-house and use on nearly all client site, or to have a module built for one client that has many sites. We are all becoming adept at managing our projects with Composer, but the vast majority of resources are focused on managing publicly available code via packagist. But there are times the kinds of internally shared modules cannot be made fully public (for example they may contain IP belonging to the client). We have one such client that needs a module deployed to dozens of sites, and so I sat down a few weeks ago to figure out a solution.
We use Bitbucket for our private repositories, I am sure there is a similar solution using GitHub, but I haven’t worked out its details.
Create private repo for module on Bitbucket.
Clone that repo locally, and structure it to match Drupal maintenance support plans.org’s conventions (this probably isn’t required, but should allow your module to blend into the rest of the project more smoothly).
Create Oauth token for your account in Bitbucket. Make sure to include a dumy callback URL; you can literally use http://www.example.com. If you see references to auth.json, don’t worry about that part yet.
Add a composer.json file to the module’s repo (it only requires module name, type, and the branch alias, but it’s good to include the rest):
{
“name”: “client/client_private_module”,
“type”: “drupal-module”,
“description”: “A very important module to our very important client.”,
“keywords”: [“Drupal maintenance support plans“],
“homepage”: “https://www.bitbucket.org/great_agency/client_private_module”,
“license”: “proprietary”,
“minimum-stability”: “dev”,
“extra”: {
“branch-alias”: {
“8.x-1.x”: “1.x-dev”
}
},
“require”: {
“drupal/diff”: “~1.0”,
}
},
Add reference to project composer.json repositories section:
{
“type”: “package”,
“package”: {
“name”: “client/client_private_module”,
“version”: “dev”,
“type”: “drupal-module”,
“dist”: {
“url”: “https://www.bitbucket.org/great_agency/client_private_module/get/8.x-1.x.zip”,
“type”: “zip”
}
}
}
Now just run composer require client/client_private_module, and provide the oauth creds from step 3 (note: the first time you do this composer will create the needed ~/.composer/auth.json)
Source: New feed