Testing new plugins

This page describes how you can test newly created Magnolia CLI plugins. After you’ve created a new CLI plugin, you can connect it with the CLI.

Building and packing

  1. Build the plugin. In the folder with your new plugin, run this npm command:

    npm run build
  2. Pack the package.

    npm pack

    You should see the following message:

    ...
    <plugin_name>-<plugin_version>.tgz

Add it to a project

With add-plugin

  1. To install the plugin, run the following command in the project folder.

    npm run mgnl add-plugin /Path/to/<plugin_name>-<plugin_version>.tgz

    It will automatically install and register the plugin in mgnl.config.js.

Manually

  1. Install the plugin.

    npm install /Path/to/<plugin_name>-<plugin_version>.tgz
  2. Add the new plugin to the mgnl.config.js file.

    import <plugin_class_name> from "<plugin_name>";
    
    export default {
      plugins: [
        new <plugin_class_name>()
      ]
    };

Using the plugin

  1. Check whether the plugin is loaded.

    npm run mgnl -h
  2. Run the new plugin.

    npm run mgnl <plugin_name> -- -plugin-option option-value (1)
    1 For example, npm run mgnl cli-foo-plugin -s — -n "John".

    The following should be displayed:

    Plugin started
    options { name: 'John' }
    Hello John
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Magnolia CLI docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules