Create Light Module plugin
A plugin to create a new light module. It creates the light module as a set of folders (mostly empty) and the following two files:
-
README.md
, in the root folder of the module. -
<moduleName>-messages_en.properties
, in thei18n
folder.
Package name |
|
Repository link |
|
Latest version |
|
Changelog link |
|
Prototypes available |
|
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. |
Usage
Options
Form (short and long) | Description | ||
---|---|---|---|
|
Create specific directories within the light module. Example: Mappings available:
|
||
|
Sets the directory path for the new light module.
By default, uses the directory specified in the |
||
|
Allows you to use the path to the custom prototype templates directory as the prototype source for light module creation.
|
||
|
Selects a light module prototype.
|
||
|
Displays the version. |
||
|
Displays help information. |
Examples
In the following examples, assume that the mgnl.config.js
file looks like this:
import CreateLightModulePlugin from "@magnolia/cli-create-light-module-plugin";
export default {
plugins: [
new CreateLightModulePlugin()
]
};
For more information, see Configuring plugins.
Create light module
npm run mgnl -- create-light-module "my-lm"
This command creates a new light module directory called my-lm
based on the _default
prototype.
The plugin will prompt you to choose a directory where the new light module will be created.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
lightModule
-
Create a light module in a specific light modules directory
npm run mgnl -- create-light-module "my-lm" --light-modules-path "./magnolia/light-modules"
This command creates a new light module directory called my-lm
based on the _default
prototype.
If the ./magnolia/light-modules
doesn’t exist, the plugin will prompt you to choose another directory where the new light module will be created.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
lightModule
-
Create a light module with specific directories
npm run mgnl -- create-light-module "my-lm" --directories A D
This command creates a new light module directory called my-lm
with the apps
and decorations
directories.
The plugin will prompt you to choose a directory where the new light module will be created.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
lightModule
-
If the my-lm light module already exists, it will add the apps and decorations directories there (if not present yet).
|
Create a light module based on a prototype from a custom prototypes directory
npm run mgnl -- create-light-module "my-lm" --prototype-dir "/path/to/custom-prototypes-dir/light-module"
This command creates a new light module directory called my-lm
based on the _default
prototype from /path/to/custom-prototypes-dir/light-module
.
The plugin will prompt you to choose a directory where the new light module will be created.
If the _default
prototype is not present in the custom prototypes directory, it will prompt you to choose another prototype.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
lightModule
-
-
Plugin
-
prototypeDir
-
prototype
-
Example structure of the custom prototypes directory:
To use the custom
|
Create a light module based on a specific prototype
npm run mgnl -- create-light-module "my-lm" --prototype "comprehensive"
This command creates a new light module directory called my-lm
based on the comprehensive
prototype.
The plugin will prompt you to choose a directory where the new light module will be created.
The Create Light Module Plugin contains the To choose a custom prototype from a custom prototypes directory, use It can’t be used with the |
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
lightModule
-
Configuration
You can set the following properties in mgnl.config.js
to predefine the plugin’s behavior.
Global properties
Property name | Description |
---|---|
|
The path to the directory containing all light modules. Alternative forms: |
Plugin properties
Property name | Description |
---|---|
|
The path to a custom prototypes directory. Alternative forms: |
|
The name of a prototype. Alternative forms: |
For more information, see Configuring plugins.