CLI to interact with DatoCMS APIs
npm install @datocms/cliDatoCMS CLI tool for managing DatoCMS projects, environments and schemas.
* DatoCMS CLI
* Usage
* Commands
``sh-session
$ npm install -g @datocms/cli
$ datocms COMMAND
running command...
$ datocms (--version)
@datocms/cli/0.1.6 darwin-x64 node-v16.20.0
$ datocms --help [COMMAND]
USAGE
$ datocms COMMAND
...
`
* [datocms autocomplete [SHELL]](#datocms-autocomplete-shell)datocms cma:call RESOURCE METHOD
* datocms environments:destroy ENVIRONMENT_ID
* datocms environments:fork SOURCE_ENVIRONMENT_ID NEW_ENVIRONMENT_ID
* datocms environments:index
* datocms environments:list
* datocms environments:primary
* datocms environments:promote ENVIRONMENT_ID
* datocms environments:rename ENVIRONMENT_ID NEW_ENVIRONMENT_ID
* datocms help [COMMAND]
* [](#datocms-help-command)datocms maintenance:off
* datocms maintenance:on
* datocms migrations:new NAME
* datocms migrations:run
* datocms plugins
* datocms plugins:add PLUGIN
* datocms plugins:available
* datocms plugins:inspect PLUGIN...
* datocms plugins:install PLUGIN
* datocms plugins:link PATH
* datocms plugins:remove [PLUGIN]
* [](#datocms-pluginsremove-plugin)datocms plugins:reset
* datocms plugins:uninstall [PLUGIN]
* [](#datocms-pluginsuninstall-plugin)datocms plugins:unlink [PLUGIN]
* [](#datocms-pluginsunlink-plugin)datocms plugins:update
* datocms profile:remove PROFILE_ID
* datocms profile:set PROFILE_ID
* datocms schema:generate FILENAME
*
Display autocomplete installation instructions.
`
USAGE
$ datocms autocomplete [SHELL] [-r]
ARGUMENTS
[SHELL] (zsh|bash|powershell) Shell type
FLAGS
-r, --refresh-cache Refresh cache (ignores displaying instructions)
DESCRIPTION
Display autocomplete installation instructions.
EXAMPLES
$ datocms autocomplete
$ datocms autocomplete bash
$ datocms autocomplete zsh
$ datocms autocomplete powershell
$ datocms autocomplete --refresh-cache
`
_See code: @oclif/plugin-autocomplete_
Call any DatoCMS Content Management API method
`
USAGE
$ datocms cma:call RESOURCE... METHOD... [--json] [--config-file
ARGUMENTS
RESOURCE... The resource to call (e.g., items, itemTypes, etc.)
METHOD... The method to execute (e.g., list, find, create, etc.)
FLAGS
-e, --environment=
--data=
--params=
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
DESCRIPTION
Call any DatoCMS Content Management API method
EXAMPLES
List all roles
$ datocms cma:call roles list
Find a specific role
$ datocms cma:call roles find 123
Create a new role
$ datocms cma:call roles create --data '{name: "Editor", can_edit_site: true}'
Update a role
$ datocms cma:call roles update 123 --data '{name: "Updated Name"}'
Delete a role
$ datocms cma:call roles destroy 123
List items with query parameters
$ datocms cma:call items list --params '{filter: {type: "blog_post"}}'
Execute command in a specific environment
$ datocms cma:call items list --environment my-environment
`
_See code: src/commands/cma/call.ts_
Destroys a sandbox environment
`
USAGE
$ datocms environments:destroy ENVIRONMENT_ID [--json] [--config-file
[--log-level NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory]
ARGUMENTS
ENVIRONMENT_ID The environment to destroy
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Destroys a sandbox environment
`
_See code: src/commands/environments/destroy.ts_
Creates a new sandbox environment by forking an existing one
`
USAGE
$ datocms environments:fork SOURCE_ENVIRONMENT_ID NEW_ENVIRONMENT_ID [--json] [--config-file
[--force --fast]
ARGUMENTS
SOURCE_ENVIRONMENT_ID The environment to copy
NEW_ENVIRONMENT_ID The name of the new sandbox environment to generate
FLAGS
--fast Run a fast fork. A fast fork reduces processing time, but it also prevents writing to the source environment
during the process
--force Forces the start of a fast fork, even there are users currently editing records in the environment to copy
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Creates a new sandbox environment by forking an existing one
`
_See code: src/commands/environments/fork.ts_
Lists primary/sandbox environments of a project
`
USAGE
$ datocms environments:index [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory]
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Lists primary/sandbox environments of a project
ALIASES
$ datocms environments:index
$ datocms environments:list
`
Lists primary/sandbox environments of a project
`
USAGE
$ datocms environments:list [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory]
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Lists primary/sandbox environments of a project
ALIASES
$ datocms environments:index
$ datocms environments:list
`
_See code: src/commands/environments/list.ts_
Returns the name the primary environment of a project
`
USAGE
$ datocms environments:primary [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory]
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Returns the name the primary environment of a project
`
_See code: src/commands/environments/primary.ts_
Promotes a sandbox environment to primary
`
USAGE
$ datocms environments:promote ENVIRONMENT_ID [--json] [--config-file
[--log-level NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory]
ARGUMENTS
ENVIRONMENT_ID The environment to promote
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Promotes a sandbox environment to primary
`
_See code: src/commands/environments/promote.ts_
Renames an environment
`
USAGE
$ datocms environments:rename ENVIRONMENT_ID NEW_ENVIRONMENT_ID [--json] [--config-file
[--api-token
ARGUMENTS
ENVIRONMENT_ID The environment to rename
NEW_ENVIRONMENT_ID The new environment ID
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Renames an environment
`
_See code: src/commands/environments/rename.ts_
Display help for datocms.
`
USAGE
$ datocms help [COMMAND...] [-n]
ARGUMENTS
[COMMAND...] Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for datocms.
`
_See code: @oclif/plugin-help_
Take a project out of maintenance mode
`
USAGE
$ datocms maintenance:off [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory]
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Take a project out of maintenance mode
`
_See code: src/commands/maintenance/off.ts_
Put a project in maintenance mode
`
USAGE
$ datocms maintenance:on [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory] [--force]
FLAGS
--force Forces the activation of maintenance mode even there are users currently editing records
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Put a project in maintenance mode
`
_See code: src/commands/maintenance/on.ts_
Create a new migration script
`
USAGE
$ datocms migrations:new NAME [--json] [--config-file
[--log-level NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory] [--ts | --js] [--template
| --autogenerate
ARGUMENTS
NAME The name to give to the script
FLAGS
--autogenerate=
Auto-generates script by diffing the schema of two environments
Examples:
* --autogenerate=foo finds changes made to sandbox environment 'foo' and applies them to primary environment
* --autogenerate=foo:bar finds changes made to environment 'foo' and applies them to environment 'bar'
--js
Forces the creation of a JavaScript migration file
--schema=
Include schema definitions for models and blocks (TypeScript only). Use "all" for all item types, or specify
comma-separated API keys for specific ones
--template=
Start the migration script from a custom template
--ts
Forces the creation of a TypeScript migration file
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Create a new migration script
`
_See code: src/commands/migrations/new.ts_
Run migration scripts that have not run yet
`
USAGE
$ datocms migrations:run [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory] [--source
[--fast-fork [--destination
[--migrations-tsconfig
FLAGS
--destination=
--dry-run Simulate the execution of the migrations, without making any actual change
--fast-fork Run a fast fork. A fast fork reduces processing time, but it also prevents writing to
the source environment during the process
--force Forces the start of a fast fork, even there are users currently editing records in the
environment to copy
--in-place Run the migrations in the --source environment, without forking
--migrations-dir=
--migrations-model=
--migrations-tsconfig=
--source=
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Run migration scripts that have not run yet
`
_See code: src/commands/migrations/run.ts_
List installed plugins.
`
USAGE
$ datocms plugins [--json] [--core]
FLAGS
--core Show core plugins.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
List installed plugins.
EXAMPLES
$ datocms plugins
`
_See code: @oclif/plugin-plugins_
Installs a plugin into datocms.
`
USAGE
$ datocms plugins:add PLUGIN... [--json] [-f] [-h] [-s | -v]
ARGUMENTS
PLUGIN... Plugin to install.
FLAGS
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
-h, --help Show CLI help.
-s, --silent Silences npm output.
-v, --verbose Show verbose npm output.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Installs a plugin into datocms.
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Use the DATOCMS_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the DATOCMS_NPM_REGISTRY environment variable to set the npm registry.
ALIASES
$ datocms plugins:add
EXAMPLES
Install a plugin from npm registry.
$ datocms plugins:add myplugin
Install a plugin from a github url.
$ datocms plugins:add https://github.com/someuser/someplugin
Install a plugin from a github slug.
$ datocms plugins:add someuser/someplugin
`
Lists official DatoCMS CLI plugins
`
USAGE
$ datocms plugins:available [--json]
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Lists official DatoCMS CLI plugins
`
_See code: src/commands/plugins/available.ts_
Displays installation properties of a plugin.
`
USAGE
$ datocms plugins:inspect PLUGIN...
ARGUMENTS
PLUGIN... [default: .] Plugin to inspect.
FLAGS
-h, --help Show CLI help.
-v, --verbose
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Displays installation properties of a plugin.
EXAMPLES
$ datocms plugins:inspect myplugin
`
_See code: @oclif/plugin-plugins_
Installs a plugin into datocms.
`
USAGE
$ datocms plugins:install PLUGIN... [--json] [-f] [-h] [-s | -v]
ARGUMENTS
PLUGIN... Plugin to install.
FLAGS
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
-h, --help Show CLI help.
-s, --silent Silences npm output.
-v, --verbose Show verbose npm output.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Installs a plugin into datocms.
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Use the DATOCMS_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the DATOCMS_NPM_REGISTRY environment variable to set the npm registry.
ALIASES
$ datocms plugins:add
EXAMPLES
Install a plugin from npm registry.
$ datocms plugins:install myplugin
Install a plugin from a github url.
$ datocms plugins:install https://github.com/someuser/someplugin
Install a plugin from a github slug.
$ datocms plugins:install someuser/someplugin
`
_See code: @oclif/plugin-plugins_
Links a plugin into the CLI for development.
`
USAGE
$ datocms plugins:link PATH [-h] [--install] [-v]
ARGUMENTS
PATH [default: .] path to plugin
FLAGS
-h, --help Show CLI help.
-v, --verbose
--[no-]install Install dependencies after linking the plugin.
DESCRIPTION
Links a plugin into the CLI for development.
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
command will override the user-installed or core plugin implementation. This is useful for development work.
EXAMPLES
$ datocms plugins:link myplugin
`
_See code: @oclif/plugin-plugins_
Removes a plugin from the CLI.
`
USAGE
$ datocms plugins:remove [PLUGIN...] [-h] [-v]
ARGUMENTS
[PLUGIN...] plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ datocms plugins:unlink
$ datocms plugins:remove
EXAMPLES
$ datocms plugins:remove myplugin
`
Remove all user-installed and linked plugins.
`
USAGE
$ datocms plugins:reset [--hard] [--reinstall]
FLAGS
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
--reinstall Reinstall all plugins after uninstalling.
`
_See code: @oclif/plugin-plugins_
Removes a plugin from the CLI.
`
USAGE
$ datocms plugins:uninstall [PLUGIN...] [-h] [-v]
ARGUMENTS
[PLUGIN...] plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ datocms plugins:unlink
$ datocms plugins:remove
EXAMPLES
$ datocms plugins:uninstall myplugin
`
_See code: @oclif/plugin-plugins_
Removes a plugin from the CLI.
`
USAGE
$ datocms plugins:unlink [PLUGIN...] [-h] [-v]
ARGUMENTS
[PLUGIN...] plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ datocms plugins:unlink
$ datocms plugins:remove
EXAMPLES
$ datocms plugins:unlink myplugin
`
Update installed plugins.
`
USAGE
$ datocms plugins:update [-h] [-v]
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Update installed plugins.
`
_See code: @oclif/plugin-plugins_
Remove a profile from DatoCMS config file
`
USAGE
$ datocms profile:remove PROFILE_ID [--json] [--config-file
ARGUMENTS
PROFILE_ID The name of the profile
GLOBAL FLAGS
--config-file=
--json Format output as json.
DESCRIPTION
Remove a profile from DatoCMS config file
`
_See code: src/commands/profile/remove.ts_
Add/update profile configuration in DatoCMS config file
`
USAGE
$ datocms profile:set PROFILE_ID [--json] [--config-file
NONE|BASIC|BODY|BODY_AND_HEADERS] [--migrations-dir
ARGUMENTS
PROFILE_ID [default: default] Name of the profile to create/update
FLAGS
--log-level=
--migrations-dir=
--migrations-model=
--migrations-template=
--migrations-tsconfig=
GLOBAL FLAGS
--config-file=
--json Format output as json.
DESCRIPTION
Add/update profile configuration in DatoCMS config file
`
_See code: src/commands/profile/set.ts_
Generate TypeScript definitions for the schema
`
USAGE
$ datocms schema:generate FILENAME [--json] [--config-file
[--log-level NONE|BASIC|BODY|BODY_AND_HEADERS] [--log-mode stdout|file|directory] [-e
ARGUMENTS
FILENAME Output filename for the generated TypeScript definitions
FLAGS
-e, --environment=
-t, --item-types=
GLOBAL FLAGS
--api-token=
--config-file=
--json Format output as json.
--log-level=
--log-mode=
--profile=
DESCRIPTION
Generate TypeScript definitions for the schema
``
_See code: src/commands/schema/generate.ts_