We are releasing Node Mecano on GitHub which gather common functions used while deploying systems. The idea was to group those functions into a comprehensive library.

The code started when we wrote Heco as well as when we deployed a Hadoop cluster for one of our customer. It found inspiration in the Chef Resource API.

The functionalities are sill limited and there are obviously many potential improvements but we wanted to release the code early. We found it already very usefully and the API should be stable enough to integrate it into your own project.

The functions covered by Mecano are copy, download, execute, extract, git, ln, mkdir, remove and render. Their API is always the same. The first argument defines one or more command to run (an object or an array of objects) and the second one is a callback called on completion which tell you how many common where really run. For example, to copy 2 files, the code will look like:

Calling the same command a second time and the value of copied will be “0” because no new file was copied.

The command share a set of common properties to conditionally run the command and validate its result. For example, the following command will only run if a specified file exists and will emit an error if the exit code isn’t the one provided.

Hope you’ll find it useful as well and don’t hesitate to provide us with feedback.