@sanity/runtime-cli 17.1.0 → 17.2.0-blueprinit.g3a96975

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 (109) hide show
  1. package/README.md +38 -28
  2. package/SKILL.md +21 -0
  3. package/dist/actions/blueprinit/manifest.d.ts +13 -0
  4. package/dist/actions/blueprinit/manifest.js +57 -0
  5. package/dist/actions/blueprinit/studio.d.ts +6 -0
  6. package/dist/actions/blueprinit/studio.js +43 -0
  7. package/dist/actions/blueprinit/templates.d.ts +34 -0
  8. package/dist/actions/blueprinit/templates.js +83 -0
  9. package/dist/actions/blueprinit/workspace.d.ts +15 -0
  10. package/dist/actions/blueprinit/workspace.js +142 -0
  11. package/dist/actions/blueprints/assets.d.ts +2 -1
  12. package/dist/actions/blueprints/assets.js +17 -26
  13. package/dist/actions/blueprints/blueprint.d.ts +1 -1
  14. package/dist/actions/blueprints/pre-deploy.d.ts +29 -0
  15. package/dist/actions/blueprints/pre-deploy.js +164 -0
  16. package/dist/actions/blueprints/wait-for-operation.js +4 -0
  17. package/dist/actions/sanity/datasets.d.ts +15 -0
  18. package/dist/actions/sanity/datasets.js +26 -0
  19. package/dist/actions/sanity/examples.d.ts +4 -4
  20. package/dist/baseCommands.d.ts +11 -4
  21. package/dist/baseCommands.js +21 -0
  22. package/dist/commands/blueprinit.d.ts +14 -0
  23. package/dist/commands/blueprinit.js +45 -0
  24. package/dist/commands/blueprints/add.d.ts +1 -1
  25. package/dist/commands/blueprints/config.d.ts +1 -1
  26. package/dist/commands/blueprints/deploy.d.ts +1 -1
  27. package/dist/commands/blueprints/destroy.d.ts +1 -1
  28. package/dist/commands/blueprints/doctor.d.ts +0 -1
  29. package/dist/commands/blueprints/doctor.js +3 -7
  30. package/dist/commands/blueprints/info.d.ts +1 -1
  31. package/dist/commands/blueprints/logs.d.ts +1 -1
  32. package/dist/commands/blueprints/mint-deploy-token.d.ts +1 -1
  33. package/dist/commands/blueprints/plan.d.ts +1 -1
  34. package/dist/commands/blueprints/promote.d.ts +1 -1
  35. package/dist/commands/blueprints/stacks.d.ts +1 -1
  36. package/dist/commands/functions/add.d.ts +1 -1
  37. package/dist/commands/functions/build.d.ts +1 -1
  38. package/dist/commands/functions/dev.d.ts +1 -1
  39. package/dist/commands/functions/env/add.d.ts +4 -1
  40. package/dist/commands/functions/env/add.js +6 -2
  41. package/dist/commands/functions/env/list.d.ts +4 -1
  42. package/dist/commands/functions/env/list.js +9 -3
  43. package/dist/commands/functions/env/remove.d.ts +4 -1
  44. package/dist/commands/functions/env/remove.js +9 -3
  45. package/dist/commands/functions/logs.d.ts +1 -1
  46. package/dist/commands/functions/test.d.ts +1 -1
  47. package/dist/constants.d.ts +1 -0
  48. package/dist/constants.js +1 -0
  49. package/dist/cores/blueprinit/adopt.d.ts +6 -0
  50. package/dist/cores/blueprinit/adopt.js +90 -0
  51. package/dist/cores/blueprinit/finish.d.ts +14 -0
  52. package/dist/cores/blueprinit/finish.js +36 -0
  53. package/dist/cores/blueprinit/fresh.d.ts +3 -0
  54. package/dist/cores/blueprinit/fresh.js +88 -0
  55. package/dist/cores/blueprinit/prompts.d.ts +4 -0
  56. package/dist/cores/blueprinit/prompts.js +14 -0
  57. package/dist/cores/blueprinit/selection.d.ts +15 -0
  58. package/dist/cores/blueprinit/selection.js +63 -0
  59. package/dist/cores/blueprinit/types.d.ts +13 -0
  60. package/dist/cores/blueprinit/types.js +1 -0
  61. package/dist/cores/blueprinit.d.ts +7 -0
  62. package/dist/cores/blueprinit.js +39 -0
  63. package/dist/cores/blueprints/deploy.js +18 -65
  64. package/dist/cores/blueprints/doctor.js +15 -12
  65. package/dist/cores/functions/build.js +3 -2
  66. package/dist/cores/functions/test.js +4 -2
  67. package/dist/server/app.js +8 -2
  68. package/dist/server/static/favicon-dark.svg +1 -0
  69. package/dist/server/static/favicon.svg +1 -0
  70. package/dist/server/static/index.html +1 -1
  71. package/dist/server/static/vendor/vendor.bundle.js +5 -0
  72. package/dist/utils/command-skills.d.ts +2 -0
  73. package/dist/utils/command-skills.js +17 -0
  74. package/dist/utils/functions/child-process-wrapper.js +13 -171
  75. package/dist/utils/functions/child-runtime/console.d.ts +1 -0
  76. package/dist/utils/functions/child-runtime/console.js +50 -0
  77. package/dist/utils/functions/child-runtime/invoke.d.ts +4 -0
  78. package/dist/utils/functions/child-runtime/invoke.js +47 -0
  79. package/dist/utils/functions/child-runtime/resources.d.ts +4 -0
  80. package/dist/utils/functions/child-runtime/resources.js +59 -0
  81. package/dist/utils/functions/find-entry-point.d.ts +1 -1
  82. package/dist/utils/functions/find-entry-point.js +10 -12
  83. package/dist/utils/functions/invoke/local.js +1 -1
  84. package/dist/utils/functions/invoke/prepare.d.ts +1 -1
  85. package/dist/utils/functions/invoke/prepare.js +19 -8
  86. package/dist/utils/functions/package-json.d.ts +1 -2
  87. package/dist/utils/functions/package-json.js +4 -6
  88. package/dist/utils/functions/prepare-asset.d.ts +2 -2
  89. package/dist/utils/functions/prepare-asset.js +18 -7
  90. package/dist/utils/functions/resolve-dependencies.d.ts +4 -1
  91. package/dist/utils/functions/resolve-dependencies.js +5 -6
  92. package/dist/utils/functions/resource-to-arc.d.ts +1 -1
  93. package/dist/utils/functions/resource-to-arc.js +4 -5
  94. package/dist/utils/functions/should-transpile.d.ts +7 -1
  95. package/dist/utils/functions/should-transpile.js +10 -10
  96. package/dist/utils/functions/transpile/function.d.ts +4 -1
  97. package/dist/utils/functions/transpile/function.js +9 -14
  98. package/dist/utils/functions/transpile/verify-handler.js +1 -1
  99. package/dist/utils/logger.d.ts +7 -5
  100. package/dist/utils/logger.js +33 -1
  101. package/dist/utils/progress.d.ts +5 -0
  102. package/dist/utils/progress.js +40 -0
  103. package/dist/utils/studios/prepare-asset.d.ts +6 -0
  104. package/dist/utils/studios/prepare-asset.js +139 -0
  105. package/dist/utils/types.d.ts +9 -8
  106. package/dist/utils/types.js +2 -3
  107. package/oclif.manifest.json +1237 -930
  108. package/package.json +33 -24
  109. package/skills/blueprinit.md +137 -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.1.0 linux-x64 node-v24.18.0
23
+ @sanity/runtime-cli/17.2.0-blueprinit.g3a96975 linux-x64 node-v24.18.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -103,7 +103,7 @@ EXAMPLES
103
103
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
104
104
  ```
105
105
 
106
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/add.ts)_
106
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/add.ts)_
107
107
 
108
108
  ## `sanity-run blueprints config`
109
109
 
@@ -140,7 +140,7 @@ EXAMPLES
140
140
  $ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
141
141
  ```
142
142
 
143
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/config.ts)_
143
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/config.ts)_
144
144
 
145
145
  ## `sanity-run blueprints deploy`
146
146
 
@@ -194,7 +194,7 @@ EXAMPLES
194
194
  $ sanity-run blueprints deploy --new-stack-name <new-name>
195
195
  ```
196
196
 
197
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/deploy.ts)_
197
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/deploy.ts)_
198
198
 
199
199
  ## `sanity-run blueprints destroy`
200
200
 
@@ -232,7 +232,7 @@ EXAMPLES
232
232
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
233
233
  ```
234
234
 
235
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/destroy.ts)_
235
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/destroy.ts)_
236
236
 
237
237
  ## `sanity-run blueprints doctor`
238
238
 
@@ -240,13 +240,12 @@ Diagnose potential issues with local Blueprint and remote Stack configuration
240
240
 
241
241
  ```
242
242
  USAGE
243
- $ sanity-run blueprints doctor [--json] [-p <value>] [--verbose] [--fix]
243
+ $ sanity-run blueprints doctor [--json] [-p <value>] [--fix]
244
244
 
245
245
  FLAGS
246
246
  -p, --path=<value> [env: SANITY_BLUEPRINT_PATH] Path to a Blueprint file or directory containing one
247
247
  --fix Interactively fix configuration issues
248
248
  --json Format output as json
249
- --[no-]verbose Verbose output; defaults to true
250
249
 
251
250
  DESCRIPTION
252
251
  Diagnose potential issues with local Blueprint and remote Stack configuration
@@ -257,13 +256,15 @@ DESCRIPTION
257
256
  Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected
258
257
  issues.
259
258
 
259
+ Supports --json for programmatic consumption of diagnostic results.
260
+
260
261
  EXAMPLES
261
262
  $ sanity-run blueprints doctor
262
263
 
263
264
  $ sanity-run blueprints doctor --fix
264
265
  ```
265
266
 
266
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/doctor.ts)_
267
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/doctor.ts)_
267
268
 
268
269
  ## `sanity-run blueprints info`
269
270
 
@@ -300,7 +301,7 @@ EXAMPLES
300
301
  $ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
301
302
  ```
302
303
 
303
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/info.ts)_
304
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/info.ts)_
304
305
 
305
306
  ## `sanity-run blueprints init [DIR]`
306
307
 
@@ -364,7 +365,7 @@ EXAMPLES
364
365
  $ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
365
366
  ```
366
367
 
367
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/init.ts)_
368
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/init.ts)_
368
369
 
369
370
  ## `sanity-run blueprints logs`
370
371
 
@@ -410,7 +411,7 @@ EXAMPLES
410
411
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
411
412
  ```
412
413
 
413
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/logs.ts)_
414
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/logs.ts)_
414
415
 
415
416
  ## `sanity-run blueprints mint-deploy-token`
416
417
 
@@ -455,7 +456,7 @@ EXAMPLES
455
456
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
456
457
  ```
457
458
 
458
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/mint-deploy-token.ts)_
459
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/mint-deploy-token.ts)_
459
460
 
460
461
  ## `sanity-run blueprints plan`
461
462
 
@@ -488,7 +489,7 @@ EXAMPLES
488
489
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
489
490
  ```
490
491
 
491
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/plan.ts)_
492
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/plan.ts)_
492
493
 
493
494
  ## `sanity-run blueprints promote`
494
495
 
@@ -524,7 +525,7 @@ EXAMPLES
524
525
  $ sanity-run blueprints promote --new-stack-name <new-name>
525
526
  ```
526
527
 
527
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/promote.ts)_
528
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/promote.ts)_
528
529
 
529
530
  ## `sanity-run blueprints stacks`
530
531
 
@@ -560,7 +561,7 @@ EXAMPLES
560
561
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
561
562
  ```
562
563
 
563
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/blueprints/stacks.ts)_
564
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/blueprints/stacks.ts)_
564
565
 
565
566
  ## `sanity-run functions add`
566
567
 
@@ -612,7 +613,7 @@ EXAMPLES
612
613
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
613
614
  ```
614
615
 
615
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/add.ts)_
616
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/add.ts)_
616
617
 
617
618
  ## `sanity-run functions dev`
618
619
 
@@ -647,7 +648,7 @@ EXAMPLES
647
648
  $ sanity-run functions dev --timeout 60
648
649
  ```
649
650
 
650
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/dev.ts)_
651
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/dev.ts)_
651
652
 
652
653
  ## `sanity-run functions env add NAME KEY VALUE`
653
654
 
@@ -655,7 +656,7 @@ Add or set an environment variable for a deployed function
655
656
 
656
657
  ```
657
658
  USAGE
658
- $ sanity-run functions env add NAME KEY VALUE [--json]
659
+ $ sanity-run functions env add NAME KEY VALUE [--json] [--stack <value>]
659
660
 
660
661
  ARGUMENTS
661
662
  NAME The name of the Sanity Function
@@ -663,7 +664,8 @@ ARGUMENTS
663
664
  VALUE The value of the environment variable
664
665
 
665
666
  FLAGS
666
- --json Format output as json
667
+ --json Format output as json
668
+ --stack=<value> Stack name or ID to use instead of the locally configured Stack
667
669
 
668
670
  DESCRIPTION
669
671
  Add or set an environment variable for a deployed function
@@ -675,9 +677,11 @@ DESCRIPTION
675
677
 
676
678
  EXAMPLES
677
679
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
680
+
681
+ $ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
678
682
  ```
679
683
 
680
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/env/add.ts)_
684
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/env/add.ts)_
681
685
 
682
686
  ## `sanity-run functions env list NAME`
683
687
 
@@ -685,13 +689,14 @@ List environment variables for a deployed function
685
689
 
686
690
  ```
687
691
  USAGE
688
- $ sanity-run functions env list NAME [--json]
692
+ $ sanity-run functions env list NAME [--json] [--stack <value>]
689
693
 
690
694
  ARGUMENTS
691
695
  NAME The name of the Sanity Function
692
696
 
693
697
  FLAGS
694
- --json Format output as json
698
+ --json Format output as json
699
+ --stack=<value> Stack name or ID to use instead of the locally configured Stack
695
700
 
696
701
  DESCRIPTION
697
702
  List environment variables for a deployed function
@@ -702,9 +707,11 @@ DESCRIPTION
702
707
 
703
708
  EXAMPLES
704
709
  $ sanity-run functions env list MyFunction
710
+
711
+ $ sanity-run functions env list --stack <name-or-id> MyFunction
705
712
  ```
706
713
 
707
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/env/list.ts)_
714
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/env/list.ts)_
708
715
 
709
716
  ## `sanity-run functions env remove NAME KEY`
710
717
 
@@ -712,14 +719,15 @@ Remove an environment variable from a deployed function
712
719
 
713
720
  ```
714
721
  USAGE
715
- $ sanity-run functions env remove NAME KEY [--json]
722
+ $ sanity-run functions env remove NAME KEY [--json] [--stack <value>]
716
723
 
717
724
  ARGUMENTS
718
725
  NAME The name of the Sanity Function
719
726
  KEY The name of the environment variable
720
727
 
721
728
  FLAGS
722
- --json Format output as json
729
+ --json Format output as json
730
+ --stack=<value> Stack name or ID to use instead of the locally configured Stack
723
731
 
724
732
  DESCRIPTION
725
733
  Remove an environment variable from a deployed function
@@ -731,9 +739,11 @@ DESCRIPTION
731
739
 
732
740
  EXAMPLES
733
741
  $ sanity-run functions env remove MyFunction API_URL
742
+
743
+ $ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
734
744
  ```
735
745
 
736
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/env/remove.ts)_
746
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/env/remove.ts)_
737
747
 
738
748
  ## `sanity-run functions logs [NAME]`
739
749
 
@@ -773,7 +783,7 @@ EXAMPLES
773
783
  $ sanity-run functions logs <name> --delete
774
784
  ```
775
785
 
776
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/logs.ts)_
786
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/logs.ts)_
777
787
 
778
788
  ## `sanity-run functions test [NAME]`
779
789
 
@@ -830,7 +840,7 @@ EXAMPLES
830
840
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
831
841
  ```
832
842
 
833
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.1.0/src/commands/functions/test.ts)_
843
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.2.0-blueprinit.g3a96975/src/commands/functions/test.ts)_
834
844
 
835
845
  ## `sanity-run help [COMMAND]`
836
846
 
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,6 @@
1
+ export interface DetectedStudio {
2
+ configFile: string;
3
+ projectId?: string;
4
+ dataset?: string;
5
+ }
6
+ export declare function detectStudio(dir: string): DetectedStudio | undefined;
@@ -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
+ }
@@ -0,0 +1,34 @@
1
+ export declare function renderStudioConfig(options: {
2
+ displayName: string;
3
+ projectId: string;
4
+ datasetName: string;
5
+ }): string;
6
+ export declare const STUDIO_SCHEMA_TYPES = "import {post} from './post'\n\nexport const schemaTypes = [post]\n";
7
+ export declare const STUDIO_POST_TYPE = "import {defineField, defineType} from 'sanity'\n\nexport const post = defineType({\n name: 'post',\n title: 'Post',\n type: 'document',\n fields: [\n defineField({name: 'title', type: 'string', validation: (rule) => rule.required()}),\n // The set-slug function fills this when it is empty.\n defineField({name: 'slug', type: 'slug', options: {source: 'title'}}),\n defineField({name: 'publishedAt', title: 'Published at', type: 'datetime'}),\n defineField({name: 'body', type: 'text'}),\n ],\n})\n";
8
+ export declare const FUNCTION_SET_SLUG = "import {createClient} from '@sanity/client'\nimport {documentEventHandler} from '@sanity/functions'\n\nconst slugify = (title: string) =>\n title\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 96)\n\nexport const handler = documentEventHandler(async ({context, event}) => {\n const {_id, title, slug} = event.data\n if (!title || slug?.current) return\n\n const client = createClient({apiVersion: '2025-05-01', ...context.clientOptions})\n const current = slugify(title)\n await client.patch(_id).set({slug: {_type: 'slug', current}}).commit()\n\n console.log(`Set slug for ${_id}: ${current}`)\n})\n";
9
+ export declare const studioPackageJson: (name: string) => {
10
+ name: string;
11
+ version: string;
12
+ private: boolean;
13
+ scripts: {
14
+ dev: string;
15
+ build: string;
16
+ deploy: string;
17
+ };
18
+ dependencies: {
19
+ react: string;
20
+ 'react-dom': string;
21
+ sanity: string;
22
+ 'styled-components': string;
23
+ };
24
+ };
25
+ export declare const functionPackageJson: (name: string) => {
26
+ name: string;
27
+ version: string;
28
+ private: boolean;
29
+ type: string;
30
+ dependencies: {
31
+ '@sanity/client': string;
32
+ '@sanity/functions': string;
33
+ };
34
+ };
@@ -0,0 +1,83 @@
1
+ import { STARTER_DOCUMENT_TYPE, STARTER_FUNCTION_NAME } from './manifest.js';
2
+ const quote = (value) => `'${value.replaceAll('\\', '\\\\').replaceAll("'", "\\'")}'`;
3
+ export function renderStudioConfig(options) {
4
+ return `import {defineConfig} from 'sanity'
5
+ import {structureTool} from 'sanity/structure'
6
+ import {schemaTypes} from './schemaTypes'
7
+
8
+ export default defineConfig({
9
+ name: 'default',
10
+ title: ${quote(options.displayName)},
11
+ projectId: ${quote(options.projectId)},
12
+ dataset: ${quote(options.datasetName)},
13
+ plugins: [structureTool()],
14
+ schema: {types: schemaTypes},
15
+ })
16
+ `;
17
+ }
18
+ export const STUDIO_SCHEMA_TYPES = `import {post} from './post'
19
+
20
+ export const schemaTypes = [post]
21
+ `;
22
+ export const STUDIO_POST_TYPE = `import {defineField, defineType} from 'sanity'
23
+
24
+ export const post = defineType({
25
+ name: '${STARTER_DOCUMENT_TYPE}',
26
+ title: 'Post',
27
+ type: 'document',
28
+ fields: [
29
+ defineField({name: 'title', type: 'string', validation: (rule) => rule.required()}),
30
+ // The ${STARTER_FUNCTION_NAME} function fills this when it is empty.
31
+ defineField({name: 'slug', type: 'slug', options: {source: 'title'}}),
32
+ defineField({name: 'publishedAt', title: 'Published at', type: 'datetime'}),
33
+ defineField({name: 'body', type: 'text'}),
34
+ ],
35
+ })
36
+ `;
37
+ export const FUNCTION_SET_SLUG = `import {createClient} from '@sanity/client'
38
+ import {documentEventHandler} from '@sanity/functions'
39
+
40
+ const slugify = (title: string) =>
41
+ title
42
+ .toLowerCase()
43
+ .replace(/[^a-z0-9]+/g, '-')
44
+ .replace(/^-+|-+$/g, '')
45
+ .slice(0, 96)
46
+
47
+ export const handler = documentEventHandler(async ({context, event}) => {
48
+ const {_id, title, slug} = event.data
49
+ if (!title || slug?.current) return
50
+
51
+ const client = createClient({apiVersion: '2025-05-01', ...context.clientOptions})
52
+ const current = slugify(title)
53
+ await client.patch(_id).set({slug: {_type: 'slug', current}}).commit()
54
+
55
+ console.log(\`Set slug for \${_id}: \${current}\`)
56
+ })
57
+ `;
58
+ export const studioPackageJson = (name) => ({
59
+ name,
60
+ version: '0.1.0',
61
+ private: true,
62
+ scripts: {
63
+ dev: 'sanity dev',
64
+ build: 'sanity build',
65
+ deploy: 'sanity deploy',
66
+ },
67
+ dependencies: {
68
+ react: '^19',
69
+ 'react-dom': '^19',
70
+ sanity: '^4',
71
+ 'styled-components': '^6',
72
+ },
73
+ });
74
+ export const functionPackageJson = (name) => ({
75
+ name,
76
+ version: '0.1.0',
77
+ private: true,
78
+ type: 'module',
79
+ dependencies: {
80
+ '@sanity/client': '^7',
81
+ '@sanity/functions': '^1',
82
+ },
83
+ });
@@ -0,0 +1,15 @@
1
+ export interface WorkspaceOptions {
2
+ dir: string;
3
+ projectId: string;
4
+ displayName: string;
5
+ datasetName: string;
6
+ stackName: string;
7
+ studioName: string;
8
+ blueprintsVersion: string;
9
+ }
10
+ export interface WorkspaceResult {
11
+ blueprintFilePath: string;
12
+ files: string[];
13
+ }
14
+ export declare function scaffoldWorkspace(options: WorkspaceOptions): WorkspaceResult;
15
+ export declare function adoptWorkspace(options: WorkspaceOptions): WorkspaceResult;