Install the CLI
Contentstack CLI can be installed in macOS, Windows and Linux environments. In this guide, you will learn how to install and update command-line interface (CLI).
Prerequisites
Install CLI
To install CLI as a global module in your machine, open your terminal (command prompt) and run this command:
npm install -g @contentstack/cli
Once the CLI is successfully installed, you can use the csdx command from your terminal.
The csdx is a top-level namespace in Contentstack that gives you access to Contentstack's extensive range of commands and functionalities.
Additional Resource: Visit our CLI GitHub page for more information. You can also read about Contentstack CLI on the npm page.
Next, let us verify the CLI installation.
Verify installation
Verify your installation by running the following command in your terminal to get a list of commands that will help you to interact with Contentstack.
csdx --help
C:\Users\vxxxh>csdx --help
____ _ _ _ _
/ ___|___ _ __ | |_ ___ _ __ | |_ ___| |_ __ _ ___| | __
| | / _ \| '_ \| __/ _ \ '_ \| __/ __| __/ _` |/ __| |/ /
| |__| (_) | | | | || __/ | | | |_\__ \ || (_| | (__| <
\____\___/|_| |_|\__\___|_| |_|\__|___/\__\__,_|\___|_|\_\
Command-line tool (CLI) to interact with Contentstack
VERSION
@contentstack/cli/1.17.2 win32-x64 node-v20.10.0
USAGE
$ csdx [COMMAND]
TOPICS
auth Perform authentication-related activities
cm Perform content management activities
config Perform configuration related activities
launch Launch related operations
plugins List installed plugins
COMMANDS
help Display help for csdx.
launch Launch related operations
plugins List installed plugins.
As shown in the above code, the help namespace contains other namespaces within it.
Let us understand these namespaces in detail.
Namespaces
Namespace is used to categorize commands as per their functionality or purpose.
The following namespaces exist within the csdx command:
- auth: To perform authentication-related activities.
- cm: To perform content management activities such as bulk publish, bulk unpublish, import, export, branches, and migration content.
- help: To list useful commands in the CLI.
- launch: To perform Launch related operations.
- plugins: To list the installed plugins.
- config: To perform configuration related activities in the CLI.
Note: The guide to create your own plugin within csdx is yet to come. But, as our CLI is built using the oclif package, you can create your custom plugin by referring to oclif plugin documentation.
Here are the commands within each namespace:
- auth
- cm
- cm:assets:publish
- cm:assets:unpublish
- cm:branches:create
- cm:branches:delete
- cm:branches:diff
- cm:branches:merge
- cm:bulk-publish
- cm:bulk-publish:cross-publish
- cm:entries:migrate-html-rte
- cm:entries:publish
- cm:entries:publish-modified
- cm:entries:publish-non-localized-fields
- cm:entries:publish-only-unpublished
- cm:entries:unpublish
- cm:entries:update-and-publish
- cm:stacks:export
- cm:stacks:import
- cm:stacks:clone
- cm:stacks:migration
- cm:stacks:seed
- cm:stacks:publish-configure
- cm:stacks:publish-revert
- launch
- config
Refer the section below to check the CLI version on your machine and update it to use the latest version.
Check CLI Version
To check the current version of CLI installed on your machine, run this command in the terminal:
csdx --version
Running this command will display the current version, as shown below:
C:\Users\vxxxh>csdx --version
@contentstack/cli/1.17.2 win32-x64 node-v20.10.0
Update CLI Version
As mentioned above, you can check the version of CLI installed on your machine.
To get the latest version of CLI, run the following command in your terminal:
npm install -g @contentstack/cli update