@sanity/runtime-cli 17.1.0 → 17.2.0-blueprinit.g62f8017
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 +86 -55
- package/SKILL.md +21 -0
- package/dist/actions/blueprinit/manifest.d.ts +13 -0
- package/dist/actions/blueprinit/manifest.js +57 -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 +15 -0
- package/dist/actions/blueprinit/workspace.js +142 -0
- package/dist/actions/blueprints/assets.d.ts +2 -1
- package/dist/actions/blueprints/assets.js +17 -26
- package/dist/actions/blueprints/blueprint.d.ts +1 -1
- package/dist/actions/blueprints/pre-deploy.d.ts +29 -0
- package/dist/actions/blueprints/pre-deploy.js +164 -0
- package/dist/actions/blueprints/wait-for-operation.js +4 -0
- package/dist/actions/sanity/datasets.d.ts +15 -0
- package/dist/actions/sanity/datasets.js +26 -0
- package/dist/actions/sanity/examples.d.ts +4 -4
- package/dist/baseCommands.d.ts +7 -4
- package/dist/baseCommands.js +17 -0
- package/dist/commands/blueprinit.d.ts +13 -0
- package/dist/commands/blueprinit.js +44 -0
- package/dist/commands/blueprints/add.d.ts +1 -1
- package/dist/commands/blueprints/config.d.ts +1 -1
- package/dist/commands/blueprints/deploy.d.ts +1 -1
- package/dist/commands/blueprints/destroy.d.ts +1 -1
- package/dist/commands/blueprints/doctor.d.ts +0 -1
- package/dist/commands/blueprints/doctor.js +3 -7
- package/dist/commands/blueprints/info.d.ts +1 -1
- package/dist/commands/blueprints/logs.d.ts +1 -1
- package/dist/commands/blueprints/mint-deploy-token.d.ts +1 -1
- package/dist/commands/blueprints/plan.d.ts +1 -1
- package/dist/commands/blueprints/promote.d.ts +1 -1
- package/dist/commands/blueprints/stacks.d.ts +1 -1
- package/dist/commands/functions/add.d.ts +1 -1
- package/dist/commands/functions/build.d.ts +1 -1
- package/dist/commands/functions/dev.d.ts +1 -1
- package/dist/commands/functions/env/add.d.ts +4 -1
- package/dist/commands/functions/env/add.js +6 -2
- package/dist/commands/functions/env/list.d.ts +4 -1
- package/dist/commands/functions/env/list.js +9 -3
- package/dist/commands/functions/env/remove.d.ts +4 -1
- package/dist/commands/functions/env/remove.js +9 -3
- package/dist/commands/functions/logs.d.ts +1 -1
- package/dist/commands/functions/test.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/cores/blueprinit/adopt.d.ts +6 -0
- package/dist/cores/blueprinit/adopt.js +90 -0
- package/dist/cores/blueprinit/finish.d.ts +14 -0
- package/dist/cores/blueprinit/finish.js +36 -0
- package/dist/cores/blueprinit/fresh.d.ts +3 -0
- package/dist/cores/blueprinit/fresh.js +88 -0
- package/dist/cores/blueprinit/prompts.d.ts +4 -0
- package/dist/cores/blueprinit/prompts.js +14 -0
- package/dist/cores/blueprinit/selection.d.ts +15 -0
- package/dist/cores/blueprinit/selection.js +63 -0
- package/dist/cores/blueprinit/types.d.ts +13 -0
- package/dist/cores/blueprinit/types.js +1 -0
- package/dist/cores/blueprinit.d.ts +7 -0
- package/dist/cores/blueprinit.js +39 -0
- package/dist/cores/blueprints/deploy.js +18 -65
- package/dist/cores/blueprints/doctor.js +15 -12
- package/dist/cores/functions/build.js +3 -2
- package/dist/cores/functions/test.js +4 -2
- package/dist/server/app.js +8 -2
- package/dist/server/static/favicon-dark.svg +1 -0
- package/dist/server/static/favicon.svg +1 -0
- package/dist/server/static/index.html +1 -1
- package/dist/server/static/vendor/vendor.bundle.js +5 -0
- package/dist/utils/command-skills.d.ts +2 -0
- package/dist/utils/command-skills.js +17 -0
- package/dist/utils/functions/child-process-wrapper.js +13 -171
- package/dist/utils/functions/child-runtime/console.d.ts +1 -0
- package/dist/utils/functions/child-runtime/console.js +50 -0
- package/dist/utils/functions/child-runtime/invoke.d.ts +4 -0
- package/dist/utils/functions/child-runtime/invoke.js +47 -0
- package/dist/utils/functions/child-runtime/resources.d.ts +4 -0
- package/dist/utils/functions/child-runtime/resources.js +59 -0
- package/dist/utils/functions/find-entry-point.d.ts +1 -1
- package/dist/utils/functions/find-entry-point.js +10 -12
- package/dist/utils/functions/invoke/local.js +1 -1
- package/dist/utils/functions/invoke/prepare.d.ts +1 -1
- package/dist/utils/functions/invoke/prepare.js +19 -8
- package/dist/utils/functions/package-json.d.ts +1 -2
- package/dist/utils/functions/package-json.js +4 -6
- package/dist/utils/functions/prepare-asset.d.ts +2 -2
- package/dist/utils/functions/prepare-asset.js +18 -7
- package/dist/utils/functions/resolve-dependencies.d.ts +4 -1
- package/dist/utils/functions/resolve-dependencies.js +5 -6
- package/dist/utils/functions/resource-to-arc.d.ts +1 -1
- package/dist/utils/functions/resource-to-arc.js +4 -5
- package/dist/utils/functions/should-transpile.d.ts +7 -1
- package/dist/utils/functions/should-transpile.js +10 -10
- package/dist/utils/functions/transpile/function.d.ts +4 -1
- package/dist/utils/functions/transpile/function.js +9 -14
- package/dist/utils/functions/transpile/verify-handler.js +1 -1
- package/dist/utils/logger.d.ts +7 -5
- package/dist/utils/logger.js +33 -1
- package/dist/utils/progress.d.ts +5 -0
- package/dist/utils/progress.js +40 -0
- package/dist/utils/studios/prepare-asset.d.ts +6 -0
- package/dist/utils/studios/prepare-asset.js +139 -0
- package/dist/utils/types.d.ts +9 -8
- package/dist/utils/types.js +2 -3
- package/oclif.manifest.json +1218 -931
- package/package.json +33 -24
- package/skills/blueprinit.md +40 -0
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/17.
|
|
23
|
+
@sanity/runtime-cli/17.2.0-blueprinit.g62f8017 linux-x64 node-v24.18.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -56,7 +56,7 @@ USAGE
|
|
|
56
56
|
|
|
57
57
|
```
|
|
58
58
|
USAGE
|
|
59
|
-
$ sanity-run blueprints add TYPE [--json] [--example <value> | -n <value> | --fn-type
|
|
59
|
+
$ sanity-run blueprints add TYPE [--json] [--llms] [--example <value> | -n <value> | --fn-type
|
|
60
60
|
document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-asset-dele
|
|
61
61
|
te|media-library-asset-update|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
|
|
62
62
|
--fn-helpers | --fn-installer skip|npm|pnpm|yarn] [-i | ]
|
|
@@ -81,6 +81,7 @@ FLAGS
|
|
|
81
81
|
--json Format output as json
|
|
82
82
|
--language=<option> [default: ts] Language of the new function
|
|
83
83
|
<options: ts|js>
|
|
84
|
+
--llms Show agent-oriented guidance for this command
|
|
84
85
|
|
|
85
86
|
DESCRIPTION
|
|
86
87
|
[deprecated] Use "functions add" instead
|
|
@@ -103,7 +104,7 @@ EXAMPLES
|
|
|
103
104
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
104
105
|
```
|
|
105
106
|
|
|
106
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
107
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/add.ts)_
|
|
107
108
|
|
|
108
109
|
## `sanity-run blueprints config`
|
|
109
110
|
|
|
@@ -111,11 +112,13 @@ View or edit the local Blueprint configuration
|
|
|
111
112
|
|
|
112
113
|
```
|
|
113
114
|
USAGE
|
|
114
|
-
$ sanity-run blueprints config [--json] [--stack <value> -e] [--project-id <value> ] [--organization-id
|
|
115
|
+
$ sanity-run blueprints config [--json] [--llms] [--stack <value> -e] [--project-id <value> ] [--organization-id
|
|
116
|
+
<value> ]
|
|
115
117
|
|
|
116
118
|
FLAGS
|
|
117
119
|
-e, --edit Modify the configuration interactively, or directly when combined with ID flags.
|
|
118
120
|
--json Format output as json
|
|
121
|
+
--llms Show agent-oriented guidance for this command
|
|
119
122
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
120
123
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
121
124
|
--stack=<value> Stack name or ID to set in the configuration. Requires --edit flag
|
|
@@ -140,7 +143,7 @@ EXAMPLES
|
|
|
140
143
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
141
144
|
```
|
|
142
145
|
|
|
143
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
146
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/config.ts)_
|
|
144
147
|
|
|
145
148
|
## `sanity-run blueprints deploy`
|
|
146
149
|
|
|
@@ -148,12 +151,13 @@ Deploy the local Blueprint to the remote Stack
|
|
|
148
151
|
|
|
149
152
|
```
|
|
150
153
|
USAGE
|
|
151
|
-
$ sanity-run blueprints deploy [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
152
|
-
<value>] [--no-wait] [--new-stack-name <value>]
|
|
154
|
+
$ sanity-run blueprints deploy [--json] [--llms] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
155
|
+
[-m <value>] [--no-wait] [--new-stack-name <value>]
|
|
153
156
|
|
|
154
157
|
FLAGS
|
|
155
158
|
-m, --message=<value> Message describing the deployment (e.g. reason for change)
|
|
156
159
|
--json Format output as json
|
|
160
|
+
--llms Show agent-oriented guidance for this command
|
|
157
161
|
--new-stack-name=<value> Set a new name for the Stack
|
|
158
162
|
--no-wait Do not wait for Stack deployment to complete
|
|
159
163
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
@@ -194,7 +198,7 @@ EXAMPLES
|
|
|
194
198
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
195
199
|
```
|
|
196
200
|
|
|
197
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
201
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/deploy.ts)_
|
|
198
202
|
|
|
199
203
|
## `sanity-run blueprints destroy`
|
|
200
204
|
|
|
@@ -202,12 +206,13 @@ Destroy a remote Stack deployment and its resources
|
|
|
202
206
|
|
|
203
207
|
```
|
|
204
208
|
USAGE
|
|
205
|
-
$ sanity-run blueprints destroy [--json] [--project-id <value> --stack <value> --force] [--organization-id
|
|
206
|
-
[--no-wait]
|
|
209
|
+
$ sanity-run blueprints destroy [--json] [--llms] [--project-id <value> --stack <value> --force] [--organization-id
|
|
210
|
+
<value> ] [--no-wait]
|
|
207
211
|
|
|
208
212
|
FLAGS
|
|
209
213
|
--force Force Stack destruction (skip confirmation)
|
|
210
214
|
--json Format output as json
|
|
215
|
+
--llms Show agent-oriented guidance for this command
|
|
211
216
|
--no-wait Do not wait for Stack destruction to complete
|
|
212
217
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
213
218
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
@@ -232,7 +237,7 @@ EXAMPLES
|
|
|
232
237
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
233
238
|
```
|
|
234
239
|
|
|
235
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
240
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/destroy.ts)_
|
|
236
241
|
|
|
237
242
|
## `sanity-run blueprints doctor`
|
|
238
243
|
|
|
@@ -240,13 +245,13 @@ Diagnose potential issues with local Blueprint and remote Stack configuration
|
|
|
240
245
|
|
|
241
246
|
```
|
|
242
247
|
USAGE
|
|
243
|
-
$ sanity-run blueprints doctor [--json] [-p <value>] [--
|
|
248
|
+
$ sanity-run blueprints doctor [--json] [--llms] [-p <value>] [--fix]
|
|
244
249
|
|
|
245
250
|
FLAGS
|
|
246
251
|
-p, --path=<value> [env: SANITY_BLUEPRINT_PATH] Path to a Blueprint file or directory containing one
|
|
247
252
|
--fix Interactively fix configuration issues
|
|
248
253
|
--json Format output as json
|
|
249
|
-
--
|
|
254
|
+
--llms Show agent-oriented guidance for this command
|
|
250
255
|
|
|
251
256
|
DESCRIPTION
|
|
252
257
|
Diagnose potential issues with local Blueprint and remote Stack configuration
|
|
@@ -257,13 +262,15 @@ DESCRIPTION
|
|
|
257
262
|
Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected
|
|
258
263
|
issues.
|
|
259
264
|
|
|
265
|
+
Supports --json for programmatic consumption of diagnostic results.
|
|
266
|
+
|
|
260
267
|
EXAMPLES
|
|
261
268
|
$ sanity-run blueprints doctor
|
|
262
269
|
|
|
263
270
|
$ sanity-run blueprints doctor --fix
|
|
264
271
|
```
|
|
265
272
|
|
|
266
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
273
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/doctor.ts)_
|
|
267
274
|
|
|
268
275
|
## `sanity-run blueprints info`
|
|
269
276
|
|
|
@@ -271,10 +278,11 @@ Display the status and resources of the remote Stack deployment
|
|
|
271
278
|
|
|
272
279
|
```
|
|
273
280
|
USAGE
|
|
274
|
-
$ sanity-run blueprints info [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
281
|
+
$ sanity-run blueprints info [--json] [--llms] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
275
282
|
|
|
276
283
|
FLAGS
|
|
277
284
|
--json Format output as json
|
|
285
|
+
--llms Show agent-oriented guidance for this command
|
|
278
286
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
279
287
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
280
288
|
--stack=<value> Stack name or ID
|
|
@@ -300,7 +308,7 @@ EXAMPLES
|
|
|
300
308
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
301
309
|
```
|
|
302
310
|
|
|
303
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
311
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/info.ts)_
|
|
304
312
|
|
|
305
313
|
## `sanity-run blueprints init [DIR]`
|
|
306
314
|
|
|
@@ -308,8 +316,8 @@ Initialize a Blueprint and create a remote Stack
|
|
|
308
316
|
|
|
309
317
|
```
|
|
310
318
|
USAGE
|
|
311
|
-
$ sanity-run blueprints init [DIR] [--json] [--dir <value>] [--example <value> | --blueprint-type
|
|
312
|
-
--stack-id <value> | --stack-name <value>] [--project-id <value> | --organization-id <value>]
|
|
319
|
+
$ sanity-run blueprints init [DIR] [--json] [--llms] [--dir <value>] [--example <value> | --blueprint-type
|
|
320
|
+
json|js|ts | --stack-id <value> | --stack-name <value>] [--project-id <value> | --organization-id <value>]
|
|
313
321
|
|
|
314
322
|
ARGUMENTS
|
|
315
323
|
[DIR] Directory to create the local Blueprint in (defaults to the current directory)
|
|
@@ -320,6 +328,7 @@ FLAGS
|
|
|
320
328
|
--dir=<value> Directory to create the local Blueprint in
|
|
321
329
|
--example=<value> Example to use for the local Blueprint
|
|
322
330
|
--json Format output as json
|
|
331
|
+
--llms Show agent-oriented guidance for this command
|
|
323
332
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
324
333
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
325
334
|
--stack-id=<value> Existing Stack ID used to scope local Blueprint
|
|
@@ -364,7 +373,7 @@ EXAMPLES
|
|
|
364
373
|
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
365
374
|
```
|
|
366
375
|
|
|
367
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
376
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/init.ts)_
|
|
368
377
|
|
|
369
378
|
## `sanity-run blueprints logs`
|
|
370
379
|
|
|
@@ -372,14 +381,15 @@ Display logs for the current Blueprint's Stack deployment
|
|
|
372
381
|
|
|
373
382
|
```
|
|
374
383
|
USAGE
|
|
375
|
-
$ sanity-run blueprints logs [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
376
|
-
<value> | -w] [--since <value> | ] [--before <value> | ]
|
|
384
|
+
$ sanity-run blueprints logs [--json] [--llms] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
385
|
+
[-l <value> | -w] [--since <value> | ] [--before <value> | ]
|
|
377
386
|
|
|
378
387
|
FLAGS
|
|
379
388
|
-l, --limit=<value> Maximum number of log entries to retrieve (1-500)
|
|
380
389
|
-w, --watch Watch for new Stack logs
|
|
381
390
|
--before=<value> Only show logs before this ISO 8601 timestamp
|
|
382
391
|
--json Format output as json
|
|
392
|
+
--llms Show agent-oriented guidance for this command
|
|
383
393
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
384
394
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
385
395
|
--since=<value> Only show logs after this ISO 8601 timestamp
|
|
@@ -410,7 +420,7 @@ EXAMPLES
|
|
|
410
420
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
411
421
|
```
|
|
412
422
|
|
|
413
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
423
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/logs.ts)_
|
|
414
424
|
|
|
415
425
|
## `sanity-run blueprints mint-deploy-token`
|
|
416
426
|
|
|
@@ -418,13 +428,14 @@ Create a robot API token for deploying Blueprints from CI/CD
|
|
|
418
428
|
|
|
419
429
|
```
|
|
420
430
|
USAGE
|
|
421
|
-
$ sanity-run blueprints mint-deploy-token [--project-id <value> | --organization-id <value>] [--label <value>] [-P |
|
|
422
|
-
|
|
431
|
+
$ sanity-run blueprints mint-deploy-token [--llms] [--project-id <value> | --organization-id <value>] [--label <value>] [-P |
|
|
432
|
+
--json]
|
|
423
433
|
|
|
424
434
|
FLAGS
|
|
425
435
|
-P, --print Print only the raw token to stdout (suitable for shell substitution)
|
|
426
436
|
--json Format output as json
|
|
427
437
|
--label=<value> Human-readable label for the robot. Defaults to a generated value.
|
|
438
|
+
--llms Show agent-oriented guidance for this command
|
|
428
439
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
429
440
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
430
441
|
|
|
@@ -455,7 +466,7 @@ EXAMPLES
|
|
|
455
466
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
456
467
|
```
|
|
457
468
|
|
|
458
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
469
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/mint-deploy-token.ts)_
|
|
459
470
|
|
|
460
471
|
## `sanity-run blueprints plan`
|
|
461
472
|
|
|
@@ -463,10 +474,11 @@ Preview changes that will be applied to the remote Stack
|
|
|
463
474
|
|
|
464
475
|
```
|
|
465
476
|
USAGE
|
|
466
|
-
$ sanity-run blueprints plan [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
477
|
+
$ sanity-run blueprints plan [--json] [--llms] [--stack <value>] [--project-id <value> | --organization-id <value>]
|
|
467
478
|
|
|
468
479
|
FLAGS
|
|
469
480
|
--json Format output as json
|
|
481
|
+
--llms Show agent-oriented guidance for this command
|
|
470
482
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
471
483
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
472
484
|
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
@@ -488,7 +500,7 @@ EXAMPLES
|
|
|
488
500
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
489
501
|
```
|
|
490
502
|
|
|
491
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
503
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/plan.ts)_
|
|
492
504
|
|
|
493
505
|
## `sanity-run blueprints promote`
|
|
494
506
|
|
|
@@ -496,12 +508,13 @@ Promote a Stack from project scope to organization scope
|
|
|
496
508
|
|
|
497
509
|
```
|
|
498
510
|
USAGE
|
|
499
|
-
$ sanity-run blueprints promote [--json] [--stack <value>] [--project-id <value> | ] [--force]
|
|
500
|
-
<value>]
|
|
511
|
+
$ sanity-run blueprints promote [--json] [--llms] [--stack <value>] [--project-id <value> | ] [--force]
|
|
512
|
+
[--new-stack-name <value>]
|
|
501
513
|
|
|
502
514
|
FLAGS
|
|
503
515
|
--force Skip confirmation prompt
|
|
504
516
|
--json Format output as json
|
|
517
|
+
--llms Show agent-oriented guidance for this command
|
|
505
518
|
--new-stack-name=<value> Set a new name for the Stack while promoting
|
|
506
519
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
507
520
|
--stack=<value> Stack name or ID to promote
|
|
@@ -524,7 +537,7 @@ EXAMPLES
|
|
|
524
537
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
525
538
|
```
|
|
526
539
|
|
|
527
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
540
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/promote.ts)_
|
|
528
541
|
|
|
529
542
|
## `sanity-run blueprints stacks`
|
|
530
543
|
|
|
@@ -532,11 +545,13 @@ List remote Stack deployments for your project or organization
|
|
|
532
545
|
|
|
533
546
|
```
|
|
534
547
|
USAGE
|
|
535
|
-
$ sanity-run blueprints stacks [--json] [--project-id <value> | --organization-id <value> |
|
|
548
|
+
$ sanity-run blueprints stacks [--json] [--llms] [--project-id <value> | --organization-id <value> |
|
|
549
|
+
--include-projects]
|
|
536
550
|
|
|
537
551
|
FLAGS
|
|
538
552
|
--include-projects Include Stacks from all projects within the organization. Requires --organization-id.
|
|
539
553
|
--json Format output as json
|
|
554
|
+
--llms Show agent-oriented guidance for this command
|
|
540
555
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
541
556
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
542
557
|
|
|
@@ -560,7 +575,7 @@ EXAMPLES
|
|
|
560
575
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
561
576
|
```
|
|
562
577
|
|
|
563
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
578
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/blueprints/stacks.ts)_
|
|
564
579
|
|
|
565
580
|
## `sanity-run functions add`
|
|
566
581
|
|
|
@@ -568,9 +583,9 @@ Add a Function to your Blueprint
|
|
|
568
583
|
|
|
569
584
|
```
|
|
570
585
|
USAGE
|
|
571
|
-
$ sanity-run functions add [--json] [--example <value> | -n <value> | | --language ts|js | --javascript
|
|
572
|
-
[--type document-publish|document-create|document-delete|document-update|media-library-asset-create|media-
|
|
573
|
-
|
|
586
|
+
$ sanity-run functions add [--json] [--llms] [--example <value> | -n <value> | | --language ts|js | --javascript
|
|
587
|
+
| | ] [--type document-publish|document-create|document-delete|document-update|media-library-asset-create|media-lib
|
|
588
|
+
rary-asset-delete|media-library-asset-update|scheduled-function|sync-tag-invalidate... ] [--helpers] [--installer
|
|
574
589
|
skip|npm|pnpm|yarn] [-i | ]
|
|
575
590
|
|
|
576
591
|
FLAGS
|
|
@@ -584,6 +599,7 @@ FLAGS
|
|
|
584
599
|
--json Format output as json
|
|
585
600
|
--language=<option> [default: ts] Language of the new Function
|
|
586
601
|
<options: ts|js>
|
|
602
|
+
--llms Show agent-oriented guidance for this command
|
|
587
603
|
--type=<option>... Document change event(s) that should trigger the function; you can specify multiple events
|
|
588
604
|
by specifying this flag multiple times
|
|
589
605
|
<options: document-publish|document-create|document-delete|document-update|media-library-ass
|
|
@@ -612,7 +628,7 @@ EXAMPLES
|
|
|
612
628
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
613
629
|
```
|
|
614
630
|
|
|
615
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
631
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/add.ts)_
|
|
616
632
|
|
|
617
633
|
## `sanity-run functions dev`
|
|
618
634
|
|
|
@@ -620,7 +636,7 @@ Start the Sanity Function emulator
|
|
|
620
636
|
|
|
621
637
|
```
|
|
622
638
|
USAGE
|
|
623
|
-
$ sanity-run functions dev [--json] [-h <value>] [-p <value>] [-t <value>]
|
|
639
|
+
$ sanity-run functions dev [--json] [--llms] [-h <value>] [-p <value>] [-t <value>]
|
|
624
640
|
|
|
625
641
|
FLAGS
|
|
626
642
|
-h, --host=<value> The local network interface at which to listen. [default: "localhost"]
|
|
@@ -628,6 +644,7 @@ FLAGS
|
|
|
628
644
|
-t, --timeout=<value> Maximum execution time for all functions, in seconds. Takes precedence over function-specific
|
|
629
645
|
`timeout`
|
|
630
646
|
--json Format output as json
|
|
647
|
+
--llms Show agent-oriented guidance for this command
|
|
631
648
|
|
|
632
649
|
DESCRIPTION
|
|
633
650
|
Start the Sanity Function emulator
|
|
@@ -647,7 +664,7 @@ EXAMPLES
|
|
|
647
664
|
$ sanity-run functions dev --timeout 60
|
|
648
665
|
```
|
|
649
666
|
|
|
650
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
667
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/dev.ts)_
|
|
651
668
|
|
|
652
669
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
653
670
|
|
|
@@ -655,7 +672,7 @@ Add or set an environment variable for a deployed function
|
|
|
655
672
|
|
|
656
673
|
```
|
|
657
674
|
USAGE
|
|
658
|
-
$ sanity-run functions env add NAME KEY VALUE [--json]
|
|
675
|
+
$ sanity-run functions env add NAME KEY VALUE [--json] [--llms] [--stack <value>]
|
|
659
676
|
|
|
660
677
|
ARGUMENTS
|
|
661
678
|
NAME The name of the Sanity Function
|
|
@@ -663,7 +680,9 @@ ARGUMENTS
|
|
|
663
680
|
VALUE The value of the environment variable
|
|
664
681
|
|
|
665
682
|
FLAGS
|
|
666
|
-
--json
|
|
683
|
+
--json Format output as json
|
|
684
|
+
--llms Show agent-oriented guidance for this command
|
|
685
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
667
686
|
|
|
668
687
|
DESCRIPTION
|
|
669
688
|
Add or set an environment variable for a deployed function
|
|
@@ -675,9 +694,11 @@ DESCRIPTION
|
|
|
675
694
|
|
|
676
695
|
EXAMPLES
|
|
677
696
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
697
|
+
|
|
698
|
+
$ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
|
|
678
699
|
```
|
|
679
700
|
|
|
680
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
701
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/env/add.ts)_
|
|
681
702
|
|
|
682
703
|
## `sanity-run functions env list NAME`
|
|
683
704
|
|
|
@@ -685,13 +706,15 @@ List environment variables for a deployed function
|
|
|
685
706
|
|
|
686
707
|
```
|
|
687
708
|
USAGE
|
|
688
|
-
$ sanity-run functions env list NAME [--json]
|
|
709
|
+
$ sanity-run functions env list NAME [--json] [--llms] [--stack <value>]
|
|
689
710
|
|
|
690
711
|
ARGUMENTS
|
|
691
712
|
NAME The name of the Sanity Function
|
|
692
713
|
|
|
693
714
|
FLAGS
|
|
694
|
-
--json
|
|
715
|
+
--json Format output as json
|
|
716
|
+
--llms Show agent-oriented guidance for this command
|
|
717
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
695
718
|
|
|
696
719
|
DESCRIPTION
|
|
697
720
|
List environment variables for a deployed function
|
|
@@ -702,9 +725,11 @@ DESCRIPTION
|
|
|
702
725
|
|
|
703
726
|
EXAMPLES
|
|
704
727
|
$ sanity-run functions env list MyFunction
|
|
728
|
+
|
|
729
|
+
$ sanity-run functions env list --stack <name-or-id> MyFunction
|
|
705
730
|
```
|
|
706
731
|
|
|
707
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
732
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/env/list.ts)_
|
|
708
733
|
|
|
709
734
|
## `sanity-run functions env remove NAME KEY`
|
|
710
735
|
|
|
@@ -712,14 +737,16 @@ Remove an environment variable from a deployed function
|
|
|
712
737
|
|
|
713
738
|
```
|
|
714
739
|
USAGE
|
|
715
|
-
$ sanity-run functions env remove NAME KEY [--json]
|
|
740
|
+
$ sanity-run functions env remove NAME KEY [--json] [--llms] [--stack <value>]
|
|
716
741
|
|
|
717
742
|
ARGUMENTS
|
|
718
743
|
NAME The name of the Sanity Function
|
|
719
744
|
KEY The name of the environment variable
|
|
720
745
|
|
|
721
746
|
FLAGS
|
|
722
|
-
--json
|
|
747
|
+
--json Format output as json
|
|
748
|
+
--llms Show agent-oriented guidance for this command
|
|
749
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
723
750
|
|
|
724
751
|
DESCRIPTION
|
|
725
752
|
Remove an environment variable from a deployed function
|
|
@@ -731,9 +758,11 @@ DESCRIPTION
|
|
|
731
758
|
|
|
732
759
|
EXAMPLES
|
|
733
760
|
$ sanity-run functions env remove MyFunction API_URL
|
|
761
|
+
|
|
762
|
+
$ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
|
|
734
763
|
```
|
|
735
764
|
|
|
736
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
765
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/env/remove.ts)_
|
|
737
766
|
|
|
738
767
|
## `sanity-run functions logs [NAME]`
|
|
739
768
|
|
|
@@ -741,7 +770,7 @@ Retrieve or delete logs for a Sanity Function
|
|
|
741
770
|
|
|
742
771
|
```
|
|
743
772
|
USAGE
|
|
744
|
-
$ sanity-run functions logs [NAME] [--stack <value>] [-u] [-f [-d | -l <value> | --json]] [-w]
|
|
773
|
+
$ sanity-run functions logs [NAME] [--llms] [--stack <value>] [-u] [-f [-d | -l <value> | --json]] [-w]
|
|
745
774
|
|
|
746
775
|
ARGUMENTS
|
|
747
776
|
[NAME] The name of the Sanity Function
|
|
@@ -753,6 +782,7 @@ FLAGS
|
|
|
753
782
|
-u, --utc Show dates in UTC time zone
|
|
754
783
|
-w, --watch Watch for new logs (streaming mode)
|
|
755
784
|
--json Format output as json
|
|
785
|
+
--llms Show agent-oriented guidance for this command
|
|
756
786
|
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
757
787
|
|
|
758
788
|
DESCRIPTION
|
|
@@ -773,7 +803,7 @@ EXAMPLES
|
|
|
773
803
|
$ sanity-run functions logs <name> --delete
|
|
774
804
|
```
|
|
775
805
|
|
|
776
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
806
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/logs.ts)_
|
|
777
807
|
|
|
778
808
|
## `sanity-run functions test [NAME]`
|
|
779
809
|
|
|
@@ -781,11 +811,11 @@ Invoke a local Sanity Function
|
|
|
781
811
|
|
|
782
812
|
```
|
|
783
813
|
USAGE
|
|
784
|
-
$ sanity-run functions test [NAME] [--json] [--data-before <value> | [-d <value> | -f <value> |
|
|
785
|
-
<value>] | | | --file-before <value> | --file-after <value> | --document-id-before <value> |
|
|
786
|
-
<value>] [--data-after <value> | | | | | | | ] [-e create|update|delete] [-t <value>] [-a
|
|
787
|
-
[--with-user-token] [--media-library-id <value> | [--project-id <value> | --organization-id <value>] |
|
|
788
|
-
<value>]
|
|
814
|
+
$ sanity-run functions test [NAME] [--json] [--llms] [--data-before <value> | [-d <value> | -f <value> |
|
|
815
|
+
--document-id <value>] | | | --file-before <value> | --file-after <value> | --document-id-before <value> |
|
|
816
|
+
--document-id-after <value>] [--data-after <value> | | | | | | | ] [-e create|update|delete] [-t <value>] [-a
|
|
817
|
+
<value>] [--with-user-token] [--media-library-id <value> | [--project-id <value> | --organization-id <value>] |
|
|
818
|
+
--dataset <value>]
|
|
789
819
|
|
|
790
820
|
ARGUMENTS
|
|
791
821
|
[NAME] The name of the Sanity Function
|
|
@@ -806,6 +836,7 @@ FLAGS
|
|
|
806
836
|
--file-after=<value> Current document
|
|
807
837
|
--file-before=<value> Original document
|
|
808
838
|
--json Format output as json
|
|
839
|
+
--llms Show agent-oriented guidance for this command
|
|
809
840
|
--media-library-id=<value> Sanity Media Library ID to use
|
|
810
841
|
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
|
|
811
842
|
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
|
|
@@ -830,7 +861,7 @@ EXAMPLES
|
|
|
830
861
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
831
862
|
```
|
|
832
863
|
|
|
833
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
864
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g62f8017/src/commands/functions/test.ts)_
|
|
834
865
|
|
|
835
866
|
## `sanity-run help [COMMAND]`
|
|
836
867
|
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: runtime-cli
|
|
3
|
+
description: Use the Sanity Runtime CLI for Blueprints and Functions workflows. Use when an agent needs to run or explain sanity-run commands, especially unattended command flows, local Blueprint management, Stack operations, Function development, or the experimental blueprinit command.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Sanity Runtime CLI
|
|
7
|
+
|
|
8
|
+
Use `sanity-run <command> --help` for flags and arguments. Use
|
|
9
|
+
`sanity-run <command> --llms` (or `--skill`) for the agent-oriented workflow and examples for that
|
|
10
|
+
command.
|
|
11
|
+
|
|
12
|
+
Read only the command skill relevant to the task:
|
|
13
|
+
|
|
14
|
+
- `blueprinit` → `skills/blueprinit.md`
|
|
15
|
+
- `blueprints deploy` → `skills/blueprints-deploy.md`
|
|
16
|
+
- `functions test` → `skills/functions-test.md`
|
|
17
|
+
|
|
18
|
+
Derive other filenames by joining the command words with hyphens.
|
|
19
|
+
|
|
20
|
+
Command skills are added incrementally. If one is absent, inspect the command's `--help` output and
|
|
21
|
+
the repository implementation before acting.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const STARTER_DOCUMENT_TYPE = "post";
|
|
2
|
+
export declare const STARTER_FUNCTION_NAME = "set-slug";
|
|
3
|
+
export interface BlueprintManifestOptions {
|
|
4
|
+
projectName: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
datasetName: string;
|
|
8
|
+
studioName: string;
|
|
9
|
+
studioSrc: string;
|
|
10
|
+
withFunction: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function renderBlueprint(options: BlueprintManifestOptions): string;
|
|
13
|
+
export declare function slugify(value: string): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const quote = (value) => `'${value.replaceAll('\\', '\\\\').replaceAll("'", "\\'")}'`;
|
|
2
|
+
export const STARTER_DOCUMENT_TYPE = 'post';
|
|
3
|
+
export const STARTER_FUNCTION_NAME = 'set-slug';
|
|
4
|
+
export function renderBlueprint(options) {
|
|
5
|
+
const { projectName, displayName, projectId, datasetName, studioName, studioSrc, withFunction } = options;
|
|
6
|
+
const definers = ['defineBlueprint', 'defineDataset', 'defineProject', 'defineStudio'];
|
|
7
|
+
if (withFunction)
|
|
8
|
+
definers.splice(2, 0, 'defineDocumentFunction');
|
|
9
|
+
const functionResource = withFunction
|
|
10
|
+
? ` defineDocumentFunction({
|
|
11
|
+
name: ${quote(STARTER_FUNCTION_NAME)},
|
|
12
|
+
project: ${quote(projectId)},
|
|
13
|
+
event: {
|
|
14
|
+
on: ['create', 'update'],
|
|
15
|
+
filter: "_type == '${STARTER_DOCUMENT_TYPE}' && !defined(slug.current)",
|
|
16
|
+
projection: '{_id, title, slug}',
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
`
|
|
20
|
+
: '';
|
|
21
|
+
// Project references stay literal until the deploy API can resolve resource references here.
|
|
22
|
+
return `import {${definers.join(', ')}} from '@sanity/blueprints'
|
|
23
|
+
|
|
24
|
+
export default defineBlueprint({
|
|
25
|
+
resources: [
|
|
26
|
+
defineProject({
|
|
27
|
+
name: ${quote(projectName)},
|
|
28
|
+
displayName: ${quote(displayName)},
|
|
29
|
+
lifecycle: {
|
|
30
|
+
deletionPolicy: 'retain',
|
|
31
|
+
ownershipAction: {type: 'attach', id: ${quote(projectId)}},
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
defineDataset({
|
|
35
|
+
name: ${quote(datasetName)},
|
|
36
|
+
project: ${quote(projectId)},
|
|
37
|
+
lifecycle: {
|
|
38
|
+
deletionPolicy: 'retain',
|
|
39
|
+
ownershipAction: {type: 'attach', id: ${quote(datasetName)}, projectId: ${quote(projectId)}},
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
defineStudio({
|
|
43
|
+
name: ${quote(studioName)},
|
|
44
|
+
src: ${quote(studioSrc)},
|
|
45
|
+
autoUpdates: {enabled: true},
|
|
46
|
+
project: ${quote(projectId)},
|
|
47
|
+
}),
|
|
48
|
+
${functionResource} ],
|
|
49
|
+
})
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
export function slugify(value) {
|
|
53
|
+
return value
|
|
54
|
+
.toLowerCase()
|
|
55
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
56
|
+
.replace(/^-+|-+$/g, '');
|
|
57
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const STUDIO_CONFIG_PATTERN = /^sanity\.config\.[cm]?[jt]sx?$/;
|
|
4
|
+
const STUDIO_CLI_PATTERN = /^sanity\.cli\.[cm]?[jt]sx?$/;
|
|
5
|
+
export function detectStudio(dir) {
|
|
6
|
+
let entries;
|
|
7
|
+
try {
|
|
8
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
9
|
+
.filter((entry) => entry.isFile())
|
|
10
|
+
.map((entry) => entry.name);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const configFile = entries.find((name) => STUDIO_CONFIG_PATTERN.test(name));
|
|
16
|
+
if (!configFile)
|
|
17
|
+
return undefined;
|
|
18
|
+
const detected = { configFile };
|
|
19
|
+
const cliFile = entries.find((name) => STUDIO_CLI_PATTERN.test(name));
|
|
20
|
+
for (const file of [configFile, cliFile]) {
|
|
21
|
+
if (!file)
|
|
22
|
+
continue;
|
|
23
|
+
const source = readSource(join(dir, file));
|
|
24
|
+
if (!source)
|
|
25
|
+
continue;
|
|
26
|
+
detected.projectId ??= extractLiteral(source, 'projectId');
|
|
27
|
+
detected.dataset ??= extractLiteral(source, 'dataset');
|
|
28
|
+
if (detected.projectId && detected.dataset)
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return detected;
|
|
32
|
+
}
|
|
33
|
+
function readSource(filePath) {
|
|
34
|
+
try {
|
|
35
|
+
return readFileSync(filePath, 'utf8');
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function extractLiteral(source, key) {
|
|
42
|
+
return source.match(new RegExp(`\\b${key}\\s*:\\s*(['"\`])([^'"\`\\\\]+)\\1`))?.[2];
|
|
43
|
+
}
|