Example composer.json for SVN repos with no structure and no composer.json

Today I needed to include some WordPress.com themes from the official SVN repository, using Composer. This repository uses SVN and has not got the usual trunk, branches, etc directories that Composer expects, which makes it tricky. It’s possible though, and thanks to colleague Tom Nowell, I eventually got there.

Here’s that example code:

{
  "name"              : "example/stuff",
  "description"       : "Example composer.json for SVN repos with no structure and no composer.json",
  "license"           : "GPL-2.0",
  "authors"           : [
    {
      "name"    : "Automattic",
      "homepage": "http://automattic.com"
    }
  ],
  "type"              : "project",
  "minimum-stability" : "dev",
  "repositories": [
    {
      "type": "package",
      "package": {
          "name": "wpcom/suburbia",
          "type" : "wordpress-theme",
          "version": "1.1.2",
          "source": {
              "url": "https://wpcom-themes.svn.automattic.com/",
              "type": "svn",
              "reference": "suburbia@29626"
          }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "wpcom-theme/oxygen",
        "type": "wordpress-theme",
        "version": "1.0.1",
        "source": {
          "url": "https://wpcom-themes.svn.automattic.com/",
          "type": "svn",
          "reference": "oxygen@29670"
        }
      }
    }
  ],
  "extra"       : {
    "installer-paths": {
      "htdocs/wp-content/plugins/{$name}/"     : ["type:wordpress-plugin"],
      "htdocs/wp-content/themes/{$name}/"      : ["type:wordpress-theme"]
    }
  },
  "require": {
        "wpcom/suburbia": "1.1.2",
        "wpcom/oxygen": "1.0.1",
        "composer/installers": "*"
  }
}

When a new version comes out I have to update a couple of things for each repo:

  • repositories > (individual repository) > package > version – change to the most recent version
  • repositories > (individual repository) > package > source > reference – change the revision number after the @
  • require > (individual package) – change the version required

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.