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

bot-caster

v0.0.2

Published

Bot to deliver messages in postversion scripts on node apps

Downloads

5

Readme

bot-caster Dependencies Status

Bot to deliver messages in postversion scripts on node apps.

This bot was designed to send messages to a software team when a new version is generated. So, the normal steps to use this tool are:

  • Update your 'master' branch or trunk
  • run tests
  • update version in package.json
  • generate/update changelog
  • commit changed files
  • git push && git push --tags
  • bot-caster

Installation and usage

$ npm install --save-dev bot-caster

Or, globally:

# npm install -g bot-caster

Example:

/* package.json */
...

"scripts":{
  ...
  "postversion": "git push && git push --tags && bot-caster -m 'key1'"
},

...

"bot-caster":{
  "options": {
    "key1": {
      "title": "title for message 1",
      "content": "this is the content for message 1",
      "attachChangelog": true
    },
    "key2":{
      "title": "title to another activity (ex: deploy the version to production environment)",
      "content": "another content to this message",
      "attachChangelog": false // the changelog for this version will not be loaded.
    },
    "key3":{
      "title": "app name and app version",
      "content": "You can use %app_name% and %app_version% and the tool will replace this words with 'name' and 'version' properties from your package.json"
    }
  },
  "changelogFile": "./CHANGELOG.md",
  "slack": {
    "webhookUri":"access this link: https://my.slack.com/services/new/incoming-webhook to obtain your slack bot url",
    "channel": "#general",
    "username": "memo"
  }
}

Options

The bot-caster options goes inside the package.json file. There's two ways to write the options:

  • Direct way, inside package.json
  • Indirect way, writing the file path of configs and put your path indide package.json.

Writing the direct way

Just add the object inside the 'bot-caster' property on your package.json. The first example of usage for this tool shows the direct way.

package.json

{
  "name": "my-package",
  "version": "1.0.0",
  ...
  "bot-caster": {
    options: {
      ...
    },
    "changelogFile": { ... }
    ...
  }
}

Writing the indirect way

Just write your configs in another file, and put this file on package.json.

/* bot-caster-configs.js */
module.exports = {
  "bot-caster":{
    "options": {
      "key1": {
        "title": "title for message 1",
        "content": "this is the content for message 1",
        "attachChangelog": true
      }
    },
    "changelogFile": "./CHANGELOG.md",
    "slack": {
      "webhookUri":"access this link: https://hooks.slack.com/services/my-bot-url",
      "channel": "#general",
      "username": "bot-caster"
    }
  }
};

/* package.json */
{
...
"bot-caster": "path/to/bot-caster-configs.js/created/earlier"
}

Available options

  • options: Object to store the message types available to this installation. Each property have a custom key and your value is another object with:
    • title: The message title
    • content: The message content
    • attachChangelog: Flag to attach or not the changelog to message. Default: false.
  • changelogFile: Path to changelog file. The tool was designed to read the changelog files generated by conventional-changelog.
  • slack: The configurations used to publish the generated message to slack service.
    • webhookUri: The slack webhook url. Access this link for details
    • channel: The slack channel to post the message
    • username: The bot's username

Testing

To make tests, rename the testConfigs.js.example to testConfigs.json, set the needed informations and run:

$ npm test