使用 `create-discourse-plugin` gem 自动化 Discourse 插件设置

:mega: 此插件现已与 Discourse 核心捆绑在一起。无需使用此 gem。
创建新插件,请使用:
rake plugin:create[plugin-name]

自从我开始开发 Discourse 插件以来,我一直觉得整体设置可以更简单。我们在创建插件时应该有更好的整体开发体验。

本着这种精神,我利用业余时间创建了这个名为 create-discourse-plugin 的 gem。

它有什么作用?

它会根据您的选择,在您的用户名或组织下克隆并创建 discourse-plugin-skeleton 的副本。之后,它会用您的插件名称更新所有占位符。使其准备好开始开发。

如何使用?

npx create-next-appnpx meteor 精神相同

 gem exec create-discourse-plugin <plugin-name>

要求

  • 拥有可正常工作的 GH CLI

贡献

16 个赞

谢谢!在过去几年里,我每次制作新插件时都曾想过这样做!看起来你做得比我好多了。我迫不及待地想试试!

6 个赞

这太棒了,你们什么时候会厌烦到制作

gem exec create-discourse-theme <theme-name>

:wink:

6 个赞

那将是 discourse_theme new :wink:


@grubba 你觉得把这个合并到核心作为一个 rake 任务怎么样?比如

bin/rake plugin:create

人们需要有一个可用的核心开发环境来处理插件,所以这似乎是个好主意?它也会让它更加“官方”,并且整个团队更容易维护。

我想知道是否最好让它 100% 基于 git,而不是依赖人们使用 github(以及 gh cli)?有些人使用其他服务来托管他们的插件,并且可能不希望它们立即公开。

在 discourse_theme 中,我们维护着 一个本地缓存 的 theme-skeleton,所以它甚至可以在离线状态下工作!

6 个赞

哎呀!我只用过 watch!而且我觉得很久以前我尝试过,我不知道。但我忘了它。 :exploding_head:

2 个赞

我觉得有道理!大家已经测试过了,我也收到了一些抱怨和反馈并进行了一些调整。我认为它已经准备得很充分,可以正式发布了。我会在接下来的几天内努力将其添加到核心中。

我同意使用 gh 并不是理想的解决方案,我会想办法解决的。也许 discourse_theme new 的做法正是我想要的……

5 个赞

我有一个好消息!我刚刚将这个新的 rake 任务合并到了核心中:

rake plugin:create[name]

它的工作方式与 gem 类似,但它不会推送到 GitHub,让您可以选择如何操作——这与 discourse_theme new 完全相同。

我将把这个 gem 标记为已弃用,因为我们有了更“官方”的解决方案。

10 个赞

编辑:我已按照说明从 .gitignore 中删除了 Gemfile.lock,现在可以正常工作了。

`.gitignore` 不允许包含 `Gemfile.lock`
Cloning 'https://github.com/discourse/discourse-plugin-skeleton' to '/home/pfaffman/src/discourse-repos/discourse/plugins/discourse-public-bookmark-timers'...
Initializing git repository...
Initialized empty Git repository in /home/pfaffman/src/discourse-repos/discourse/plugins/discourse-public-bookmark-timers/.git/
The following paths are ignored by one of your .gitignore files:
Gemfile.lock
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
rake aborted!
Command failed with exit 1: git
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/plugin.rake:352:in `system'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/plugin.rake:352:in `block (2 levels) in <main>'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/plugin.rake:344:in `chdir'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/plugin.rake:344:in `block in <main>'
Tasks: TOP => plugin:create
(See full trace by running task with --trace)

运行 git config advice.addIgnoredFile false 后再次尝试,结果相同。

还有

$ gem exec create-discourse-theme discourse-public-bookmark-timers

ERROR:  Could not find a valid gem 'create-discourse-theme' (>= 0) in any repository
ERROR:  Possible alternatives: create-discourse-plugin, discourse_theme, askclass-course-theme, date_discreter, opensource-theme
1 个赞