Decoupling components as independent modules
In 2019 the YMCA Website Services team started decoupling major components to streamline the distribution and simplify support.
Communication started in the Community Board - Ejecting modules from OpenY distro as independent projects.
The decoupling process is ongoing. See the index of decoupled projects.
In 2021 the YMCA Website Services core team faced coupling blockers in the distribution during the upgrade from Drupal 8 to Drupal 9
To formalize the ongoing development and maintenance strategy, the YMCA Website Services core team shared its decoupling plan with the wider community in mid-2021.
This document elaborates on those processes.
- Every new component or sub-project of YMCA Website Services should be developed in its own repository - either on GitHub or Drupal.org.
- The decoupled project could be
- GitHub should be used when there is no strategy to make a component or project available for the wider Drupal community - that is, when it is tied to YMCA business and unlikely to be leveraged by somebody else.
- Drupal.org should be used when the component could be useful to projects outside of YMCA Website Services.
for creating a new decoupled component
- Create a new GitHub/Drupal.org repository.
- Work on getting an initial release with at least
- Create a composer.json file for the component in order to be able to start using it via
composer. See Virtual Y for an example.
- Make it available for the public via packagist.org or drupal.org as a release. Ensure
podarokis added as a co-maintainer to the respective system.
- Suggest adding to YMCA Website Services by opening an issue.
- If approved, create a Pull Request adding it as a dependency in composer.json.
- Ensure this component is enabled in any of the packages maintained in the YMCA Website Services profile installation
- Ask for review and release, according to the release plan.
for decoupling an existing component of YMCA Website Services
Follow the steps above, but:
- After creating the repo, filter the selected component by running
git filter-branch --subdirectory-filter ...from the latest development branch of the YMCA Website Services profile. This keeps credits of work done for this component as a part of the Code of Conduct.
- After separating the code, ensure the ejected code is not duplicated in the YMCA Website Services profile. Remove duplicated code in the same Pull Request in which you add the new dependency.
How to update module on Drupal.org
- Git filter-branch to get a history of changes.
- Change git origin to Drupal.org project.
- Create a new branch and push the code to Drupal.org.
- Create and push tag to Drupal.org. Create a release on drupal.org.
- Update composer.json in this distribution with a new tag.
How to decouple module from YN to Drupal.org
git clone firstname.lastname@example.org:YCloudYUSA/yusaopeny.git decouple rm -rf decouple_copy && cp -a decouple decouple_copy cd decouple_copy git filter-branch --subdirectory-filter docroot/modules/contrib/paragraph_skins git clean -dfx git remote remove origin && git remote add origin email@example.com:project/paragraph_skins.git git pull origin 8.x-1.x --allow-unrelated-histories # Resolve conflicts if applicable. git push origin production:8.x-1.x # Create tags and release on Drupal.org
How to decouple module from YMCA Website Services to YMCA Website Services Subprojects
Request a repository for the module. Example: shared_content_server
git clone firstname.lastname@example.org:YCloudYUSA/yusaopeny.git decouple rm -rf decouple_copy && cp -a decouple decouple_copy cd decouple_copy git filter-branch --subdirectory-filter docroot/profiles/contrib/openy/modules/custom/SOME_MODULE_HERE git clean -dfx git remote remove origin && git remote add origin email@example.com:Open-Y-subprojects/SOME_MODULE_HERE.git git push origin production # Create composer.json on the decoupled repository. Example: https://github.com/YCloudYUSA/yusaopeny_activity_finder/blob/4.x/composer.json git clone firstname.lastname@example.org:ynorth-projects/distribution.git yn-distribution # Update composer json for distrubution. See below
- A useful article for future decoupling - Move files from one repository to another, preserving git history