Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
Magnolia CLI is an npm package providing a command line interface (CLI) tool to set up and facilitate light development with Magnolia. You can use Magnolia CLI to quickly create a light module skeleton: the folders and files that form a Magnolia light module.
We currently have two versions of the CLI that are maintained. The main difference is how prototypes are handled. If you are a new user, use v3.0. If you are an existing user and want to continue with the same prototype structure as before, use v2.2.0.
This page provides instructions on how to install Magnolia CLI and tracks the changes in Magnolia CLI releases.
If you want to jump straight in, try out our Magnolia CLI walkthrough that provides step-by-step instructions to get everything set up and create a working light module.
Released in February 2018.
-f
(force) option has been removed from the create-light-module
command.jumpstart
jumpstart
command.mgnl-cli.json
lightDevFoldersInModule
property. The folder structure of a light module created with the CLI is defined in the prototypes.webapps
property used to define the list of possible webapps you can choose from from when running the jumpstart
command.The -V
option, which used to display the version information of the installed Magnolia CLI, has been replaced with a more intuitive lower-case variant (-v
). The output now also displays the version of Node.js installed.
Released on 18 January 2018.
-c
(--cloud
) has been added to the jumpstart
command. mgnl jumpstart -c
downloads and sets up a Magnolia Cloud bundle. It requires Enterprise credentials to access the Magnolia Nexus repository.-p
option is set when executing the jumpstart
command, the magnolia.resources.dir
property in the magnolia.properties
file is set to a relative path by default: magnolia.resources.dir=${magnolia.home}/../../../light-modules
When creating a light module with the mgnl create-light-module
command, if you specify a path to a light modules folder that does not match the light modules root folder at the nearest Tomcat installation, you get an error. The error warns you that Magnolia cannot observe your module in the location specified. You can use the -f
option if you want to force the path to an unobserved folder.
mgnl -h
command now also prints out your node.js version, OS and Magnolia CLI version.mgnl create-component
command now generates a component dialog definition yaml file containing label
options (instead of the previously used name
) for i18n compliance. Released on 17 March 2017.
alt
attribute uses the caption
property. NPMCLI-31__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-84tab-completion install
command, if completed successfully, also displays the files (together with their paths) to which the autocompletion script has been appended. NPMCLI-107lib/locales/
). The messages in English are located in the en
subfolder. NPMCLI-91Released on 27 February 2017.
This version contains many improvements and bugfixes. Here is an incomplete list of the new or changed features:
start
for easy start, stop and logging of Magnolia. NPMCLI-58mgnl tab-completion
.setup
command renamed to customize-local-config
command. NPMCLI-101 add-availability
command defaults to main area when no area is specified. NPMCLI-48create-light-module
command generates README files. NPMCLI-62Please note that this video is based on Magnolia CLI 2.0.0 and Magnolia 5.5.1 Community Edition. (The latest release of Magnolia is
.)All pre-2.0.0 versions of Magnolia CLI are considered beta and no official documentation is available for them.
The Magnolia CLI tool runs on Node.js. Make sure you have Node.js version 6.10+ 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
If your node version is below 6.10, install the latest version of the LTS branch (see node.js/download).
The instructions that follow are based on the global npm package installation.
To display a list of released versions of Magnolia CLI, enter the following command in a shell:
npm view @magnolia/cli versions
Besides a version list, the following command shows additional information about the Magnolia CLI package:
npm view @magnolia/cli
To install the latest version (globally), 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
To install a specific version (globally), for example 2.1.0, run the following command in a shell:
npm install @magnolia/cli@2.1.0 -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@2.1.0 -g
The master branch on https://git.magnolia-cms.com/scm/build/npm-cli.git typically contains the version with the latest code. You may alternatively checkout the latest code and simply install it from source. However, please be aware that the official documentation does not cover the functionalities and changes of the unreleased versions.
To install the latest version from the master, do the following after checking out the latest code:
npm pack sudo npm install ~/dev/cli3/npm-cli/magnolia-cli-3.0.0-snapshot.tgz -g
If you have already installed the CLI and want to update to the latest version, use:
npm update @magnolia/cli -g
To test the installation, run the following command in the shell:
mgnl help
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 displays 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
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