JSPM

  • Created
  • Published
  • Downloads 214846
  • Score
    100M100P100Q180351F
  • License MIT

Sanity's Runtime CLI for Blueprints and Functions

Package Exports

  • @sanity/runtime-cli
  • @sanity/runtime-cli/actions/blueprints
  • @sanity/runtime-cli/actions/functions
  • @sanity/runtime-cli/actions/sanity
  • @sanity/runtime-cli/cores
  • @sanity/runtime-cli/cores/blueprints
  • @sanity/runtime-cli/cores/functions
  • @sanity/runtime-cli/utils

Readme

@sanity/runtime-cli

Sanity's Runtime CLI for Blueprints and Functions

oclif Version Downloads/week

Usage

$ npm install -g @sanity/runtime-cli
$ sanity-run COMMAND
running command...
$ sanity-run (--version)
@sanity/runtime-cli/11.2.4 linux-x64 node-v24.11.1
$ sanity-run --help [COMMAND]
USAGE
  $ sanity-run COMMAND
...

Commands

sanity-run blueprints add TYPE

Add a Resource to a Blueprint

USAGE
  $ sanity-run blueprints add TYPE [--example <value> | -n <value> | --fn-type
    document-create|document-delete|document-update|document-publish|media-library-asset-create|media-library-asset-upda
    te|media-library-asset-delete... | --language ts|js | --javascript | --fn-helpers | --fn-installer
    skip|npm|pnpm|yarn] [-i | ]

ARGUMENTS
  TYPE  (function) Type of Resource to add (e.g. function)

FLAGS
  -i, --install                Shortcut for --fn-installer npm
  -n, --name=<value>           Name of the Resource to add
      --example=<value>        Example to use for the Resource
      --[no-]fn-helpers        Add helpers to the new Function
      --fn-installer=<option>  How to install the @sanity/functions helpers
                               <options: skip|npm|pnpm|yarn>
      --fn-type=<option>...    Document change event(s) that should trigger the function; you can specify multiple
                               events by specifying this flag multiple times
                               <options: document-create|document-delete|document-update|document-publish|media-library-
                               asset-create|media-library-asset-update|media-library-asset-delete>
      --javascript             Use JavaScript instead of TypeScript
      --language=<option>      [default: ts] Language of the new Function
                               <options: ts|js>

DESCRIPTION
  Add a Resource to a Blueprint

EXAMPLES
  $ sanity-run blueprints add function

  $ sanity-run blueprints add function --helpers

  $ sanity-run blueprints add function --name my-function

  $ sanity-run blueprints add function --name my-function --fn-type document-create

  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js

See code: src/commands/blueprints/add.ts

sanity-run blueprints config

View or edit Blueprint configuration

USAGE
  $ sanity-run blueprints config [-t] [--project-id <value> -e] [--organization-id <value> ] [--stack-id <value> ]

FLAGS
  -e, --edit                     Edit the configuration
  -t, --test-config              Validate the configuration
      --organization-id=<value>  Update the Organization ID in the configuration. Requires --edit flag
      --project-id=<value>       Update the Project ID in the configuration. Requires --edit flag
      --stack-id=<value>         Update the Stack ID in the configuration. Requires --edit flag

DESCRIPTION
  View or edit Blueprint configuration

EXAMPLES
  $ sanity-run blueprints config

  $ sanity-run blueprints config --test-config

  $ sanity-run blueprints config --edit

  $ sanity-run blueprints config --edit --project-id <projectId>

  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>

See code: src/commands/blueprints/config.ts

sanity-run blueprints deploy

Deploy a Blueprint

USAGE
  $ sanity-run blueprints deploy [--no-wait]

FLAGS
  --no-wait  Do not wait for deployment to complete

DESCRIPTION
  Deploy a Blueprint

EXAMPLES
  $ sanity-run blueprints deploy

  $ sanity-run blueprints deploy --no-wait

See code: src/commands/blueprints/deploy.ts

sanity-run blueprints destroy

Destroy a Blueprint deployment (will not delete local files)

USAGE
  $ sanity-run blueprints destroy [--project-id <value> --stack-id <value> --force] [--organization-id <value>  ]
    [--no-wait]

FLAGS
  --force                    Force destroy (skip confirmation)
  --no-wait                  Do not wait for destruction to complete
  --organization-id=<value>  Organization associated with the Stack
  --project-id=<value>       Project associated with the Stack
  --stack-id=<value>         Stack ID to destroy (defaults to current Stack)

DESCRIPTION
  Destroy a Blueprint deployment (will not delete local files)

EXAMPLES
  $ sanity-run blueprints destroy

  $ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait

See code: src/commands/blueprints/destroy.ts

sanity-run blueprints doctor

Diagnose potential issues with Blueprint configuration

USAGE
  $ sanity-run blueprints doctor [--verbose] [--path <value>]

FLAGS
  --path=<value>  Path to the Blueprint configuration file
  --verbose       Provide detailed information about issues

DESCRIPTION
  Diagnose potential issues with Blueprint configuration

See code: src/commands/blueprints/doctor.ts

sanity-run blueprints info

Show information about a Blueprint deployment

USAGE
  $ sanity-run blueprints info [--id <value>]

FLAGS
  --id=<value>  Stack ID to show info for (defaults to current stack)

DESCRIPTION
  Show information about a Blueprint deployment

EXAMPLES
  $ sanity-run blueprints info

  $ sanity-run blueprints info --stack-id <stackId>

See code: src/commands/blueprints/info.ts

sanity-run blueprints init [DIR]

Initialize a new Blueprint

USAGE
  $ sanity-run blueprints init [DIR] [--dir <value>] [--example <value> | --blueprint-type json|js|ts | --stack-id
    <value> | --stack-name <value>] [--project-id <value>] [--organization-id <value>]

ARGUMENTS
  [DIR]  Directory to create the Blueprint in

FLAGS
  --blueprint-type=<option>  Blueprint manifest type to use for the Blueprint
                             <options: json|js|ts>
  --dir=<value>              Directory to create the Blueprint in
  --example=<value>          Example to use for the Blueprint
  --organization-id=<value>  Sanity Organization ID to use for the Blueprint
  --project-id=<value>       Sanity Project ID to use for the Blueprint
  --stack-id=<value>         Existing Stack ID to use for the Blueprint
  --stack-name=<value>       Name to use for a NEW Stack

DESCRIPTION
  Initialize a new Blueprint

EXAMPLES
  $ sanity-run blueprints init

  $ sanity-run blueprints init [directory]

  $ sanity-run blueprints init --blueprint-type <json|js|ts>

  $ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId> --stack-id <stackId>

  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>

See code: src/commands/blueprints/init.ts

sanity-run blueprints logs

Display logs for a Blueprint deployment

USAGE
  $ sanity-run blueprints logs [-w]

FLAGS
  -w, --watch  Watch for new logs (streaming mode)

DESCRIPTION
  Display logs for a Blueprint deployment

EXAMPLES
  $ sanity-run blueprints logs

  $ sanity-run blueprints logs --watch

See code: src/commands/blueprints/logs.ts

sanity-run blueprints plan

Enumerate resources to be deployed - will not modify any resources

USAGE
  $ sanity-run blueprints plan

DESCRIPTION
  Enumerate resources to be deployed - will not modify any resources

EXAMPLES
  $ sanity-run blueprints plan

See code: src/commands/blueprints/plan.ts

sanity-run blueprints stacks

List all Blueprint stacks

USAGE
  $ sanity-run blueprints stacks [--project-id <value> | --organization-id <value>]

FLAGS
  --organization-id=<value>  Organization ID to show stacks for
  --project-id=<value>       Project ID to show stacks for

DESCRIPTION
  List all Blueprint stacks

EXAMPLES
  $ sanity-run blueprints stacks

  $ sanity-run blueprints stacks --project-id <projectId>

  $ sanity-run blueprints stacks --organization-id <organizationId>

See code: src/commands/blueprints/stacks.ts

sanity-run functions add

Add a Function to your Blueprint

USAGE
  $ sanity-run functions add [--example <value> | -n <value> |  | --language ts|js | --javascript |  | ] [--type
    document-create|document-delete|document-update|document-publish|media-library-asset-create|media-library-asset-upda
    te|media-library-asset-delete... ] [--helpers] [--installer skip|npm|pnpm|yarn] [-i | ]

FLAGS
  -i, --install             Shortcut for --fn-installer npm
  -n, --name=<value>        Name of the Function to add
      --example=<value>     Example to use for the Function
      --[no-]helpers        Add helpers to the new Function
      --installer=<option>  How to install the @sanity/functions helpers
                            <options: skip|npm|pnpm|yarn>
      --javascript          Use JavaScript instead of TypeScript
      --language=<option>   [default: ts] Language of the new Function
                            <options: ts|js>
      --type=<option>...    Document change event(s) that should trigger the function; you can specify multiple events
                            by specifying this flag multiple times
                            <options: document-create|document-delete|document-update|document-publish|media-library-ass
                            et-create|media-library-asset-update|media-library-asset-delete>

DESCRIPTION
  Add a Function to your Blueprint

EXAMPLES
  $ sanity-run functions add

  $ sanity-run functions add --helpers

  $ sanity-run functions add --name my-function

  $ sanity-run functions add --name my-function --type document-create

  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js

See code: src/commands/functions/add.ts

sanity-run functions dev

Start the Sanity Function emulator

USAGE
  $ sanity-run functions dev [-h <value>] [-p <value>] [-t <value>]

FLAGS
  -h, --host=<value>     The local network interface at which to listen. [default: "localhost"]
  -p, --port=<value>     TCP port to start emulator on. [default: 8080]
  -t, --timeout=<value>  Maximum execution time for all functions, in seconds. Takes precedence over function-specific
                         `timeout`

DESCRIPTION
  Start the Sanity Function emulator

EXAMPLES
  $ sanity-run functions dev --host 127.0.0.1 --port 8974

See code: src/commands/functions/dev.ts

sanity-run functions env add NAME KEY VALUE

Add or set the value of an environment variable for a Sanity function

USAGE
  $ sanity-run functions env add NAME KEY VALUE

ARGUMENTS
  NAME   The name of the Sanity Function
  KEY    The name of the environment variable
  VALUE  The value of the environment variable

DESCRIPTION
  Add or set the value of an environment variable for a Sanity function

EXAMPLES
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/

See code: src/commands/functions/env/add.ts

sanity-run functions env list NAME

List the environment variables for a Sanity function

USAGE
  $ sanity-run functions env list NAME

ARGUMENTS
  NAME  The name of the Sanity Function

DESCRIPTION
  List the environment variables for a Sanity function

EXAMPLES
  $ sanity-run functions env list MyFunction

See code: src/commands/functions/env/list.ts

sanity-run functions env remove NAME KEY

Remove an environment variable for a Sanity function

USAGE
  $ sanity-run functions env remove NAME KEY

ARGUMENTS
  NAME  The name of the Sanity Function
  KEY   The name of the environment variable

DESCRIPTION
  Remove an environment variable for a Sanity function

EXAMPLES
  $ sanity-run functions env remove MyFunction API_URL

See code: src/commands/functions/env/remove.ts

sanity-run functions logs NAME

Retrieve or delete logs for a Sanity Function

USAGE
  $ sanity-run functions logs NAME [-u] [-f [-d | -l <value> | -j]] [-w]

ARGUMENTS
  NAME  The name of the Sanity Function

FLAGS
  -d, --delete         Delete all logs for the function
  -f, --force          Skip confirmation for deleting logs
  -j, --json           Return logs in JSON format
  -l, --limit=<value>  [default: 50] Total number of log entries to retrieve
  -u, --utc            Show dates in UTC time zone
  -w, --watch          Watch for new logs (streaming mode)

DESCRIPTION
  Retrieve or delete logs for a Sanity Function

EXAMPLES
  $ sanity-run functions logs <name>

  $ sanity-run functions logs <name> --json

  $ sanity-run functions logs <name> --limit 100

  $ sanity-run functions logs <name> --delete

See code: src/commands/functions/logs.ts

sanity-run functions test NAME

Invoke a local Sanity Function

USAGE
  $ sanity-run functions test NAME [--data-before <value> | [-d <value> | -f <value> | --document-id <value>] |  | 
    | --file-before <value> | --file-after <value> | --document-id-before <value> | --document-id-after <value>]
    [--data-after <value> |  |  |  |  |  |  | ] [-e create|update|delete] [-t <value>] [-a <value>] [--organization-id
    <value>] [--with-user-token] [--media-library-id <value> | --project-id <value> | --dataset <value>]

ARGUMENTS
  NAME  The name of the Sanity Function

FLAGS
  -a, --api=<value>                 Sanity API Version to use
  -d, --data=<value>                Data to send to the function
  -e, --event=<option>              Type of event (create, update, delete)
                                    <options: create|update|delete>
  -f, --file=<value>                Read data from file and send to the function
  -t, --timeout=<value>             Execution timeout value in seconds
      --data-after=<value>          Current document
      --data-before=<value>         Original document
      --dataset=<value>             The Sanity dataset to use
      --document-id=<value>         Document to fetch and send to function
      --document-id-after=<value>   Current document
      --document-id-before=<value>  Original document
      --file-after=<value>          Current document
      --file-before=<value>         Original document
      --media-library-id=<value>    Sanity Media Library ID to use
      --organization-id=<value>     Sanity Organization ID to use
      --project-id=<value>          Sanity Project ID to use
      --with-user-token             Prime access token from CLI config

DESCRIPTION
  Invoke a local Sanity Function

EXAMPLES
  $ sanity-run functions test <name> --data '{ "id": 1 }'

  $ sanity-run functions test <name> --file 'payload.json'

  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60

  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'

See code: src/commands/functions/test.ts

sanity-run help [COMMAND]

Display help for sanity-run.

USAGE
  $ sanity-run 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 sanity-run.

See code: @oclif/plugin-help