Plugins
The plugin system lets you add custom component types to nerva generate. Plugins are stored locally in .nerva/plugins/ and discovered automatically.
Plugin commands
nerva plugin install <source> # Install from npm or local pathnerva plugin list # List installed pluginsnerva plugin ls # Alias for listnerva plugin remove <name> # Remove an installed pluginInstalling plugins
From a local directory
nerva plugin install ./my-pluginnerva plugin install /absolute/path/to/pluginFrom npm
nerva plugin install nerva-plugin-graphqlThe CLI runs npm pack to download the package, extracts it, and copies it into .nerva/plugins/<name>.
Plugin manifest
Every plugin must contain a nerva-plugin.json at its root:
{ "name": "nerva-plugin-graphql", "version": "1.0.0", "templates": [ { "type": "resolver", "files": ["resolver.py.tmpl", "resolver.ts.tmpl"] }, { "type": "schema", "files": ["schema.py.tmpl", "schema.ts.tmpl"] } ]}Manifest fields
| Field | Required | Description |
|---|---|---|
name | Yes | Plugin name (unique identifier) |
version | Yes | Semantic version string |
templates | Yes | Array of template definitions |
templates[].type | Yes | Component type name (used in nerva g <type> <name>) |
templates[].files | Yes | Template files for this type (must be non-empty) |
Plugin storage
Plugins are installed into the project’s .nerva/plugins/ directory:
.nerva/ plugins/ nerva-plugin-graphql/ nerva-plugin.json resolver.py.tmpl resolver.ts.tmpl schema.py.tmpl schema.ts.tmplListing plugins
nerva plugin listOutput:
Installed plugins:
nerva-plugin-graphql (v1.0.0) types: resolver, schemaRemoving plugins
nerva plugin remove nerva-plugin-graphqlThis deletes the plugin directory from .nerva/plugins/. The command fails if the plugin is not installed.
Creating a plugin
- Create a directory with a
nerva-plugin.jsonmanifest - Add template files (
.tmplextension) for each component type - Templates receive the same variables as built-in generators:
name,class_name,type,description - Test locally with
nerva plugin install ./your-plugin - Publish to npm for others to use