My objective is to have a composer.json
file committed to our project repository that specifies what theme(s) or plugin(s) should be used for that project and when a developer pulls down the repo all they need to do is run composer install. We want to keep the plugins out of the project repo to stop the bloating of the project repo and it becoming slow to pull and push.
For standard wordpress plugins such as “Jetpack by WordPress.com” this is fine as we will use https://wpackagist.org/. However for Premium paid for plugins and custom made ones in house that cannot be open sourced we want to host them in a Private Composer Repository.
Because we will have multiple versions of these plugins I would like all versions to show such as 1.1, 1.2, 1.3 so the developer can specify in the composer.json which version is required, e.g. if a future version breaks something and we need to rollback to previous version.
I have read through the basics of setting up a Satis private repository which I have done so but I cannot get it to loop through the git tags of the versions and also specify that its a WordPress plugin and install it in the correct location.
This was my first attempt in which it gets all git tagged versions:
{
"name": "Private Repository",
"homepage": "http://packages.privaterepo.com",
"repositories": [
{
"type": "vcs",
"url": "git@bitbucket.org:companyname/project.git"
}
],
"require-all": true
}
And this is one where I have to specify the version but get it to install in the correct WordPress plugin location:
{
"name": "Private Repository",
"homepage": "http://packages.privaterepo.com",
"repositories": [
{
"type": "package",
"package": {
"name": "company/project",
"description": "WordPress Plugin",
"version": "1.0",
"source": {
"type": "git",
"url": "git@bitbucket.org:company/project.git",
"reference": "origin/master"
},
"type": "wordpress-plugin",
"require": {
"php": ">=5.3.2",
"composer/installers": "*"
}
}
}
],
"require-all": true,
"require-dependencies": true,
"extra": {
"installer-paths": {
"wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
}
}
}
Can anyone advise how I get both of these scenarios to work together?
I think I have a similar setup: In the local Satis repo we have both internal packages from a private Git server, and all external packages from Github.
The trick is to do two steps: Step one only pulls the metadata of all external packages, and this is where your version range comes into play to avoid pulling EVERYTHING.
The second step will scan through all local Git repos and detect all versions, and additionally will add the Composer repo created in step 1.
Effectively you will deal with two Satis configurations that will create two results, and the result from the first job for external packages will only fetch all metadata, and in the second step it is imported and used just like a local Git repo, and configuring that second step to scan for “all” versions and possibly creating ZIP files from them will create a nice local backup copy of every package you might need.
Or in other words:
satis-external.json
Run it:
satis-internal.json
Run this
Adding a “type=composer” repository in Satis will make that act like any other repository – especially it will download ALL packages mentioned there if you “require-all=true”, so be careful not to add Packagist or any other repo directly.
Also note that “require-dependencies” is true for the external packages because you likely won’t want to go through the hassle of adding every dependency of the packages you want to use.
If some of your paid packages offer remote repo access, you can add this repo in the external configuration together with access credentials – it should work.
In my experience, your first attempt should be enough, but I think that you’re missing a few things on each of the packages that you want to require (“company/project”).
Each of your packages should have its own composer.json, and you must require
composer/installers
on each of them. Also, it should correctly define"type": "wordpress-plugin"
(or theme, muplugin, dropin)Having this as a requirement takes care of installing the package on the desired path. By default, it will install on the following folders:
(from: installers/WordPress.php)
…but you can change that using this snippet from your second fragment — for instance, if you have the site code under an “htdocs” folder:
With these configs, Satis should generate the appropiate tags from your git tags.
I hope this helps!