# find-plugins

> Add plugin functionality to your tool - search for installed node_modules by keyword or other criteria.

Latest version **1.1.7** (published 2018-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install find-plugins
pnpm add find-plugins
yarn add find-plugins
bun add find-plugins
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2018-02-28 |
| First published | 2014-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 6 |
| Unpacked size | 51.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dave Wasmer |
| Maintainers | davewasmer |
| Keywords | plugin, npm, modules, keywords, find, search, list |

## Links

- npm: https://www.npmjs.com/package/find-plugins
- Repository: https://github.com/davewasmer/find-plugins
- Issues: https://github.com/davewasmer/find-plugins/issues
- npm.io page: https://npm.io/package/find-plugins

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [dag-map](https://npm.io/package/dag-map.md) ^2.0.2
- [read-pkg](https://npm.io/package/read-pkg.md) ^3.0.0
- [read-pkg-up](https://npm.io/package/read-pkg-up.md) ^3.0.0
- [resolve-pkg](https://npm.io/package/resolve-pkg.md) ^1.0.0
- [try-require](https://npm.io/package/try-require.md) ^1.2.1

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.1.7 (latest) — 2018-02-28
- 1.1.6 — 2018-02-08
- 1.1.5 — 2018-02-08
- 1.1.3 — 2017-09-19
- 1.1.2 — 2017-09-09
- 1.0.4 — 2017-09-09
- 1.1.1 — 2017-08-30
- 1.1.0 — 2017-08-23
- 1.0.3 — 2017-07-08
- 1.0.2 — 2017-02-27
- 1.0.1 — 2017-02-15
- 1.0.0 — 2017-02-15
- 0.0.1 — 2014-12-02

## README

[![CircleCI](https://img.shields.io/circleci/project/github/davewasmer/find-plugins.svg?style=flat-square)](https://circleci.com/gh/davewasmer/find-plugins)
[![Dependencies](https://img.shields.io/david/davewasmer/find-plugins.svg?style=flat-square)](https://david-dm.org/davewasmer/find-plugins)
[![npm downloads](https://img.shields.io/npm/dm/find-plugins.svg?style=flat-square)](https://www.npmjs.com/package/find-plugins)
![latest version](https://img.shields.io/npm/v/find-plugins.svg?style=flat-square)

# find-plugins

A simple tool to find installed npm packages that meet certain criteria. Great for finding installed plugins or complementary packages to yours.

## Usage

#### Simple

```js
// Looks up the package.json in process.cwd, and returns any dependencies
// listed that have your package's `name` in their keywords.
plugins = findPlugins();
```

#### Custom Keyword

```js
// Same as above, but rather than using your package.json name as the keyword
// to search for, it will look for dependencies with "plugin" in their keyword
// list.
plugins = findPlugins({
    keyword: 'plugin'
});
```

#### Custom Filter

```js
// This time, the supplied filter function will be called for each dependency,
// and only those that return true will be returned in the final array.
//
// The filter function is supplied the package.json of the dependency to check.
// In this case, this will find all dependencies whose name starts with
// "my-plugin-"
plugins = findPlugins({
    filter: function(pkg) {
        return /^my-plugin-/.test(pkg.name);
    }
});
```

#### Ignore package.json dependency list

```js
// The scanAllDirs option allows you to skip loading your app's package.json
// dependency list. Instead, it will scan all directories in the node_modules
// folder, regardless of whether they are listed as dependencies or not.
plugins = findPlugins({
    scanAllDirs: true
});
```

#### Specify node_modules directory and your package.json

```js
// Got an unusual setup? Just pass in the path of the directory containing your
// dependencies, and the path to your app's package.json file. `pkg` is
// optional if you are using `scanAllDirs` and `keyword` or `filter`.
plugins = findPlugins({
    dir: path.join('..', 'foo', 'bar', 'node_modules'),
    pkg: path.join('..', 'foo', 'bar', 'package.json')
});
```

#### Sort the plugins based on "before" and "after" config in their package.json's

```js
// Each plugin can optionally include a "plugin-config" (or whatever you pass in under `configName`)
// with a "before" and/or "after" property. These can be the name of another plugin (or an array of
// other plugin names) that this plugin should come before/after. The returned array will be sorted
// according to these rules via a directed acyclic graph
plugins = findPlugins({
    sort: true,
    configName: 'plugin-config'
});
```


## Options

```js
{

  /**
   * The node_modules directory to scan for plugins
   *
   * @type {string}
   */
  dir?: string = process.cwd(),

  /**
   * The path to the package.json that lists dependencies to check for plugins
   *
   * @type {string}
   */
  pkg?: string = './package.json',

  /**
   * An array of additional paths to check as plugins
   *
   * @type {string[]}
   */
  include?: string[] = [],

  /**
   * If supplied, a package will be considered a plugin if `keyword` is present in it's package.json
   * "keywords" array
   *
   * @type {string}
   */
  keyword?: string = pkg.name,

  /**
   * If sort: true is supplied, this determines what property of the plugin's package.json to check
   * for the sort configuration (it should be an object with "before" and "after" properties which
   * are arrays of other plugins names)
   *
   * @type {boolean}
   */
  sort?: boolean = false,

  /**
   * The property on a plugin's package.json that contains sort config (an object with "before"
   * and/or "after" properties, which are the names of the plugin, or arrays of names)
   *
   * @type {string}
   */
  configName?: string = pkg.name,

  /**
   * A custom filter function that will receive the package summary and should return a boolean
   * indicating whether or not that package is a plugin.
   *
   * @type {function}
   */
  filter?: (plugin: PluginSummary) => boolean,

  /**
   * If true, the package.json list of dependencies will be ignored, and all packages found in
   * dir will be checked.
   *
   * @type {boolean}
   */
  scanAllDirs?: boolean,

  /**
   * By default, findPlugins checks only the packages listed under "dependencies" in the
   * package.json. Setting this option to true will ignore those packages listed under
   * "dependencies".
   *
   * @type {boolean}
   */
  excludeDependencies?: boolean,

  /**
   * Also check packages listed under devDependencies
   *
   * @type {boolean}
   */
  includeDev?: boolean,

  /**
   * Also check packages listed under peerDependencies
   *
   * @type {boolean}
   */
  includePeer?: boolean,

  /**
   * Also check packages listed under bundleDependencies
   *
   * @type {boolean}
   */
  includeBundle?: boolean,

  /**
   * Also check packages listed under optionalDependencies
   *
   * @type {boolean}
   */
  includeOptional?: boolean

}
```

## Returns

```js
> findPlugins();
[
    {
        dir: './node_modules/foobar',
        pkg: { name: 'foobar', version: '0.0.1', ... }
    },
    ...
]
```

---
_Source: https://npm.io/package/find-plugins · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
