npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

botdylan

v0.1.0

Published

github bot

Downloads

50

Readme

Once upon a time, you managed your Github repositories,

the pull requests and the commits... didn't yoooou?

botdylan: Automate your Github processes with js scripts.

botdylan runs as a daemon. It's configured by writing a config.json file that describes cron and hooks scripts. cron scripts execute periodically and hook scripts execute on github hook events.

$ ls /etc/botdylan
scripts/hooks
scripts/crons
config.json

$ botdylan --dir /etc/botdylan

Why?

botdylan was initially built and used internally at Teambox.

We use Github heavily. There are some repetitive tasks that were taking away our time to hack on a better product. Since we are in the productivity space we decided to stop doing things manually and start to have a more productive environment to work with.

The project is heavily inspired by hubot.

Give me some examples...

You can automatize any process in GitHub. Some of the things we are currently doing:

  • Label issues with the status of the CI
  • Show a cowboy image when someone posts directly to develop.
  • Label issues that have 2 or more thumbs
  • Post images on demand "image me..."
  • Label issues with the status of the PR (mergeable or not)
  • Ping inactive pull requests
  • Post message to your chat room (when the CI fails for instance)
  • Interact with other services via HTTP

Command line options

botdylan has just one CLI option:

  • --dir [current_path]: Location of your scripts folder and config.json.

Config.json

Configuring botdylan is damn simple! Just populate your config.json file on your configuration directory with the following options:

  • username: Bot username
  • password: Bot password or oauth token
  • auth [basic]: Auth type to use when connecting to GitHub. Can be basic (username/password) or oauth (username/token)
  • repositories: Hash of repositories (owner/repository) with the cron and hooks setted up
  • port [80]: Port to listen github webhooks
  • silent [false]: Flag to disable output
  • secret: (Optional) String with high entropy to secure your webhook
  • github_api: (Optional) Object with options directly to GitHubApi constructor, see npm's github docs
{
  "username": "botdylan"
, "password": "blood-on-the-tracks"
, "secret": "myhashsecret"
, "url": "http://example.com:5000"
, "port": 5000
, "repositories": {
    "botdylan/test": {
      "crons": {
        "0 0 0 * * *": ["ping"]
      }
    , "hooks": {
        "issue_comment": ["pong"]
      , "push" : ["cowboys"]
      }
    }  
  }
, "github_api": {
     "host": "my-enterprise-github-instance.mycompany.com" // if you're using GitHub Enterprise,
     "timeout": 2000
  }
}

Scripts under scripts/hooks will run on any given hook event, botdylan will create the hooks automatically if they don't exist.

Scripts under scripts/crons use the cron syntax.

Environment variables

Sometimes you might not want to store your GitHub credentials inside repository. In order to prevent this you can use three environment variables: GITHUB_USERNAME, GITHUB_PASSWORD, GITHUB_WEBHOOK_SECRET - when set they will overwrite username, password, secret config options.

Example:

GITHUB_USERNAME=johndoe GITHUB_PASSWORD=qwerty GITHUB_WEBHOOK_SECRET=bazinga botdylan --dir /etc/botdylan

How to write botdylan scripts?

The scripts have to export a single function that will be executed by botdylan.

Cron scripts receive:

  • bot
  • repo_info

Hooks scripts receive:

  • bot
  • repo_info
  • payload

You will find plenty of examples under the scripts folder.

The bot helper object

This object represents our beloved bot. It has some methods to help you write your scripts:

  • trace: Write a message to the console unless the silent option is sent
  • options: Options from your config.json file
  • handleError: Function applicator that handles showing errors if any
  • github: Authenticated GitHubApi instance of node-github
  • http: A request instance
  • events: Contains a on and an emit message. Ideal to communicate between scripts
  • store: A getter/setter memory storage.

TODO

There are plenty of things that we would like to have soon done:

  • More scripts! Most of them can be imported from hubot which we love <3
  • scripts/events to be able to create scripts that are invoked from custom events
  • Better tools for bot to reduce the boilerplate on the scripts
  • Better documentation and how to script guides

License

(The MIT License)

Copyright (c) 2013 Pau Ramon [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.