@magnolia/cli-hybrid-to-lm-plugin v0.1.0-preview
HybridToLmPlugin
A plugin for Magnolia CLI to convert hybrid light modules to light modules that can be modified on the file system.
Installation
Using add-plugin
Run the following command in the project's root directory:
npm run mgnl -- add-plugin @magnolia/cli-hybrid-to-lm-pluginThe command will install the plugin, and automatically register the plugin in
mgnl.config.jsfile:import HybridToLmPlugin from "@magnolia/cli-hybrid-to-lm-plugin"; export default { plugins: [ new HybridToLmPlugin() ] };To confirm that the plugin has been successfully installed, run:
npm run mgnl -- hybrid-to-lm --help
Manually
- Run the following command in the project's root directory:
npm install @magnolia/cli-hybrid-to-lm-plugin Manually add HybridToLmPlugin to mgnl.config.js file:
import HybridToLmPlugin from "@magnolia/cli-hybrid-to-lm-plugin"; export default { plugins: [ new HybridToLmPlugin() ] };To confirm that the plugin has been successfully installed, run:
npm run mgnl -- hybrid-to-lm --help
Usage
Options
| Short | 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 module | ||
-p [path] | --config-path [path] | Path to a JSON configuration file containing JAR modules and light modules mapping | ||
| <!-- | -a [auth] | --auth [username[:password]] | Authentication credentials for remote config URLs. If password is omitted, you will be prompted for it | --> |
-v | --version | Output the version number | ||
-h | --help | Display help for command |
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 | ||
jarModule | The selected JAR modules and light modules mapping (same as seen below in the HybridToLmPlugin constructor) | ||
| <!-- | auth | Authentication credentials in the format username:password for remote config URLs. If only username is provided, you will be prompted for the password | --> |
The plugin can be configured through a JSON configuration file or directly in the constructor:
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: 'https://example.com/config.json',
// auth: 'username:password' // Auth is currently unsupported
})
]
};Examples
Extract a specific light module from a JAR
npm run mgnl -- hybrid-to-lm -j magnolia-dam-app -l dam-app-coreThis 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-appThis command extracts both 'graphql-core' and 'graphql-app' modules from the 'magnolia-graphql-core' JAR file.
Use a remote configuration file with authentication
npm run mgnl -- hybrid-to-lm -p https://example.com/config.jsonThis command will load the configuration from the remote URL.
npm run mgnl -- hybrid-to-lm -p https://example.com/config.jsonThis command will load the configuration from the remote URL.
Use a configuration file
npm run mgnl -- hybrid-to-lm -p /path/to/my-config.jsonThis 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.jsonHandling 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.
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
6 months ago