Is there a drush command to update a Feature when you add a new module dependency? I know you can use the FU command to update changes to already-added views, content types, etc... but I'm wondering about adding new views, content types, and module dependencies. So far the only way I've found to incorporate those changes into a Feature is to re-download it.
Thankfully Git has made that process a lot easier than it used to be with SVN.
If you are comfortable editing your .info file, the format Features uses to identify which components should be exported is quite simple. For example:
features[node][] = "node_type"
features[view][] = "view_name"
features[variable][] = "variable_name"
By adding any of these to your .info file and running drush fu
, the resulting module will include those specified components if they were not previou.sly exported. Features will take care of adding any other bits and pieces that it thinks should be there.
Module dependencies for features work the same as module dependencies for any module in Drupal-- just add dependencies[] = "module_name"
to your feature's .info file.
This is the primary way I update features, and with a couple more steps you can create and enable a blank module and "featurize" it by adding features components to your .info file in this way.
A drush command such as drush features-add-component featurename --node=new_type
could be created, but I don't believe there is a published command that does that. There are several drush scripts with expanded features administration functionality scattered around the Features issues queues and a few projects under development. The main advantage of a command like this would be a command-line version of the Features UI--showing the features-builder which components are available for export. That utility is somewhat limited if you are comfortable hand-editing the .info file.
The current way to do this in drush is "features-export", or "fe". (features-add is deprecated)
drush fe my_existing_feature dependencies:my_new_dependency
A few more tidbits:
The command can also be used to create a new feature, in exactly the same way, containing the component. The only difference is that the feature name doesn't already exist as a feature. For example this would create a new feature containing a node type:
drush fe my_new_feature node:my_node_type
Finally it goes hand-in-hand with the features-components (fc) command. You can see a list of all non-exported components like so:
drush fc --not-exported
As a shortcut you can specify the type of components to look for:
drush fc --not-exported field
You can leave off --not-exported to also see the exported components, but I find in practice I only want to see the non-exported ones. It allows me to go nuts inside Drupal creating stuff, and then after I'm done go to the command line and make absolutely sure that everything I created gets exported to a feature.
Now you can do the same stuff using drush features-add (drush fa). "drush fa" will produce a list of elements you can add to your feature. If you're familiar with editing the .info file or have ever looked at the machine names in the Features UI, you'll recognize the names of these featurizable elements.
Ex:
drush fa feature_name dependencies:views views_view:user_questions
This will add the Views module as a dependency and the view "user_questions" to "feature_name".
Warning: this command seems to have been added relatively recently; I needed to update features to 7.x-1.x-beta6 to get it. Unfortunately, it hasn't yet been ported to D6, but this will hopefully happen soon; see this issue for progress and a patch that'll give you "drush fa" on D6. There's also some discussion about the naming/functionality of the command; keep an eye here to see how that comes along. I'll try to update this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With