# Automating Discourse Plugin Setup with \`create-discourse-plugin\` gem

**URL:** https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013
**Category:** Developers
**Created:** [July 4, 2024, 1:53pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013 "2024-07-04T13:53:41Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![gabriel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabriel/32/367911_2.png) [@gabriel](https://meta.discourse.org/u/gabriel)
#### Post date: [July 4, 2024, 1:53pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/1 "2024-07-04T13:53:41Z")

</div>

> 📣 **This plugin is now bundled with Discourse core**. There is no need to use this gem.  
> To create a new plugin, use:  
> `rake plugin:create[plugin-name]`

Since I started developing discourse plugins, I felt the overall setup could be more straightforward. _We should_ have a better overall developer experience when creating a plugin.

In that spirit, I’ve created in my free time this gem called [`create-discourse-plugin`](https://github.com/Grubba27/create-discourse-plugin)

## What does it do?

It clones and creates a copy of the `discourse-plugin-skeleton` under your username or org based on your chosen option. After doing that, it updates all placeholders with the name of your plugin. Making it ready to start development.

## How to use?

In the same spirit as `npx create-next-app` or `npx meteor`

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

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/1/d/c1d3a38e2cdaeba5efdff8fc10ff0a5dbe926b17.png)

## Requirements

- Having a working [GH CLI](https://cli.github.com/)

## Contribuiting

> **[GitHub - Grubba27/create-discourse-plugin](https://github.com/Grubba27/create-discourse-plugin)**
>
> Contribute to Grubba27/create-discourse-plugin development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 4, 2024, 3:05pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/2 "2024-07-04T15:05:00Z")

</div>

Thank you! I’ve thought about doing this every time I’ve made a new plugin for the past couple of years! It looks like you have don’t a much better job than I would have. I can’t wait to try it!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 30, 2024, 6:46pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/3 "2024-07-30T18:46:57Z")

</div>

This is so awesome, so when are you going to get annoyed enough to make

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

```

? 😉

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [July 31, 2024, 8:51am UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/4 "2024-07-31T08:51:01Z")

</div>

That would be `discourse_theme new` 😉

> [@Install the Discourse Theme CLI console app to help you build themes](https://meta.discourse.org/t/install-the-discourse-theme-cli-console-app-to-help-you-build-themes/82950):
>
> The [[discourse] Discourse Theme CLI](https://github.com/discourse/discourse_theme) is a ruby gem that allows you to use your editor of choice when developing Discourse themes and theme components. As you save files the CLI will update the remote theme or component and changes to it will appear live! Installing To play with it, make sure you have Ruby 2.5 or up installed. If you are on Windows, you have 2 options: Option 1: [Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux). Windows 10 has access to a full Linux environment, you can use it to install …

* * *

@grubba how would you feel about rolling this into core as a rake task? Like

```plaintext
bin/rake plugin:create

```

People need to have a working core dev environment to work on plugins anyway, so it seems like a good fit? It would also make more ‘official’, and easier for the whole team to maintain.

I wonder if it would be better to make it 100% git, instead of relying on people using github (and having the `gh` cli)? Some people use other services to host their plugins, and also may not want them to immediately be made public.

In discourse\_theme we maintain [a local cache](https://github.com/discourse/discourse_theme/blob/main/lib/discourse_theme/scaffold.rb#L77-L106) of the theme-skeleton, so it even works offline!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 31, 2024, 12:30pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/5 "2024-07-31T12:30:03Z")

</div>

> [@david](#):
>
> That would be `discourse_theme new`

Doh! I only ever use watch! And I think when I tried it long ago it, I don’t know. But I forgot about it. 🤯

---

<div class="post-metadata">

### Author: ![gabriel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabriel/32/367911_2.png) [@gabriel](https://meta.discourse.org/u/gabriel)
#### Post date: [August 12, 2024, 8:22pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/6 "2024-08-12T20:22:52Z")

</div>

> [@david](#):
>
> how would you feel about rolling this into core as a rake task? Like
> 
> ```plaintext
> bin/rake plugin:create
> 
> ```

I guess it makes sense! People have tested it, and I’ve received a few complaints and feedback and made some adjustments. I think it is in pretty good shape to make it `official`. I’ll work within the next few days on adding it to the core.

I agree that using gh is not ideal, and I’ll figure out a solution. Maybe what `discourse_theme new` does is what I was looking for…

---

<div class="post-metadata">

### Author: ![gabriel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabriel/32/367911_2.png) [@gabriel](https://meta.discourse.org/u/gabriel)
#### Post date: [August 14, 2024, 3:01pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/7 "2024-08-14T15:01:32Z")

</div>

I have great news! I’ve just [merged](https://github.com/discourse/discourse/pull/28350) this new rake task into core:

```sh
rake plugin:create[name]

```

It works similarly to the gem, but it does not push to GitHub, giving you the choice of what to do–precisely like `discourse_theme new`

I’ll tag this gem as deprecated, as we have a more _official_ solution

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 27, 2024, 6:26pm UTC](https://meta.discourse.org/t/automating-discourse-plugin-setup-with-create-discourse-plugin-gem/315013/8 "2024-08-27T18:26:52Z")

</div>

EDIT: I removed `Gemfile.lock` from `.gitignore`, like it said. And now it works.

> **No Gemfile.lock allowed in .gitignore**
>
> > [@david](#):
> >
> > ```plaintext
> > bin/rake plugin:create
> > 
> > ```
> 
> ```plaintext
> 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)
> 
> ```
> 
> I tried again after running `git config advice.addIgnoredFile false` with the same result.
> 
> And also
> 
> ```plaintext
> $ 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
> 
> ```
