Page tree
Skip to end of metadata
Go to start of metadata

Magnolia CLI is an npm package providing a command line interface (CLI) tool to set up and facilitate light development with Magnolia. This page describes how to install, set up and use its commands. 

The commands of the Magnolia CLI package facilitate the creation of a light module skeleton: the folders and files that form a typical Magnolia light module. We assume that you are already familiar with some Magnolia basics of creating light modulestemplates and dialogs.

Installation

Prerequisite: Node.js

The Magnolia CLI tool runs on Node.js. Make sure you have Node.js version 6.0+ installed (node.js may be easily installed via package managers).

To check the version of your node installation run the following command in a shell:

node -v
Node.js provides two branches:

  • LTS - recommended for long term support
  • Current - providing the latest features 

If your node version is below 6.0, install the latest version of the LTS branch (see node.js/download).

Magnolia CLI installation

Best practice

Install Magnolia CLI globally.

  • The configuration is stored globally.
  • The commands are available in the shell on all directories.
  • The global configuration can be overridden on a project level using the  customize-local-config command.
The instructions that follow are based on the global npm package installation.

To install, run the following command in a shell:

npm install @magnolia/cli -g

Depending on your permissions and the Node.js installation location, you may have to execute the above command with root permissions. On Linux or OS-X to run this command as root use:

sudo npm install @magnolia/cli -g

If the installation is successful, the output in the shell should be similar to this: 

 Expand to see the output of an npm installation (v2.1.0 on Ubuntu MATE 16.04.1, nodejs v6.10.0)

/usr/local/bin/mgnl -> /usr/local/lib/node_modules/@magnolia/cli/bin/mgnl.js

> spawn-sync@1.0.15 postinstall /usr/local/lib/node_modules/@magnolia/cli/node_modules/spawn-sync
> node postinstall

/usr/local/lib
└─┬ @magnolia/cli@2.1.0 
  ├─┬ @magnolia/magnolia-build@0.5.3 
  │ ├── fs-extra@0.26.7 
  │ └─┬ path@0.12.7 
  │   ├── process@0.11.9 
  │   └─┬ util@0.10.3 
  │     └── inherits@2.0.1 
  ├── adm-zip@0.4.7 
  ├─┬ async@2.1.5 
  │ └── lodash@4.17.4 
  ├── bluebird@3.5.0 
  ├─┬ chalk@1.1.3 
  │ ├── ansi-styles@2.2.1 
  │ ├── escape-string-regexp@1.0.5 
  │ ├─┬ has-ansi@2.0.0 
  │ │ └── ansi-regex@2.1.1 
  │ ├── strip-ansi@3.0.1 
  │ └── supports-color@2.0.0 
  ├── command-exists@1.2.2 
  ├─┬ commander@2.9.0 
  │ └── graceful-readlink@1.0.1 
  ├── diff@3.2.0 
  ├─┬ findup-sync@0.4.3 
  │ ├─┬ detect-file@0.1.0 
  │ │ └── fs-exists-sync@0.1.0 
  │ ├─┬ is-glob@2.0.1 
  │ │ └── is-extglob@1.0.0 
  │ ├─┬ micromatch@2.3.11 
  │ │ ├─┬ arr-diff@2.0.0 
  │ │ │ └── arr-flatten@1.0.1 
  │ │ ├── array-unique@0.2.1 
  │ │ ├─┬ braces@1.8.5 
  │ │ │ ├─┬ expand-range@1.8.2 
  │ │ │ │ └─┬ fill-range@2.2.3 
  │ │ │ │   ├── is-number@2.1.0 
  │ │ │ │   ├── isobject@2.1.0 
  │ │ │ │   ├── randomatic@1.1.6 
  │ │ │ │   └── repeat-string@1.6.1 
  │ │ │ ├── preserve@0.2.0 
  │ │ │ └── repeat-element@1.1.2 
  │ │ ├─┬ expand-brackets@0.1.5 
  │ │ │ └── is-posix-bracket@0.1.1 
  │ │ ├── extglob@0.3.2 
  │ │ ├── filename-regex@2.0.0 
  │ │ ├─┬ kind-of@3.1.0 
  │ │ │ └── is-buffer@1.1.5 
  │ │ ├── normalize-path@2.0.1 
  │ │ ├─┬ object.omit@2.0.1 
  │ │ │ ├─┬ for-own@0.1.5 
  │ │ │ │ └── for-in@1.0.2 
  │ │ │ └── is-extendable@0.1.1 
  │ │ ├─┬ parse-glob@3.0.4 
  │ │ │ ├─┬ glob-base@0.3.0 
  │ │ │ │ └── glob-parent@2.0.0 
  │ │ │ └── is-dotfile@1.0.2 
  │ │ └─┬ regex-cache@0.4.3 
  │ │   ├── is-equal-shallow@0.1.3 
  │ │   └── is-primitive@2.0.0 
  │ └─┬ resolve-dir@0.1.1 
  │   ├── expand-tilde@1.2.2 
  │   └─┬ global-modules@0.2.3 
  │     ├─┬ global-prefix@0.1.5 
  │     │ ├─┬ homedir-polyfill@1.0.1 
  │     │ │ └── parse-passwd@1.0.0 
  │     │ ├── ini@1.3.4 
  │     │ └─┬ which@1.2.12 
  │     │   └── isexe@1.1.2 
  │     └── is-windows@0.2.0 
  ├─┬ fs-extra@0.30.0 
  │ ├── graceful-fs@4.1.11 
  │ ├── jsonfile@2.4.0 
  │ ├── klaw@1.3.1 
  │ ├── path-is-absolute@1.0.1 
  │ └─┬ rimraf@2.6.1 
  │   └─┬ glob@7.1.1 
  │     ├── fs.realpath@1.0.0 
  │     ├── inflight@1.0.6 
  │     └─┬ minimatch@3.0.3 
  │       └─┬ brace-expansion@1.1.6 
  │         ├── balanced-match@0.4.2 
  │         └── concat-map@0.0.1 
  ├── http@0.0.0 
  ├── i18next@7.1.2 
  ├─┬ i18next-sync-fs-backend@0.1.0 
  │ └── json5@0.4.0 
  ├─┬ inquirer@1.2.3 
  │ ├── ansi-escapes@1.4.0 
  │ ├─┬ cli-cursor@1.0.2 
  │ │ └─┬ restore-cursor@1.0.1 
  │ │   ├── exit-hook@1.1.1 
  │ │   └── onetime@1.1.0 
  │ ├── cli-width@2.1.0 
  │ ├─┬ external-editor@1.1.1 
  │ │ ├─┬ spawn-sync@1.0.15 
  │ │ │ └── os-shim@0.1.3 
  │ │ └── tmp@0.0.29 
  │ ├─┬ figures@1.7.0 
  │ │ └── object-assign@4.1.1 
  │ ├── mute-stream@0.0.6 
  │ ├─┬ pinkie-promise@2.0.1 
  │ │ └── pinkie@2.0.4 
  │ ├─┬ run-async@2.3.0 
  │ │ └── is-promise@2.1.0 
  │ ├── rx@4.1.0 
  │ ├─┬ string-width@1.0.2 
  │ │ ├── code-point-at@1.1.0 
  │ │ └─┬ is-fullwidth-code-point@1.0.0 
  │ │   └── number-is-nan@1.0.1 
  │ └── through@2.3.8 
  ├─┬ json2yaml@1.1.0 
  │ └── remedial@1.0.7 
  ├─┬ npm-registry-client@7.5.0 
  │ ├─┬ concat-stream@1.6.0 
  │ │ ├─┬ readable-stream@2.2.6 
  │ │ │ ├── buffer-shims@1.0.0 
  │ │ │ ├── core-util-is@1.0.2 
  │ │ │ ├── isarray@1.0.0 
  │ │ │ ├── process-nextick-args@1.0.7 
  │ │ │ ├── string_decoder@0.10.31 
  │ │ │ └── util-deprecate@1.0.2 
  │ │ └── typedarray@0.0.6 
  │ ├─┬ normalize-package-data@2.3.6 
  │ │ ├── hosted-git-info@2.4.1 
  │ │ ├─┬ is-builtin-module@1.0.0 
  │ │ │ └── builtin-modules@1.1.1 
  │ │ └─┬ validate-npm-package-license@3.0.1 
  │ │   ├─┬ spdx-correct@1.0.2 
  │ │   │ └── spdx-license-ids@1.2.2 
  │ │   └── spdx-expression-parse@1.0.4 
  │ ├── npm-package-arg@4.2.1 
  │ ├─┬ once@1.4.0 
  │ │ └── wrappy@1.0.2 
  │ ├── retry@0.10.1 
  │ └── slide@1.1.6 
  ├─┬ npmlog@4.0.2 
  │ ├─┬ are-we-there-yet@1.1.2 
  │ │ └── delegates@1.0.0 
  │ ├── console-control-strings@1.1.0 
  │ ├─┬ gauge@2.7.3 
  │ │ ├── aproba@1.1.1 
  │ │ ├── has-unicode@2.0.1 
  │ │ ├── signal-exit@3.0.2 
  │ │ └── wide-align@1.1.0 
  │ └── set-blocking@2.0.0 
  ├─┬ osenv@0.1.4 
  │ ├── os-homedir@1.0.2 
  │ └── os-tmpdir@1.0.2 
  ├── progress@1.1.8 
  ├─┬ request@2.81.0 
  │ ├── aws-sign2@0.6.0 
  │ ├── aws4@1.6.0 
  │ ├── caseless@0.12.0 
  │ ├─┬ combined-stream@1.0.5 
  │ │ └── delayed-stream@1.0.0 
  │ ├── extend@3.0.0 
  │ ├── forever-agent@0.6.1 
  │ ├─┬ form-data@2.1.2 
  │ │ └── asynckit@0.4.0 
  │ ├─┬ har-validator@4.2.1 
  │ │ ├─┬ ajv@4.11.5 
  │ │ │ ├── co@4.6.0 
  │ │ │ └─┬ json-stable-stringify@1.0.1 
  │ │ │   └── jsonify@0.0.0 
  │ │ └── har-schema@1.0.5 
  │ ├─┬ hawk@3.1.3 
  │ │ ├── boom@2.10.1 
  │ │ ├── cryptiles@2.0.5 
  │ │ ├── hoek@2.16.3 
  │ │ └── sntp@1.0.9 
  │ ├─┬ http-signature@1.1.1 
  │ │ ├── assert-plus@0.2.0 
  │ │ ├─┬ jsprim@1.4.0 
  │ │ │ ├── assert-plus@1.0.0 
  │ │ │ ├── extsprintf@1.0.2 
  │ │ │ ├── json-schema@0.2.3 
  │ │ │ └── verror@1.3.6 
  │ │ └─┬ sshpk@1.11.0 
  │ │   ├── asn1@0.2.3 
  │ │   ├── assert-plus@1.0.0 
  │ │   ├── bcrypt-pbkdf@1.0.1 
  │ │   ├─┬ dashdash@1.14.1 
  │ │   │ └── assert-plus@1.0.0 
  │ │   ├── ecc-jsbn@0.1.1 
  │ │   ├─┬ getpass@0.1.6 
  │ │   │ └── assert-plus@1.0.0 
  │ │   ├── jodid25519@1.0.2 
  │ │   ├── jsbn@0.1.1 
  │ │   └── tweetnacl@0.14.5 
  │ ├── is-typedarray@1.0.0 
  │ ├── isstream@0.1.2 
  │ ├── json-stringify-safe@5.0.1 
  │ ├─┬ mime-types@2.1.14 
  │ │ └── mime-db@1.26.0 
  │ ├── oauth-sign@0.8.2 
  │ ├── performance-now@0.2.0 
  │ ├── qs@6.4.0 
  │ ├── safe-buffer@5.0.1 
  │ ├── stringstream@0.0.5 
  │ ├─┬ tough-cookie@2.3.2 
  │ │ └── punycode@1.4.1 
  │ ├── tunnel-agent@0.6.0 
  │ └── uuid@3.0.1 
  ├── semver@5.3.0 
  ├─┬ tar@2.2.1 
  │ ├── block-stream@0.0.9 
  │ ├─┬ fstream@1.0.11 
  │ │ └─┬ mkdirp@0.5.1 
  │ │   └── minimist@0.0.8 
  │ └── inherits@2.0.3 
  └── yaml-js@0.1.4

Magnolia CLI update

If you have already installed the CLI and want to update to the latest version, use:

npm update @magnolia/cli -g

Test the installation

To test the installation, run the following command in the shell:

mgnl help 

 Expand to show the output of mgnl help (v2.1.0)
Usage: mgnl <command> [options]


  Commands:

    jumpstart                download and setup a Magnolia CMS instance for development.
    start                    start up a Magnolia CMS instance. To stop it, enter CTRL+C
    add-availability         add component availability.
    build                    scan a node_modules folder for npm packages with the keyword "magnolia-light-module" (in package.json) and extract them to a directory of choice.
    create-component         create a component and optionally add availability for it.
    create-light-module      create a light module.
    create-page              create a page template.
    customize-local-config   extract "mgnl-cli-prototypes" folder and "mgnl-cli.json" file to customize CLI configuration.
    install                  install a light module from npm to the local Magnolia instance.
    search                   search a light module.
    tab-completion           install tab autocomplete feature for Bash, zsh or PowerShell
    help [cmd]               display help for [cmd]

  A tool to setup and facilitate light development with Magnolia CMS

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

  

Shell autocompletion

The Magnolia CLI package provides autocompletion for bash, C-shell and Windows PowerShell

To install/enable autocompletion, use:

mgnl tab-completion install

To uninstall it, use:

mgnl tab-completion uninstall

A successful installation of autocompletion will display a list of files to which the tab-completion script has been appended.

To test the autocompletion installation type mgnl and then successively hit the Tab key to scroll through the available commands.

On Windows autocompletion is only available in PowerShell. If it does not work as expected after installation you may have to change your execution policy. To do this, in PowerShell run as Administrator:

Set-ExecutionPolicy RemoteSigned

Uninstallation of old autocompletion source

If you have already used autocompletion with Magnolia CLI version below 2.0, you may want to uninstall the "old" autocompletion manually. To do so, remove the following line in your bash settings (in ~/.profile or ~/.bashrc):

source /usr/local/lib/node_modules/@magnolia/cli/extra/mgnl-autocompletion.sh

Configuration

Magnolia CLI is configured in these files/folders:

Files

mgnl‑cli‑prototypes/A folder which contains the prototypes for template and dialog definitions and the README file. For further details see Magnolia CLI prototypes.
mgnl‑cli.json

The configuration file defining the folders of the light module skeleton and some other things.

When a CLI command is executed, the system searches for the JSON configuration. 

Do not modify the package.json of your global installation, consider creating one local package.json for each project instead.

Global and local configurations

  • Use the -h option to show the location of the configuration files corresponding to the location where you run the command. Using this option also shows the general help text. The command itself is not executed.
  • You can use the placeholders __name__ and __lightDevModuleFolder__ in all prototypes files for page and component templates (in mgnl-cli-prototypes/page/* and mgnl-cli-prototypes/component). 

Global

The global configuration is created during the global installation of the Magnolia CLI package. On Linux or OS-X the global configuration files are typically located in the /usr/local/lib/node_modules/@magnolia/cli folder.

The CLI commands use the global configuration if no local configuration is found in the current directory or in its parent folders.

Local

For different projects you can create various local configurations with the  customize-local-config  command. This command creates local configuration files in the /wherever/you-have/executed/the-customize-local-config-command folder.

The local configuration is created as a copy of the current configuration (used during execution of the customize-local-config command), which you can edit to define project specific prototypes or dependencies.

When executing commands from within the local configuration folders or subfolders, the local configuration is used.

You cannot mix global and local configurations. When adding a local configuration it must be complete: it must contain the mgnl-cli.json file and the complete mgnl-cli-prototypes folder.

If Magnolia CLI finds the mgnl-cli.json file in the current or a parent directory, it expects to find the complete mgnl-cli-prototypes as well.

mgnl-cli.json 

This JSON file contains basic configurations which are used when running the Magnolia CLI commands. Here is a partial list of the properties which you might want to edit:

propertymeaningused by
downloadUrl

The URL used to download the bundle.

We do not recommend editing this property.

command jumpstart
downloadJars

A map of artifacts to be added to the WEB-INF/lib directory.

command jumpstart
tomcatFolderThe name of the folder where the Magnolia bundled with Tomcat is installed during the execution of the jumpstart command.command jumpstart

magnoliaAuthor,

magnoliaPublic

If set these properties override the same properties in the magnolia.properties file by overwriting them there.

Note that you cannot set the magnolia.resources.dir property since Magnolia CLI overrides it.

The properties are used to update the magnolia.properties files (on both public and author) when executing the jumpstart command.

command jumpstart
lightDevFoldersInModuleThe folders which are created for a light module.command create-light-module
 Click here to expand to see the source of mgnl-cli.json

mgnl-cli.json
 {
  "setupMagnolia": {
    "downloadUrl": "https://nexus.magnolia-cms.com/service/local/artifact/maven/content?r=magnolia.public.releases&g=info.magnolia.bundle&a=magnolia-community-demo-bundle&c=tomcat-bundle&e=zip&v=${magnoliaVersion}",
    "tomcatFolder": "apache-tomcat",
    "webapps": {
      "magnoliaAuthor": {
        "magnolia.develop": true,
        "magnolia.update.auto": true
      },
      "magnoliaPublic": {
        "magnolia.update.auto": true
      }
    },
    "downloadJars": {}
  },
  "lightDevFoldersInModule": {
    "dialogs_components": "/dialogs/components",
    "dialogs_pages": "/dialogs/pages",
    "templates_components": "/templates/components",
    "templates_pages": "/templates/pages",
    "webresources": "webresources",
    "decorations": "decorations",
    "i18n": "i18n"
  }
}

This version of mgnl.json may not include all parameters described below.

outputPath
The name of the folder used for the magnolia.resources.dir property. The folder is created when you execute the jumpstart command.command   jumpstart

Prototypes

When executing either the create-page or the create-component command, new files are created from the prototype files. These prototype files are located in the  mgnl-cli-prototypes  folder. 

<configuration>/mgnl-cli-prototypes/
├── README.md.tpl
├── component
│   ├── definition.yaml
│   ├── dialog.yaml
│   └── template.ftl
└── page
    ├── definition.yaml
    ├── dialog.yaml
    └── template.ftl

Commands

Add the -h option to any Magnolia CLI command to display a help line showing all the options available for the command. The command itself is not executed in this case.

help

Run the help command to list all the available commands of the Magnolia CLI package.

Usage

mgnl help [<command>]

Parameter

<command>

optional

Shows basic help for the <command> specified as the option.

Without the option, a list of available CLI commands will be displayed (same as entering mgnl -h ).

tab-completion

Run the command to install or uninstall autocompletion for Magnolia CLI commands. 

Usage

mgnl tab-completion <command>

Sub commands

installInstalls the required files for autocompletion.
uninstallRemoves the files which were previously installed during installation

Examples

mgnl tab-completion install
A successful installation will display a list of files to which the tab-completion script has been appended.

customize-local-config

Run this command to create a local configuration. It installs the files for the local configuration within the current directory, or within the directory defined by the optional -p <path> parameter.

Usage

mgnl customize-local-config [options]

Parameters

-p <path>

optional

The path into which the mgnl-cli-prototypes folder and mgnl-cli.json file are installed.

Example

mgnl customize-local-config -p ~/dev/mgnl/light-modules/

jumpstart

This command downloads, unpacks and pre-configures a Magnolia Tomcat bundle.  It creates folders for the Tomcat server and for the light modules according to the Magnolia CLI Configuration

By default the command downloads the latest released version of the magnolia-community-demo-bundle. Use the -e  parameter to get the EE Pro demo bundle (magnolia-enterprise-pro-demo-bundle) instead. These bundles contain the Magnolia Travel Demo. Chose a specific version by providing the -m parameter.

The jumpstart command installs the bundle within the current directory.

You may remove the magnolia.zip file once the installation is complete.

Usage

mgnl jumpstart [options]

Parameters

-p <path>

optional

The -p option for the jumpstart command specifies the path to the light modules root folder which is observed for changes, not to an alternative location for the bundle to be installed.

If no path is provided, the a default folder named light-modules is created in the current folder. Light modules are then created under this folder which is observed by Magnolia for changes.

The path to the light modules root folder is set by the magnolia.resources.dir  property in the magnolia.properties file of the installed Magnolia bundle.

-m <version>

optional

The desired version of the Magnolia bundle. If not provided, defaults to the latest version of the chosen bundle (magnolia-community-demo-bundle or magnolia-enterprise-pro-demo-bundle).

-i <name>

optional

If provided, a sample light module under the light modules root folder with the given name is created.

-e

optional (since 1.0.5)

Will download a magnolia-enterprise-pro-demo-bundle. Requires credentials to Magnolia Nexus.

Example


mgnl jumpstart -e -m 5.4.5

When running the jumpstart command, make sure that a magnolia.zip file does not already exist in the directory in which you are running the command. The zip file prevents the command from downloading another version and simply installs from the existing file.

See NPMCLI-100 - Getting issue details... STATUS

start

This command starts up Magnolia and displays the main log file (apache-tomcat/logs/catalina.out). Magnolia CLI looks in the current working directory or parent directories for the nearest folder with a name that starts with "apache-tomcat". To stop Magnolia, simply use CTRL+C. 

Usage

mgnl start [options]

Parameters

-p <path>

optional

The path to the apache-tomcat folder. If no path is provided, Magnolia CLI will look in the current working directory or in the parent directories for the nearest folder with a name that starts with "apache-tomcat".

-d

optional

Does NOT ignore the open files limit check. The files limit check is ignored by default. See Too many open files for more.

Example 

mgnl start -p C:/magnolia-installations/magnolia-5.5.1/apache-tomcat-8.5.5

create-light-module

This command creates a new light module in the form of a set of empty light module folders and the following two files:

  • README.md , in the root folder of the module.
  • <moduleName>-messages_en.properties , in the i18n folder this command creates.

The name of the light module should be provided as a parameter when calling the command. The light module is created in the current directory or in the directory specified with the optional -p <path> parameter.

Usage

mgnl create-light-module [<moduleName>] [options]

Parameters

<moduleName>

optional (but recommended)

The name of the new light module.

Avoid spaces and special characters since this name is used as folder name.

If no <moduleName> is given, the name of the actual directory will be used as the module's name. This can be useful in case the folder for the light module already exists.

-p <path>

optional

The path of the parent directory for the new light module. If omitted, the new light module is created within the current folder.

Examples

mgnl create-light-module my-module
mgnl create-light-module my-module -p ../../light-modules/
 Expand to see the created directory tree

my-module/
├── README.md
├── decorations
├── dialogs
│   ├── components
│   └── pages
├── i18n
│   └── my-module-messages_en.properties
├── templates
│   ├── components
│   └── pages
└── webresources
    ├── css
    └── js


create-page

This command creates a new page template including:

  • A template definition YAML file.
  • A freemarker template script.
  • A YAML dialog definition file. 

The command succeeds only if the current directory (or the directory defined by the optional  -p <path> parameter) is a light module with a minimal folder structure. The files which are created when executing this command are built from the files in the  mgnl-cli-prototypes  folder of your configuration. The files contain some standard code with some commonly used properties. This is generally a good starting point to build a page template.

Usage

mgnl create-page <templateName> [options]

Parameters

<templateName>

required

The name of the new page template. The template name cannot contain spaces.

-p <path>

optional

The path to the light module to add the new template to.

If the parameter is omitted, the command must be run within an existing light module folder.

Example

mgnl create-page my-page

If you do not use the -p <path> parameter, you must run the command from an existing light module folder.

 Expand to see the output of the command in the shell

INFO: No path option provided, page template will be created in the current folder.
DONE: Page template created
INFO: /Users/jdoe/dev/mgnl/light-modules/my-module/templates/pages/my-page.yaml created
INFO: /Users/jdoe/dev/mgnl/light-modules/my-module/templates/pages/my-page.ftl created
INFO: /Users/jdoe/dev/mgnl/light-modules/my-module/dialogs/pages/my-page.yaml created

add-availability

This command makes a component available to a page by:

  • Adding or updating the page template definition to enable the component for an area.
  • Adding the cms:area directive to the template script (if it is not already there).

The command only succeeds if the current directory (or the directory defined by the -p <path> parameter) is a light module with a minimal folder structure and if the page specified by the second argument exists.

Usage

mgnl add-availability  <[module-id:]path-to-component>  <path-to-page[@area]> [options]

Parameters

<[module‑id:]path‑to‑component>

required

The component you want to make available.

Must at least contain the path to a component.

Can optionally start with the module identifier [module‑id:] . If the module identifier is not used, Magnolia CLI assumes the component belongs to the current light module or to the light module specified by the -p <path> option.

Magnolia CLI does not check the existence of the specified component.

<path‑to‑page[@area]>

required

The page you want to make the component available to.

The parameter starts with the path to the page template within the templates directory and it must end with an area name [@area] . If the area does not exist yet, the command adds an area to both the template script and the template definition.

If no area is specified, the command defaults to main area (if it exists) or creates main area (if it does not).

-p <path>

optional

The path to the light module that contains the page template.

If the parameter is omitted, the command must be run in an existing light module folder.

-gAdd this parameter to autogenerate the component instead of providing plain availability.

Examples

This example makes a component from the mtk module available to the page named my-page in the area named main:

mgnl add-availability mtk:components/textImage pages/my-page@main
This example makes the component my-component available to the page my-page. Both the component and the page are part of the light module located at /Users/jdoe/dev/mgnl/light-modules/my-module/:
mgnl add-availability components/my-component pages/my-page@main -p /Users/jdoe/dev/mgnl/light-modules/my-module/

create-component

This command creates a new component template including:

  • A template definition YAML file.
  • A freemarker template script.
  • A YAML dialog definition file. 

Optionally, the component can be made available to a page using the -a option (internally calling the the  add-availability  command).

The command succeeds only if the current directory (or the directory defined by the -p option) is a light module with a minimal folder structure.

The files which are created while executing this command are based on the files in the  mgnl-cli-prototypes  folder of your configuration. The files contain some standard code with some commonly used properties. This is generally a good starting point to build a component template.

Usage

mgnl create-component <name> [options]

<name>

required

The name of the new component template. The name cannot contain spaces.

-p <path>

optional

The path to the light module you want to add the component template to.

If the parameter is omitted, the command must be run within an existing light module folder.

-a <path‑to‑page[@area]>

optional

The page you want to make the component available to. When you specify this option, add-availability is called after the creation of component to make it available in a page area.

The parameter must start with the path to the page template within the templates directory and it must end with an area name. If the area does not exist yet, the command adds an area to both the template script and the template definition. If no area is specified, the command defaults to main area (if it exists) or creates main area (if it does not).

-g  <path‑to‑page[@area]>

optional

Add this parameter to autogenerate the component   instead of providing plain availability. As for the -a option the target area and page must be specified.

Example


mgnl create-component my-component -a pages/my-page@footer -p /Users/johndoe/dev/mgnl/light-modules/my-module/


Searches for Magnolia-related packages available from npm and returns their list together with the following information:

  • Package name.
  • Date and version of the latest commit.
  • Brief description of the package.
  • Contributor's username.

Usage

mgnl search [<query>]

Parameters

<query>

optional

The search query sent to the npm's API (see https://api-docs.npms.io).

By default the command sends keywords:magnolia-light-module with every search instance to make the search results more relevant to Magnolia light modules.

Example

mgnl search language-switcher

info 1 result found
info 
info 1) language-switcher-magnolia
info     2017-02-25 1.0.5
info     Language Switcher - Component template for Magnolia CMS
info     magnolia

install


Downloads and installs one or more light modules from npm to the light module directory.

Usage

mgnl install <light-module-name> [options]

Parameters

<light-module-name>

required

At least one name of a light module to be downloaded from npm. If installing more than one module from the repository, separate the module names with a space.

-p <path>

optional

The path to the light-modules folder.

If omitted, mgnl is searching for the nearest apache-tomcat* folder and checks the value of the magnolia.resources.dir property as defined within the webapps of the folder.

Example

mgnl install google-maps-magnolia mgnl-bobby -p /Users/johndoe/dev/mgnl/light-modules/other-users-modules/

Appendix

Light module minimal folder structure

The following is the minimal folder structure to be recognized by the Magnolia CLI as a Magnolia light module.

<module-name>/
└── templates/
    ├── components/
    └── pages/
If one of these folders is missing, Magnolia CLI refuses to execute create-pagecreate-component and add-availability.

Differences between v2.1.0 and the CLI teaser video

The Magnolia CLI is under continuous development. Since the video at the top of the page was created there have been subtle enhancements. Note the following differences:

  1. [time: 5:37]
    In 2.1.0 the output of the mgnl create-component list -a pages/demo-page command adds a seventh field to cli-demo/dialogs/components/list.yaml :

    - name: caption
       class: info.magnolia.ui.form.field.definition.TextFieldDefinition
       label: Image Caption

  2. [time: 5:59]
    The video has a static value in the alt attribute of the img element in cli-demo/templates/components/list.ftl :

    <img src='${imageLink!}' class='img-responsive' alt='image'>

    compared to the dynamically generated value in v2.1.0:

    <img src='${imageLink!}' class='img-responsive' alt='${content.caption!"image"}'>
  3. [time: 7:43]
    The output of the mgnl -help command is different in v2.1.0.

Release history

2.1.0

What has changed?

  • Two new commands have been added:
    • search - helps find light modules on npm. NPMCLI-99
    • install - installs a light module from the registry into your light modules folder. NPMCLI-98
  • In the prototype dialog template, the image alt attribute uses the caption property. NPMCLI-31
  • The placeholder __lightDevModuleFolder__ for the name of the corresponding light module can be used in all prototypes files for page and component templates (in mgnl-cli-prototypes/page/* and mgnl-cli-prototypes/component). NPMCLI-84
  • The tab-completion install command, if completed successfully,  will also display the files (together with their paths) to which the autocompletion script has been appended. NPMCLI-107
  • All CLI i18n messages are served from a single location ( lib/locales/ ). The messages in English are located in the en subfolder. NPMCLI-91
  • This release also fixes a few bugfixes. A complete list of the issues which have been resolved in version 2.1.0 is available via the following link:
 Click here to see the list of issues resolved in version 2.1.0

Key Summary T Created Status
Loading...
Refresh

2.0

What has changed?

Version 2.0 of the Magnolia CLI contains many improvements and bugfixes. Here is an incomplete list of the new or changed features:

  • New command start for easy start, stop and logging of Magnolia. NPMCLI-58
  • Improved autocompletion: (NPMCLI-69)
    • Can be enabled and disabled with the new command mgnl tab-completion.
    • Is now available not only for bash, but also for C-shell and Windows PowerShell
    • Knows more things to autocomplete.
    • (warning) If you were using autocompletion in a Magnolia CLI version below 2.0, you may want to uninstall autocomplete version 1.
  • User experience enhanced by:
    • Improved error and crash handling.
    • Instructions on how to continue when a command is successfully executed.
  • setup command renamed to customize-local-config command. NPMCLI-101 
  • add-availability command defaults to main area when no area is specified. NPMCLI-48
  • create-light-module command generates README files. NPMCLI-62
  • Node v 6.0+ is required to run the CLI.
 Click here for a complete list of the issues which have been resolved in version 2.0

Key Summary T Created Status
Loading...
Refresh