Add Contrib and Custom Code
This section describes how to replicate your selection of contributed modules and themes, and any custom modules or themes your development team has created in your new project structure.
Modules
On the composerify
branch, make a list of the modules that will need to be re-added:
If you know that all the sites have the same contrib and custom modules, get the list of modules from a single representative site. You will need this list in next steps:
terminus drush $SITE.dev -- pm-list --type=module --no-core --status=enabled
If you do not know whether the sites have the same contrib and custom modules installed, audit the modules across all sites and compile a unified list:
Audit Contrib and Custom Modules
To audit modules on all sites, create a new file called
audit_site_modules.sh
with the following content:audit_site_modules.sh#!/usr/bin/env bash echo 'Updating site list now with site urls from the custom Drupal Upstream.' SITES=$(terminus site:list --upstream=a2457b48-2c68-4d01-b471-7ae1337c9320 --field=Name) for site in $SITES do echo "---------- $site -----------" terminus drush $site.dev -- pm-list --type=module --no-core --status=enabled echo "----------------------------" echo done | tee d8_upstream_sites_modules.txt for site in $SITES do echo "---------- $site -----------" terminus drush $site.dev -- pm-list --type=theme --no-core --status=enabled echo "----------------------------" echo done | tee d8_upstream_sites_themes.txt
Make the script executable:
chmod +x audit_site_modules.sh
Run the script:
./audit_site_modules.sh
This creates two new files in the same folder:
d8_upstream_sites_modules.txt
: list of modules from each sited8_upstream_sites_themes.txt
: list of themes from each site
Go through these files and build a list of modules and themes you'll need to add to the codebase.
Contrib Modules and Themes
In your terminal, from the
composerify
branch,cd
toupstream-configuration
:cd upstream-configuration
For each contrib module and theme in the list you've gathered
Add the package and version with Composer. If the version starts with
8.x-
, remove that and only include the version number after8.x-
.For example, if the version is
8.x-3.2
, use the version number3.2
:composer require drupal/MODULE_NAME:^VERSION --no-update
Confirm that only
composer.json
has been modified:git status
- If anything other than
composer.json
has been modified, add the modified file to.gitignore
.
- If anything other than
Commit the change:
git commit -am "Adding MODULE_NAME"
Custom Modules and Themes
To move modules, use the following commands:
git checkout master web/modules/custom
git mv web/modules/custom web/modules/
git commit -m "Copy custom modules"
git checkout master modules/custom
git mv modules/custom web/modules/
git commit -m "Copy custom modules"
To move themes, use the following commands:
git checkout master web/themes/custom
git mv web/themes/custom web/themes/
git commit -m "Copy custom themes"
git checkout master themes/custom
git mv themes/custom web/themes/
git commit -m "Copy custom themes"