Releases: datocms/cli
Releases · datocms/cli
v4.0.12
Changes
- The CLI is now published as
datocmsinstead of@datocms/cli. Going forward, install with:npm install -g datocms - The binary name, commands, plugins, and on-disk config (
~/.config/datocms/...) are unchanged. This is purely a package-name change — shorter to type, matches the binary, and plays nicely withnpx datocms. @datocms/clikeeps working. It is now a thin alias that depends ondatocmsand re-exports its binary and programmatic API. Existing installs and code that doesimport { Client } from '@datocms/cli/lib/cma-client-node'continue to work unmodified.
Migrating
If you had the scoped package installed globally, uninstall it before installing the new one so they don't fight over the datocms binary:
npm uninstall -g @datocms/cli
npm install -g datocmsUser-installed plugins and saved profiles are preserved — they live under ~/.config/datocms and are shared between both install paths.
Also in this release
- Upgraded
@whatwg-node/fetchand external DatoCMS client dependencies to latest.
v4.0.9
Changes
--allow-primaryflag formigrations:run— The CLI previously refused any in-place migration run on the primary environment. The recommended workflow is still to fork → run → promote, but that flow has real cost when a migration is strictly additive (e.g. adding an optional field, creating a new model). You can now opt in with--allow-primaryto run the migration directly against primary.- The guardrail error now surfaces both the recommended fork+promote workflow and the
--allow-primaryescape hatch via oclif suggestions, so the way out is discoverable the first time you hit it. - Using
--allow-primaryprints a runtime warning: an in-place run has no automatic rollback, so a failure partway through leaves primary in a partially-migrated state. Only use this flag for migrations you've verified to be safe and additive.
Examples
# Recommended: fork, migrate, promote
datocms migrations:run --source=main
datocms environments:promote main-post-migrations
# New: in-place on primary (additive migrations only)
datocms migrations:run --source=main --in-place --allow-primaryv4.0.8
Changes
cma:scriptnow accepts a positional file argument — Most TS runners (tsx,node,bun) take the script path as a positional, sodatocms cma:script /tmp/x.tswas a natural thing to try. Both the positional and-f/--fileare accepted; the command errors out if they disagree.
Examples
# Both forms are now equivalent
datocms cma:script /tmp/my-script.ts
datocms cma:script -f /tmp/my-script.tsv4.0.7
Changes
- New
projects:listcommand — OAuth-only command that enumerates projects the logged-in account can reach across personal and organization workspaces, with optional fuzzy filtering by name/domain. Enables non-interactive agents to discover asiteIdbefore invokinglink --site-id. - Non-interactive friendly
linkcommand — Detects non-TTY environments and either errors out with actionable guidance (when an interactive prompt would be needed) or falls back to sensible defaults for optional inputs. Unblocks the agent flow that discovers asiteIdviaprojects:listand then runslink --site-id.
Examples
# Discover available projects
datocms projects:list
# Filter by name/domain
datocms projects:list --query my-blog
# Link non-interactively using a known site id
datocms link --site-id <siteId>v4.0.6
Changes
- New
cma:scriptcommand — Run one-off TypeScript scripts against the DatoCMS CMA. Accepts either a default-exportasync function (client: Client) => Promise<void>(portable, migrations-compatible) or plain top-level-await code withclientandSchemaavailable as ambient globals. Scripts run in an isolated workspace with live-generated project schema types andtsctype-checking, with stdout piped directly through (so output works withjqand other tools). - Credentials moved to platform config dirs —
credentials.jsonnow lives underenv-paths('datocms-cli')for platform-correct config locations.
Examples
# Run a script that uses the typed client
datocms cma:script -f ./my-script.ts
# Pipe output to jq
datocms cma:script -f ./list-items.ts | jq '.[] | .id'v4.0.5
Changes
- New
cma:docscommand — Browse the DatoCMS Content Management API reference documentation directly from the terminal. List resources, describe actions, and expand details sections without leaving the CLI.
Examples
# List all available resources
datocms cma:docs
# Describe a specific resource and its actions
datocms cma:docs items
# Describe a specific action with examples
datocms cma:docs items create
# Expand a collapsed details section
datocms cma:docs items create --expand "Example: Basic example"v4.0.4
Changes
- Revoke OAuth token on logout —
datocms logoutnow revokes the OAuth token remotely before deleting local credentials - Detect revoked tokens — When a stored OAuth token has been revoked (e.g. from account settings), the CLI now shows a clear error message instead of a generic "could not access project" error
v4.0.3
Changes
- Hide inaccessible projects in link command — Projects where the user doesn't have access permissions are no longer shown in the project selection list during
datocms link
v4.0.2
Changes
- Allow re-login without requiring logout first — Running
datocms loginwhen already authenticated now replaces existing credentials instead of blocking - Improve OAuth token resolution — Linked projects (via
datocms link) now take priority over theDATOCMS_API_TOKENenvironment variable, so OAuth-based authentication is not silently overridden - Improve error messages — Better error message when a linked project cannot be accessed, mentioning possible OAuth permission changes
v4.0.1
Changes
- Hide empty workspaces in
linkcommand — Workspaces with no projects are filtered out before presenting the selection prompt, removing options the user can't meaningfully pick. - Credentials path change — Internal change to where credentials are stored.