Skip to content

Latest commit

 

History

History
167 lines (106 loc) · 4.09 KB

README.md

File metadata and controls

167 lines (106 loc) · 4.09 KB

Leonel

Circle CI JavaScript Style Guide

Overview

Leonel is a bot we use to make our life easier for our colombia-dev community

Running locally for development

The easy way

Setup your environment

Make a bot integration, or have a bot token handy

Create a slack.env file:

$ cp slack.env.example slack.env

The only token that needs to be valid is SLACK_TOKEN, the rest can be placeholder unless you want to test the invitation or onboarding flows.

After setting the right SLACK_TOKEN in your slack.env file, use docker-compose to bring up leonel:

$ docker-compose up

Go to your Slack, and send a DM to leonel saying coqueto. He'll respond if he's up. You can run docker in a detached state by using docker-compose up -d instead.

Make changes

The docker-compose setup is configured to reboot the bot when any local file changes, using nodemon to make development easier.

Seed users

Leonel uses MongoDB to store specific information about users, you can create the user accounts by running:

$ docker-compose run bot yarn db:seed

This will execute the script db:seed in a container to create all the users from Slack's API.

Running Tests

You can run ava tests in a container, by running:

$ docker-compose run bot yarn test

If you want for tests to watch your files, you can run:

$ docker-compose run bot yarn test -- -w

If you want to modify the DEBUG env var, you can run:

$ docker-compose run -e DEBUG="" bot yarn test -- -w

Shutting Down

When you're done, you can use docker-compose to clean up your environment:

$ docker-compose down

The not so easy way

Setup your environment

All environment variables in example env file should be set before running Leonel.

Other requirements:

  • Yarn
  • NodeJS 7.7.x
  • MongoDB

Install dependencies:

$ yarn

Start leonel:

$ yarn start

Things are looking good if the console prints something like:

** API CALL: https://slack.com/api/rtm.start
** BOT ID:  leonel  ...attempting to connect to RTM!
** API CALL: https://slack.com/api/chat.postMessage
bot:main Estamos coneptados al Eslá

We have added yarn start:watch script which uses Nodemon for convenience during development. This restarts the bot after any change done to source files.

Seed users

Leonel uses MongoDB to store specific information about users, you can create the user accounts by running:

$ yarn db:seed

This will execute the script db:seed to create all the users from Slack's API.

Running Tests

note: make sure the proper environment vars in example env file are set before running tests

We use ava for unit and integration testing, you can run tests by typing:

$ yarn test

You can watch files and run tests when any changes are detected by using:

$ yarn test -- -w

JavaScript Style

In order to minimize code style differences, we have adopted the StandardJS style. Please make sure your changes are compatible with the guide.

note: you can check compatibility by running tests

$ yarn test

note: you may also be able to automatically fix any style issues with the standard tool

$ node_modules/.bin/standard --fix

Please see the documentation at StandardJS for more information.

Acknowledgements

This code uses the botkit npm module by the fine folks at Howdy.ai.

License

See the LICENSE file (MIT).