So you just thought of the next killer Hubot script and you want to share it with the world? Well if you haven’t been paying attention, you should know that the hubot-scripts community has changed their contributing policy:
It’s now preferred that if you are able to, you should release your script as part of a npm package built for Hubot.
And it’s a good change, because this now allows scripts to be distributed and versioned as individual NPM packages. This also means that individual scripts can easily declare dependencies, which is a big improvement.
If you’re familiar with the process for creating a NPM package, then you’re off to a good start. We’re going to be using yeoman and the generator-hubot-script to generate all the boilerplate necessary for quickly creating a NPM package for our Hubot script.
NOTE: The generated boilerplate is based on the hubot-example repository.
Now let’s ago head and install
yeoman and the
Secondly, let’s go ahead and create a directory for our script. For the sake of
this example, we’re gonna assume we created a script called
foobar.coffee, so we want to appropriately namespace our package with
1 2 3
Follow the prompts and wait until the NPM install completes. Now let’s initialize the directory as a Git repository and commit our initial files:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Cool, so now all the boilerplate is in place, it’s out with the old and in with the new:
1 2 3 4 5 6 7 8
Unit testing is cool, so let’s go ahead and set that up:
1 2 3
Once you have some passing test cases, let’s go ahead and commit these changes:
1 2 3 4
Next, you want to go ahead and update the
package.json file to include
all the relevant information for your script. Make sure the following fields
are all satisfactory:
More details on this file can be found here. Once you’re done, go ahead and commit your changes:
1 2 3 4
Lastly, go ahead and review the
README.md file. Feel free to make any
changes, and add any missing documentation you think is necessary. Make sure
to commit any changes you make.
1 2 3 4
Congratulations, you’ve packaged your Hubot script and are ready to share it with the world! So go ahead and push this repository to Github or publish the package on NPM.