Magnolia CLI introduction
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. This page provides instructions on how to install Magnolia CLI.
We currently support three major versions of CLI. The main difference is how prototypes are handled and which Magnolia UI framework they are compatible with. If you are a new user, use CLI v4.
-
Magnolia CLI v4 - Default prototypes are based on the Magnolia 6 UI framework. The
createcommands generate Magnolia 6 UI definitions. The legacy 5 UI prototypes are present as well, but are marked with-m5. You can generate the 5 UI definitions by using the-Por--prototypecommand flag and specifying one of them5prototypes available. -
Magnolia CLI v3 - Only 5 UI prototypes are present, and existing CLI v2 configurations and prototypes need to be migrated, see Updating CLI to v3.
-
Magnolia CLI v2 - Only 5 UI prototypes are present.
Light module minimal folder structure
Some Magnolia CLI commands may require that a minimal light module skeleton exists. For example, to run the create-app command, at least the following folder structure is expected to have been created:
<module-name>/
└── templates
├── components
└── pages
Installing Magnolia CLI
Prerequisites
Node.js
The Magnolia CLI tool runs on Node.js. To check the version of your node.js 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
Make sure you are running the latest version of the LTS branch. You can get it from Node.js downloads. It may also be installed via package managers.
Get Java
Magnolia needs at least a Java Runtime Environment (JRE) to run.
Check if there’s a version of Java already installed on your computer by opening the terminal or command prompt and typing java -version.
If the system reports a version number, Java is installed on your computer.
| See Certified stack page to confirm that the version installed is supported. |
On Windows, you need a Java SE Development Kit (JDK). The Java Runtime Environment (JRE) is not enough because the Tomcat application server does not recognize it.
-
JRE is for users who run Java programs on their computers.
-
JDK is for developers who write Java-based applications.
Download and install JDK.
By default, JDK is installed at C:\Program Files\Java\jdk-<version>\.
| Instructions | |||
|---|---|---|---|
Check for |
|
||
Set |
The |
For Mac, you need to download or update to Java 11 or higher.
After reviewing and agreeing to the terms of the license agreement, download the file, then double-click it to launch the installation wizard and follow the installation instructions.
The installation directory varies from one Linux system to another.
On Debian-based distributions, JREs or JDKs are usually installed in /usr/lib/jvm/.
Instructions
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-configcommand.
The instructions that follow are based on the global npm package installation.
Which versions are available?
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
Installing the latest version
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 the following… |
sudo npm install @magnolia/cli -g
Installing a specific version
To install a specific version (globally), for example, 3.1.0, run the following command in a shell:
npm install @magnolia/cli@3.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 the following… |
sudo npm install @magnolia/cli@3.1.0 -g
Installing the latest development version
The master branch on the Magnolia NPM CLI repo typically contains the version with the latest code.
| You may alternatively check out the latest code and simply install it from source. |
| Please be aware that the official documentation does not cover the functionalities and changes of development 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-<version>.tgz -g
Updating Magnolia CLI
If you have already installed the CLI and want to update to the latest version, use:
npm update @magnolia/cli -g
Testing the installation
To test the installation, run the following command in the shell:
mgnl help
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 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:
|
Uninstalling 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.
This is typically found at ~/.profile or ~/.bashrc from your terminal.
|
source /usr/local/lib/node_modules/@magnolia/cli/extra/mgnl-autocompletion.sh
v3 release history
3.1.0
- Released on June 26, 2019
-
-
This release comes with full support for Magnolia 6.1 and content types. It also seamlessly handles both the new DX Core artifacts introduced with the release of Magnolia 6.1 and the old ones.
If you install Magnolia using the CLIjumpstartcommand and set the-mswitch to6.1or higher, the CLI offers the newdx-corewebapps for installation.
$ mgnl jumpstart -m 6.1 ? What Magnolia would you like to install? 1) magnolia-empty-webapp 2) magnolia-community-webapp 3) magnolia-community-demo-webapp 4) magnolia-dx-core-webapp 5) magnolia-dx-core-demo-webapp
If you set
-mto below 6.1, the CLI offers the former Enterprise and Cloud webapps.$ mgnl jumpstart -m 5.7.3 ? What Magnolia would you like to install? 1) magnolia-empty-webapp 2) magnolia-community-webapp 3) magnolia-community-demo-webapp 4) magnolia-enterprise-standard-webapp 5) magnolia-enterprise-standard-demo-webapp 6) magnolia-enterprise-pro-webapp 7) magnolia-enterprise-pro-demo-webapp 8) magnolia-cloud-dev-webapp
-
Two new commands have been added:
create-app, which creates a content type and an app based on it, andcreate-content-type, which creates a content type. NPMCLI-149 -
This release also fixes an issue with the
jumpstartcommand when running it behind a proxy and updates third-party dependencies due to some vulnerabilities. NPMCLI-206, NPMCLI-223
-
3.0.7
- Released on March 12, 2019
-
This release fixes a security vulnerability found in the
adm-zippackage by removing the dependency to this package. The unzipping process during the CLI installation is now handled by thedecompress-ziplibrary. NPMCLI-198
3.0.6
- Released on February 11, 2019
-
This release brings an additional fix to the
jumpstartcommand, which was failing when issued from behind a proxy server. The issue, again, originated in the Axios client. CLI is now using axios-https-proxy-fix instead of the axios-proxy-fix. NPMCLI-207
3.0.5
- Released on December 17, 2018
-
This release fixes an issue with the
jumpstartcommand, which was failing when issued from behind a proxy server. The issue concerns Axios, a promise-based HTTP client. Until the issue is solved by Axios, you can work around it by including the axios-proxy-fix package. NPMCLI-176
3.0.4
- Released on September 24, 2018
-
When executing the
jumpstartcommand with thesnapshotflag, Magnolia CLI will download not only the latest snapshot development version of the specified webapp but also the latest snapshot version of the Magnoliatomcat-barebonebundle. NPMCLI-194
3.0.3
- Released on August 28, 2018
-
Fixed an issue with the
create-pagecommand on Windows where thedialogandtemplateScriptproperties were incorrectly set to undefined. NPMCLI-189
3.0.1
- Released on June 8, 2018
-
Fixed an issue with the
jumpstartcommand that was caused by a regression in theadm-zipdependency. NPMCLI-182
3.0.0
- Released on March 12, 2018
-
-
New command
create-blocksto create blocks. NPMCLI-132 -
New command
create-virtual-urito create a virtual URI mapping. NPMCLI-135 -
Prototypes:
-
New prototype structure with an expanded choice of prototype options. NPMCLI-119
-
Prototypes allow the creation of additional custom files in any directory of the light module. NPMCLI-86
-
Prototype variants to create component or page templates with a JavaScript model. NPMCLI-137
-
Prototype variants to create a light module. NPMCLI-148
-
Prototypes to create blocks with the new command
create-block. -
Prototypes to create a virtual URI mapping with the new command
create-virtual-uri.
-
-
Based on user feedback, Magnolia no longer checks for the nearest Tomcat folder when you create a light-modules folder and so the
-f(force) option has been removed from thecreate-light-modulecommand. NPMCLI-159 -
jumpstart:-
You can use the new
-woption to choose which Magnolia webapp you want to install when using thejumpstartcommand. With this, the options-eand-care no longer available. NPMCLI-120 -
You can choose the latest SNAPSHOT of the selected webapp. NPMCLI-144
-
Jumpstart does not set the wrong light-modules directory on Windows anymore. NPMCLI-156
-
Jumpstart stores downloaded artifacts in a separate folder to reuse them later. This also fixes a bug where
-eand-coptions were ignored due to an already existing artifact with a generic filename. NPMCLI-100
-
-
mgnl-cli.json:-
No longer contains the
lightDevFoldersInModuleproperty. The folder structure of a light module created with the CLI is defined in the prototypes. -
The
webappsproperty is used to define the list of possible webapps you can choose from from when running thejumpstartcommand.
-
-
The
-Voption, which used to display the version information of the installed Magnolia CLI, has been replaced with a lower-case option (-v). The output now also displays the version of Node.js installed. NPMCLI-133
-
See also
-
Troubleshooting: See JVM issues in Known issues.