Drush 命令向功能添加新的模块依赖项

发布于 2024-10-18 13:48:19 字数 174 浏览 1 评论 0原文

当您添加新的模块依赖项时,是否有 drush 命令可以更新功能?我知道您可以使用 FU 命令来更新对已添加的视图、内容类型等的更改...但我想知道如何添加新的视图、内容类型和模块依赖项。到目前为止,我发现将这些更改合并到功能中的唯一方法是重新下载它。

值得庆幸的是,Git 使这个过程比以前使用 SVN 变得容易得多。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

棒棒糖 2024-10-25 13:48:19

如果您习惯于编辑 .info 文件,那么功能用于识别应导出哪些组件的格式非常简单。例如:

  features[node][] = "node_type"
  features[view][] = "view_name"
  features[variable][] = "variable_name"

通过将其中任何一个添加到您的 .info 文件并运行 drush fu,生成的模块将包含那些指定的组件(如果它们之前未导出)。功能将负责添加它认为应该存在的任何其他零碎内容。

功能的模块依赖关系与 Drupal 中任何模块的模块依赖关系的工作方式相同 - 只需将 dependency[] = "module_name" 添加到功能的 .info 文件中即可。

这是我更新功能的主要方式,通过几个步骤,您可以创建并启用空白模块,并通过以这种方式将功能组件添加到 .info 文件来“功能化”它。

可以创建诸如 drush features-add-component featurename --node=new_type 这样的 drush 命令,但我不相信有已发布的命令可以做到这一点。有几个具有扩展功能管理功能的 drush 脚本分散在功能问题队列和一些正在开发的项目中。像这样的命令的主要优点是功能 UI 的命令行版本 - 向功能构建器显示哪些组件可用于导出。如果您习惯手动编辑 .info 文件,那么该实用程序会受到一定的限制。

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.

神爱温柔 2024-10-25 13:48:19

当前在 drush 中执行此操作的方法是“features-export”或“fe”。 (features-add 已弃用)

drush fe my_existing_feature dependencies:my_new_dependency

更多花絮:

该命令还可以用于创建一个新功能,以完全相同的方式包含该组件。唯一的区别是功能名称尚未作为功能存在。例如,这将创建一个包含节点类型的新功能:

drush fe my_new_feature node:my_node_type

最后它与 features-components (fc) 命令齐头并进。您可以像这样看到所有非导出组件的列表:

drush fc --not-exported

作为快捷方式,您可以指定要查找的组件类型:

drush fc --not-exported field

您可以不使用 --not-exported 来查看导出的组件,但我发现在实践中我只想看看非出口的。它让我可以在 Drupal 中疯狂地创建东西,然后在完成后转到命令行并绝对确保我创建的所有内容都导出到功能中。

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.

慈悲佛祖 2024-10-25 13:48:19

现在你可以使用 drush features-add (drush fa) 做同样的事情。 “drush fa”将生成一个可以添加到功能中的元素列表。如果您熟悉编辑 .info 文件或曾经查看过功能 UI 中的计算机名称,您就会认出这些可特征化元素的名称。

例如:

drush fa feature_name dependencies:views views_view:user_questions

这会将 Views 模块添加为依赖项,并将视图“user_questions”添加到“feature_name”。

警告:该命令似乎是最近添加的;我需要将功能更新到 7.x-1.x-beta6 才能获得它。不幸的是,它尚未移植到 D6,但这有望很快实现;请参阅此问题了解进展情况以及在 D6 上为您提供“drush fa”的补丁。还有一些关于命令的命名/功能的讨论;请密切关注此处,了解情况如何。我会尝试更新这篇文章。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文