Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install modules, for example upgrade_status for D10 compatibility #12

Closed
pcambra opened this issue Sep 12, 2023 · 3 comments
Closed

Comments

@pcambra
Copy link
Contributor

pcambra commented Sep 12, 2023

Just some notes of what I'm doing for this workflow.

The composer.json file is untouched after dev poser, but if you need additional modules, or upgrade/downgrade the drupal core version, all the stuff ends up in vendor.

This is what my composer.json looks like to install upgrade_status on D9:

{
    "name": "drupal/${WHATEVER_MODULE}",
    "description": "Description text.",
    "type": "drupal-module",
    "license": "GPL-2.0-or-later",
    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "drupal/core": "^9",
        "composer/installers": "^1.9",
        "drupal/upgrade_status": "^4.0",
        "drush/drush": "^11.6"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "installer-paths": {
            "web/core": [
                "type:drupal-core"
            ],
            "web/libraries/{$name}": [
                "type:drupal-library"
            ],
            "web/modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "web/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "web/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/{$name}": [
                "type:drupal-drush"
            ]
        }
    },
    "config": {
        "allow-plugins": {
            "composer/installers": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "cweagans/composer-patches": true,
            "drupal/core-composer-scaffold": true
        }
    },
    "require-dev": {
        "drupal/core-dev": "^9",
        "phpspec/prophecy-phpunit": "^2"
    }
}

The bits require are the composer/installers package together with the extra/installer-paths, and the repositories.

Maybe we could have a way to emulate what poser does with expand composer json (https://git.drupalcode.org/project/gitlab_templates/-/raw/1.0.x/scripts/expand_composer_json.php) to install a module or change the core version?

@pcambra
Copy link
Contributor Author

pcambra commented Sep 12, 2023

Note: for upgrade status to work from the UI, had to temporarily remove the symlink_project.php file from the module folder but that's off topic.

@weitzman
Copy link
Collaborator

If you need additional modules you add them to require-dev and rerun poser. Does that answer your need?

@pcambra
Copy link
Contributor Author

pcambra commented Mar 15, 2024

Just giving feedback as I had to try this again and adding a contrib module with require-dev doesn't seem to work, unless I'm missing something, it still adds it in vendor.

This is the composer.json I had to add in the module this time (drupal 10).

{
    "name": "drupal/module",
    "description": "description",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "authors": [
        {
            "name": "",
            "role": ""
        }
    ],
    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "drupal/core": "^10",
        "composer/installers": "^1.9",
        "drupal/upgrade_status": "^4.0",
        "drush/drush": "^12"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "installer-paths": {
            "web/core": [
                "type:drupal-core"
            ],
            "web/libraries/{$name}": [
                "type:drupal-library"
            ],
            "web/modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "web/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "web/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/{$name}": [
                "type:drupal-drush"
            ]
        }
    },
    "require-dev": {
        "drupal/core-dev": "^10",
        "phpspec/prophecy-phpunit": "^2"
    },
    "config": {
        "allow-plugins": {
            "composer/installers": true,
            "php-http/discovery": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "phpstan/extension-installer": true,
            "cweagans/composer-patches": true,
            "drupal/core-composer-scaffold": true
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants