This is a boilerplate for having your own hubot instance running using Typescript.
Supports all existing hubot scripts written in coffescript / javascript.
It comes with the slack adapter pre-installed.
Run:
cp .env.sample .envTo create your own .env file. Modify it as desired, then run:
yarn devThe .env file is only used during development. When running in production use your provider means of setting environment variables.
First build the code:
yarn buildThen run the bot:
HUBOT_NAME=my-bot HUBOT_OTHER_ENVS=x yarn startIf using Windows I recommend to install
cross-env, so you can run like the following:cross-env HUBOT_NAME=my-bot HUBOT_OTHER_ENVS=x yarn start
This will by default use the shell adapter, which is great for testing.
This boilerplate comes with the slack adapter pre-installed, so you can specify it by running:
HUBOT_NAME=my-bot HUBOT_ADAPTER=slack HUBOT_SLACK_TOKEN=xoxb-YOUR-TOKEN-HERE yarn startFor more documentation about running hubot itself or the slack adapter, please check their corresponding
docs:
https://hubot.github.com/docs/
https://slackapi.github.io/hubot-slack/#basic-setup
The code should be self-documented.
Start by looking into the .env.sample file, then the scripts inside src/scripts, the files inside the src/utils and finally test files.
The folder types has some helpers for Typescript.
Do not use Hubot robot.http method, it uses an old lib and cannot be easily tested.
Use something more modern, like axios or fetch.
We are using hubot-test-helper.
Testing hubot is not an easy task, mainly because if you have any async call inside your scripts, your tests will need to have some kind of delay.
The best option here is to include a mock for the library you are using to make async calls, and include a small delay on your tests for each async interaction.
This boilerplate comes with axios installed, and a mock that works with jest, preinstalled. The test example at example.spec.ts can be used as reference. It should be self-documented.
See mtsmfm/hubot-test-helper#19
There is no brain persister installed, it's your job to install one if needed.
They don't.
There is a postinstall hook that calls the script tools/compile-coffee-deps.js
which is responsible for compilling the dependencies .coffee files to pure .js.