1.0.0 • Published 9 months ago

@magnolia/cli-create-virtual-uri-plugin v1.0.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
9 months ago

CreateVirtualUriPlugin

A plugin for Magnolia CLI to create a virtual URI mapping in a light module

Installation

Using add-plugin

  1. Run the following command in the project's root directory:

    npm run mgnl -- add-plugin @magnolia/cli-create-virtual-uri-plugin

    The command will install the plugin, and automatically register the plugin in mgnl.config.js file:

    import CreateVirtualUriPlugin from "@magnolia/cli-create-virtual-uri-plugin";
    
    export default {
      plugins: [
        new CreateVirtualUriPlugin()
      ]
    };
  2. To confirm that the plugin has been successfully installed, run:

    npm run mgnl -- create-virtual-uri --help

Manually

  1. Run the following command in the project's root directory:
    npm install @magnolia/cli-create-virtual-uri-plugin
  2. Manually add CreateVirtualUriPlugin to mgnl.config.js file:

    import CreateVirtualUriPlugin from "@magnolia/cli-create-virtual-uri-plugin";
    
    export default {
      plugins: [
        new CreateVirtualUriPlugin()
      ]
    };
  3. To confirm that the plugin has been successfully installed, run:

    npm run mgnl -- create-virtual-uri --help

Usage

Options

ShortLongDescription
-f <uri>--from <uri>set the pattern to match in the requested URI; defaults to an empty string
-t <prefix:uri>--to <prefix:uri>map the request to a concrete URI; following action prefixes are supported: 'redirect:', 'permanent:' and 'forward:'; defaults to an empty string
-lm [name]--light-module [name]set the light module for the virtual URI mapping; defaults to the directory specified in mgnl.config.js file
-pd <path>--prototype-dir <path>use the specified path to the custom prototype templates directory as the prototype source for virtual URI mapping creation
-p [name]--prototype [name]select a prototype for virtual-uri creation
-v--versionoutput the version number
-h--helpdisplay help for command

Examples

Create virtual URI

npm run mgnl -- create-virtual-uri "myFooMapping"

This commands creates a new virtual URI file called "myFooMapping" based on "_default" prototype. If neither the lightModulesPath nor the lightModule property exists in mgnl.config.js, the plugin will prompt you to choose each.

Create virtual URI with defined "fromUri" parameter

npm run mgnl -- create-virtual-uri "myFooMapping" --from "/foo"

This commands creates a new virtual URI file called "myFooMapping" based on "_default" prototype, with fromUri set to /foo. If neither the lightModulesPath nor the lightModule property exists in mgnl.config.js, the plugin will prompt you to choose each.

Create virtual URI with defined "toUri" and "fromUri" parameters

npm run mgnl -- create-virtual-uri "myFooMapping" --from "/foo" --to "forward:/bar"

This commands creates a new virtual URI file called "myFooMapping" based on "_default" prototype, with fromUri set to /foo and toUri set to forward:/bar. If neither the lightModulesPath nor the lightModule property exists in mgnl.config.js, the plugin will prompt you to choose each.

Plugin Documentation

For detailed documentation of the plugin, please refer to Plugin Documentation

Magnolia CMS

This plugin is created to work with Magnolia CMS. For more information, please refer to Magnolia CMS Documentation