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.
Tip |
---|
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. |
Table of Contents |
---|
maxLevel | 4 |
---|
minLevel | 2 |
---|
exclude | (What.*)|(Vide.*)|(Uninstall.*) |
---|
|
Release history
Anchor |
---|
| release-3.0.0 |
---|
| release-3.0.0 |
---|
|
3.0.0
Released in March 2018.
What has changed?
- New command
create-blocks
to create blocks. NPMCLI-132 - New command
create-virtual-uri
to 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 the create-light-module
command. NPMCLI-159 jumpstart
:- You can choose which Magnolia webapp you want to install when using the
jumpstart
command. 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
-e
and -c
options where ignored due to already existing artifact with a generic filename. NPMCLI-100
mgnl-cli.json
:- No longer contains the
lightDevFoldersInModule
property. The folder structure of a light module created with the CLI is defined in the prototypes. - The
webapps
property is 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 lower-case option (-v
). The output now also displays the version of Node.js installed. NPMCLI-133
Expand |
---|
title | Click here to see the list of issues resolved in version 3.0.0 |
---|
|
Jira |
---|
server | Magnolia - Issue tracker |
---|
columns | key,summary,type,created,status |
---|
maximumIssues | 30 |
---|
jqlQuery | project=NPMCLI AND fixVersion=3.0.0 |
---|
serverId | 500b06a6-e204-3125-b989-2d75b973d05f |
---|
|
|
Anchor |
---|
| release-2.2.0 |
---|
| release-2.2.0 |
---|
|
2.2.0
Released on 18 January 2018.
What has changed?
- Node v 6.10+ is required to run the CLI.
- A new option
-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. NPMCLI-138 - If no
-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
NPMCLI-129 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. NPMCLI-103
- To help us help you in case you run into an issue, the
mgnl -h
command now also prints out your node.js version, OS and Magnolia CLI version. NPMCLI-128 - The
mgnl create-component
command now generates a component dialog definition yaml file containing label
options (instead of the previously used name
) for i18n compliance. NPMCLI-105
Expand |
---|
title | Click here to see the list of issues resolved in version 2.2.0 |
---|
|
Jira |
---|
server | Magnolia - Issue tracker |
---|
columns | key,summary,type,created,status |
---|
maximumIssues | 20 |
---|
jqlQuery | project=NPMCLI AND fixVersion=2.2.0 |
---|
serverId | 500b06a6-e204-3125-b989-2d75b973d05f |
---|
|
|
Anchor |
---|
| release-2.1.0 |
---|
| release-2.1.0 |
---|
|
2.1.0
Released on 17 March 2017.
What has changed?
- Two new commands have been added:
search
- helps find light modules on npm. NPMCLI-99install
- 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, also displays 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:
Expand |
---|
title | Click here to see the list of issues resolved in version 2.1.0 |
---|
|
Jira |
---|
server | Magnolia - Issue tracker |
---|
columns | key,summary,type,created,status |
---|
maximumIssues | 20 |
---|
jqlQuery | project=NPMCLI AND fixVersion=2.1.0 |
---|
serverId | 500b06a6-e204-3125-b989-2d75b973d05f |
---|
|
|
2.0.0
Released on 27 February 2017.
What has changed?
This version 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.
- 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-48create-light-module
command generates README files. NPMCLI-62- Node v 6.0+ is required to run the CLI.
Expand |
---|
title | Click here for a complete list of the issues which have been resolved in version 2.0 |
---|
|
Jira |
---|
server | Magnolia - Issue tracker |
---|
columns | key,summary,type,created,status |
---|
maximumIssues | 20 |
---|
jqlQuery | project=NPMCLI AND fixVersion=2.0 |
---|
serverId | 500b06a6-e204-3125-b989-2d75b973d05f |
---|
|
|
Video: Magnolia CLI Tool makes web developers' lives easier
Youtube |
---|
width | 370 |
---|
videoId | qdDb-oYt18k |
---|
height | 210 |
---|
|
Please 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
Artifact resource link |
---|
groupId | info.magnolia.bundle |
---|
artifactId | magnolia-community-demo-bundle |
---|
label | $version |
---|
renderType | display_only |
---|
resourceType | ZIP |
---|
|
.)
Pre-2.0.0 versions
All pre-2.0.0 versions of Magnolia CLI are considered beta and no official documentation is available for them.
Installing
Prerequisite: Node.js
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.js provides two branches:
- LTS - recommended for long term support
- Current - providing the latest features
If your node version is below 6.10, install the latest version of the LTS branch (see node.js/download).
Anchor |
---|
| mgnl-cli-installation |
---|
| mgnl-cli-installation |
---|
|
Installing Magnolia CLI
Bestpractice |
---|
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.
Which versions are available?
To display a list of released versions of Magnolia CLI, enter the following command in a shell:
Code Block |
---|
npm view @magnolia/cli versions |
Besides a version list, the following command shows additional information about the Magnolia CLI package:
Code Block |
---|
npm view @magnolia/cli |
Installing the latest version
To install the latest version (globally), run the following command in a shell:
Code Block |
---|
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:
Code Block |
---|
sudo npm install @magnolia/cli -g |
Installing a specific version
To install a specific version (globally), for example 2.1.0, run the following command in a shell:
Code Block |
---|
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:
Code Block |
---|
sudo npm install @magnolia/cli@2.1.0 -g |
Installing the latest development version
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. 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:
Code Block |
---|
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:
Code Block |
---|
npm update @magnolia/cli -g |
Testing the installation
To test the installation, run the following command in the shell:
Anchor |
---|
| autocompletion |
---|
| autocompletion |
---|
|
Shell autocompletion
The Magnolia CLI package provides autocompletion for bash, C-shell and Windows PowerShell.
To install/enable autocompletion, use:
Code Block |
---|
mgnl tab-completion install |
To uninstall it, use:
Code Block |
---|
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.
Note |
---|
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: Code Block |
---|
Set-ExecutionPolicy RemoteSigned |
|
Anchor |
---|
| uninstall-autocomplete-1 |
---|
| uninstall-autocomplete-1 |
---|
|
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 (in ~/.profile or ~/.bashrc):
Code Pro |
---|
source /usr/local/lib/node_modules/@magnolia/cli/extra/mgnl-autocompletion.sh |
See also