@sanity/runtime-cli 17.3.2 → 17.4.0-blueprinit.g596ac51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -47
- package/SKILL.md +59 -0
- package/dist/actions/blueprinit/manifest.d.ts +15 -0
- package/dist/actions/blueprinit/manifest.js +82 -0
- package/dist/actions/blueprinit/studio.d.ts +6 -0
- package/dist/actions/blueprinit/studio.js +43 -0
- package/dist/actions/blueprinit/templates.d.ts +34 -0
- package/dist/actions/blueprinit/templates.js +83 -0
- package/dist/actions/blueprinit/workspace.d.ts +16 -0
- package/dist/actions/blueprinit/workspace.js +143 -0
- package/dist/actions/blueprints/pre-deploy.d.ts +15 -6
- package/dist/actions/blueprints/pre-deploy.js +29 -70
- package/dist/actions/blueprints/process-assets.d.ts +29 -0
- package/dist/actions/blueprints/process-assets.js +80 -0
- package/dist/actions/functions/list.d.ts +34 -0
- package/dist/actions/functions/list.js +33 -0
- package/dist/actions/sanity/datasets.d.ts +15 -0
- package/dist/actions/sanity/datasets.js +26 -0
- package/dist/baseCommands.d.ts +2 -0
- package/dist/baseCommands.js +3 -0
- package/dist/commands/blueprinit.d.ts +17 -0
- package/dist/commands/blueprinit.js +59 -0
- package/dist/commands/blueprints/deploy.d.ts +2 -0
- package/dist/commands/blueprints/deploy.js +22 -1
- package/dist/commands/blueprints/destroy.js +1 -1
- package/dist/commands/blueprints/info.d.ts +1 -0
- package/dist/commands/blueprints/info.js +5 -0
- package/dist/commands/blueprints/init.js +1 -2
- package/dist/commands/blueprints/logs.js +1 -0
- package/dist/commands/functions/add.js +3 -3
- package/dist/commands/functions/dev.js +2 -2
- package/dist/commands/functions/list.d.ts +14 -0
- package/dist/commands/functions/list.js +38 -0
- package/dist/commands/functions/logs.d.ts +1 -1
- package/dist/commands/functions/logs.js +3 -0
- package/dist/cores/blueprinit/adopt.d.ts +6 -0
- package/dist/cores/blueprinit/adopt.js +119 -0
- package/dist/cores/blueprinit/finish.d.ts +14 -0
- package/dist/cores/blueprinit/finish.js +64 -0
- package/dist/cores/blueprinit/fresh.d.ts +3 -0
- package/dist/cores/blueprinit/fresh.js +120 -0
- package/dist/cores/blueprinit/preview.d.ts +15 -0
- package/dist/cores/blueprinit/preview.js +14 -0
- package/dist/cores/blueprinit/prompts.d.ts +5 -0
- package/dist/cores/blueprinit/prompts.js +22 -0
- package/dist/cores/blueprinit/selection.d.ts +15 -0
- package/dist/cores/blueprinit/selection.js +90 -0
- package/dist/cores/blueprinit/types.d.ts +16 -0
- package/dist/cores/blueprinit/types.js +1 -0
- package/dist/cores/blueprinit.d.ts +7 -0
- package/dist/cores/blueprinit.js +48 -0
- package/dist/cores/blueprints/deploy.js +69 -19
- package/dist/cores/functions/add.js +1 -1
- package/dist/cores/functions/list.d.ts +10 -0
- package/dist/cores/functions/list.js +34 -0
- package/dist/utils/display/blueprints-formatting.js +3 -3
- package/dist/utils/display/functions-formatting.d.ts +7 -0
- package/dist/utils/display/functions-formatting.js +95 -0
- package/dist/utils/style-text.js +1 -0
- package/oclif.manifest.json +271 -15
- package/package.json +31 -17
- package/skills/_functions-build.md +23 -0
- package/skills/_functions-list.md +28 -0
- package/skills/blueprinit.md +155 -0
- package/skills/blueprints-add.md +8 -0
- package/skills/blueprints-config.md +33 -0
- package/skills/blueprints-deploy.md +36 -0
- package/skills/blueprints-destroy.md +30 -0
- package/skills/blueprints-doctor.md +31 -0
- package/skills/blueprints-info.md +23 -0
- package/skills/blueprints-init.md +48 -0
- package/skills/blueprints-logs.md +33 -0
- package/skills/blueprints-mint-deploy-token.md +25 -0
- package/skills/blueprints-plan.md +28 -0
- package/skills/blueprints-promote.md +31 -0
- package/skills/blueprints-stacks.md +28 -0
- package/skills/functions-add.md +35 -0
- package/skills/functions-dev.md +21 -0
- package/skills/functions-env-add.md +29 -0
- package/skills/functions-env-list.md +21 -0
- package/skills/functions-env-remove.md +22 -0
- package/skills/functions-logs.md +39 -0
- package/skills/functions-test.md +31 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Blueprinit
|
|
2
|
+
|
|
3
|
+
Use `blueprinit` to scaffold a Blueprint around an existing Sanity project. The command is
|
|
4
|
+
experimental, hidden from root help, and available from the `blueprinit` npm dist-tag.
|
|
5
|
+
|
|
6
|
+
Use it for demos and evaluation, not as a stable project initializer. Its flags, generated files,
|
|
7
|
+
and resource model may change.
|
|
8
|
+
|
|
9
|
+
## Know what it does
|
|
10
|
+
|
|
11
|
+
`blueprinit` uses an existing Sanity organization, project, and dataset. It writes local Blueprint
|
|
12
|
+
files, then creates an empty organization-scoped Stack. The generated Blueprint attaches the
|
|
13
|
+
project and dataset and declares resources for a later deployment.
|
|
14
|
+
|
|
15
|
+
It does not create an organization, project, or dataset. It does not deploy the attached resources,
|
|
16
|
+
CORS origin, Studio, or Function. Those changes happen only if `blueprints deploy` is run later.
|
|
17
|
+
|
|
18
|
+
## Inspect the target directory
|
|
19
|
+
|
|
20
|
+
Run the command from the directory that should contain the Blueprint.
|
|
21
|
+
|
|
22
|
+
Before running:
|
|
23
|
+
|
|
24
|
+
1. Check the working tree and existing files. Do not discard unrelated user changes.
|
|
25
|
+
2. Look for a root `sanity.blueprint.*` file. If one exists, use the existing Blueprint instead of
|
|
26
|
+
initializing again.
|
|
27
|
+
3. Look for a root `sanity.config.*` file. Its presence selects the Studio adoption flow.
|
|
28
|
+
4. Confirm the user asked to initialize this directory. The command writes files and creates a
|
|
29
|
+
remote Stack.
|
|
30
|
+
5. Confirm the user is signed in. If needed, have them run:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx sanity login
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The account must have at least one organization, one project in the selected organization, and one
|
|
37
|
+
dataset in the selected project.
|
|
38
|
+
|
|
39
|
+
Interactive runs show the Blueprint resources, hosted Studio URL, local changes, and remote Stack
|
|
40
|
+
action before the confirmation prompt. Project and dataset attachment plus CORS, Studio, and
|
|
41
|
+
Function creation remain pending until a later deployment.
|
|
42
|
+
|
|
43
|
+
## Choose the flow
|
|
44
|
+
|
|
45
|
+
- **Existing Blueprint with a configured Stack:** Exit without changes and use
|
|
46
|
+
`blueprints config --edit` or `blueprints doctor`.
|
|
47
|
+
- **Existing Blueprint without a configured Stack:** Finish setup with `blueprints init`; it can
|
|
48
|
+
connect the existing manifest without rewriting it.
|
|
49
|
+
- **Root Studio config:** Adopt the Studio in place. Read literal `projectId` and `dataset` strings
|
|
50
|
+
from `sanity.config.*`, falling back to `sanity.cli.*`. Do not move the Studio.
|
|
51
|
+
- **Fresh workspace:** Create a Blueprint, an npm-workspace Studio, and a starter `set-slug`
|
|
52
|
+
document function.
|
|
53
|
+
|
|
54
|
+
Do not rewrite a Studio config merely to make adoption work unless the user asks. Dynamic
|
|
55
|
+
`projectId` or `dataset` values built from environment variables or imports cannot be detected.
|
|
56
|
+
|
|
57
|
+
For an existing Blueprint, inspect it with:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npx @sanity/runtime-cli@blueprinit blueprints doctor
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Run unattended
|
|
64
|
+
|
|
65
|
+
When the organization and project IDs are known, run this from the target directory:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
npx @sanity/runtime-cli@blueprinit blueprinit --yes \
|
|
69
|
+
--organization-id <organization-id> \
|
|
70
|
+
--project-id <project-id> \
|
|
71
|
+
--dataset <dataset-name>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Replace all placeholders with real values. The project must belong to the organization, and the
|
|
75
|
+
dataset must belong to the project. Do not guess any value.
|
|
76
|
+
|
|
77
|
+
`--yes` skips confirmation. Without explicit values, an unattended run stops when the account has
|
|
78
|
+
several organizations, projects, or datasets. Ask the user for the missing value or have them run
|
|
79
|
+
the command interactively.
|
|
80
|
+
|
|
81
|
+
Use `--stack-name <name>` and `--studio-name <name>` when those generated names need to be stable.
|
|
82
|
+
The command normalizes both names to lowercase kebab case. The Studio name is also its hosted slug,
|
|
83
|
+
so it must be available in the target environment. Stack and Studio names must differ because they
|
|
84
|
+
also name Blueprint resources.
|
|
85
|
+
|
|
86
|
+
When `SANITY_INTERNAL_ENV=staging`, the generated Studio URL and CORS origin use
|
|
87
|
+
`https://<studio-name>.studio.sanity.work`. Other environments use
|
|
88
|
+
`https://<studio-name>.sanity.studio`.
|
|
89
|
+
|
|
90
|
+
For interactive organization, project, dataset, confirmation, and Studio-name prompts, have the
|
|
91
|
+
user run:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npx @sanity/runtime-cli@blueprinit blueprinit
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
When the project has several datasets, the interactive command prompts for one and lists
|
|
98
|
+
`production` first. Report the selected dataset from the command output.
|
|
99
|
+
|
|
100
|
+
## Review the result
|
|
101
|
+
|
|
102
|
+
A successful fresh run creates or updates:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
.
|
|
106
|
+
├── .sanity/blueprint.config.json
|
|
107
|
+
├── sanity.blueprint.ts
|
|
108
|
+
├── package.json
|
|
109
|
+
├── functions/
|
|
110
|
+
│ └── set-slug/
|
|
111
|
+
└── studios/
|
|
112
|
+
└── studio/
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The command also creates or updates `.gitignore`. It preserves existing package metadata and adds
|
|
116
|
+
the required npm workspaces and `@sanity/blueprints` dependency.
|
|
117
|
+
|
|
118
|
+
An adopted Studio stays at the repository root. The command adds the Blueprint, Blueprint config,
|
|
119
|
+
dependency, and `.gitignore` entry, but does not generate the starter Function.
|
|
120
|
+
|
|
121
|
+
After the command exits:
|
|
122
|
+
|
|
123
|
+
1. Confirm the output names the expected organization, project, and dataset.
|
|
124
|
+
2. Confirm `.sanity/blueprint.config.json` exists. Its presence means Stack creation completed.
|
|
125
|
+
3. Review `sanity.blueprint.ts`, including the Studio slug and credentialed CORS origin, plus
|
|
126
|
+
`package.json`, `.gitignore`, and the working-tree diff.
|
|
127
|
+
4. Report the Stack ID and every created or modified path.
|
|
128
|
+
|
|
129
|
+
Do not deploy as part of initialization unless the user separately asks for deployment. To continue
|
|
130
|
+
after reviewing the scaffold, install dependencies and preview the deployment:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
npm install
|
|
134
|
+
npx @sanity/runtime-cli@blueprinit blueprints plan
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Treat dependency installation and planning as separate follow-up actions when they were not part of
|
|
138
|
+
the user's request.
|
|
139
|
+
|
|
140
|
+
## Handle failures
|
|
141
|
+
|
|
142
|
+
- **`No Sanity session found.`** Stop and ask the user to run `npx sanity login`. Authentication
|
|
143
|
+
fails before files are written.
|
|
144
|
+
- **Multiple organizations or projects found.** Rerun with the matching `--organization-id` and
|
|
145
|
+
`--project-id`. Selection fails before files are written.
|
|
146
|
+
- **No datasets found.** Ask the user to create or choose a project with a dataset. The command does
|
|
147
|
+
not create datasets.
|
|
148
|
+
- **Could not read `projectId` and `dataset`.** The detected Studio config does not contain both
|
|
149
|
+
values as string literals. Pass explicit `--project-id` and `--dataset` values or report the config
|
|
150
|
+
file and let the user decide whether to change it.
|
|
151
|
+
- **Refusing to overwrite an existing path.** Inspect the reported Studio or Function directory.
|
|
152
|
+
Do not delete or replace it without the user's direction.
|
|
153
|
+
- **Stack quota or duplicate-name error.** Local scaffold files may already exist while
|
|
154
|
+
`.sanity/blueprint.config.json` does not. Resolve the Stack error, then run the recovery command
|
|
155
|
+
printed by `blueprinit`. It uses `blueprints init` to connect the existing manifest.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints add`
|
|
2
|
+
|
|
3
|
+
Treat this command as legacy compatibility only. It is deprecated and supports only the `function` resource type. Prefer `npx @sanity/cli functions add` for new work.
|
|
4
|
+
|
|
5
|
+
## Agent guidance
|
|
6
|
+
|
|
7
|
+
- Warn that the command is deprecated before adding new usage to scripts or documentation.
|
|
8
|
+
- Migrate existing legacy invocations to `npx @sanity/cli functions add`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints config`
|
|
2
|
+
|
|
3
|
+
Read or update `.sanity/blueprint.config.json`, written next to the Blueprint manifest, which connects the local Blueprint to a Sanity scope and Stack.
|
|
4
|
+
|
|
5
|
+
## Inspect first
|
|
6
|
+
|
|
7
|
+
Run from the Blueprint directory and request structured output:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints config --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Without `--edit`, the command only displays the current configuration; with no config file on disk, `--json` emits nothing and exits `0`. Treat the project or organization ID and Stack ID as a single target; changing one can redirect later plan, deploy, info, logs, promote, or destroy commands.
|
|
14
|
+
|
|
15
|
+
## Update
|
|
16
|
+
|
|
17
|
+
For agent-driven changes, pass the intended values instead of using the interactive editor:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx @sanity/cli blueprints config --edit --project-id PROJECT_ID --stack NAME_OR_ID --json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Use `--organization-id ORGANIZATION_ID` instead of `--project-id` for an organization scope. The two scope flags are mutually exclusive. `--stack` accepts a Stack name or ID.
|
|
24
|
+
|
|
25
|
+
Scope or Stack flags without `--edit` write nothing: the command prints `To update the Blueprint config, use the --edit flag.` (suppressed under `--json`) and exits `0`, so a successful exit does not mean the change was applied.
|
|
26
|
+
|
|
27
|
+
## Switching scope
|
|
28
|
+
|
|
29
|
+
An update only sets the keys it was given. Adding `--organization-id` to a config that already holds `projectId` leaves both in the file, and project scope takes precedence over organization scope, so the switch has no effect on later commands.
|
|
30
|
+
|
|
31
|
+
To move a Blueprint from project to organization scope, either edit `.sanity/blueprint.config.json` to remove `projectId`, or use `blueprints promote`, which clears it as part of the scope change.
|
|
32
|
+
|
|
33
|
+
After an update, run `blueprints config --json` again and verify every ID before executing a mutating command.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints deploy`
|
|
2
|
+
|
|
3
|
+
Apply the local Blueprint to a remote Stack. This command can create, update, and remove remote resources.
|
|
4
|
+
|
|
5
|
+
## Preflight
|
|
6
|
+
|
|
7
|
+
1. Locate and inspect the Blueprint manifest.
|
|
8
|
+
2. Resolve the target from local configuration, or pass an explicit scope and `--stack`.
|
|
9
|
+
3. Run `npx @sanity/cli blueprints plan --json`.
|
|
10
|
+
4. Review all planned changes, especially replacements and removals.
|
|
11
|
+
|
|
12
|
+
Do not deploy when the target or plan is ambiguous.
|
|
13
|
+
|
|
14
|
+
## Deploy
|
|
15
|
+
|
|
16
|
+
Include a message that records the reason for the change:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx @sanity/cli blueprints deploy --message "Deploy order processing changes" --json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To target another Stack, pass `--stack NAME_OR_ID`, adding `--project-id PROJECT_ID` or `--organization-id ORGANIZATION_ID` when the scope also differs.
|
|
23
|
+
|
|
24
|
+
Use `--no-wait` only when the caller does not need a confirmed result. Follow an asynchronous deployment with:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx @sanity/cli blueprints info --json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Exit code `0` means the deployment completed, or was accepted when `--no-wait` is set. Exit code `2` means it failed. Exit code `75` means the request was accepted but completion could not be confirmed; inspect `blueprints info` and `blueprints logs` before retrying.
|
|
31
|
+
|
|
32
|
+
The command refuses to start while the Stack has a `QUEUED` or `IN_PROGRESS` operation, so a retry during one fails with that message rather than deploying twice. Once the earlier operation settles, a retry does deploy again.
|
|
33
|
+
|
|
34
|
+
Use `--new-stack-name NAME` only when the deployment should also rename the Stack.
|
|
35
|
+
|
|
36
|
+
Set `SANITY_ASSET_TIMEOUT` in seconds to raise the 180-second per-asset limit on processing resource assets when large Functions time out during preparation. Set `SANITY_ASSET_CONCURRENCY` to change how many assets are processed at once (default 4).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints destroy`
|
|
2
|
+
|
|
3
|
+
Permanently destroy a remote Stack and its provisioned resources. The local Blueprint manifest and resource files remain, and a matching local Stack ID is cleared from `.sanity/blueprint.config.json`.
|
|
4
|
+
|
|
5
|
+
## Required safety checks
|
|
6
|
+
|
|
7
|
+
1. Obtain explicit authorization to destroy the Stack.
|
|
8
|
+
2. Resolve the exact project or organization scope and Stack ID.
|
|
9
|
+
3. Run `npx @sanity/cli blueprints info --json` for that target.
|
|
10
|
+
4. Present the resolved target and affected resources before continuing.
|
|
11
|
+
|
|
12
|
+
Do not infer authorization from a request to clean up files, redeploy, or fix configuration.
|
|
13
|
+
|
|
14
|
+
## Run
|
|
15
|
+
|
|
16
|
+
Interactive use prompts for confirmation:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx @sanity/cli blueprints destroy
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For an authorized non-interactive destruction, provide the complete target:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npx @sanity/cli blueprints destroy --project-id PROJECT_ID --stack NAME_OR_ID --force --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use `--organization-id` instead of `--project-id` for an organization-scoped Stack. The explicit scope flags require both `--stack` and `--force`.
|
|
29
|
+
|
|
30
|
+
Use `--no-wait` only when asynchronous destruction is intended: it exits `0` as soon as the request is accepted. While waiting, exit code `75` means the request was accepted but completion could not be confirmed. Check `blueprints info` before retrying.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints doctor`
|
|
2
|
+
|
|
3
|
+
Runs five checks: Host online, Authenticated, Manifest valid, Stack ready, User has access. Run this before changing files when another Blueprint command fails for an unclear reason.
|
|
4
|
+
|
|
5
|
+
## Diagnose
|
|
6
|
+
|
|
7
|
+
Run from the project directory:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints doctor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Use `--path PATH` when the Blueprint manifest is outside the current directory or cannot be discovered automatically. `SANITY_BLUEPRINT_PATH` provides the same path through the environment.
|
|
14
|
+
|
|
15
|
+
Read the reported diagnostics and warnings before proposing changes. Do not assume every warning requires a fix.
|
|
16
|
+
|
|
17
|
+
## Read the exit code, not just the JSON
|
|
18
|
+
|
|
19
|
+
The command exits non-zero unless every check passes; a check that cannot be determined also fails the run. `--json` suppresses the report: a clean run prints `{"diagnostics": {"online": true, "tokenValid": true, ...}}` with `true`, `false`, or `null` per check, and a failing run prints an error object with no diagnostics. Rerun without `--json` to see which checks failed and why.
|
|
20
|
+
|
|
21
|
+
## Fix
|
|
22
|
+
|
|
23
|
+
`--fix` prompts for scope and Stack, then writes `.sanity/blueprint.config.json`:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx @sanity/cli blueprints doctor --fix
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`--fix` cannot be combined with `--path`, including a path supplied through `SANITY_BLUEPRINT_PATH`. It also requires authentication and a readable Blueprint manifest; without either it reports what is missing and changes nothing.
|
|
30
|
+
|
|
31
|
+
Use `--fix` only when interactive input is available and the user has authorized configuration changes. Otherwise, apply a specific, reviewed fix and rerun the read-only diagnostic command.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints info`
|
|
2
|
+
|
|
3
|
+
Read the current state and deployed resources of one remote Stack, including the status of its most recent deploy or destroy operation. Use it to verify a target before mutation.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
Use the locally configured Stack:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints info --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Query a specific target when local configuration is absent or should not be trusted:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sanity/cli blueprints info --project-id PROJECT_ID --stack NAME_OR_ID --json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Use `--organization-id` instead of `--project-id` for an organization scope. `--stack` accepts a Stack name or ID. `--verbose` (`-v`) adds each resource's ID and external ID to human-readable output.
|
|
20
|
+
|
|
21
|
+
The JSON result contains a `stack` object with `id`, `name`, `scopeType`, `scopeId`, `resources`, and `recentOperation`. Check `recentOperation.status` rather than relying on a successful exit alone.
|
|
22
|
+
|
|
23
|
+
Run this command after `deploy --no-wait`, `destroy --no-wait`, or exit code `75`. Use `blueprints stacks --json` first when the Stack ID is unknown.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints init`
|
|
2
|
+
|
|
3
|
+
Initialize a local Blueprint and connect it to a new or existing remote Stack. Use this at the start of a Blueprint project or to configure an existing manifest.
|
|
4
|
+
|
|
5
|
+
## Before running
|
|
6
|
+
|
|
7
|
+
- Authenticate with Sanity.
|
|
8
|
+
- Choose the target directory and whether the Stack belongs to a project or an organization.
|
|
9
|
+
- Check the target directory and its parents for an existing manifest (`sanity.blueprint` or `blueprint`, with `.json`, `.js`, `.mjs`, or `.ts`). When one is found, the command configures it instead of creating another manifest.
|
|
10
|
+
- Confirm whether to create a Stack or attach an existing one.
|
|
11
|
+
|
|
12
|
+
## Run
|
|
13
|
+
|
|
14
|
+
Pass `.` to initialize the current directory without the directory confirmation prompt:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx @sanity/cli blueprints init . --project-id PROJECT_ID --stack-name development
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
To connect to an existing Stack, provide its ID and scope:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npx @sanity/cli blueprints init . --project-id PROJECT_ID --stack-id STACK_ID
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use `--organization-id` instead of `--project-id` for an organization-scoped Stack. `--stack-id` and `--stack-name` are mutually exclusive, and either one requires an explicit project or organization scope.
|
|
27
|
+
|
|
28
|
+
For a new local Blueprint, choose the manifest format with `--blueprint-type json|js|ts`. JavaScript and TypeScript setups add `@sanity/blueprints` to `devDependencies`, writing a `package.json` with `"type": "module"` if the directory has none. A `js` manifest is written as `sanity.blueprint.mjs` when a `package.json` already exists there without `"type": "module"`. The command also writes `.sanity/blueprint.config.json` and a `.gitignore` covering `node_modules`, `.env`, and function build output; the `.sanity` config itself is not ignored. `--example NAME` takes a different path: it scaffolds a published example into the named directory (or `./NAME` when none is given), creates a project-scoped Stack called `example-NAME`, and cannot be combined with `--blueprint-type`, `--stack-id`, or `--stack-name`.
|
|
29
|
+
|
|
30
|
+
## Avoid the prompts
|
|
31
|
+
|
|
32
|
+
A fresh initialization is interactive unless every decision is supplied up front. Pass all four:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npx @sanity/cli blueprints init . --project-id PROJECT_ID --stack-name development --blueprint-type ts
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Omitting `--blueprint-type` prompts for the manifest format. Omitting both `--stack-id` and `--stack-name` prompts for Stack selection. Omitting the scope starts a full organization and project wizard. Omitting the directory prompts to confirm the current one.
|
|
39
|
+
|
|
40
|
+
## Verify
|
|
41
|
+
|
|
42
|
+
Inspect the created files, then preview the first deployment:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npx @sanity/cli blueprints plan --json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Do not deploy until the plan targets the expected Stack and contains the expected resource changes.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints logs`
|
|
2
|
+
|
|
3
|
+
Retrieve deployment logs for one remote Stack. Prefer bounded, one-shot queries for agent work.
|
|
4
|
+
|
|
5
|
+
## Query logs
|
|
6
|
+
|
|
7
|
+
Request structured output with an explicit limit:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints logs --limit 100 --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Narrow a query with ISO 8601 timestamps:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sanity/cli blueprints logs --since 2026-07-29T00:00:00Z --limit 100 --json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Use `--before` to page toward older entries. `--limit` must be between 1 and 500; without it the API's default page size applies. When entries are found, the JSON result contains `logs` and `hasMore`; an empty range returns no JSON payload.
|
|
20
|
+
|
|
21
|
+
Pass `--stack NAME_OR_ID` with `--project-id PROJECT_ID` or `--organization-id ORGANIZATION_ID` when overriding the locally configured target.
|
|
22
|
+
|
|
23
|
+
## Watch mode
|
|
24
|
+
|
|
25
|
+
`--watch` (`-w`, alias `--follow`) prints the 10 most recent entries, then polls for new ones until interrupted. It cannot be combined with `--json`, `--limit`, `--since`, or `--before`.
|
|
26
|
+
|
|
27
|
+
Use watch mode only when continuous monitoring is requested:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npx @sanity/cli blueprints logs --watch
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If no expected logs appear, run `blueprints info --json` and verify the Stack ID and deployment status.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints mint-deploy-token`
|
|
2
|
+
|
|
3
|
+
Create a robot token for deploying Blueprints from CI, scoped to one project or organization. The role granted is `blueprints-deployer` for a project, `blueprints-deployer-robot` for an organization.
|
|
4
|
+
|
|
5
|
+
## Protect the credential
|
|
6
|
+
|
|
7
|
+
- Obtain authorization before creating a new robot credential.
|
|
8
|
+
- Confirm the exact scope and use a label that identifies the CI system or deployment purpose.
|
|
9
|
+
- Send the token only to the user-approved secret destination.
|
|
10
|
+
- Never write the token to source files, commit it, paste it into an issue, or include it in a response or log.
|
|
11
|
+
- Revoke unused tokens in Sanity Manage.
|
|
12
|
+
|
|
13
|
+
## Run
|
|
14
|
+
|
|
15
|
+
The default command prints the robot label, ID, and expiry, then prompts for clipboard, terminal, or discard handling. For automation, `--print` emits only the raw token:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx @sanity/cli blueprints mint-deploy-token --project-id PROJECT_ID --label "production-ci" --print
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Use `--organization-id ORGANIZATION_ID` instead of `--project-id` for organization scope. The two scope flags are mutually exclusive.
|
|
22
|
+
|
|
23
|
+
`--json` returns the full robot response, including sensitive token material. Do not use it when output is collected in ordinary build logs.
|
|
24
|
+
|
|
25
|
+
A `ROLE_UNAVAILABLE` error means the role does not exist in that project or organization. Other access or permission errors mean the account needs project or organization administrator access. Do not mint repeated replacement tokens without checking whether the earlier request succeeded.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints plan`
|
|
2
|
+
|
|
3
|
+
Preview the resource changes produced by the local Blueprint without creating, modifying, or deleting deployed resources.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
Run after editing the Blueprint and before every deployment:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints plan --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The JSON result contains the resolved local `resources` and the remote deployment `plan`. Review the operations instead of treating a zero exit code as approval to deploy.
|
|
14
|
+
|
|
15
|
+
To plan against a Stack other than the locally configured one, pass its name or ID, and the scope when that differs too:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx @sanity/cli blueprints plan --project-id PROJECT_ID --stack NAME_OR_ID --json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Use `--organization-id` instead of `--project-id` for organization scope. The scope flags are mutually exclusive.
|
|
22
|
+
|
|
23
|
+
## Review
|
|
24
|
+
|
|
25
|
+
- Confirm the Stack ID and scope.
|
|
26
|
+
- Match planned resources to the requested change.
|
|
27
|
+
- Flag unexpected deletions, replacements, or unrelated changes.
|
|
28
|
+
- Stop when the target or impact cannot be determined.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints promote`
|
|
2
|
+
|
|
3
|
+
Promote a deployed Stack from project scope to organization scope. Promotion cannot be reversed, and the local Blueprint configuration is updated to the organization scope after success.
|
|
4
|
+
|
|
5
|
+
## Required safety checks
|
|
6
|
+
|
|
7
|
+
1. Obtain explicit authorization for the scope change.
|
|
8
|
+
2. Run `npx @sanity/cli blueprints info --json`.
|
|
9
|
+
3. Confirm the exact Stack ID, current project scope, and deployed resources.
|
|
10
|
+
4. Confirm the caller has organization admin access.
|
|
11
|
+
|
|
12
|
+
The command requires a local Blueprint manifest and an existing `.sanity/blueprint.config.json` to update.
|
|
13
|
+
|
|
14
|
+
## Run
|
|
15
|
+
|
|
16
|
+
Interactive use prompts for confirmation:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx @sanity/cli blueprints promote --project-id PROJECT_ID --stack NAME_OR_ID
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`--force` skips that prompt. Use `--new-stack-name NAME` to rename during promotion, which is required when the destination organization already holds a Stack with the current name; it is rejected on a Stack that is already organization-scoped.
|
|
23
|
+
|
|
24
|
+
After success, run:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx @sanity/cli blueprints config --json
|
|
28
|
+
npx @sanity/cli blueprints info --json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the remote promotion succeeds but the local config update fails, repair the configuration with `blueprints config --edit`; do not promote the Stack again.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints stacks`
|
|
2
|
+
|
|
3
|
+
List remote Stacks for a project or organization. Use this read-only command to discover a Stack ID before running a targeted info, logs, config, deploy, promote, or destroy command.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
List Stacks for the locally configured scope:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints stacks --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Select a scope explicitly when working outside the local Blueprint:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sanity/cli blueprints stacks --project-id PROJECT_ID --json
|
|
17
|
+
npx @sanity/cli blueprints stacks --organization-id ORGANIZATION_ID --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The JSON result contains `stacks`, `scopeType`, and `scopeId`; each entry carries `resourceCount` rather than a full `resources` array. Zero results prints `No stacks found` and emits no JSON. Match both the Stack and its scope; names alone may be ambiguous.
|
|
21
|
+
|
|
22
|
+
To also include Stacks scoped to the organization's projects:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npx @sanity/cli blueprints stacks --organization-id ORGANIZATION_ID --include-projects --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`--include-projects` requires `--organization-id`, cannot be combined with `--project-id`, and only queries the organization's first 50 projects. This command does not change the local Blueprint target; use `blueprints config --edit` for that.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# `npx @sanity/cli functions add`
|
|
2
|
+
|
|
3
|
+
Scaffold a local Function and its resource definition for the current Blueprint.
|
|
4
|
+
|
|
5
|
+
## Before running
|
|
6
|
+
|
|
7
|
+
- Run from a project containing a Blueprint manifest.
|
|
8
|
+
- Choose a Function name not already used by a Blueprint resource, and one event family: document, media-library asset, scheduled, or sync-tag invalidation.
|
|
9
|
+
- Names must be at least three characters, start with a letter or digit, and otherwise contain only letters, digits, hyphens, and underscores.
|
|
10
|
+
- Decide whether to install `@sanity/functions`, which provides typed helpers for authoring handler code, and which package manager to use.
|
|
11
|
+
|
|
12
|
+
## Add a Function
|
|
13
|
+
|
|
14
|
+
Provide flags to avoid interactive prompts:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx @sanity/cli functions add --name process-order --type document-create --type document-update --language ts --helpers --installer npm
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
No flag is required and any omitted value is prompted for, but `--type` without `--name` is rejected. The accepted `--type` values are `document-create`, `document-update`, `document-delete`, `document-publish`, `media-library-asset-create`, `media-library-asset-update`, `media-library-asset-delete`, `scheduled-function`, and `sync-tag-invalidate`. Repeat the flag for multiple events from the same family; the command rejects a mix of families.
|
|
21
|
+
|
|
22
|
+
TypeScript is the default language. Use `--language js` or `--javascript` for JavaScript, but do not combine those flags. Use `--no-helpers` when helper installation is not wanted. `--installer` accepts `npm`, `pnpm`, `yarn`, or `skip`.
|
|
23
|
+
|
|
24
|
+
`--example EXAMPLE_NAME` downloads a Function example from the `sanity-labs/function-recipes` repository into `functions/EXAMPLE_NAME/` instead of running the normal scaffold flow. Browse recipes at https://www.sanity.io/exchange/type=recipes/solution=functions. Each recipe's Quick Start contains the correct `--example` value. Pass it alone: every other scaffold flag is rejected, and the manifest is not updated. Use it only for an example the user requested, then follow the configuration instructions printed by the command.
|
|
25
|
+
|
|
26
|
+
## Verify
|
|
27
|
+
|
|
28
|
+
The scaffold writes one file, `functions/NAME/index.ts` (or `index.js`). Only `.json` manifests are edited in place; for `.ts`, `.js`, and `.mjs` manifests the command prints a resource definition that still needs to be added by hand.
|
|
29
|
+
|
|
30
|
+
Run the Function locally with a payload that matches the handler before deployment:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx @sanity/cli functions test process-order --file payload.json --json
|
|
34
|
+
npx @sanity/cli blueprints plan --json
|
|
35
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# `npx @sanity/cli functions dev`
|
|
2
|
+
|
|
3
|
+
Start the local web emulator for interactive Function development. The command keeps running until interrupted.
|
|
4
|
+
|
|
5
|
+
## Start the emulator
|
|
6
|
+
|
|
7
|
+
Use the default host and port:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli functions dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The emulator is available at `http://localhost:8080`. Choose another loopback port when needed:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sanity/cli functions dev --host 127.0.0.1 --port 3333 --timeout 60
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Port 8974 is not available: the emulator's WebSocket server binds it. `--timeout` sets the execution limit in seconds for every Function, taking precedence over each Function's configured `timeout` (default 10 seconds). Bind to a non-loopback interface only when network access is requested and exposing the development server is acceptable.
|
|
20
|
+
|
|
21
|
+
Run this command in a persistent terminal, report the URL, and stop the process when development is complete. For one bounded invocation without a web server, use `functions test`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# `npx @sanity/cli functions env add`
|
|
2
|
+
|
|
3
|
+
Set or replace one environment variable on a deployed Function. The command writes to the Functions API and does not redeploy the Stack.
|
|
4
|
+
|
|
5
|
+
Run from the Blueprint directory or a subdirectory; the manifest is required even though the command only touches remote state.
|
|
6
|
+
|
|
7
|
+
## Confirm the target
|
|
8
|
+
|
|
9
|
+
Resolve the deployed Function name and Stack before changing remote state. Use `functions env list` to inspect existing keys when replacing a value was not explicitly requested.
|
|
10
|
+
|
|
11
|
+
Set a non-secret value:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx @sanity/cli functions env add process-order API_URL https://api.example.com/
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Override the locally configured Stack with `--stack NAME_OR_ID`.
|
|
18
|
+
|
|
19
|
+
## Protect secret values
|
|
20
|
+
|
|
21
|
+
The value is a positional command argument and may be visible in shell history, process inspection, or agent tool transcripts. Do not run the command with a secret until the user has approved both the target and the handling method.
|
|
22
|
+
|
|
23
|
+
Do not use `--json` or `--trace` for secrets: the JSON result contains the value, and trace output prints the request body. Never paste a secret value into source files, logs, issue comments, or an assistant response.
|
|
24
|
+
|
|
25
|
+
After setting the variable, verify only its key:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npx @sanity/cli functions env list process-order --json
|
|
29
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# `npx @sanity/cli functions env list`
|
|
2
|
+
|
|
3
|
+
List the environment-variable keys configured on one deployed Function. Values are not returned.
|
|
4
|
+
|
|
5
|
+
Run from the Blueprint directory or a subdirectory; the manifest is required even though the command only touches remote state.
|
|
6
|
+
|
|
7
|
+
## Run
|
|
8
|
+
|
|
9
|
+
Use the locally configured Stack:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npx @sanity/cli functions env list process-order --json
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Query another Stack:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx @sanity/cli functions env list process-order --stack NAME_OR_ID --json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The JSON result contains the Function `name` and an `envvars` array of keys. Match the Function name and Stack before using the result to add, replace, or remove a variable.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# `npx @sanity/cli functions env remove`
|
|
2
|
+
|
|
3
|
+
Delete one environment variable from a deployed Function. The command does not ask for confirmation and does not redeploy the Stack.
|
|
4
|
+
|
|
5
|
+
Run from the Blueprint directory or a subdirectory; the manifest is required even though the command only touches remote state.
|
|
6
|
+
|
|
7
|
+
## Required checks
|
|
8
|
+
|
|
9
|
+
1. Obtain authorization to remove the key.
|
|
10
|
+
2. Resolve the exact Function and Stack.
|
|
11
|
+
3. Run `functions env list` and confirm that the key is present.
|
|
12
|
+
4. Check whether the Function still requires the variable.
|
|
13
|
+
|
|
14
|
+
## Remove
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx @sanity/cli functions env remove process-order LEGACY_API_URL --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Override the locally configured Stack with `--stack NAME_OR_ID`.
|
|
21
|
+
|
|
22
|
+
The JSON result contains the Function name and removed key, not the old value. If the value may be needed again, arrange a user-approved backup before removal; this command cannot retrieve it.
|