Use the command line interface (CLI) to manage Datastore
The DXP Console CLI lets you manage products that are part of the Squiz Digital Experience Platform (DXP).
If you are using Datastore, you need to use the command line interface (CLI) to deploy your blueprints.
Set up the CLI
There are multiple steps required to set up the CLI. However, the process should not take long.
Install Node Package Manager (NPM)
You need to install Node and NPM to use the DXP Console CLI.
-
Install Node and NPM from https://nodejs.org/en/download/.
-
Ensure you have the right versions by running the following commands, which should each display a version number:
npm -v
node -v
The output should be higher than version 7 for NPM and higher than version 14 for Node, both of which are the minimum supported versions.
If you already have Node and NPM installed, make sure you are using the minimum supported versions or higher. |
Install the DXP Console CLI
-
To install the DXP Console CLI package, run the following command:
npm install --global @squiz/dxp-cli
-
When the command has run, you should see the following output:
✔ Successfully added plugins @squiz/dxp - plugin - plugin add - plugin list - plugin remove @squiz/dxp-plugin-core - help - login - logout - whoami
Uninstall the DXP Console CLI
Run the following two commands:
$ rm -rf ~/.config/dxp
$ npm uninstall -g @squiz/dxp-cli
You should get some output something like this:
removed 239 packages in 7.252s
You can now repeat the installation step above to install the latest version of the DXP Console CLI.
Update the DXP Console CLI to the latest version
When a new version of the DXP Console CLI is released, CLI will prompt the notification message on any command execution like:
$ dxp whoami
A new version of DXP CLI is available (x.1.x -> x.2.x). Do you want to continue without upgrading?
It is always recommended to update the DXP Console CLI tool to the latest version via dxp-upgrade
command:
$ dxp-upgrade
The command installs the latest DXP Console CLI tool including all the existing plugins.
Test the DXP Console CLI
Now that you have installed the required plugins and the DXP Console CLI package, you can test it out by typing dxp
into your console.
This command lists the basic CLI commands that are now available to you.
-
Type the following command and press enter:
dxp
-
You should see the following output:
The command-line interface for dxp Usages $ dxp help <command> $ dxp login [--email|--phone-number|--username] [--password] $ dxp logout $ dxp plugin add <plugin> [<plugin>...] $ dxp plugin list $ dxp plugin remove <plugin> [<plugin>...] $ dxp whoami Options --lang The language to use when printing messages to the terminal --version Show the version number Examples $ dxp help add $ dxp login --email jdoe@squiz.net --password 'my-super-secret-password'
Add plugins to the DXP Console CLI
If you want to use product-specific CLI commands, you must install the relevant plugins. For now, this only applies to Datastore, which is a command-line based tool.
Install the Datastore plugin using the following commands:
dxp plugin add @squiz/dxp-plugin-datastore
Read the Datastore documentation for more information on using Datastore.
Sign in to the CLI
Sign in to the CLI, use the dxp login
command, and provide your email address and password:
dxp login --username 'jsmith@example.com' --password 'password'
If your sign-in is successful, you see the following confirmation in the terminal.
✔ Login to dxp succeeded
After signing in to DXP Console, you can confirm your authentication status with the dxp whoami
command.
dxp whoami
If you authenticate successfully, the command returns your email address.