Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Moved Drupal components dependency from composer to .info file #301

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

evanmwillhite
Copy link
Contributor

@evanmwillhite evanmwillhite commented Oct 29, 2018

As of Drupal core 8.6.x, themes can now declare dependencies! Since the composer installation method was causing problems (Drupal being installed incorrectly in Emulsify's vendor directory since it is a requirement of the components module), we are moving the dependency to emulsify.info.yml and are going to make the instructions clear in the wiki/readme for those installing on older versions of Drupal.

To Test:

  • Verify in a Drupal installation that installing Emulsify correctly installs the components module and the theme works when enabled per our instructions.
  • Verify the readme/wiki are clear on the dependency and how to install for older versions.

New WIKI contents:

## Requirements

1.  [PHP 7.1](http:https://www.php.net/)
2.  [Node (we recommend NVM)](https://github.com/creationix/nvm)
3.  [Gulp](http:https://gulpjs.com/)
4.  [Composer](https://getcomposer.org/)
5.  Optional: [Yarn](https://github.com/yarnpkg/yarn)
6.  Drupal only: [Components](https://www.drupal.org/project/components) module

## Prototyping (separate from Drupal, Wordpress, etc.)
Emulsify supports both NPM and YARN.

Install with NPM:
`composer create-project fourkitchens/emulsify --stability dev --no-interaction emulsify && cd emulsify && npm install`

Install with Yarn:
`composer create-project fourkitchens/emulsify --stability dev --no-interaction emulsify && cd emulsify && yarn install`

## Committing to Emulsify

1. Clone the repository and cd into the created directory
2. `composer install`
3. `yarn (or npm) install`

## Drupal installation

### In a Composer-based Drupal install (recommended)

1. Require emulsify in your project `composer require fourkitchens/emulsify`
2. Move into the original emulsify theme `cd web/themes/contrib/emulsify/`
3. Create your new theme by cloning emulsify `php emulsify.php "THEME NAME"` (Run `php emulsify.php -h` for other available options)
4. Move into your theme directory `cd web/themes/custom/THEME_NAME/`
5. Install the theme dependencies `npm install` or `yarn install`
6. Enable your theme and its dependencies `drush then THEME_NAME -y`
7. Proceed to the "Starting Pattern Lab…" section below

If you're not using a Composer-based Drupal install (e.g. tarball download from drupal.org) installation [instructions can be found on the Wiki](https://github.com/fourkitchens/emulsify/wiki/Installation).

Troubleshooting Installation: See [Drupal Installation FAQ](https://github.com/fourkitchens/emulsify/wiki/Installation#drupal-installation-faq).

_Note: Once you're created your custom theme, you can remove Emulsify as a dependency of your project. If you'd like to get updates as we push them, solely for educational/best-practice information, feel free to leave it in and receive the updates. Updating Emulsify will not affect your custom theme in any way._

### In a non-Composer Drupal install (e.g. tarball download from drupal.org)

  1. `cd themes/custom` (You may need to create this directory)
  2. `composer create-project fourkitchens/emulsify --stability dev --no-interaction emulsify`
  3. `cd emulsify`
  4. `npm install` or `yarn install`
  5. Move the Unified Twig Extension module from `themes/custom/emulsify/vendor/drupal-pattern-lab/unified-twig-extensions/` to `modules/unified-twig-extensions`. (You can do this from the Drupal root with `cp -r themes/custom/emulsify/vendor/drupal-pattern-lab/unified-twig-extensions/ modules/unified-twig-extensions`)
  6. Enable Emulsify and its dependencies `drush then emulsify -y`
  7. Optional: Create cloned theme `php emulsify.php "THEME NAME"` (You may need to run `drush cr` to clear the drush cache. Also, you can run `php emulsify.php -h` for other available options)
  8. Enable your new theme in Drupal

### Drupal installation FAQ

**Do I need to run `npm install` or `yarn install` on Emulsify if I use the drush command to create my own custom clone?**

No. Your new custom theme is not a subtheme of Emulsify, and has no references to the original Emulsify contributed theme. You should do all development on the new cloned theme, including running any npm/gulp tasks or doing any local gulp config.

**Do I have to use the PHP command or can I just use Emulsify as-is?**

You can use Emulsify as your theme!

However, any changes you make to the components will be overwritten if you update Emulsify. So, it's recommended that you run the PHP command to create a clone, and make your customizations there.

**I enabled Emulsify but I am getting a `Command emulsify needs the following extension(s) enabled to run: emulsify.` message.**

Try running `drush cr`. Even though the theme is enabled, you may still receive this error if drush doesn't recognize the command yet.

README.md Outdated
@@ -11,6 +11,7 @@ Component-driven prototyping tool using [Pattern Lab v2](http:https://patternlab.io/)
3. [Gulp](http:https://gulpjs.com/)
4. [Composer](https://getcomposer.org/)
5. Optional: [Yarn](https://github.com/yarnpkg/yarn)
6. Drupal only: [Components](https://www.drupal.org/project/components) module
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing unified_twig_ext right?

@ccjjmartin
Copy link
Collaborator

@evanmwillhite
Copy link
Contributor Author

@ccjjmartin that module is only hosted on github, so I think we have to keep that to get it into place - right?

@ccjjmartin
Copy link
Collaborator

@evanmwillhite The modules being in composer.json (NOTE: These are drupal modules which should not be installed in a theme directory) are causing Drupal core to be installed within Emulsify due to dependencies when composer install is run. I recommend that we leave the composer require instructions in the readme and remove these lines of code to prevent broken installs.

@evanmwillhite
Copy link
Contributor Author

@ccjjmartin I think what you are talking about is a separate issue. If you're still experiencing it, let's open that up in a separate issue as I cannot recreate it using a composer install on my end with the official release or this branch.

That said, this dependencies feature is not working for me. It errors out with The emulsify theme was not found. (or whatever theme name). Putting this story on hold, as this feature is too unstable (or possibly unsupported?) currently.

@ccjjmartin
Copy link
Collaborator

@evanmwillhite I ran through this myself and still believe we need to take that line out AND update composer.lock. I have a patch ready to go I can push up to this branch. You will see that we are removing a lot of stuff from composer.lock that would be autoloaded twice and make a Drupal install fail with cannot redeclare class errors (Drupal core is installed in the vendor directory). To reproduce this I did a fresh clone of Emulsify and composer install then checked the vendor directory. It is much cleaner once we remove the modules from composer.json.

You have addressed the need to notify users of the dependencies in the .info file already though so we are halfway there on this PR. Let me know if I should push up the changes.

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

Successfully merging this pull request may close these issues.

None yet

2 participants