Provide semver versioning shim for Drupal.org Composer facade

Migrated issue

Reported by: hestenet

To fully support Composer for contrib projects, which currently do not use semver versioning, and may ultimately use a non-standard semver format, Drupal.org must provide a shim for our composer json endpoints that translates the drupal contrib semver into standard semver.

Semver(which Drupal core uses) currently supports Major.Minor.Patch(8.0.3) whereas Drupal contrib uses Platform.Major.Minor (7.x-3.4).

The ideal format for Drupal contrib would be Platform.Major.Minor.Patch - but until that versioning scheme is supported by Semver it will not be compatible with tools like Composer, which expects packages to adhere to semver.

Hence, we will need a Semver versioning shim on Drupal.org to allow contrib projects to be used as a composer packages.

The solution we will be using is as follows:

Platform.Major.Minor.Patch
Platform - Each platform (D7 or D8) will be a separate endpoint on Drupal.org. This means we will not have to specify the platform as part of the version scheme.
Major - The major version of the individual project (not tied to core version)
Minor - The minor version of the project
Patch - The patch version - not currently accommodated by Contrib so defaulting to .0 until/unless Contrib changes their versioning scheme.
-Stability - Stability indicators (-alpha, -beta, -rc1) can be accommodated in both semver and composer

Example D7 Endpoint Version Mapping

Current Format Translated Format
{Platform.x}-{major}.{minor}-{stabilty#} {major}.{minor}.0-{stability}{#}
7.x-3.4-beta2 3.4.0-beta2
7.x-2.10-rc2 2.10.0-rc2
7.x-1.0-unstable3 unstable releases will not be translated, and not available to composer
7.x-1.0-alpha5 1.0.0-alpha5
7.x-0.1-rc2 0.1.0-rc2
7.x-1.x-dev last major release -dev e.g. 7.1.12-dev

Related issue: Issue #2313917

Related issue: Issue #2576285

Edited by drupalbot