drupal-composer / drupal-packagist

:package: Drupal Packagist server to automatically build package information from projects on drupal.org
http://packagist.drupal-composer.org
28 stars 4 forks source link

Example composer.json #14

Closed mikkeschiren closed 8 years ago

mikkeschiren commented 9 years ago

Hi,

I tried drupal 7 and composer this week (with help from some of you), and just wanted to share some of the results of composer.json examples.

First a couple of words about the workflow I use (that is the same as Wunderkraut Sweden, where I work). First of all we have normaly a platform repo, the platform is usually only a normal drupal-core installation, second we have a profile with all contrib and custom stuff in (we dont use sites/all). We work with profiles, because of that matches we workflow perfectly when we use aegir for deployment.

My example profile is called d7-composer-example-profile and is just a dummy profile, and just sharing the stuff here if somebody is interested.

Composer.son for the platform (normaly in /srv/www/project-name):

{
   "name":"nodeone/d7-composer-example",
   "description":"A demo Composer project",
   "repositories":[
      {
         "type":"composer",
         "url":"http://drupal-packagist.webflo.io/"
      },
      {
         "type":"package",
         "package":{
            "name":"d7-composer/d7-composer",
            "version":"1.0",
            "type":"drupal-profile",
            "source":{
               "type":"git",
               "url":"http://gitlab.wklive.net/misc/d7-composer-example-profile.git",
               "reference":"1.0"
            },
            "require":{
               "composer/installers":"~1.0"
            }
         }
      }
   ],
   "require":{
      "drupal/drupal":"7.34.0",
      "composer/installers":"~1.0",
      "d7-composer/d7-composer":"~1.0"
   },
   "extra":{
      "installer-paths":{
         "web/":["drupal/drupal"],
         "web/profiles/{$name}/":["type:drupal-profile"]
      }
   },
   "config":{
      "vendor-dir":"vendor",
      "component-dir":"libraries"
   },
   "authors":[
      {
         "name":"Mikke Schrén",
         "email":"mikke.schiren@wunderkraut.com"
      }
   ]
}

Second the profile (normaly in /srv/www/project-name/profiles/profile-name)

{
    "name": "d7-composer/d7-composer",
    "description": "A demo Composer project",
    "repositories": [
        {
          "type": "composer",
          "url": "http://drupal-packagist.webflo.io/"
        },
        {
          "type": "package",
          "package": {
            "name": "jquery/jquery.ui",
              "version": "1.10.4",
              "type": "drupal-library",
                "dist": {
                  "url": "http://jqueryui.com/resources/download/jquery-ui-1.10.4.zip",
                  "type": "zip"
                }
            }
        },
        {
          "type": "package",
          "package": {
            "name":"drupal/imagesloaded",
            "version": "master",
            "type": "drupal-library",
            "source": {
              "url": "http://github.com/desandro/imagesloaded.git",
               "type": "git",
               "reference": "master"
            }
          }
        }
    ],
    "replace": {
      "drupal/drupal": "*"
     },
    "require": {
        "drupal/features": "7.2.2",
        "drupal/wysiwyg": "7.2.2",
        "drupal/ctools": "7.1.4",
        "drupal/views": "7.3.8",
        "jquery/jquery.ui": "1.10.4",
        "composer/installers": "~1.0",
        "netresearch/composer-patches-plugin": "~1.0"
    },
    "require-dev": {
      "drupal/imagesloaded": "dev-master#0e68c8ea901cdec8844d4ceca2df8efb8a7a75a5"
    },
    "extra": {
      "installer-paths": {
        "modules/contrib/{$name}/": ["type:drupal-module"],
        "libraries/{$name}/": ["type:drupal-library"]
      }
    },
    "config": {
        "vendor-dir": "vendor",
        "component-dir": "libraries"
    },
    "authors": [
        {
            "name": "Mikke Schrén",
            "email": "mikke.schiren@wunderkraut.com"
        }
    ]
}
mikkeschiren commented 9 years ago

Problem I still need to figure out how to solve is for instance when installing a contrib module that has a dependency on drupal core module in the profile, that I still not know how to solve right now.

The solution I have is to add the dependency as a replace, like:

    "replace": {
      "drupal/drupal": "*",
      "drupal/locale": "*"
     },

Or, just to not have the contrib in the profile at all - just put them in sites/all instead...

webflo commented 9 years ago

Thats because skipped the drupal core depedency by adding drupal/drupal to the replace section. You could add any other core module to the replace section as well.

webflo commented 9 years ago

Here is another workaround. Override the drupal/drupal package definition and declare it as metapackage.

{
    "name": "d7-composer/d7-composer",
    "description": "A demo Composer project",
    "repositories": [
        {
          "type": "composer",
          "url": "https://raw.githubusercontent.com/webflo/d7/master/packages.json"
        },
        {
          "type": "composer",
          "url": "http://drupal-packagist.webflo.io/"
        },
        {
          "type": "package",
          "package": {
            "name": "jquery/jquery.ui",
              "version": "1.10.4",
              "type": "drupal-library",
                "dist": {
                  "url": "http://jqueryui.com/resources/download/jquery-ui-1.10.4.zip",
                  "type": "zip"
                }
            }
        },
        {
          "type": "package",
          "package": {
            "name":"drupal/imagesloaded",
            "version": "master",
            "type": "drupal-library",
            "source": {
              "url": "http://github.com/desandro/imagesloaded.git",
               "type": "git",
               "reference": "master"
            }
          }
        }
    ],
    "require": {
        "drupal/drupal": "*",
        "drupal/features": "7.2.2",
        "drupal/wysiwyg": "7.2.2",
        "drupal/ctools": "7.1.4",
        "drupal/views": "7.3.8",
        "drupal/i18n": "7.1.12",
        "jquery/jquery.ui": "1.10.4",
        "composer/installers": "~1.0",
        "netresearch/composer-patches-plugin": "~1.0"
    },
    "require-dev": {
      "drupal/imagesloaded": "dev-master#0e68c8ea901cdec8844d4ceca2df8efb8a7a75a5"
    },
    "extra": {
      "installer-paths": {
        "modules/contrib/{$name}/": ["type:drupal-module"],
        "libraries/{$name}/": ["type:drupal-library"]
      }
    },
    "config": {
        "vendor-dir": "vendor",
        "component-dir": "libraries"
    },
    "authors": [
        {
            "name": "Mikke Schrén",
            "email": "mikke.schiren@wunderkraut.com"
        }
    ]
}

https://raw.githubusercontent.com/webflo/d7/master/packages.json overrides the package definition von drupal-packagist.webflo.io

kasperg commented 9 years ago

I think the metapackage proposal from @webflo is the right way to go.

The drupal-composer organization could provide a reference metapackage for this use case and link to it from the documentation.

webflo commented 8 years ago

We added replace links to drupal/drupal for D7 a while ago.