Read my book

I wrote books about Webpack and React. Check them out!

Saturday, June 29, 2013

Mankees - update_deps and init plugins

Monkeys by Trey Ratcliff
If you follow this blog, you might remember my recent post about mankees a small scripting platform I developed. As it happens I've done some additional development on it. The terminal client is more or less the same. The real innovation has happened on the plugin side.

In order to organize my work better, I defined an organization at GitHub. It contains all mankees development and acts as a hub of sort. Way better than going through my massive GitHub profile. It really starts to break down as you accumulate lots of small projects making it difficult to find the interesting stuff.

Basic Idea - Recap

But I digress. Back to the topic. As I was saying before, I've done some development on the plugin side. In order to make the plugins simpler, they are now simple Node.js modules. Effectively this means all you need to do is to set up an index.js that has module.exports containing the entry point (function) of your plugin. The template highlights this idea well.

To make it possible for mankees to discover your plugin, you need to have it at your ~/.mankees directory. After that you should be able to see it by invoking mankees -l. To invoke it, just pass its name to mankees like this: mankees template 1 2. You may access those parameters at the plugin entry point.

update_deps plugin

I don't like to use semvers in when developing services. It is way too easy for things to get broken as some Node.js packages get updated. I know that in principle that shouldn't happen if everyone is doing the right thing but better to be safe than sorry. That's why I like to lock down versions in a strict way (ie. 0.2.1).

update_deps plugin supports this workflow. It simply fetches the versions of the project dependencies and then puts those to package.json. After that it's up to me to continue. This is something that's quite painful to do manually and the plugin allows me to do the same thing literally in seconds. Not bad!

init plugin

Starting a project involves setting up a lot of boilerplate. You have to do things like write a, set up a package.json, set up a LICENSE and perhaps something else. It's always a chore to do this.

init plugin solves this problem for me. It uses some predefined configuration that contains things like my name and then injects that data into a set of templates. Based on this simple operation I get a fresh project on which to start working on.

It is simple to write new project presets. A Node.js oriented one is included in the plugin. The system relies on Handlebars and the data to be injected is defined at ~/.mankees/config.json.

This is another good example of a plugin that simplifies life somewhat and makes it faster to author packages. You still have to work hard on the logic but that's just inevitable.

If you want to try out something way more hardcore, consider giving Yeoman a go.


I think it's safe to say that developing this scrappy little plugin platform has been a personal success. I keep finding myself using it. As a result I get some new ideas on how to improve my workflow. This is truly the best thing about being a developer. You can eliminate at least some of those boring parts and focus on the more interesting ones quite easily.