0.1.0-preview • Published 6 months ago

@magnolia/cli-hybrid-to-lm-plugin v0.1.0-preview

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

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

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

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

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

    import HybridToLmPlugin from "@magnolia/cli-hybrid-to-lm-plugin";
    
    export default {
      plugins: [
        new HybridToLmPlugin()
      ]
    };
  2. 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's root directory:
    npm install @magnolia/cli-hybrid-to-lm-plugin
  2. Manually add HybridToLmPlugin to mgnl.config.js file:

    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

Options

ShortLongDescription
-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--versionOutput the version number
-h--helpDisplay help for command

Configurable Properties in mgnl.config.js

Global Properties

PropertyDescription
lightModulesPathThe directory where light modules will be created
lightModuleThe selected light module

Plugin-Specific Properties

PropertyDescription
configPathPath to a JSON configuration file containing JAR modules and light modules mapping
jarModuleThe selected JAR modules and light modules mapping (same as seen below in the HybridToLmPlugin constructor)
<!--authAuthentication 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-core

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 remote configuration file with authentication

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

This command will load the configuration from the remote URL.

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

This command will load the configuration from the remote URL.

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.

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