CLI reference

Init

Auto-Updates Now Enabled by Default for Newly Initialized Studios

v3.57.3

✨ Highlights

Auto-updates enabled by default

Newly initialized studios now have auto-updates enabled by default.

This feature keeps your deployed studio up to date with the latest versions of Sanity while maintaining full control over your code and customizations, ensuring the same great developer experience you’re accustomed to.

With auto-updates enabled, you'll only need to rebuild and redeploy when making your own changes, as new features and improvements from Sanity are delivered automatically.

Learn more at https://www.sanity.io/docs/auto-updating-studios

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.

Sanity Studio update: Enhancements to Studio initialization and migration commands, and bugfix for image/file assets in structure lists

v3.45.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

✨ Highlights

  • The studio initialization command now allows you to specify a package manager with a flag in a single line. This was previously only possible to do via an interactive CLI prompt. You can now skip this step:
npm create sanity@latest --package-manager pnpm
  • The dryRun parameter is now available in the context provided for the defineMigration command available from sanity/migrate. This allows developers to write scripts that skip certain actions (for example, mutating external data stores) if it is only a dry run. An example might look like this:
import { defineMigration } from "sanity/migrate"

/**
 * Run this migration with
 * `npx sanity migration run my-migration`
 */
export default defineMigration({
  title: "my-migration",

  // pass whether the migration is a dry-run as context
  async *migrate(documents, { dryRun }) {
    for await (const document of documents()) {
      if(dryRun) {
        // Only log the effect
        console.log(`Something happened`)
      } else {
        // Execute the side-effect
        await thirdPartyRequest()
      }
      // ... do something with the document, maybe yield patches
    }
  },
})

🐛 Notable bugfixes

  • Fixes an issue where image/file assets would not be listed in Structure lists, even if specified to do so.

Improvements and bugfixes

v2.29.3

Upgrade the Command Line Interface (CLI) with:

npm install --global @sanity/cli

Upgrade Sanity Studio with:

sanity upgrade

✨ Highlights

Select organization with the CLI

Allow selecting an organization to attach new projects to during sanity init.

Other features

  • Update image input height based on image size.
  • Adds support for @sanity/language-filter to fallback to a different language select implementation when the current one is not relevant. (thank you @LiamMartens)

🐛 Notable bugfixes

  • Improves how patches are sent to the server in the Portable Text editor, potentially fixing a very rare heisenbug where the latest change in the editor would not be persisted.
  • Fixes a regression in the Portable Text editor's custom paste handler support.
  • Fixes issues in the Portable Text editor when merging two paragraphs with text annotations in some circumstances.
  • Fixes an issue where the number input wasn't allowing for decimal numbers (when the input is active).
  • Fixes an issue with the changelog when filtering out entries without data to display.