Folder management when developing plugins

Folder management when developing plugins
0

Folder structure

The way I manage my local file system when developing plugins is as follows. Note that I develop on a Mac in a standard environment (i.e. non-dockerized).

I have a folder in my home directory called “discourse”. This has the following subfolders:

discourse
  discourse // the discourse codebase
  plugins // discourse plugins (currently 68 plugins in here on my local)
  scripts // scripts I use to manage discourse folders
  themes // discourse themes

Folder management scripts

I use two simple scripts to change what plugins I’m using in development:

remove_non_core_plugins.sh (519 Bytes)
setup_discourse_plugin.sh (893 Bytes)

Both have notes in them describing how they work and the assumptions they make (basically they assume you have a folder structure like mine).

Essentially they create symlinks for the plugin(s) you nominate in the plugins directory in the discourse codebase, and remove any existing symlinks.

3 Likes

Yeah, I put all my plugins in ~/code and then symlink with:

ln -s ~/code/discourse-example-plugin

within discourse/plugin folder.

Then I just delete the symlink to exclude the plugin without having to touch the git managed code repo.

The only time I have to delete the code is when I’m switching between forks.

I do all my dev on a remote server (4 core, 4GB that I got cheap when Scaleway was building its client base).

After a spell with Atom, I now use VS Code with the Microsoft’s own Remote SSH plugin.

2 Likes

Does that allow you to edit the code on your remote instance seamlessly?

1 Like

Yup, you just have to log in. And even better, VS Code automatically looks for and uses your .ssh config (which I set up with git bash when on Windows, on mac it’s native)

2 Likes

@angus Thanks for sharing this.

I use RubyMine which is powerful IDE for Ruby development by Jetbrains (which is a part of my student dev pack which I still have a subscription of).

I use an old 2012 MacBook Pro with an SSD and 10 gigs of ram. I use VSCode for my PHP/WordPress development and RubyMine for Discourse.

I save all the reusable code snippets to this open-source tool called CodeNotes.

I use a local setup of discourse for development and just today I bought an external Dell Monitor to be able to wrestle with so many discourse files without losing sanity.

I know about symlinks but I’m not used to them so I do all the file stuff with file manager or command line.

2 Likes

That’s great.

2 Likes

Really interesting stuff, interested to hear the different ways of skinning this cat

  • I use Linux (Mint - 5+ happy years as daily driver OS)

  • I use the Docker Discourse env in development:

code/
  |- discourse/   https://github.com/discourse/discourse.git
  |- a-plugin/    # git@github.com:pacharanero/a-plugin.git
  • To make my plugin get auto-loaded by Discourse I have to create a symlink when the Docker container is built, I do this by manually editing one line in bin/docker/boot-dev:

docker run -d -p 9405:9405 -p 1080:1080 -p 3000:3000 -p 9292:9292 -v \ "$DATA_DIR:/shared/postgres_data:delegated" -v "$SOURCE_DIR:/src:delegated" -v "/home/marcus/code/a-plugin:/src/plugins/discourse-reflective-learning-plugin" $ENV_ARGS --hostname=discourse --name=discourse_dev --restart=always discourse/discourse_dev:release /sbin/boot

basically you map your plugin as a Docker Volume to a subdir of /src/plugins, and it will be there in your Docker instance.

  • I use a Dell XPS15 with 2 external monitors when I’m at home. I probably don’t need 2, but it’s very handy to be able to put reference/documentation on one screen and text editor on the other. It’s also MUCH better for posture to be looking at the monitors rather than the laptop screen.

  • I save snippets inside my Clipboard Manager CopyQ, they are sync’d to text files on disk by CopyQ

  • I use Ngrok to demo stuff on the public internet to people, if I don’t want to set up a dedicated internet-facing server for it. It’s really useful for testing other random stuff like webhooks too, where you can’t necessarily have the entire stack on your local machine.

  • I use Atom

2 Likes

Finally adapting this structure and scripts

2 Likes

I’ve added a few more scripts by building upon these. One is add_discourse_plugin which simply adds a plugin without removing the existing ones. Another one is list-included-plugins.sh which lists the currently included plugins(this is the result of my laziness to use finder).

Other two are start.sh and purge-start.sh which start the server without and with removing tmp folder respectively.

I’ll share after cleaning them up a bit.

2 Likes