Hybrid to Light Module plugin

A plugin for Magnolia CLI to convert hybrid light modules to light modules that can be modified on the file system.

Package name

@magnolia/cli-hybrid-to-lm-plugin

Repository link

Latest version

Magnolia CLI hybrid to light module plugin - latest version tag

Changelog link

Installing

The plugin doesn’t come pre-installed with Magnolia CLI. You must add it to the mgnl.config.js project file.

The plugin is installed automatically by the Jumpstart plugin if it is defined in a project template.

With add-plugin

Run the following command in the project folder.

npm run mgnl -- add-plugin @magnolia/cli-hybrid-to-lm-plugin

Windows users using PowerShell must enclose the two consecutive hyphens (--) in quotes:

npm run mgnl "--" ...

The command automatically downloads, installs, and registers the plugin in mgnl.config.js.

To confirm that the plugin has been successfully installed, run:

npm run mgnl -- hybrid-to-lm --help

Manually

  1. Run the following command in the project folder.

    npm install @magnolia/cli-hybrid-to-lm-plugin
  2. Modify the mgnl.config.js file accordingly.

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

    npm run mgnl -- hybrid-to-lm --help

Usage

Command

hybrid-to-lm [options]

Options

Form (short and long) Description

-j [name]

--jar-module [name]

Specify the JAR module to extract light modules from.

-l [names…​]

--light-modules [names…​]

Specify the light modules to extract from the JAR. Multiple -l options can be specified to extract multiple modules.

-p [path]

--config-path [path]

Path to a JSON configuration file containing JAR modules and light modules mapping.

-v

--version

Displays the version.

-h

--help

Displays help information.

Configurable Properties in mgnl.config.js

Global Properties

Property

Description

lightModulesPath

The directory where light modules will be created.

lightModule

The selected light module.

Plugin-Specific Properties

Property

Description

configPath

Path to a JSON configuration file containing JAR modules and light modules mapping.

jarModules

The selected JAR modules and light modules mapping (configured in the HybridToLmPlugin constructor).

Examples

In the following examples, assume that the mgnl.config.js file looks like this:

import HybridToLmPlugin from "@magnolia/cli-hybrid-to-lm-plugin";

export default {
  plugins: [
    new HybridToLmPlugin({
      jarModules: {
        'magnolia-password-manager-app': ['password-manager-app'],
        'magnolia-dam-app': ['dam-app-core'],
        'magnolia-graphql-core': ['graphql-core']
      },
      configPath: 'path/to/config.json'
    })
  ]
};

For more information, see Configuring plugins.

Extract a specific light module from a JAR

npm run mgnl -- hybrid-to-lm -j magnolia-dam-app -l dam-app-core

Windows users using PowerShell must enclose the two consecutive hyphens (--) in quotes:

npm run mgnl "--" ...

This command extracts the 'dam-app-core' module from the 'magnolia-dam-app' JAR file.

Extract multiple light modules from a JAR

npm run mgnl -- hybrid-to-lm -j magnolia-graphql-core -l graphql-core graphql-app

This command extracts both 'graphql-core' and 'graphql-app' modules from the 'magnolia-graphql-core' JAR file.

Use a configuration file

npm run mgnl -- hybrid-to-lm -p /path/to/my-config.json

This command uses a configuration file to extract multiple modules from multiple JARs. Example configuration file:

{
  "jarModules": {
    "magnolia-password-manager-app": ["password-manager-app"],
    "magnolia-dam-app": ["dam-app-core"],
    "magnolia-graphql-core": ["graphql-core"]
  }
}

The -p can also be a remote resource via a URL:

npm run mgnl -- hybrid-to-lm -p https://example.com/my-config.json

Handling Existing Light Modules

When a light module already exists, the plugin will prompt you to confirm if you want to overwrite it:

Light module 'password-manager-app' already exists at /path/to/light-modules/password-manager-app. Do you want to overwrite it? (y/N)

You can choose to overwrite the existing module or skip it.

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