# ssb-plugins

> `ssb-plugins` is a plugin that provides additional plugin related functionality to a [secret-stack](https://github.com/ssbc/secret-stack) instance.

Latest version **1.0.4** (published 2020-01-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-01-05 |
| First published | 2019-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 32.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dominic Tarr |
| Maintainers | ahdinosaur, aljoscha-meyer, andregarzia, arj03, cel, christianbundy, cryp7ix, dominictarr, happy0, kyphae, luandro, mixmix, mmckegg, noffle, pfrazee, pietgeursen, regular, staltz, vtduncan |

## Links

- npm: https://www.npmjs.com/package/ssb-plugins
- Repository: https://github.com/dominictarr/ssb-plugins2
- Issues: https://github.com/dominictarr/ssb-plugins2/issues
- npm.io page: https://npm.io/package/ssb-plugins

## Dependencies (12)

- [mv](https://npm.io/package/mv.md) ^2.1.1
- [osenv](https://npm.io/package/osenv.md) ^0.1.5
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [muxrpc](https://npm.io/package/muxrpc.md) ^6.4.6
- [pull-cat](https://npm.io/package/pull-cat.md) ^1.1.11
- [pull-many](https://npm.io/package/pull-many.md) ^1.0.8
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^6.0.5
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.9
- [explain-error](https://npm.io/package/explain-error.md) ^1.0.4
- [pull-pushable](https://npm.io/package/pull-pushable.md) ^2.2.0
- [muxrpc-validation](https://npm.io/package/muxrpc-validation.md) ^3.0.0
- [stream-to-pull-stream](https://npm.io/package/stream-to-pull-stream.md) ^1.7.2

## Recent versions

- 1.0.4 (latest) — 2020-01-05
- 1.0.3 — 2019-09-26
- 1.0.2 — 2019-06-06
- 1.0.0 — 2019-05-13
- 0.0.0 — 2019-04-02

## README

# ssb-plugins

`ssb-plugins` is a plugin that provides additional plugin related functionality to a [secret-stack](https://github.com/ssbc/secret-stack) instance.

Without `ssb-plugins`, plugins can only be loaded explicitly by an ssb-server with the `.use()` method.

Generally speaking, this plugin provides the abilility for plugins to be loaded and run as a separate process, with communication over muxrpc.

There are 2 main ways that plugins can be enabled using `ssb-plugins`:
1. loaded explicitly as part of the creation of a secret-stack instance
2. loaded as a set of user configured plugins, defined in one's ssb config folder

Additionally, if enabling plugins from user-configuration, making use of `.use(require('ssb-plugins'))` explicitly will enable the CLI commands for users to install / uninstall / enable / disable plugins manually.

For explicit documentation of the CLI API, see [here](api.md).

## How to write plugins

[See `secret-stack/PLUGINS.md` for how to create a plugin](https://github.com/ssbc/secret-stack/blob/master/PLUGINS.md)


# Examples

```
var createSbot = require('secret-stack')()
.use(require('ssb-db'))

createSbot
  .use(require('ssb-plugins/load-user-plugins')()) //load user plugins from configuration. This may be used without the above!
  .use(require('ssb-plugins/load')(path, name))  //load an out of process plugin directly.
  .use(require('ssb-plugins'))  //provides install, uninstall, enable, disable. (optional)
```

## In-line out of process plugins

Run a plugin as a separate process. The process is
started by the parent process, and they communicate
by running muxrpc over stdio. This means that plugins
may now be written in a language other than javascript.

out of process plugins can be loaded manually.
using require('ssb-plugins/load')(location, name)`

``` js
var Load = require('ssb-plugins/load')
createSbot
  .use(Load(path/to/plugin, 'plugin'))
```

## Load user configured plugins

add all plugins defined in configuration.
``` js
createSbot
  .use(require('ssb-plugins/load-user-plugins'))
```

Plugins are configured as following:
Normally this is created by `sbot plugins.install <plugin-name>` but it can also be installed manually.

```
  "plugins": {
    //load a javascript plugin, exposed as "plugin1"
    "ssb-plugin1: true,
    //load your own version of plugin2. note it is renamed to "plugin2"
    //so it is exposed as "plugin2" not "plugin2-forked"
    "ssb-plugin2-forked: "plugin2",
    "ssb-plugin2": {
      enabled: true,
      name, process
    }
  }
```

### Installing a user configured ssb-plugin manually

```
cd ~/.ssb
npm install <plugin-name>
# open `./config` in your favorite editor
nano config
# set the config
"plugins": {
  "<plugin-name>": true
}
# or if it's an out of process plugin
"plugins": {
  "<plugin-name>": {
    "process": true,
    "name": ... //if it should be exposed with a different name...
  }
} 
```

## License

MIT

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