@sanity/runtime-cli 12.3.0 → 13.0.0

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.
Files changed (137) hide show
  1. package/README.md +190 -76
  2. package/dist/actions/blueprints/assets.d.ts +3 -1
  3. package/dist/actions/blueprints/assets.js +15 -5
  4. package/dist/actions/blueprints/blueprint.d.ts +2 -1
  5. package/dist/actions/blueprints/blueprint.js +3 -1
  6. package/dist/actions/blueprints/config.d.ts +5 -2
  7. package/dist/actions/blueprints/config.js +4 -4
  8. package/dist/actions/blueprints/logs-streaming.d.ts +4 -2
  9. package/dist/actions/blueprints/logs-streaming.js +5 -2
  10. package/dist/actions/blueprints/logs.d.ts +2 -1
  11. package/dist/actions/blueprints/logs.js +4 -2
  12. package/dist/actions/blueprints/resources.d.ts +2 -1
  13. package/dist/actions/blueprints/resources.js +2 -2
  14. package/dist/actions/blueprints/stacks.d.ts +12 -6
  15. package/dist/actions/blueprints/stacks.js +18 -11
  16. package/dist/actions/functions/dev.d.ts +2 -1
  17. package/dist/actions/functions/dev.js +2 -2
  18. package/dist/actions/functions/env/list.d.ts +2 -1
  19. package/dist/actions/functions/env/list.js +4 -2
  20. package/dist/actions/functions/env/remove.d.ts +2 -1
  21. package/dist/actions/functions/env/remove.js +4 -2
  22. package/dist/actions/functions/env/update.d.ts +2 -1
  23. package/dist/actions/functions/env/update.js +4 -2
  24. package/dist/actions/functions/logs.d.ts +4 -3
  25. package/dist/actions/functions/logs.js +10 -6
  26. package/dist/actions/node.d.ts +2 -1
  27. package/dist/actions/node.js +2 -2
  28. package/dist/actions/sanity/examples.d.ts +5 -2
  29. package/dist/actions/sanity/examples.js +6 -6
  30. package/dist/actions/sanity/projects.d.ts +7 -3
  31. package/dist/actions/sanity/projects.js +11 -7
  32. package/dist/baseCommands.d.ts +47 -7
  33. package/dist/baseCommands.js +90 -12
  34. package/dist/commands/blueprints/add.d.ts +3 -2
  35. package/dist/commands/blueprints/add.js +14 -10
  36. package/dist/commands/blueprints/config.d.ts +3 -2
  37. package/dist/commands/blueprints/config.js +12 -6
  38. package/dist/commands/blueprints/deploy.d.ts +3 -2
  39. package/dist/commands/blueprints/deploy.js +10 -4
  40. package/dist/commands/blueprints/destroy.d.ts +3 -2
  41. package/dist/commands/blueprints/destroy.js +10 -4
  42. package/dist/commands/blueprints/doctor.d.ts +6 -4
  43. package/dist/commands/blueprints/doctor.js +17 -14
  44. package/dist/commands/blueprints/info.d.ts +3 -2
  45. package/dist/commands/blueprints/info.js +11 -5
  46. package/dist/commands/blueprints/init.d.ts +3 -2
  47. package/dist/commands/blueprints/init.js +26 -20
  48. package/dist/commands/blueprints/logs.d.ts +3 -2
  49. package/dist/commands/blueprints/logs.js +10 -4
  50. package/dist/commands/blueprints/plan.d.ts +3 -2
  51. package/dist/commands/blueprints/plan.js +8 -4
  52. package/dist/commands/blueprints/stacks.d.ts +3 -2
  53. package/dist/commands/blueprints/stacks.js +10 -6
  54. package/dist/commands/functions/add.d.ts +3 -2
  55. package/dist/commands/functions/add.js +10 -4
  56. package/dist/commands/functions/dev.d.ts +3 -2
  57. package/dist/commands/functions/dev.js +16 -5
  58. package/dist/commands/functions/env/add.d.ts +4 -3
  59. package/dist/commands/functions/env/add.js +8 -4
  60. package/dist/commands/functions/env/list.d.ts +4 -3
  61. package/dist/commands/functions/env/list.js +8 -4
  62. package/dist/commands/functions/env/remove.d.ts +4 -3
  63. package/dist/commands/functions/env/remove.js +8 -4
  64. package/dist/commands/functions/logs.d.ts +5 -4
  65. package/dist/commands/functions/logs.js +11 -5
  66. package/dist/commands/functions/test.d.ts +5 -4
  67. package/dist/commands/functions/test.js +13 -6
  68. package/dist/cores/blueprints/config.d.ts +2 -5
  69. package/dist/cores/blueprints/config.js +9 -9
  70. package/dist/cores/blueprints/deploy.js +14 -17
  71. package/dist/cores/blueprints/destroy.d.ts +2 -5
  72. package/dist/cores/blueprints/destroy.js +6 -6
  73. package/dist/cores/blueprints/doctor.js +32 -29
  74. package/dist/cores/blueprints/info.js +5 -5
  75. package/dist/cores/blueprints/init.d.ts +3 -3
  76. package/dist/cores/blueprints/init.js +15 -8
  77. package/dist/cores/blueprints/logs.js +6 -7
  78. package/dist/cores/blueprints/plan.js +1 -0
  79. package/dist/cores/blueprints/stacks.d.ts +2 -5
  80. package/dist/cores/blueprints/stacks.js +4 -4
  81. package/dist/cores/functions/add.js +8 -3
  82. package/dist/cores/functions/dev.js +2 -2
  83. package/dist/cores/functions/env/add.js +3 -4
  84. package/dist/cores/functions/env/list.js +3 -4
  85. package/dist/cores/functions/env/remove.js +3 -4
  86. package/dist/cores/functions/index.d.ts +3 -9
  87. package/dist/cores/functions/logs.d.ts +3 -1
  88. package/dist/cores/functions/logs.js +19 -11
  89. package/dist/cores/functions/test.d.ts +3 -1
  90. package/dist/cores/functions/test.js +18 -10
  91. package/dist/cores/index.d.ts +4 -7
  92. package/dist/cores/index.js +3 -3
  93. package/dist/index.d.ts +1 -2
  94. package/dist/index.js +1 -2
  95. package/dist/server/app.d.ts +2 -1
  96. package/dist/server/app.js +4 -4
  97. package/dist/server/handlers/invoke.d.ts +2 -1
  98. package/dist/server/handlers/invoke.js +2 -2
  99. package/dist/server/static/components/app.css +0 -116
  100. package/dist/server/static/components/clear-button.js +1 -1
  101. package/dist/server/static/components/console-panel.js +27 -6
  102. package/dist/server/static/components/fetch-button.js +1 -1
  103. package/dist/server/static/components/filter-api-version.js +39 -3
  104. package/dist/server/static/components/filter-document-id.js +39 -3
  105. package/dist/server/static/components/filter-with-token.js +27 -4
  106. package/dist/server/static/components/filters.js +127 -62
  107. package/dist/server/static/components/function-list.js +33 -13
  108. package/dist/server/static/components/network-spinner.js +6 -4
  109. package/dist/server/static/components/payload-panel.js +46 -24
  110. package/dist/server/static/components/response-panel.js +33 -6
  111. package/dist/server/static/components/rule-panel.js +13 -4
  112. package/dist/server/static/components/run-panel.js +14 -7
  113. package/dist/server/static/components/select-dropdown.js +34 -5
  114. package/dist/server/static/components/shared-styles.js +31 -0
  115. package/dist/server/static/components/toggle-switch.js +11 -2
  116. package/dist/utils/display/blueprints-formatting.d.ts +2 -2
  117. package/dist/utils/display/blueprints-formatting.js +31 -26
  118. package/dist/utils/display/prompt.d.ts +5 -2
  119. package/dist/utils/display/prompt.js +5 -4
  120. package/dist/utils/find-function.d.ts +4 -0
  121. package/dist/utils/find-function.js +6 -0
  122. package/dist/utils/functions/fetch-document.d.ts +3 -2
  123. package/dist/utils/functions/fetch-document.js +7 -6
  124. package/dist/utils/index.d.ts +2 -0
  125. package/dist/utils/index.js +2 -0
  126. package/dist/utils/logger.d.ts +13 -0
  127. package/dist/utils/logger.js +61 -0
  128. package/dist/utils/other/github.d.ts +2 -1
  129. package/dist/utils/other/github.js +4 -2
  130. package/dist/utils/other/npmjs.d.ts +2 -1
  131. package/dist/utils/other/npmjs.js +4 -2
  132. package/dist/utils/traced-fetch.d.ts +35 -0
  133. package/dist/utils/traced-fetch.js +238 -0
  134. package/dist/utils/validated-token.d.ts +3 -2
  135. package/dist/utils/validated-token.js +6 -4
  136. package/oclif.manifest.json +455 -75
  137. package/package.json +14 -6
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity-run COMMAND
21
21
  running command...
22
22
  $ sanity-run (--version)
23
- @sanity/runtime-cli/12.3.0 linux-x64 node-v24.11.1
23
+ @sanity/runtime-cli/13.0.0 linux-x64 node-v24.12.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -44,13 +44,13 @@ USAGE
44
44
  * [`sanity-run functions env add NAME KEY VALUE`](#sanity-run-functions-env-add-name-key-value)
45
45
  * [`sanity-run functions env list NAME`](#sanity-run-functions-env-list-name)
46
46
  * [`sanity-run functions env remove NAME KEY`](#sanity-run-functions-env-remove-name-key)
47
- * [`sanity-run functions logs NAME`](#sanity-run-functions-logs-name)
48
- * [`sanity-run functions test NAME`](#sanity-run-functions-test-name)
47
+ * [`sanity-run functions logs [NAME]`](#sanity-run-functions-logs-name)
48
+ * [`sanity-run functions test [NAME]`](#sanity-run-functions-test-name)
49
49
  * [`sanity-run help [COMMAND]`](#sanity-run-help-command)
50
50
 
51
51
  ## `sanity-run blueprints add TYPE`
52
52
 
53
- Add a Resource to a Blueprint
53
+ Add a function resource to a Blueprint
54
54
 
55
55
  ```
56
56
  USAGE
@@ -60,25 +60,31 @@ USAGE
60
60
  skip|npm|pnpm|yarn] [-i | ]
61
61
 
62
62
  ARGUMENTS
63
- TYPE (function) Type of Resource to add (e.g. function)
63
+ TYPE (function) Type of resource to add (only "function" is supported)
64
64
 
65
65
  FLAGS
66
66
  -i, --install Shortcut for --fn-installer npm
67
- -n, --name=<value> Name of the Resource to add
68
- --example=<value> Example to use for the Resource
69
- --[no-]fn-helpers Add helpers to the new Function
70
- --fn-installer=<option> How to install the @sanity/functions helpers
67
+ -n, --name=<value> Name of the resource to add
68
+ --example=<value> Example to use for the function resource. Discover examples at
69
+ https://www.sanity.io/exchange/type=recipes/by=sanity
70
+ --[no-]fn-helpers Add helpers to the new function
71
+ --fn-installer=<option> Which package manager to use when installing the @sanity/functions helpers
71
72
  <options: skip|npm|pnpm|yarn>
72
73
  --fn-type=<option>... Document change event(s) that should trigger the function; you can specify multiple
73
74
  events by specifying this flag multiple times
74
75
  <options: document-create|document-delete|document-update|document-publish|media-library-
75
76
  asset-create|media-library-asset-update|media-library-asset-delete>
76
77
  --javascript Use JavaScript instead of TypeScript
77
- --language=<option> [default: ts] Language of the new Function
78
+ --language=<option> [default: ts] Language of the new function
78
79
  <options: ts|js>
79
80
 
80
81
  DESCRIPTION
81
- Add a Resource to a Blueprint
82
+ Add a function resource to a Blueprint
83
+
84
+ Scaffolds a new Sanity Function in your Blueprint. Functions are serverless handlers triggered by document events
85
+ (create, update, delete, publish) or media library events.
86
+
87
+ After adding a function, use 'functions dev' to test locally, then 'blueprints deploy' to publish it.
82
88
 
83
89
  EXAMPLES
84
90
  $ sanity-run blueprints add function
@@ -92,11 +98,11 @@ EXAMPLES
92
98
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
93
99
  ```
94
100
 
95
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/add.ts)_
101
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/add.ts)_
96
102
 
97
103
  ## `sanity-run blueprints config`
98
104
 
99
- View or edit Blueprint configuration
105
+ View or edit the local Blueprint configuration
100
106
 
101
107
  ```
102
108
  USAGE
@@ -104,12 +110,19 @@ USAGE
104
110
 
105
111
  FLAGS
106
112
  -e, --edit Modify the configuration interactively, or directly when combined with ID flags.
107
- --organization-id=<value> Directly set the Organization ID in the configuration. Requires --edit flag
108
- --project-id=<value> Directly set the Project ID in the configuration. Requires --edit flag
113
+ --organization-id=<value> Directly set the organization ID in the configuration. Requires --edit flag
114
+ --project-id=<value> Directly set the project ID in the configuration. Requires --edit flag
109
115
  --stack-id=<value> Directly set the Stack ID in the configuration. Requires --edit flag
110
116
 
111
117
  DESCRIPTION
112
- View or edit Blueprint configuration
118
+ View or edit the local Blueprint configuration
119
+
120
+ Manages the local Blueprint configuration, which links your Blueprint to a Sanity project and Stack.
121
+
122
+ Without flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with
123
+ ID flags to update values directly (useful for scripting and automation).
124
+
125
+ If you need to switch your Blueprint to a different Stack, use --edit --stack-id.
113
126
 
114
127
  EXAMPLES
115
128
  $ sanity-run blueprints config
@@ -121,11 +134,11 @@ EXAMPLES
121
134
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
122
135
  ```
123
136
 
124
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/config.ts)_
137
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/config.ts)_
125
138
 
126
139
  ## `sanity-run blueprints deploy`
127
140
 
128
- Deploy a Blueprint
141
+ Deploy the local Blueprint to the remote Stack
129
142
 
130
143
  ```
131
144
  USAGE
@@ -135,7 +148,15 @@ FLAGS
135
148
  --no-wait Do not wait for Stack deployment to complete
136
149
 
137
150
  DESCRIPTION
138
- Deploy a Blueprint
151
+ Deploy the local Blueprint to the remote Stack
152
+
153
+ Pushes your local Blueprint configuration to the remote Stack; provisioning, updating, or destroying resources as
154
+ needed. This is the primary command for applying infrastructure changes.
155
+
156
+ Before deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack
157
+ status or 'blueprints logs' to monitor activity.
158
+
159
+ Use --no-wait to queue the deployment and return immediately without waiting for completion.
139
160
 
140
161
  EXAMPLES
141
162
  $ sanity-run blueprints deploy
@@ -143,11 +164,11 @@ EXAMPLES
143
164
  $ sanity-run blueprints deploy --no-wait
144
165
  ```
145
166
 
146
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/deploy.ts)_
167
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/deploy.ts)_
147
168
 
148
169
  ## `sanity-run blueprints destroy`
149
170
 
150
- Destroy a Blueprint Stack deployment and its resources (will not delete local files)
171
+ Destroy the remote Stack deployment and its resources (will not delete local files)
151
172
 
152
173
  ```
153
174
  USAGE
@@ -162,7 +183,14 @@ FLAGS
162
183
  --stack-id=<value> Stack ID to destroy (defaults to current Stack)
163
184
 
164
185
  DESCRIPTION
165
- Destroy a Blueprint Stack deployment and its resources (will not delete local files)
186
+ Destroy the remote Stack deployment and its resources (will not delete local files)
187
+
188
+ Permanently removes the remote Stack and all its provisioned resources. Your local Blueprint files remain untouched,
189
+ allowing you to redeploy later with 'blueprints init' + 'blueprints deploy'.
190
+
191
+ This is a destructive operation. You will be prompted to confirm unless --force is specified.
192
+
193
+ Use this to clean up test environments or decommission a Stack you no longer need.
166
194
 
167
195
  EXAMPLES
168
196
  $ sanity-run blueprints destroy
@@ -170,40 +198,55 @@ EXAMPLES
170
198
  $ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
171
199
  ```
172
200
 
173
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/destroy.ts)_
201
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/destroy.ts)_
174
202
 
175
203
  ## `sanity-run blueprints doctor`
176
204
 
177
- Diagnose potential issues with Blueprint configuration
205
+ Diagnose potential issues with local Blueprint and remote Stack configuration
178
206
 
179
207
  ```
180
208
  USAGE
181
- $ sanity-run blueprints doctor [--verbose] [--path <value>] [--fix]
209
+ $ sanity-run blueprints doctor [--json] [--path <value>] [--verbose] [--fix]
182
210
 
183
211
  FLAGS
184
212
  --fix Interactively fix configuration issues
185
- --path=<value> Path to the Blueprint configuration file
186
- --verbose Provide detailed information about issues
213
+ --json Format output as json.
214
+ --path=<value> Path to the directory containing the Blueprint
215
+ --verbose Verbose output
187
216
 
188
217
  DESCRIPTION
189
- Diagnose potential issues with Blueprint configuration
218
+ Diagnose potential issues with local Blueprint and remote Stack configuration
219
+
220
+ Analyzes your local Blueprint and remote Stack configuration for common issues, such as missing authentication,
221
+ invalid project references, or misconfigured resources.
222
+
223
+ Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected
224
+ issues.
190
225
  ```
191
226
 
192
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/doctor.ts)_
227
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/doctor.ts)_
193
228
 
194
229
  ## `sanity-run blueprints info`
195
230
 
196
- Show information about a Blueprint Stack deployment
231
+ Show information about the local Blueprint's remote Stack deployment
197
232
 
198
233
  ```
199
234
  USAGE
200
235
  $ sanity-run blueprints info [--id <value>]
201
236
 
202
237
  FLAGS
203
- --id=<value> Stack ID to show info for (defaults to current Stack)
238
+ --id=<value> Stack ID to show info for (defaults to the current Stack)
204
239
 
205
240
  DESCRIPTION
206
- Show information about a Blueprint Stack deployment
241
+ Show information about the local Blueprint's remote Stack deployment
242
+
243
+ Displays the current state and metadata of your remote Stack deployment, including deployed resources, status, and
244
+ configuration.
245
+
246
+ Use this command to verify a deployment succeeded, check what resources are live, or confirm which Stack your local
247
+ Blueprint is connected to.
248
+
249
+ Run 'blueprints stacks' to see all available Stacks in your project or organization.
207
250
 
208
251
  EXAMPLES
209
252
  $ sanity-run blueprints info
@@ -211,33 +254,44 @@ EXAMPLES
211
254
  $ sanity-run blueprints info --id <stackId>
212
255
  ```
213
256
 
214
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/info.ts)_
257
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/info.ts)_
215
258
 
216
259
  ## `sanity-run blueprints init [DIR]`
217
260
 
218
- Initialize a new Blueprint Stack deployment
261
+ Initialize a local Blueprint and optionally provision a remote Stack deployment
219
262
 
220
263
  ```
221
264
  USAGE
222
- $ sanity-run blueprints init [DIR] [--dir <value>] [--example <value> | --blueprint-type json|js|ts | --stack-id
223
- <value> | --stack-name <value>] [--project-id <value>] [--organization-id <value>] [--verbose]
265
+ $ sanity-run blueprints init [DIR] [--verbose] [--dir <value>] [--example <value> | --blueprint-type json|js|ts |
266
+ --stack-id <value> | --stack-name <value>] [--project-id <value>] [--organization-id <value>]
224
267
 
225
268
  ARGUMENTS
226
- [DIR] Directory to create the Blueprint in
269
+ [DIR] Directory to create the local Blueprint in
227
270
 
228
271
  FLAGS
229
- --blueprint-type=<option> Blueprint manifest type to use for the Blueprint
272
+ --blueprint-type=<option> Blueprint manifest type to use for the local Blueprint
230
273
  <options: json|js|ts>
231
- --dir=<value> Directory to create the Blueprint in
232
- --example=<value> Example to use for the Blueprint
233
- --organization-id=<value> Sanity Organization ID to use for the Blueprint
234
- --project-id=<value> Sanity Project ID to use for the Blueprint
235
- --stack-id=<value> Existing Stack ID to use for the Blueprint
236
- --stack-name=<value> Name to use for a NEW Stack
274
+ --dir=<value> Directory to create the local Blueprint in
275
+ --example=<value> Example to use for the local Blueprint
276
+ --organization-id=<value> Sanity organization ID used to scope local Blueprint and remote Stack
277
+ --project-id=<value> Sanity project ID used to scope local Blueprint and remote Stack
278
+ --stack-id=<value> Existing Stack ID used to scope local Blueprint
279
+ --stack-name=<value> Name to use for a new Stack provisioned during initialization
237
280
  --verbose Verbose output
238
281
 
239
282
  DESCRIPTION
240
- Initialize a new Blueprint Stack deployment
283
+ Initialize a local Blueprint and optionally provision a remote Stack deployment
284
+
285
+ A Blueprint is your local infrastructure-as-code configuration that defines Sanity resources (datasets, functions,
286
+ etc.). A Stack is the remote deployment target where your Blueprint is applied.
287
+ [NOTE: Currently, accounts are limited to three (3) Stacks per project scope.]
288
+
289
+ This is typically the first command you run in a new project. It creates a local Blueprint manifest file
290
+ (sanity.blueprint.ts, .js, or .json) and provisions a new remote Stack.
291
+ Additionally, a Blueprint configuration file is created in .sanity/ containing the scope and Stack IDs. This is
292
+ .gitignored by default.
293
+
294
+ After initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.
241
295
 
242
296
  EXAMPLES
243
297
  $ sanity-run blueprints init
@@ -251,11 +305,11 @@ EXAMPLES
251
305
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
252
306
  ```
253
307
 
254
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/init.ts)_
308
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/init.ts)_
255
309
 
256
310
  ## `sanity-run blueprints logs`
257
311
 
258
- Display logs for a Blueprint Stack deployment
312
+ Display logs for the current Blueprint's Stack deployment
259
313
 
260
314
  ```
261
315
  USAGE
@@ -265,7 +319,13 @@ FLAGS
265
319
  -w, --watch Watch for new Stack logs (streaming mode)
266
320
 
267
321
  DESCRIPTION
268
- Display logs for a Blueprint Stack deployment
322
+ Display logs for the current Blueprint's Stack deployment
323
+
324
+ Retrieves Stack deployment logs, useful for debugging and monitoring deployment activity.
325
+
326
+ Use --watch (-w) to stream logs in real-time.
327
+
328
+ If you're not seeing expected logs, verify your Stack is deployed with 'blueprints info'.
269
329
 
270
330
  EXAMPLES
271
331
  $ sanity-run blueprints logs
@@ -273,39 +333,50 @@ EXAMPLES
273
333
  $ sanity-run blueprints logs --watch
274
334
  ```
275
335
 
276
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/logs.ts)_
336
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/logs.ts)_
277
337
 
278
338
  ## `sanity-run blueprints plan`
279
339
 
280
- Enumerate resources to be deployed - will not modify any resources
340
+ Enumerate resources to be deployed to the remote Stack - will not modify any resources
281
341
 
282
342
  ```
283
343
  USAGE
284
344
  $ sanity-run blueprints plan
285
345
 
286
346
  DESCRIPTION
287
- Enumerate resources to be deployed - will not modify any resources
347
+ Enumerate resources to be deployed to the remote Stack - will not modify any resources
348
+
349
+ Use this command to preview what changes will be applied to your remote Stack before deploying. This is a safe,
350
+ read-only operation—no resources are created, modified, or deleted.
351
+
352
+ Run 'blueprints plan' after making local changes to your Blueprint manifest to verify the expected diff. When ready,
353
+ run 'blueprints deploy' to apply changes.
288
354
 
289
355
  EXAMPLES
290
356
  $ sanity-run blueprints plan
291
357
  ```
292
358
 
293
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/plan.ts)_
359
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/plan.ts)_
294
360
 
295
361
  ## `sanity-run blueprints stacks`
296
362
 
297
- List all Blueprint Stacks
363
+ List all remote Stack deployments (defaults to the current Blueprint's project scope)
298
364
 
299
365
  ```
300
366
  USAGE
301
367
  $ sanity-run blueprints stacks [--project-id <value> | --organization-id <value>]
302
368
 
303
369
  FLAGS
304
- --organization-id=<value> Organization ID to show stacks for
305
- --project-id=<value> Project ID to show stacks for
370
+ --organization-id=<value> Organization ID to show Stack deployments for
371
+ --project-id=<value> Project ID to show Stack deployments for
306
372
 
307
373
  DESCRIPTION
308
- List all Blueprint Stacks
374
+ List all remote Stack deployments (defaults to the current Blueprint's project scope)
375
+
376
+ Shows all Stacks associated with a project or organization. By default, lists Stacks scoped to the local Blueprint.
377
+
378
+ Use this to discover existing Stacks you can scope a local Blueprint to (using 'blueprints config --edit'), or to
379
+ audit what's deployed across your project.
309
380
 
310
381
  EXAMPLES
311
382
  $ sanity-run blueprints stacks
@@ -315,7 +386,7 @@ EXAMPLES
315
386
  $ sanity-run blueprints stacks --organization-id <organizationId>
316
387
  ```
317
388
 
318
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/blueprints/stacks.ts)_
389
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/blueprints/stacks.ts)_
319
390
 
320
391
  ## `sanity-run functions add`
321
392
 
@@ -345,6 +416,13 @@ FLAGS
345
416
  DESCRIPTION
346
417
  Add a Function to your Blueprint
347
418
 
419
+ Scaffolds a new Function in the functions/ folder and templates a resource for your Blueprint manifest.
420
+
421
+ Functions are serverless handlers triggered by document events (create, update, delete, publish) or media library
422
+ events.
423
+
424
+ After adding, use 'functions dev' to test locally, then 'blueprints deploy' to publish.
425
+
348
426
  EXAMPLES
349
427
  $ sanity-run functions add
350
428
 
@@ -357,7 +435,7 @@ EXAMPLES
357
435
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
358
436
  ```
359
437
 
360
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/add.ts)_
438
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/add.ts)_
361
439
 
362
440
  ## `sanity-run functions dev`
363
441
 
@@ -376,15 +454,26 @@ FLAGS
376
454
  DESCRIPTION
377
455
  Start the Sanity Function emulator
378
456
 
457
+ Runs a local, web-based development server to test your functions before deploying.
458
+
459
+ Open the emulator in your browser to interactively test your functions with the payload editor.
460
+
461
+ Optionally, set the host and port with the --host and --port flags. Function timeout can be configured with the
462
+ --timeout flag.
463
+
464
+ To invoke a function with the CLI, use 'functions test'.
465
+
379
466
  EXAMPLES
380
467
  $ sanity-run functions dev --host 127.0.0.1 --port 8974
468
+
469
+ $ sanity-run functions dev --timeout 60
381
470
  ```
382
471
 
383
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/dev.ts)_
472
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/dev.ts)_
384
473
 
385
474
  ## `sanity-run functions env add NAME KEY VALUE`
386
475
 
387
- Add or set the value of an environment variable for a Sanity function
476
+ Add or set an environment variable for a deployed function
388
477
 
389
478
  ```
390
479
  USAGE
@@ -396,17 +485,22 @@ ARGUMENTS
396
485
  VALUE The value of the environment variable
397
486
 
398
487
  DESCRIPTION
399
- Add or set the value of an environment variable for a Sanity function
488
+ Add or set an environment variable for a deployed function
489
+
490
+ Sets an environment variable in a deployed Sanity Function. If the variable already exists, its value is updated.
491
+
492
+ Environment variables are useful for API keys, configuration values, and other secrets that shouldn't be hardcoded.
493
+ Changes take effect on the next function invocation.
400
494
 
401
495
  EXAMPLES
402
496
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
403
497
  ```
404
498
 
405
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/env/add.ts)_
499
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/env/add.ts)_
406
500
 
407
501
  ## `sanity-run functions env list NAME`
408
502
 
409
- List the environment variables for a Sanity function
503
+ List environment variables for a deployed function
410
504
 
411
505
  ```
412
506
  USAGE
@@ -416,17 +510,21 @@ ARGUMENTS
416
510
  NAME The name of the Sanity Function
417
511
 
418
512
  DESCRIPTION
419
- List the environment variables for a Sanity function
513
+ List environment variables for a deployed function
514
+
515
+ Displays all environment variables (keys only) configured in a deployed Sanity Function.
516
+
517
+ Use 'functions env add' to set variables or 'functions env remove' to delete them.
420
518
 
421
519
  EXAMPLES
422
520
  $ sanity-run functions env list MyFunction
423
521
  ```
424
522
 
425
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/env/list.ts)_
523
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/env/list.ts)_
426
524
 
427
525
  ## `sanity-run functions env remove NAME KEY`
428
526
 
429
- Remove an environment variable for a Sanity function
527
+ Remove an environment variable from a deployed function
430
528
 
431
529
  ```
432
530
  USAGE
@@ -437,24 +535,29 @@ ARGUMENTS
437
535
  KEY The name of the environment variable
438
536
 
439
537
  DESCRIPTION
440
- Remove an environment variable for a Sanity function
538
+ Remove an environment variable from a deployed function
539
+
540
+ Deletes an environment variable from a deployed Sanity Function. The change takes effect on the next function
541
+ invocation.
542
+
543
+ Use 'functions env list' to see current variables before removing.
441
544
 
442
545
  EXAMPLES
443
546
  $ sanity-run functions env remove MyFunction API_URL
444
547
  ```
445
548
 
446
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/env/remove.ts)_
549
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/env/remove.ts)_
447
550
 
448
- ## `sanity-run functions logs NAME`
551
+ ## `sanity-run functions logs [NAME]`
449
552
 
450
553
  Retrieve or delete logs for a Sanity Function
451
554
 
452
555
  ```
453
556
  USAGE
454
- $ sanity-run functions logs NAME [-u] [-f [-d | -l <value> | -j]] [-w]
557
+ $ sanity-run functions logs [NAME] [-u] [-f [-d | -l <value> | -j]] [-w]
455
558
 
456
559
  ARGUMENTS
457
- NAME The name of the Sanity Function
560
+ [NAME] The name of the Sanity Function
458
561
 
459
562
  FLAGS
460
563
  -d, --delete Delete all logs for the function
@@ -467,6 +570,11 @@ FLAGS
467
570
  DESCRIPTION
468
571
  Retrieve or delete logs for a Sanity Function
469
572
 
573
+ Fetches execution logs from a deployed function, useful for debugging production issues or monitoring activity.
574
+
575
+ Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for a function (requires confirmation
576
+ unless --force is specified).
577
+
470
578
  EXAMPLES
471
579
  $ sanity-run functions logs <name>
472
580
 
@@ -477,21 +585,21 @@ EXAMPLES
477
585
  $ sanity-run functions logs <name> --delete
478
586
  ```
479
587
 
480
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/logs.ts)_
588
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/logs.ts)_
481
589
 
482
- ## `sanity-run functions test NAME`
590
+ ## `sanity-run functions test [NAME]`
483
591
 
484
592
  Invoke a local Sanity Function
485
593
 
486
594
  ```
487
595
  USAGE
488
- $ sanity-run functions test NAME [--data-before <value> | [-d <value> | -f <value> | --document-id <value>] | |
596
+ $ sanity-run functions test [NAME] [--data-before <value> | [-d <value> | -f <value> | --document-id <value>] | |
489
597
  | --file-before <value> | --file-after <value> | --document-id-before <value> | --document-id-after <value>]
490
598
  [--data-after <value> | | | | | | | ] [-e create|update|delete] [-t <value>] [-a <value>] [--organization-id
491
599
  <value>] [--with-user-token] [--media-library-id <value> | --project-id <value> | --dataset <value>]
492
600
 
493
601
  ARGUMENTS
494
- NAME The name of the Sanity Function
602
+ [NAME] The name of the Sanity Function
495
603
 
496
604
  FLAGS
497
605
  -a, --api=<value> Sanity API Version to use
@@ -516,6 +624,12 @@ FLAGS
516
624
  DESCRIPTION
517
625
  Invoke a local Sanity Function
518
626
 
627
+ Executes a function locally with the provided payload, simulating how it would run when deployed. Use this to test
628
+ your function logic before deploying.
629
+
630
+ Provide test data via --data (inline JSON), --file (JSON file), or --document-id (fetch from Sanity). For update
631
+ events, use the before/after flag pairs to simulate document changes.
632
+
519
633
  EXAMPLES
520
634
  $ sanity-run functions test <name> --data '{ "id": 1 }'
521
635
 
@@ -526,7 +640,7 @@ EXAMPLES
526
640
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
527
641
  ```
528
642
 
529
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v12.3.0/src/commands/functions/test.ts)_
643
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.0/src/commands/functions/test.ts)_
530
644
 
531
645
  ## `sanity-run help [COMMAND]`
532
646
 
@@ -1,10 +1,12 @@
1
1
  import AdmZip from 'adm-zip';
2
+ import type { Logger } from '../../utils/logger.js';
2
3
  import type { AuthParams, CollectionFunction, FunctionResource } from '../../utils/types.js';
3
4
  export declare const ASSET_CHECK_URL: string;
4
5
  export declare const ASSET_STASH_URL: string;
5
- export declare function stashAsset({ resource, auth, }: {
6
+ export declare function stashAsset({ resource, auth, logger, }: {
6
7
  resource: FunctionResource | CollectionFunction;
7
8
  auth: AuthParams;
9
+ logger: ReturnType<typeof Logger>;
8
10
  }): Promise<{
9
11
  success: boolean;
10
12
  assetId?: string;
@@ -10,6 +10,7 @@ import { resolveResourceDependencies } from '../../utils/functions/resolve-depen
10
10
  import { shouldAutoResolveDependencies } from '../../utils/functions/should-auto-resolve-deps.js';
11
11
  import { shouldTranspileFunction } from '../../utils/functions/should-transpile.js';
12
12
  import getHeaders from '../../utils/get-headers.js';
13
+ import { createTracedFetch } from '../../utils/traced-fetch.js';
13
14
  import { transpileFunction } from '../../utils/transpile/transpile-function.js';
14
15
  import { isLocalFunctionCollection } from '../../utils/types.js';
15
16
  const { apiUrl } = config;
@@ -17,10 +18,11 @@ const ASSETS_URL = `${apiUrl}vX/blueprints/assets`;
17
18
  export const ASSET_CHECK_URL = `${ASSETS_URL}/check`;
18
19
  export const ASSET_STASH_URL = `${ASSETS_URL}/stash`;
19
20
  const MAX_ASSET_SIZE = 209_715_200; // 200 MB in bytes
20
- export async function stashAsset({ resource, auth, }) {
21
+ export async function stashAsset({ resource, auth, logger, }) {
21
22
  const isCollection = isLocalFunctionCollection(resource);
22
23
  const functions = isCollection ? resource.functions : [resource];
23
24
  const combinedAsset = [];
25
+ const prepareErrors = [];
24
26
  try {
25
27
  for (const func of functions) {
26
28
  const prepResult = await prepareAsset({ resource: func, auth });
@@ -30,13 +32,18 @@ export async function stashAsset({ resource, auth, }) {
30
32
  partAsset: { outputPath: prepResult.outputPath, cleanup: prepResult.cleanup },
31
33
  });
32
34
  }
35
+ else if (prepResult.error) {
36
+ prepareErrors.push({ name: func.name, error: prepResult.error });
37
+ }
33
38
  }
34
39
  if (combinedAsset.length !== functions.length) {
35
40
  const processedNames = new Set(combinedAsset.map((asset) => asset.name));
36
41
  const failedFunctions = functions.filter((func) => !processedNames.has(func.name));
42
+ const failedNames = failedFunctions.map((f) => f.name).join(', ');
43
+ const errorDetails = prepareErrors.map((e) => `${e.name}: ${e.error}`).join('; ');
37
44
  return {
38
45
  success: false,
39
- error: `Failed to prepare ${failedFunctions.length} function(s) in collection: ${failedFunctions.map((f) => f.name).join(', ')}`,
46
+ error: `Failed to prepare ${failedFunctions.length} function(s) in blueprint: ${failedNames}${errorDetails ? `. Details: ${errorDetails}` : ''}`,
40
47
  };
41
48
  }
42
49
  let result = { success: false };
@@ -48,6 +55,7 @@ export async function stashAsset({ resource, auth, }) {
48
55
  cleanup: combinedResult.cleanup,
49
56
  resource: resource,
50
57
  auth,
58
+ logger,
51
59
  collectionInfo: {
52
60
  name: resource.name,
53
61
  functionCount: resource.functions.length,
@@ -64,6 +72,7 @@ export async function stashAsset({ resource, auth, }) {
64
72
  cleanup: combinedAsset[0].partAsset.cleanup,
65
73
  resource: resource,
66
74
  auth,
75
+ logger,
67
76
  });
68
77
  }
69
78
  return result;
@@ -149,11 +158,12 @@ async function combineAssets(allAssets) {
149
158
  return { error: err instanceof Error ? err.message : `${err}` };
150
159
  }
151
160
  }
152
- async function stashSingleAsset({ outputPath, cleanup, resource, auth, collectionInfo, }) {
161
+ async function stashSingleAsset({ outputPath, cleanup, resource, auth, logger, collectionInfo, }) {
162
+ const fetchFn = createTracedFetch(logger);
153
163
  try {
154
164
  const { b64, hash } = await pathToB64ZipHash(outputPath);
155
165
  try {
156
- const checkResponse = await fetch(`${ASSET_CHECK_URL}/${hash}`, {
166
+ const checkResponse = await fetchFn(`${ASSET_CHECK_URL}/${hash}`, {
157
167
  method: 'GET',
158
168
  headers: getHeaders(auth),
159
169
  });
@@ -164,7 +174,7 @@ async function stashSingleAsset({ outputPath, cleanup, resource, auth, collectio
164
174
  }
165
175
  catch { } // Continue to stash the Asset
166
176
  // Asset doesn't exist, so stash it
167
- const assetResponse = await fetch(ASSET_STASH_URL, {
177
+ const assetResponse = await fetchFn(ASSET_STASH_URL, {
168
178
  method: 'POST',
169
179
  headers: getHeaders(auth),
170
180
  body: JSON.stringify({