@sanity/runtime-cli 12.4.0 → 13.0.1
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 +176 -63
- package/dist/actions/blueprints/assets.d.ts +3 -1
- package/dist/actions/blueprints/assets.js +8 -4
- package/dist/actions/blueprints/blueprint.d.ts +2 -1
- package/dist/actions/blueprints/blueprint.js +3 -1
- package/dist/actions/blueprints/config.d.ts +5 -2
- package/dist/actions/blueprints/config.js +4 -4
- package/dist/actions/blueprints/logs-streaming.d.ts +4 -2
- package/dist/actions/blueprints/logs-streaming.js +5 -2
- package/dist/actions/blueprints/logs.d.ts +2 -1
- package/dist/actions/blueprints/logs.js +4 -2
- package/dist/actions/blueprints/resources.d.ts +2 -1
- package/dist/actions/blueprints/resources.js +2 -2
- package/dist/actions/blueprints/stacks.d.ts +12 -6
- package/dist/actions/blueprints/stacks.js +18 -11
- package/dist/actions/functions/dev.d.ts +2 -1
- package/dist/actions/functions/dev.js +2 -2
- package/dist/actions/functions/env/list.d.ts +2 -1
- package/dist/actions/functions/env/list.js +4 -2
- package/dist/actions/functions/env/remove.d.ts +2 -1
- package/dist/actions/functions/env/remove.js +4 -2
- package/dist/actions/functions/env/update.d.ts +2 -1
- package/dist/actions/functions/env/update.js +4 -2
- package/dist/actions/functions/logs.d.ts +4 -3
- package/dist/actions/functions/logs.js +10 -6
- package/dist/actions/node.d.ts +2 -1
- package/dist/actions/node.js +2 -2
- package/dist/actions/sanity/examples.d.ts +5 -2
- package/dist/actions/sanity/examples.js +6 -6
- package/dist/actions/sanity/projects.d.ts +7 -3
- package/dist/actions/sanity/projects.js +11 -7
- package/dist/baseCommands.d.ts +4 -0
- package/dist/baseCommands.js +8 -2
- package/dist/commands/blueprints/add.d.ts +1 -0
- package/dist/commands/blueprints/add.js +12 -8
- package/dist/commands/blueprints/config.d.ts +1 -0
- package/dist/commands/blueprints/config.js +10 -4
- package/dist/commands/blueprints/deploy.d.ts +1 -0
- package/dist/commands/blueprints/deploy.js +8 -2
- package/dist/commands/blueprints/destroy.d.ts +1 -0
- package/dist/commands/blueprints/destroy.js +8 -2
- package/dist/commands/blueprints/doctor.d.ts +1 -0
- package/dist/commands/blueprints/doctor.js +7 -2
- package/dist/commands/blueprints/info.d.ts +1 -0
- package/dist/commands/blueprints/info.js +9 -3
- package/dist/commands/blueprints/init.d.ts +1 -0
- package/dist/commands/blueprints/init.js +20 -11
- package/dist/commands/blueprints/logs.d.ts +1 -0
- package/dist/commands/blueprints/logs.js +8 -2
- package/dist/commands/blueprints/plan.d.ts +1 -0
- package/dist/commands/blueprints/plan.js +6 -2
- package/dist/commands/blueprints/stacks.d.ts +1 -0
- package/dist/commands/blueprints/stacks.js +8 -4
- package/dist/commands/functions/add.d.ts +1 -0
- package/dist/commands/functions/add.js +8 -2
- package/dist/commands/functions/dev.d.ts +1 -0
- package/dist/commands/functions/dev.js +14 -3
- package/dist/commands/functions/env/add.d.ts +2 -1
- package/dist/commands/functions/env/add.js +6 -2
- package/dist/commands/functions/env/list.d.ts +2 -1
- package/dist/commands/functions/env/list.js +6 -2
- package/dist/commands/functions/env/remove.d.ts +2 -1
- package/dist/commands/functions/env/remove.js +6 -2
- package/dist/commands/functions/logs.d.ts +2 -1
- package/dist/commands/functions/logs.js +7 -4
- package/dist/commands/functions/test.d.ts +2 -1
- package/dist/commands/functions/test.js +6 -2
- package/dist/cores/blueprints/config.js +9 -9
- package/dist/cores/blueprints/deploy.js +14 -16
- package/dist/cores/blueprints/destroy.js +6 -6
- package/dist/cores/blueprints/doctor.js +20 -27
- package/dist/cores/blueprints/info.js +3 -3
- package/dist/cores/blueprints/init.d.ts +3 -3
- package/dist/cores/blueprints/init.js +15 -8
- package/dist/cores/blueprints/logs.js +6 -7
- package/dist/cores/blueprints/plan.js +1 -0
- package/dist/cores/blueprints/stacks.js +4 -4
- package/dist/cores/functions/add.js +8 -3
- package/dist/cores/functions/dev.js +2 -2
- package/dist/cores/functions/env/add.js +3 -4
- package/dist/cores/functions/env/list.js +3 -4
- package/dist/cores/functions/env/remove.js +3 -4
- package/dist/cores/functions/index.d.ts +3 -9
- package/dist/cores/functions/logs.js +8 -9
- package/dist/cores/functions/test.js +7 -8
- package/dist/cores/index.d.ts +4 -7
- package/dist/cores/index.js +3 -3
- package/dist/index.d.ts +18 -2
- package/dist/index.js +20 -2
- package/dist/server/app.d.ts +2 -1
- package/dist/server/app.js +4 -4
- package/dist/server/handlers/invoke.d.ts +2 -1
- package/dist/server/handlers/invoke.js +2 -2
- package/dist/server/static/components/response-panel.js +3 -0
- package/dist/server/static/components/rule-panel.js +9 -1
- package/dist/utils/display/prompt.d.ts +5 -2
- package/dist/utils/display/prompt.js +5 -4
- package/dist/utils/functions/fetch-document.d.ts +3 -2
- package/dist/utils/functions/fetch-document.js +7 -6
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.js +61 -0
- package/dist/utils/other/github.d.ts +2 -1
- package/dist/utils/other/github.js +4 -2
- package/dist/utils/other/npmjs.d.ts +2 -1
- package/dist/utils/other/npmjs.js +4 -2
- package/dist/utils/traced-fetch.d.ts +35 -0
- package/dist/utils/traced-fetch.js +238 -0
- package/dist/utils/validated-token.d.ts +3 -2
- package/dist/utils/validated-token.js +6 -4
- package/oclif.manifest.json +175 -38
- package/package.json +13 -5
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/
|
|
23
|
+
@sanity/runtime-cli/13.0.1 linux-x64 node-v24.12.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -50,7 +50,7 @@ USAGE
|
|
|
50
50
|
|
|
51
51
|
## `sanity-run blueprints add TYPE`
|
|
52
52
|
|
|
53
|
-
Add a
|
|
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
|
|
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
|
|
68
|
-
--example=<value> Example to use for the
|
|
69
|
-
|
|
70
|
-
--fn-
|
|
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
|
|
78
|
+
--language=<option> [default: ts] Language of the new function
|
|
78
79
|
<options: ts|js>
|
|
79
80
|
|
|
80
81
|
DESCRIPTION
|
|
81
|
-
Add a
|
|
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/
|
|
101
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/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
|
|
108
|
-
--project-id=<value> Directly set the
|
|
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/
|
|
137
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/config.ts)_
|
|
125
138
|
|
|
126
139
|
## `sanity-run blueprints deploy`
|
|
127
140
|
|
|
128
|
-
Deploy
|
|
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
|
|
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/
|
|
167
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/deploy.ts)_
|
|
147
168
|
|
|
148
169
|
## `sanity-run blueprints destroy`
|
|
149
170
|
|
|
150
|
-
Destroy
|
|
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
|
|
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,11 +198,11 @@ 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/
|
|
201
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/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
|
|
@@ -187,24 +215,38 @@ FLAGS
|
|
|
187
215
|
--verbose Verbose output
|
|
188
216
|
|
|
189
217
|
DESCRIPTION
|
|
190
|
-
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.
|
|
191
225
|
```
|
|
192
226
|
|
|
193
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
227
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/doctor.ts)_
|
|
194
228
|
|
|
195
229
|
## `sanity-run blueprints info`
|
|
196
230
|
|
|
197
|
-
Show information about
|
|
231
|
+
Show information about the local Blueprint's remote Stack deployment
|
|
198
232
|
|
|
199
233
|
```
|
|
200
234
|
USAGE
|
|
201
235
|
$ sanity-run blueprints info [--id <value>]
|
|
202
236
|
|
|
203
237
|
FLAGS
|
|
204
|
-
--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)
|
|
205
239
|
|
|
206
240
|
DESCRIPTION
|
|
207
|
-
Show information about
|
|
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.
|
|
208
250
|
|
|
209
251
|
EXAMPLES
|
|
210
252
|
$ sanity-run blueprints info
|
|
@@ -212,11 +254,11 @@ EXAMPLES
|
|
|
212
254
|
$ sanity-run blueprints info --id <stackId>
|
|
213
255
|
```
|
|
214
256
|
|
|
215
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
257
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/info.ts)_
|
|
216
258
|
|
|
217
259
|
## `sanity-run blueprints init [DIR]`
|
|
218
260
|
|
|
219
|
-
Initialize a
|
|
261
|
+
Initialize a local Blueprint and optionally provision a remote Stack deployment
|
|
220
262
|
|
|
221
263
|
```
|
|
222
264
|
USAGE
|
|
@@ -224,21 +266,32 @@ USAGE
|
|
|
224
266
|
--stack-id <value> | --stack-name <value>] [--project-id <value>] [--organization-id <value>]
|
|
225
267
|
|
|
226
268
|
ARGUMENTS
|
|
227
|
-
[DIR] Directory to create the Blueprint in
|
|
269
|
+
[DIR] Directory to create the local Blueprint in
|
|
228
270
|
|
|
229
271
|
FLAGS
|
|
230
|
-
--blueprint-type=<option> Blueprint manifest type to use for the Blueprint
|
|
272
|
+
--blueprint-type=<option> Blueprint manifest type to use for the local Blueprint
|
|
231
273
|
<options: json|js|ts>
|
|
232
|
-
--dir=<value> Directory to create the Blueprint in
|
|
233
|
-
--example=<value> Example to use for the Blueprint
|
|
234
|
-
--organization-id=<value> Sanity
|
|
235
|
-
--project-id=<value> Sanity
|
|
236
|
-
--stack-id=<value> Existing Stack ID to
|
|
237
|
-
--stack-name=<value> Name to use for a
|
|
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
|
|
238
280
|
--verbose Verbose output
|
|
239
281
|
|
|
240
282
|
DESCRIPTION
|
|
241
|
-
Initialize a
|
|
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.
|
|
242
295
|
|
|
243
296
|
EXAMPLES
|
|
244
297
|
$ sanity-run blueprints init
|
|
@@ -252,11 +305,11 @@ EXAMPLES
|
|
|
252
305
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
253
306
|
```
|
|
254
307
|
|
|
255
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
308
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/init.ts)_
|
|
256
309
|
|
|
257
310
|
## `sanity-run blueprints logs`
|
|
258
311
|
|
|
259
|
-
Display logs for
|
|
312
|
+
Display logs for the current Blueprint's Stack deployment
|
|
260
313
|
|
|
261
314
|
```
|
|
262
315
|
USAGE
|
|
@@ -266,7 +319,13 @@ FLAGS
|
|
|
266
319
|
-w, --watch Watch for new Stack logs (streaming mode)
|
|
267
320
|
|
|
268
321
|
DESCRIPTION
|
|
269
|
-
Display logs for
|
|
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'.
|
|
270
329
|
|
|
271
330
|
EXAMPLES
|
|
272
331
|
$ sanity-run blueprints logs
|
|
@@ -274,39 +333,50 @@ EXAMPLES
|
|
|
274
333
|
$ sanity-run blueprints logs --watch
|
|
275
334
|
```
|
|
276
335
|
|
|
277
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
336
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/logs.ts)_
|
|
278
337
|
|
|
279
338
|
## `sanity-run blueprints plan`
|
|
280
339
|
|
|
281
|
-
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
|
|
282
341
|
|
|
283
342
|
```
|
|
284
343
|
USAGE
|
|
285
344
|
$ sanity-run blueprints plan
|
|
286
345
|
|
|
287
346
|
DESCRIPTION
|
|
288
|
-
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.
|
|
289
354
|
|
|
290
355
|
EXAMPLES
|
|
291
356
|
$ sanity-run blueprints plan
|
|
292
357
|
```
|
|
293
358
|
|
|
294
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
359
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/plan.ts)_
|
|
295
360
|
|
|
296
361
|
## `sanity-run blueprints stacks`
|
|
297
362
|
|
|
298
|
-
List all Blueprint
|
|
363
|
+
List all remote Stack deployments (defaults to the current Blueprint's project scope)
|
|
299
364
|
|
|
300
365
|
```
|
|
301
366
|
USAGE
|
|
302
367
|
$ sanity-run blueprints stacks [--project-id <value> | --organization-id <value>]
|
|
303
368
|
|
|
304
369
|
FLAGS
|
|
305
|
-
--organization-id=<value> Organization ID to show
|
|
306
|
-
--project-id=<value> Project ID to show
|
|
370
|
+
--organization-id=<value> Organization ID to show Stack deployments for
|
|
371
|
+
--project-id=<value> Project ID to show Stack deployments for
|
|
307
372
|
|
|
308
373
|
DESCRIPTION
|
|
309
|
-
List all Blueprint
|
|
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.
|
|
310
380
|
|
|
311
381
|
EXAMPLES
|
|
312
382
|
$ sanity-run blueprints stacks
|
|
@@ -316,7 +386,7 @@ EXAMPLES
|
|
|
316
386
|
$ sanity-run blueprints stacks --organization-id <organizationId>
|
|
317
387
|
```
|
|
318
388
|
|
|
319
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
389
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/blueprints/stacks.ts)_
|
|
320
390
|
|
|
321
391
|
## `sanity-run functions add`
|
|
322
392
|
|
|
@@ -346,6 +416,13 @@ FLAGS
|
|
|
346
416
|
DESCRIPTION
|
|
347
417
|
Add a Function to your Blueprint
|
|
348
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
|
+
|
|
349
426
|
EXAMPLES
|
|
350
427
|
$ sanity-run functions add
|
|
351
428
|
|
|
@@ -358,7 +435,7 @@ EXAMPLES
|
|
|
358
435
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
359
436
|
```
|
|
360
437
|
|
|
361
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
438
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/add.ts)_
|
|
362
439
|
|
|
363
440
|
## `sanity-run functions dev`
|
|
364
441
|
|
|
@@ -377,15 +454,26 @@ FLAGS
|
|
|
377
454
|
DESCRIPTION
|
|
378
455
|
Start the Sanity Function emulator
|
|
379
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
|
+
|
|
380
466
|
EXAMPLES
|
|
381
467
|
$ sanity-run functions dev --host 127.0.0.1 --port 8974
|
|
468
|
+
|
|
469
|
+
$ sanity-run functions dev --timeout 60
|
|
382
470
|
```
|
|
383
471
|
|
|
384
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
472
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/dev.ts)_
|
|
385
473
|
|
|
386
474
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
387
475
|
|
|
388
|
-
Add or set
|
|
476
|
+
Add or set an environment variable for a deployed function
|
|
389
477
|
|
|
390
478
|
```
|
|
391
479
|
USAGE
|
|
@@ -397,17 +485,22 @@ ARGUMENTS
|
|
|
397
485
|
VALUE The value of the environment variable
|
|
398
486
|
|
|
399
487
|
DESCRIPTION
|
|
400
|
-
Add or set
|
|
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.
|
|
401
494
|
|
|
402
495
|
EXAMPLES
|
|
403
496
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
404
497
|
```
|
|
405
498
|
|
|
406
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
499
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/env/add.ts)_
|
|
407
500
|
|
|
408
501
|
## `sanity-run functions env list NAME`
|
|
409
502
|
|
|
410
|
-
List
|
|
503
|
+
List environment variables for a deployed function
|
|
411
504
|
|
|
412
505
|
```
|
|
413
506
|
USAGE
|
|
@@ -417,17 +510,21 @@ ARGUMENTS
|
|
|
417
510
|
NAME The name of the Sanity Function
|
|
418
511
|
|
|
419
512
|
DESCRIPTION
|
|
420
|
-
List
|
|
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.
|
|
421
518
|
|
|
422
519
|
EXAMPLES
|
|
423
520
|
$ sanity-run functions env list MyFunction
|
|
424
521
|
```
|
|
425
522
|
|
|
426
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
523
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/env/list.ts)_
|
|
427
524
|
|
|
428
525
|
## `sanity-run functions env remove NAME KEY`
|
|
429
526
|
|
|
430
|
-
Remove an environment variable
|
|
527
|
+
Remove an environment variable from a deployed function
|
|
431
528
|
|
|
432
529
|
```
|
|
433
530
|
USAGE
|
|
@@ -438,13 +535,18 @@ ARGUMENTS
|
|
|
438
535
|
KEY The name of the environment variable
|
|
439
536
|
|
|
440
537
|
DESCRIPTION
|
|
441
|
-
Remove an environment variable
|
|
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.
|
|
442
544
|
|
|
443
545
|
EXAMPLES
|
|
444
546
|
$ sanity-run functions env remove MyFunction API_URL
|
|
445
547
|
```
|
|
446
548
|
|
|
447
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
549
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/env/remove.ts)_
|
|
448
550
|
|
|
449
551
|
## `sanity-run functions logs [NAME]`
|
|
450
552
|
|
|
@@ -468,6 +570,11 @@ FLAGS
|
|
|
468
570
|
DESCRIPTION
|
|
469
571
|
Retrieve or delete logs for a Sanity Function
|
|
470
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
|
+
|
|
471
578
|
EXAMPLES
|
|
472
579
|
$ sanity-run functions logs <name>
|
|
473
580
|
|
|
@@ -478,7 +585,7 @@ EXAMPLES
|
|
|
478
585
|
$ sanity-run functions logs <name> --delete
|
|
479
586
|
```
|
|
480
587
|
|
|
481
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
588
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/logs.ts)_
|
|
482
589
|
|
|
483
590
|
## `sanity-run functions test [NAME]`
|
|
484
591
|
|
|
@@ -517,6 +624,12 @@ FLAGS
|
|
|
517
624
|
DESCRIPTION
|
|
518
625
|
Invoke a local Sanity Function
|
|
519
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
|
+
|
|
520
633
|
EXAMPLES
|
|
521
634
|
$ sanity-run functions test <name> --data '{ "id": 1 }'
|
|
522
635
|
|
|
@@ -527,7 +640,7 @@ EXAMPLES
|
|
|
527
640
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
528
641
|
```
|
|
529
642
|
|
|
530
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
643
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.0.1/src/commands/functions/test.ts)_
|
|
531
644
|
|
|
532
645
|
## `sanity-run help [COMMAND]`
|
|
533
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,7 +18,7 @@ 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 = [];
|
|
@@ -54,6 +55,7 @@ export async function stashAsset({ resource, auth, }) {
|
|
|
54
55
|
cleanup: combinedResult.cleanup,
|
|
55
56
|
resource: resource,
|
|
56
57
|
auth,
|
|
58
|
+
logger,
|
|
57
59
|
collectionInfo: {
|
|
58
60
|
name: resource.name,
|
|
59
61
|
functionCount: resource.functions.length,
|
|
@@ -70,6 +72,7 @@ export async function stashAsset({ resource, auth, }) {
|
|
|
70
72
|
cleanup: combinedAsset[0].partAsset.cleanup,
|
|
71
73
|
resource: resource,
|
|
72
74
|
auth,
|
|
75
|
+
logger,
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
78
|
return result;
|
|
@@ -155,11 +158,12 @@ async function combineAssets(allAssets) {
|
|
|
155
158
|
return { error: err instanceof Error ? err.message : `${err}` };
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
|
-
async function stashSingleAsset({ outputPath, cleanup, resource, auth, collectionInfo, }) {
|
|
161
|
+
async function stashSingleAsset({ outputPath, cleanup, resource, auth, logger, collectionInfo, }) {
|
|
162
|
+
const fetchFn = createTracedFetch(logger);
|
|
159
163
|
try {
|
|
160
164
|
const { b64, hash } = await pathToB64ZipHash(outputPath);
|
|
161
165
|
try {
|
|
162
|
-
const checkResponse = await
|
|
166
|
+
const checkResponse = await fetchFn(`${ASSET_CHECK_URL}/${hash}`, {
|
|
163
167
|
method: 'GET',
|
|
164
168
|
headers: getHeaders(auth),
|
|
165
169
|
});
|
|
@@ -170,7 +174,7 @@ async function stashSingleAsset({ outputPath, cleanup, resource, auth, collectio
|
|
|
170
174
|
}
|
|
171
175
|
catch { } // Continue to stash the Asset
|
|
172
176
|
// Asset doesn't exist, so stash it
|
|
173
|
-
const assetResponse = await
|
|
177
|
+
const assetResponse = await fetchFn(ASSET_STASH_URL, {
|
|
174
178
|
method: 'POST',
|
|
175
179
|
headers: getHeaders(auth),
|
|
176
180
|
body: JSON.stringify({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
2
|
import { type Blueprint } from '@sanity/blueprints-parser';
|
|
3
|
+
import type { Logger } from '../../utils/logger.js';
|
|
3
4
|
import type { BlueprintParserError } from '../../utils/types.js';
|
|
4
5
|
import { type ScopeType } from '../../utils/types.js';
|
|
5
6
|
import { type LocatedBlueprintsConfig } from './config.js';
|
|
@@ -47,7 +48,7 @@ export interface ReadBlueprintResult {
|
|
|
47
48
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
48
49
|
* @returns Known information about the Blueprint, config, and Stack
|
|
49
50
|
*/
|
|
50
|
-
export declare function readLocalBlueprint(blueprintPath?: string): Promise<ReadBlueprintResult>;
|
|
51
|
+
export declare function readLocalBlueprint(logger: ReturnType<typeof Logger>, blueprintPath?: string): Promise<ReadBlueprintResult>;
|
|
51
52
|
export declare function writeBlueprintToDisk({ blueprintFilePath, jsonContent, }: {
|
|
52
53
|
blueprintFilePath: string;
|
|
53
54
|
jsonContent?: Blueprint;
|
|
@@ -67,7 +67,7 @@ export function findBlueprintFile(blueprintPath) {
|
|
|
67
67
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
68
68
|
* @returns Known information about the Blueprint, config, and Stack
|
|
69
69
|
*/
|
|
70
|
-
export async function readLocalBlueprint(blueprintPath) {
|
|
70
|
+
export async function readLocalBlueprint(logger, blueprintPath) {
|
|
71
71
|
const blueprintFile = findBlueprintFile(blueprintPath);
|
|
72
72
|
if (!blueprintFile)
|
|
73
73
|
throw Error('Could not find Blueprint file! Use the `blueprints init` command.');
|
|
@@ -137,6 +137,7 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
137
137
|
await backfillOrganizationId({
|
|
138
138
|
projectId: blueprintConfig.projectId,
|
|
139
139
|
blueprintFilePath: foundFilePath,
|
|
140
|
+
logger,
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
143
|
catch { }
|
|
@@ -170,6 +171,7 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
170
171
|
stackId = await backfillProjectBasedStackId({
|
|
171
172
|
blueprintFilePath: foundFilePath,
|
|
172
173
|
projectId,
|
|
174
|
+
logger,
|
|
173
175
|
});
|
|
174
176
|
}
|
|
175
177
|
catch {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BLUEPRINT_CONFIG_VERSION, RUNTIME_CLI_VERSION } from '../../config.js';
|
|
2
|
+
import type { Logger } from '../../utils/logger.js';
|
|
2
3
|
export interface ConfigUpdate {
|
|
3
4
|
organizationId?: string;
|
|
4
5
|
projectId?: string;
|
|
@@ -48,11 +49,13 @@ export declare function patchConfigFile(blueprintFilePath: string, updateablePro
|
|
|
48
49
|
* @throws {Error} if unable to fetch project
|
|
49
50
|
* @returns {Promise<string>} the discovered organizationId
|
|
50
51
|
*/
|
|
51
|
-
export declare function backfillOrganizationId({ blueprintFilePath, projectId, }: {
|
|
52
|
+
export declare function backfillOrganizationId({ blueprintFilePath, projectId, logger, }: {
|
|
52
53
|
blueprintFilePath: string;
|
|
53
54
|
projectId: string;
|
|
55
|
+
logger: ReturnType<typeof Logger>;
|
|
54
56
|
}): Promise<string>;
|
|
55
|
-
export declare function backfillProjectBasedStackId({ blueprintFilePath, projectId, }: {
|
|
57
|
+
export declare function backfillProjectBasedStackId({ blueprintFilePath, projectId, logger, }: {
|
|
56
58
|
blueprintFilePath: string;
|
|
57
59
|
projectId: string;
|
|
60
|
+
logger: ReturnType<typeof Logger>;
|
|
58
61
|
}): Promise<string | undefined>;
|