Updating Open Social to 1.5 with Composer

Last updated on
10 February 2020

This page has not yet been reviewed by Open Social maintainer(s) and added to the menu.

This documentation is deprecated.

Introduction

We have been working hard on fixing coding standards issues in Open Social. In order to take the next step and get covered by Drupal's security advisory policy we are removing third party libraries we had included in the codebase. There are several options to do this, but we wanted to make it as easy for people as possible. To minimize the impact for our users now, but also in the future, we decided to take the same approach as the Lightning distribution does.

Asset Packagist

For third party JavaScript libraries we will from now on be using Asset Packagist. This repository is very similar to the normal Packagist repository. It allows the installation of Bower and NPM packages as native Composer packages. Unfortunately this change does require you to change the project's composer.json file which requires the Open Social distribution. Further in this document we will explain you what to do and what to do in case of any issues.

Good to know: this is something you only need to do once! If any Bower or NPM packages are needed in the future, we can simply add them as dependencies to the Open Social distribution. They will then be automatically installed for you.

Required changes

In order to be able to update to Open Social 1.5 you will need to update your project's composer.json file.

Please note that Composer 1.5 is required!

Finding your project's composer.json file

Your project's composer.json file is the file that requires the Open Social distribution. You should see something similar to this in the file.

"require": {
  "goalgorilla/open_social": "^1.0",
},

Changing the composer.json file

There are three things that you need to merge in your project's composer.json file. The repository, installer types and the path where the libraries should be installed.

Attached you will also find a patch file that you can use to update your project's composer.json file. Please check if your custom changes do not interfere with the patch.

1. Repository

Find the part where you add the repositories. It will most likely already contain this:

"repositories": [
  {
    "type": "composer",
    "url": "https://packages.drupal.org/8"
  }
]

Now simply add the Asset Packagist as an additional repository. You should end up with this:

"repositories": [
  {
    "type": "composer",
    "url": "https://packages.drupal.org/8"
  },
  {
    "type": "composer",
    "url": "https://asset-packagist.org"
  }
]

2. Adding the installer types

Find the part where you already have defined the installer-paths. This should be under extra. Now you can simply add the installer-types under extra, next to the installer-paths.

"installer-types": [
  "bower-asset",
  "npm-asset"
]

3. Add the path to the libraries

We need to have the libraries with the Bower and NPM assets installed in your webroot in the libraries folder. This is where the socialbase theme will try to find it.

Add the following to the list of installer-paths. Please be aware that it could be that your Open Social is running in a different folder than html, change it to what it needs to be.

"html/libraries/{$name}": [
  "type:drupal-library",
  "type:bower-asset",
  "type:npm-asset"
]

Full example

We have a template you can use to easily install your Open Social site. In there we made the required changes to the composer.json file already.

If you are unsure where to change things, take a look at: https://github.com/goalgorilla/social_template/blob/master/composer.json.

Common issues

... requires bower-asset/* -> no matching package found
In this case you probably did not (correctly) update your project's composer.json file. Take a look at the steps above and the full example.

If you did everything correct and are still facing issues, try adding the composer installer extender plugin to your composer.json file.

composer require oomphinc/composer-installers-extender

Composer is not up to date
In order to be able to use these changes your Composer needs to be up to date. You will need to use at least version 1.5 as this contains a bug fix for a dependency problem.

Run the following to update Composer to the latest version.

composer self-update

Help improve this page

Page status: Deprecated

You can: