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

generator-spark-bot

v1.0.1

Published

Scaffold a Cisco spark bot with simplicity and usability in mind

Downloads

12

Readme

generator-spark-bot Travis XO code style

generator-spark-bot is a yeoman generator that scaffolds out a node Cisco Spark bot following an event-driven fashion, and is extremely easy to get started with.

trigger context => callback()

Designed with simplicity and usability in mind:

  • Fast to get started, just drop a .js file within /commands and your bot will register a listener on start
  • Easier unit testing with access to commands' private methods
  • Includes Flint for a more robust framework

Usage

Ensure yeoman is is installed:

npm install -g yo or yarn global add yo

After yeoman is installed:

yo spark-bot

App Structure

.
├── commands                  # Event handlers are within the commands
│   └── example.js            # An example command for reference
├── app.js                    # Bot entry point
├── config.js                 # Configurations
├── test.js                   # AVA Test
├── readme.md
├── license
└── package.json

Commands

A command sub-generator [yo spark-bot:command] is soon to come

Commands will instruct the bot on when and how to respond to particular contextual triggers.

To add a command, simply add a .js file within the commands directory. When the bot is initializing, commands will automatically register with Flint at runtime.

These command must implement an interface that contains a trigger property and a callback method. Refer to example.js within the commands directory.

trigger | <RegEx>, <string>

The contextual trigger that will cause the bot to execute the callback upon matches.

callback | <function>

The function to be executed (event handler).

Scripts

  • npm run test - Run linter and unit test
  • npm start - Start the bot
  • npm run debug - Activate debugging to log

Unit Testing

Unit testing is straightforward, simple, and already configured with the AVA test runner. Commands are accessible through the fileName as a property of the commands object. Thus, any command callbacks can be tested as such: commands.fileName.callback.

In addition, the rewire module is pre-configured to test private methods and is easily accessible without the need of exporting any private methods. This is done with the __get__() method. IE: commands.example.__get__('buildExampleMessage').

Tech Dependencies

Test Runner

  • AVA - 🚀 Futuristic JavaScript test runner

Linter

  • XO - JavaScript happiness style linter

Framework

  • Express - Fast, unopinionated, minimalist web framework for node.
  • Flint - Cisco Spark Bot SDK for Node JS

License

MIT © Brandon Him