CLI reference

Dataset

Introduction of Copy-Paste for Fields, Array Tree Editing, Auto-Updating Studio Deployments, and Improved Large Dataset Exports in Sanity Studio

v3.50.0

Copy-and-paste for fields and documents

This version of Sanity Studio introduces a powerful new way to work with structured content within Sanity Studio: Copy-paste support for fields and documents. Use the familiar copy-and-paste hotkeys (cmd/ctrl+c and cmd/ctrl+v) and the field and document actions menus to copy content across different fields and types seamlessly.

  • Copy between different document types: You can seamlessly copy fields from one document and paste them into a different document type while maintaining the content structure.
  • Copy deeply nested structures: Easily copy entire blocks of Portable Text and arrays with complex nested structures between documents.
  • Copy full documents: Effortlessly copy full documents and integrate them into existing documents of the same or similar types.

Beta: Array Tree Editing

Sanity offers powerful content models that let you define lists of object types and even nest these, if necessary. This enables developers to work with intuitive and convenient data structures in the API, but it has sometimes led to a cumbersome editorial experience with a lot of navigation between layers of modals.

That's why we're thrilled to introduce an improved experience for editing arrays of objects. With this new view, you can see and edit arrays in one place, making working with nested content much simpler and faster.

Screenshot of new Array Tree Editor
Screenshot of new Array Tree Editor

To enable the new tree editor, add the following to your SanityStudio configuration:

export default defineConfig({
  // ...
  beta: {
    treeArrayEditing: {
      enabled: true,
    },
  },
});

Gotcha

Beta: Auto-updating Studio deployments

We're shipping improvents and fixes to Sanity Studio on a weekly basis. To make it easier to get these improvements to Sanity Studio users without requiring developer involvement, we have shipped a way to build the studio for auto-updates.

You can try this out with the new --auto-updates flag to the sanity build and sanity deploy. This enables your Sanity Studio to automatically update to the latest minor and patch versions of Sanity Studio without having to rebuild and redeploy new bundles.

Learn more about the new auto update flag in docs.

Sanity Studio is ready to update! Push to reload

Improved support for large datasets exports

To improve the export experience for users with large datasets, we have introduced a new cursor export mode in the Sanity CLI:

sanity dataset export --mode cursor

In this mode, the CLI will use cursors under the hood when exporting, which can significantly speed up the export process for larger datasets.

Gotcha

🐛 Notable bugfixes

  • Fixes an issue when trying to extract schemas/deploy GraphQL APIs when a sub-dependency tries to call document.execCommand at import time.
  • Fixes a warning being printed about using useClient() without specifying an API version.

Install or upgrade Sanity Studio

To initiate a new Sanity Studio project or upgrade an existing one, please refer to our comprehensive guide on Installing and Upgrading Sanity Studio.

If you are updating from a version earlier than 3.37.0, you should also check out this article to ensure your dependencies are up to date.

Parameterized templates for Presentation, System documents support in CLI import command ++

v3.29.0

Installation and upgrading

To initiate a new Studio without installing the CLI globally:

npm create sanity@latest

To upgrade a v3 Studio, run this command in its folder:

npm install sanity@latest

🐛 Notable bugfixes

  • Fixes an issue where the alert messages for published or deleted documents sometimes displayed incorrect titles
  • Fixes a comments-related error dialog from inadvertently showing up to users
  • Removes layout shift when loading document locations when the Presentation tool is used (#5702)
  • Fixes a bug that hid unpublished documents in "Documents on this page" in the Presentation tool (#5702)
  • Fixes a bug that caused the document pane to stay open in the Presentation tool (#5702)

Other features

  • Adds support for importing system documents via --allow-system-documents for dataset imports
  • Adds support for parameterized templates in the Presentation tool (#5694)

New CLI Feature flags and bugfixes

v2.33.3

Upgrade the Command Line Interface (CLI) with:

npm install --global @sanity/cli

Upgrade Sanity Studio with:

sanity upgrade

✨ Highlights

New CLI flags!

We've added a few new flags to make automation easier!

The --force flag was added to a few already existing commands and will skip the confirmation prompt and proceed with the command:

sanity dataset alias unlink <alias-name> --force

sanity dataset alias delete <alias-name> --force

sanity dataset delete <dataset-name> --force

sanity graphql undeploy --dataset <dataset-name> --force

When added, the --no-open flag prevents the login page from automatically opening in the browser.

sanity login --provider <provider-name> --no-open