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

plugin-registry

v0.2.6

Published

Maintains a general purpose registry of plugins

Downloads

14

Readme

plugin-registry

Maintain a flexible and composable registry of plugins for your project.

NPM

Build Status Coverage Status

Usage

First, install plugin-registry locally.

npm install --save plugin-registry

Next, create a plugin registry for your tool.

var pluginRegistry = require('plugin-registry');

pluginRegistry
  .get('my-tool')
  .add([
    'my-tool-foo-task',
    'my-tool-bar-task'
  ]);

Finally, access the plugin registry when you need it.

var pluginRegistry = require('plugin-registry');

pluginRegistry
  .get('my-tool')
  .getAllOfCategory('task')
  .forEach(function eachTaskPluginDefinition(definition) {
    // Use `plugin` to do awesome things!
  });

Plugin registry will find the plugins by their name. See advanced usage section below for details.

Advanced usage

Plugins may be specified as objects as well, not just strings:

var pluginRegistry = require('plugin-registry');

pluginRegistry
  .get('my-tool')
  .context({
    toolPath: __dirname,
    projectPath: process.cwd(),
  })
  .add([
    {
      name: 'my-tool-foo-task',
    },
    {
      name: 'my-tool-bar-transform',
      category: 'stream-transform',
      requirePath: '/absolute/path/to/my-tool-bar-transform'
    }
  ]);

context(pluginContext)

When the tool asks plugin registry to find its plugins by name - and not specify an explicit requirePath, it attempts to infer the location of the plugin from a number of possible locations, based on the location of the tool, and the location of the project.

The default values for each of these work well in most cases, however, they can be explicitly specified too if this is desired.

Note that this method can only be called once - it does not make sense for the context to change once set.

toolPath

  • Type: string - an absolute file path
  • Optional: true
  • Default: path.dirname(module.parent.id), if available, otherwise path.resolve(__dirname, '../..')

projectPath

  • Type: string - an absolute file path
  • Optional: true
  • Default: path.resolve('.') (current working directory)

add(pluginDefintion)

name

  • Type: string
  • Optional: false
  • Default: Not Applicable

category

  • Type: string
  • Optional: true
  • Default: task

requirePath

  • Type: string - an absolute file path
  • Optional: true
  • Default: Determined programmatically based on value of name
    • By looking in the possible following locations:
      • A dependency of the tool using the plugin registry
      • A dependency of the project at the current working directory
      • A sibling folder of the tool using the plugin registry
        • If tool is a global installation, this will pick up other global installations

Parsed Plugin Definition

After plugin definitions have been parsed, their optional values will be set, as described above.

In addition, the plugin definitions are augmented:

plugin

The require()d plugin.

The plugin must, of course, be valid Javascript or JSON, as per NodeJs' and CommonJs' specifications, in order for this to work.

Contributing

This repository uses the git flow branching strategy. If you wish to contribute, please branch from the develop branch - pull requests will only be requested if they request merging into the develop branch.

Author

Maintained by Brendan Graetz

bguiz.com

Licence

GPLv3