@sanity/runtime-cli 17.1.0-next.gcfbd613 → 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 (58) hide show
  1. package/README.md +35 -26
  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.js +15 -24
  12. package/dist/actions/blueprints/pre-deploy.d.ts +29 -0
  13. package/dist/actions/blueprints/pre-deploy.js +164 -0
  14. package/dist/actions/sanity/datasets.d.ts +15 -0
  15. package/dist/actions/sanity/datasets.js +26 -0
  16. package/dist/baseCommands.d.ts +7 -0
  17. package/dist/baseCommands.js +21 -0
  18. package/dist/commands/blueprinit.d.ts +14 -0
  19. package/dist/commands/blueprinit.js +45 -0
  20. package/dist/commands/functions/env/add.d.ts +3 -0
  21. package/dist/commands/functions/env/add.js +6 -2
  22. package/dist/commands/functions/env/list.d.ts +3 -0
  23. package/dist/commands/functions/env/list.js +9 -3
  24. package/dist/commands/functions/env/remove.d.ts +3 -0
  25. package/dist/commands/functions/env/remove.js +9 -3
  26. package/dist/constants.d.ts +1 -0
  27. package/dist/constants.js +1 -0
  28. package/dist/cores/blueprinit/adopt.d.ts +6 -0
  29. package/dist/cores/blueprinit/adopt.js +90 -0
  30. package/dist/cores/blueprinit/finish.d.ts +14 -0
  31. package/dist/cores/blueprinit/finish.js +36 -0
  32. package/dist/cores/blueprinit/fresh.d.ts +3 -0
  33. package/dist/cores/blueprinit/fresh.js +88 -0
  34. package/dist/cores/blueprinit/prompts.d.ts +4 -0
  35. package/dist/cores/blueprinit/prompts.js +14 -0
  36. package/dist/cores/blueprinit/selection.d.ts +15 -0
  37. package/dist/cores/blueprinit/selection.js +63 -0
  38. package/dist/cores/blueprinit/types.d.ts +13 -0
  39. package/dist/cores/blueprinit/types.js +1 -0
  40. package/dist/cores/blueprinit.d.ts +7 -0
  41. package/dist/cores/blueprinit.js +39 -0
  42. package/dist/cores/blueprints/deploy.js +16 -64
  43. package/dist/utils/command-skills.d.ts +2 -0
  44. package/dist/utils/command-skills.js +17 -0
  45. package/dist/utils/functions/child-process-wrapper.js +13 -171
  46. package/dist/utils/functions/child-runtime/console.d.ts +1 -0
  47. package/dist/utils/functions/child-runtime/console.js +50 -0
  48. package/dist/utils/functions/child-runtime/invoke.d.ts +4 -0
  49. package/dist/utils/functions/child-runtime/invoke.js +47 -0
  50. package/dist/utils/functions/child-runtime/resources.d.ts +4 -0
  51. package/dist/utils/functions/child-runtime/resources.js +59 -0
  52. package/dist/utils/studios/prepare-asset.d.ts +6 -0
  53. package/dist/utils/studios/prepare-asset.js +139 -0
  54. package/dist/utils/types.d.ts +4 -7
  55. package/dist/utils/types.js +2 -3
  56. package/oclif.manifest.json +313 -7
  57. package/package.json +12 -4
  58. package/skills/blueprinit.md +137 -0
@@ -1,5 +1,111 @@
1
1
  {
2
2
  "commands": {
3
+ "blueprinit": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "Scaffolds a Blueprint, Studio, and starter function around an existing Sanity project.\n\nThis hidden command is an experiment; its interface and generated files are not stable.",
7
+ "examples": [
8
+ "<%= config.bin %> <%= command.id %>",
9
+ "<%= config.bin %> <%= command.id %> --yes"
10
+ ],
11
+ "flags": {
12
+ "json": {
13
+ "description": "Format output as json",
14
+ "name": "json",
15
+ "allowNo": false,
16
+ "type": "boolean"
17
+ },
18
+ "llms": {
19
+ "aliases": [
20
+ "skill"
21
+ ],
22
+ "description": "Show agent-oriented guidance for this command",
23
+ "name": "llms",
24
+ "allowNo": false,
25
+ "type": "boolean"
26
+ },
27
+ "path": {
28
+ "aliases": [
29
+ "blueprint-path"
30
+ ],
31
+ "char": "p",
32
+ "description": "Path to a Blueprint file or directory containing one",
33
+ "env": "SANITY_BLUEPRINT_PATH",
34
+ "hidden": true,
35
+ "name": "path",
36
+ "hasDynamicHelp": false,
37
+ "multiple": false,
38
+ "type": "option"
39
+ },
40
+ "trace": {
41
+ "description": "Trace output",
42
+ "hidden": true,
43
+ "name": "trace",
44
+ "allowNo": false,
45
+ "type": "boolean"
46
+ },
47
+ "validate-resources": {
48
+ "description": "Validate resources",
49
+ "hidden": true,
50
+ "name": "validate-resources",
51
+ "allowNo": true,
52
+ "type": "boolean"
53
+ },
54
+ "verbose": {
55
+ "description": "Verbose output",
56
+ "hidden": true,
57
+ "name": "verbose",
58
+ "allowNo": false,
59
+ "type": "boolean"
60
+ },
61
+ "yes": {
62
+ "char": "y",
63
+ "description": "Skip confirmation prompts",
64
+ "name": "yes",
65
+ "allowNo": false,
66
+ "type": "boolean"
67
+ },
68
+ "organization-id": {
69
+ "aliases": [
70
+ "organization",
71
+ "organizationId",
72
+ "org"
73
+ ],
74
+ "description": "Organization to use when the account has several",
75
+ "name": "organization-id",
76
+ "hasDynamicHelp": false,
77
+ "multiple": false,
78
+ "type": "option"
79
+ },
80
+ "project-id": {
81
+ "aliases": [
82
+ "project",
83
+ "projectId"
84
+ ],
85
+ "description": "Project to use when the organization has several",
86
+ "name": "project-id",
87
+ "hasDynamicHelp": false,
88
+ "multiple": false,
89
+ "type": "option"
90
+ }
91
+ },
92
+ "hasDynamicHelp": false,
93
+ "hidden": true,
94
+ "hiddenAliases": [],
95
+ "id": "blueprinit",
96
+ "pluginAlias": "@sanity/runtime-cli",
97
+ "pluginName": "@sanity/runtime-cli",
98
+ "pluginType": "core",
99
+ "strict": true,
100
+ "summary": "Experimental blueprints-first project init",
101
+ "enableJsonFlag": true,
102
+ "isESM": true,
103
+ "relativePath": [
104
+ "dist",
105
+ "commands",
106
+ "blueprinit.js"
107
+ ]
108
+ },
3
109
  "blueprints:add": {
4
110
  "aliases": [],
5
111
  "args": {
@@ -30,6 +136,16 @@
30
136
  "allowNo": false,
31
137
  "type": "boolean"
32
138
  },
139
+ "llms": {
140
+ "aliases": [
141
+ "skill"
142
+ ],
143
+ "description": "Show agent-oriented guidance for this command",
144
+ "hidden": true,
145
+ "name": "llms",
146
+ "allowNo": false,
147
+ "type": "boolean"
148
+ },
33
149
  "path": {
34
150
  "aliases": [
35
151
  "blueprint-path"
@@ -258,6 +374,16 @@
258
374
  "allowNo": false,
259
375
  "type": "boolean"
260
376
  },
377
+ "llms": {
378
+ "aliases": [
379
+ "skill"
380
+ ],
381
+ "description": "Show agent-oriented guidance for this command",
382
+ "hidden": true,
383
+ "name": "llms",
384
+ "allowNo": false,
385
+ "type": "boolean"
386
+ },
261
387
  "path": {
262
388
  "aliases": [
263
389
  "blueprint-path"
@@ -390,6 +516,16 @@
390
516
  "allowNo": false,
391
517
  "type": "boolean"
392
518
  },
519
+ "llms": {
520
+ "aliases": [
521
+ "skill"
522
+ ],
523
+ "description": "Show agent-oriented guidance for this command",
524
+ "hidden": true,
525
+ "name": "llms",
526
+ "allowNo": false,
527
+ "type": "boolean"
528
+ },
393
529
  "path": {
394
530
  "aliases": [
395
531
  "blueprint-path"
@@ -535,6 +671,16 @@
535
671
  "allowNo": false,
536
672
  "type": "boolean"
537
673
  },
674
+ "llms": {
675
+ "aliases": [
676
+ "skill"
677
+ ],
678
+ "description": "Show agent-oriented guidance for this command",
679
+ "hidden": true,
680
+ "name": "llms",
681
+ "allowNo": false,
682
+ "type": "boolean"
683
+ },
538
684
  "path": {
539
685
  "aliases": [
540
686
  "blueprint-path"
@@ -668,6 +814,16 @@
668
814
  "allowNo": false,
669
815
  "type": "boolean"
670
816
  },
817
+ "llms": {
818
+ "aliases": [
819
+ "skill"
820
+ ],
821
+ "description": "Show agent-oriented guidance for this command",
822
+ "hidden": true,
823
+ "name": "llms",
824
+ "allowNo": false,
825
+ "type": "boolean"
826
+ },
671
827
  "path": {
672
828
  "aliases": [
673
829
  "blueprint-path"
@@ -742,6 +898,16 @@
742
898
  "allowNo": false,
743
899
  "type": "boolean"
744
900
  },
901
+ "llms": {
902
+ "aliases": [
903
+ "skill"
904
+ ],
905
+ "description": "Show agent-oriented guidance for this command",
906
+ "hidden": true,
907
+ "name": "llms",
908
+ "allowNo": false,
909
+ "type": "boolean"
910
+ },
745
911
  "path": {
746
912
  "aliases": [
747
913
  "blueprint-path"
@@ -864,6 +1030,16 @@
864
1030
  "allowNo": false,
865
1031
  "type": "boolean"
866
1032
  },
1033
+ "llms": {
1034
+ "aliases": [
1035
+ "skill"
1036
+ ],
1037
+ "description": "Show agent-oriented guidance for this command",
1038
+ "hidden": true,
1039
+ "name": "llms",
1040
+ "allowNo": false,
1041
+ "type": "boolean"
1042
+ },
867
1043
  "path": {
868
1044
  "aliases": [
869
1045
  "blueprint-path"
@@ -1045,6 +1221,16 @@
1045
1221
  "allowNo": false,
1046
1222
  "type": "boolean"
1047
1223
  },
1224
+ "llms": {
1225
+ "aliases": [
1226
+ "skill"
1227
+ ],
1228
+ "description": "Show agent-oriented guidance for this command",
1229
+ "hidden": true,
1230
+ "name": "llms",
1231
+ "allowNo": false,
1232
+ "type": "boolean"
1233
+ },
1048
1234
  "path": {
1049
1235
  "aliases": [
1050
1236
  "blueprint-path"
@@ -1197,6 +1383,16 @@
1197
1383
  "allowNo": false,
1198
1384
  "type": "boolean"
1199
1385
  },
1386
+ "llms": {
1387
+ "aliases": [
1388
+ "skill"
1389
+ ],
1390
+ "description": "Show agent-oriented guidance for this command",
1391
+ "hidden": true,
1392
+ "name": "llms",
1393
+ "allowNo": false,
1394
+ "type": "boolean"
1395
+ },
1200
1396
  "path": {
1201
1397
  "aliases": [
1202
1398
  "blueprint-path"
@@ -1322,6 +1518,16 @@
1322
1518
  "allowNo": false,
1323
1519
  "type": "boolean"
1324
1520
  },
1521
+ "llms": {
1522
+ "aliases": [
1523
+ "skill"
1524
+ ],
1525
+ "description": "Show agent-oriented guidance for this command",
1526
+ "hidden": true,
1527
+ "name": "llms",
1528
+ "allowNo": false,
1529
+ "type": "boolean"
1530
+ },
1325
1531
  "path": {
1326
1532
  "aliases": [
1327
1533
  "blueprint-path"
@@ -1431,6 +1637,16 @@
1431
1637
  "allowNo": false,
1432
1638
  "type": "boolean"
1433
1639
  },
1640
+ "llms": {
1641
+ "aliases": [
1642
+ "skill"
1643
+ ],
1644
+ "description": "Show agent-oriented guidance for this command",
1645
+ "hidden": true,
1646
+ "name": "llms",
1647
+ "allowNo": false,
1648
+ "type": "boolean"
1649
+ },
1434
1650
  "path": {
1435
1651
  "aliases": [
1436
1652
  "blueprint-path"
@@ -1557,6 +1773,16 @@
1557
1773
  "allowNo": false,
1558
1774
  "type": "boolean"
1559
1775
  },
1776
+ "llms": {
1777
+ "aliases": [
1778
+ "skill"
1779
+ ],
1780
+ "description": "Show agent-oriented guidance for this command",
1781
+ "hidden": true,
1782
+ "name": "llms",
1783
+ "allowNo": false,
1784
+ "type": "boolean"
1785
+ },
1560
1786
  "path": {
1561
1787
  "aliases": [
1562
1788
  "blueprint-path"
@@ -1677,6 +1903,16 @@
1677
1903
  "allowNo": false,
1678
1904
  "type": "boolean"
1679
1905
  },
1906
+ "llms": {
1907
+ "aliases": [
1908
+ "skill"
1909
+ ],
1910
+ "description": "Show agent-oriented guidance for this command",
1911
+ "hidden": true,
1912
+ "name": "llms",
1913
+ "allowNo": false,
1914
+ "type": "boolean"
1915
+ },
1680
1916
  "path": {
1681
1917
  "aliases": [
1682
1918
  "blueprint-path"
@@ -1890,6 +2126,16 @@
1890
2126
  "allowNo": false,
1891
2127
  "type": "boolean"
1892
2128
  },
2129
+ "llms": {
2130
+ "aliases": [
2131
+ "skill"
2132
+ ],
2133
+ "description": "Show agent-oriented guidance for this command",
2134
+ "hidden": true,
2135
+ "name": "llms",
2136
+ "allowNo": false,
2137
+ "type": "boolean"
2138
+ },
1893
2139
  "path": {
1894
2140
  "aliases": [
1895
2141
  "blueprint-path"
@@ -2025,6 +2271,16 @@
2025
2271
  "allowNo": false,
2026
2272
  "type": "boolean"
2027
2273
  },
2274
+ "llms": {
2275
+ "aliases": [
2276
+ "skill"
2277
+ ],
2278
+ "description": "Show agent-oriented guidance for this command",
2279
+ "hidden": true,
2280
+ "name": "llms",
2281
+ "allowNo": false,
2282
+ "type": "boolean"
2283
+ },
2028
2284
  "path": {
2029
2285
  "aliases": [
2030
2286
  "blueprint-path"
@@ -2169,6 +2425,16 @@
2169
2425
  "allowNo": false,
2170
2426
  "type": "boolean"
2171
2427
  },
2428
+ "llms": {
2429
+ "aliases": [
2430
+ "skill"
2431
+ ],
2432
+ "description": "Show agent-oriented guidance for this command",
2433
+ "hidden": true,
2434
+ "name": "llms",
2435
+ "allowNo": false,
2436
+ "type": "boolean"
2437
+ },
2172
2438
  "path": {
2173
2439
  "aliases": [
2174
2440
  "blueprint-path"
@@ -2337,6 +2603,16 @@
2337
2603
  "allowNo": false,
2338
2604
  "type": "boolean"
2339
2605
  },
2606
+ "llms": {
2607
+ "aliases": [
2608
+ "skill"
2609
+ ],
2610
+ "description": "Show agent-oriented guidance for this command",
2611
+ "hidden": true,
2612
+ "name": "llms",
2613
+ "allowNo": false,
2614
+ "type": "boolean"
2615
+ },
2340
2616
  "path": {
2341
2617
  "aliases": [
2342
2618
  "blueprint-path"
@@ -2655,7 +2931,8 @@
2655
2931
  },
2656
2932
  "description": "Sets an environment variable in a deployed Sanity Function. If the variable already exists, its value is updated.\n\nEnvironment variables are useful for API keys, configuration values, and other secrets that shouldn't be hardcoded. Changes take effect on the next function invocation.",
2657
2933
  "examples": [
2658
- "<%= config.bin %> <%= command.id %> MyFunction API_URL https://api.example.com/"
2934
+ "<%= config.bin %> <%= command.id %> MyFunction API_URL https://api.example.com/",
2935
+ "<%= config.bin %> <%= command.id %> --stack <name-or-id> MyFunction API_URL https://api.example.com/"
2659
2936
  ],
2660
2937
  "flags": {
2661
2938
  "json": {
@@ -2664,6 +2941,16 @@
2664
2941
  "allowNo": false,
2665
2942
  "type": "boolean"
2666
2943
  },
2944
+ "llms": {
2945
+ "aliases": [
2946
+ "skill"
2947
+ ],
2948
+ "description": "Show agent-oriented guidance for this command",
2949
+ "hidden": true,
2950
+ "name": "llms",
2951
+ "allowNo": false,
2952
+ "type": "boolean"
2953
+ },
2667
2954
  "path": {
2668
2955
  "aliases": [
2669
2956
  "blueprint-path"
@@ -2700,7 +2987,6 @@
2700
2987
  },
2701
2988
  "stack": {
2702
2989
  "description": "Stack name or ID to use instead of the locally configured Stack",
2703
- "hidden": true,
2704
2990
  "name": "stack",
2705
2991
  "hasDynamicHelp": false,
2706
2992
  "multiple": false,
@@ -2771,7 +3057,8 @@
2771
3057
  },
2772
3058
  "description": "Displays all environment variables (keys only) configured in a deployed Sanity Function.\n\nUse 'functions env add' to set variables or 'functions env remove' to delete them.",
2773
3059
  "examples": [
2774
- "<%= config.bin %> <%= command.id %> MyFunction"
3060
+ "<%= config.bin %> <%= command.id %> MyFunction",
3061
+ "<%= config.bin %> <%= command.id %> --stack <name-or-id> MyFunction"
2775
3062
  ],
2776
3063
  "flags": {
2777
3064
  "json": {
@@ -2780,6 +3067,16 @@
2780
3067
  "allowNo": false,
2781
3068
  "type": "boolean"
2782
3069
  },
3070
+ "llms": {
3071
+ "aliases": [
3072
+ "skill"
3073
+ ],
3074
+ "description": "Show agent-oriented guidance for this command",
3075
+ "hidden": true,
3076
+ "name": "llms",
3077
+ "allowNo": false,
3078
+ "type": "boolean"
3079
+ },
2783
3080
  "path": {
2784
3081
  "aliases": [
2785
3082
  "blueprint-path"
@@ -2816,7 +3113,6 @@
2816
3113
  },
2817
3114
  "stack": {
2818
3115
  "description": "Stack name or ID to use instead of the locally configured Stack",
2819
- "hidden": true,
2820
3116
  "name": "stack",
2821
3117
  "hasDynamicHelp": false,
2822
3118
  "multiple": false,
@@ -2892,7 +3188,8 @@
2892
3188
  },
2893
3189
  "description": "Deletes an environment variable from a deployed Sanity Function. The change takes effect on the next function invocation.\n\nUse 'functions env list' to see current variables before removing.",
2894
3190
  "examples": [
2895
- "<%= config.bin %> <%= command.id %> MyFunction API_URL"
3191
+ "<%= config.bin %> <%= command.id %> MyFunction API_URL",
3192
+ "<%= config.bin %> <%= command.id %> --stack <name-or-id> MyFunction API_URL"
2896
3193
  ],
2897
3194
  "flags": {
2898
3195
  "json": {
@@ -2901,6 +3198,16 @@
2901
3198
  "allowNo": false,
2902
3199
  "type": "boolean"
2903
3200
  },
3201
+ "llms": {
3202
+ "aliases": [
3203
+ "skill"
3204
+ ],
3205
+ "description": "Show agent-oriented guidance for this command",
3206
+ "hidden": true,
3207
+ "name": "llms",
3208
+ "allowNo": false,
3209
+ "type": "boolean"
3210
+ },
2904
3211
  "path": {
2905
3212
  "aliases": [
2906
3213
  "blueprint-path"
@@ -2937,7 +3244,6 @@
2937
3244
  },
2938
3245
  "stack": {
2939
3246
  "description": "Stack name or ID to use instead of the locally configured Stack",
2940
- "hidden": true,
2941
3247
  "name": "stack",
2942
3248
  "hasDynamicHelp": false,
2943
3249
  "multiple": false,
@@ -2998,5 +3304,5 @@
2998
3304
  ]
2999
3305
  }
3000
3306
  },
3001
- "version": "17.1.0-next.gcfbd613"
3307
+ "version": "17.2.0-blueprinit.g3a96975"
3002
3308
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "17.1.0-next.gcfbd613",
4
+ "version": "17.2.0-blueprinit.g3a96975",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -26,7 +26,9 @@
26
26
  "files": [
27
27
  "./bin",
28
28
  "./dist",
29
- "./oclif.manifest.json"
29
+ "./oclif.manifest.json",
30
+ "./SKILL.md",
31
+ "./skills"
30
32
  ],
31
33
  "bin": {
32
34
  "sanity-run": "bin/run.js"
@@ -40,7 +42,9 @@
40
42
  "clean": "shx rm -rf dist oclif.manifest.json",
41
43
  "copy:design-tokens": "shx rm -rf ./src/server/static/vendor/design-tokens && shx cp -r ./node_modules/@sanity-labs/design-tokens/dist/css ./src/server/static/vendor/design-tokens",
42
44
  "copy:server": "shx cp -r ./src/server/static ./dist/server",
43
- "copy:wrapper": "shx cp ./src/utils/functions/child-process-wrapper.js ./dist/utils/functions/child-process-wrapper.js",
45
+ "copy:wrapper": "npm run copy:wrapper:entry && npm run copy:wrapper:modules",
46
+ "copy:wrapper:entry": "shx cp ./src/utils/functions/child-process-wrapper.js ./dist/utils/functions/child-process-wrapper.js",
47
+ "copy:wrapper:modules": "shx rm -rf ./dist/utils/functions/child-runtime && shx cp -r ./src/utils/functions/child-runtime ./dist/utils/functions/child-runtime",
44
48
  "lint": "biome ci",
45
49
  "lint:write": "biome check --write",
46
50
  "lint:fix": "npm run lint:write",
@@ -64,8 +68,10 @@
64
68
  "@oclif/core": "^4.11.14",
65
69
  "@oclif/plugin-help": "^6.2.53",
66
70
  "@sanity-labs/design-tokens": "^0.0.2-alpha.2",
67
- "@sanity/blueprints": "^0.22.0",
71
+ "@sanity/blueprints": "^0.23.0",
68
72
  "@sanity/blueprints-parser": "^0.4.0",
73
+ "@sanity/cli-build": "^5.0.0",
74
+ "@sanity/cli-core": "^2.5.1",
69
75
  "@sanity/client": "^7.23.1",
70
76
  "adm-zip": "^0.6.0",
71
77
  "array-treeify": "^0.1.5",
@@ -78,6 +84,7 @@
78
84
  "ora": "^9.4.1",
79
85
  "signal-exit": "^4.1.0",
80
86
  "strip-ansi": "^7.2.0",
87
+ "tar-fs": "^3.1.3",
81
88
  "tar-stream": "^3.2.0",
82
89
  "vite": "^8.1.4",
83
90
  "ws": "^8.21.1",
@@ -97,6 +104,7 @@
97
104
  "@types/cardinal": "^2.1.1",
98
105
  "@types/mime-types": "^3.0.1",
99
106
  "@types/node": "^22",
107
+ "@types/tar-fs": "^2.0.4",
100
108
  "@types/tar-stream": "^3.1.4",
101
109
  "@types/ws": "^8.18.1",
102
110
  "@vitest/coverage-v8": "4.1.10",
@@ -0,0 +1,137 @@
1
+ # Blueprinit
2
+
3
+ Use `blueprinit` to scaffold a Blueprint around an existing Sanity project. The command is
4
+ experimental, hidden from root help, and available from the `blueprinit` npm dist-tag.
5
+
6
+ Use it for demos and evaluation, not as a stable project initializer. Its flags, generated files,
7
+ and resource model may change.
8
+
9
+ ## Know what it does
10
+
11
+ `blueprinit` uses an existing Sanity organization, project, and dataset. It writes local Blueprint
12
+ files, then creates an empty organization-scoped Stack. The generated Blueprint attaches the
13
+ project and dataset and declares resources for a later deployment.
14
+
15
+ It does not create an organization, project, or dataset. It does not deploy the attached resources,
16
+ Studio, or Function. Those changes happen only if `blueprints deploy` is run later.
17
+
18
+ ## Inspect the target directory
19
+
20
+ Run the command from the directory that should contain the Blueprint.
21
+
22
+ Before running:
23
+
24
+ 1. Check the working tree and existing files. Do not discard unrelated user changes.
25
+ 2. Look for a root `sanity.blueprint.*` file. If one exists, use the existing Blueprint instead of
26
+ initializing again.
27
+ 3. Look for a root `sanity.config.*` file. Its presence selects the Studio adoption flow.
28
+ 4. Confirm the user asked to initialize this directory. The command writes files and creates a
29
+ remote Stack.
30
+ 5. Confirm the user is signed in. If needed, have them run:
31
+
32
+ ```sh
33
+ npx sanity login
34
+ ```
35
+
36
+ The account must have at least one organization, one project in the selected organization, and one
37
+ dataset in the selected project.
38
+
39
+ ## Choose the flow
40
+
41
+ - **Existing Blueprint:** Exit without changes and use `blueprints config --edit` or
42
+ `blueprints doctor`.
43
+ - **Root Studio config:** Adopt the Studio in place. Read literal `projectId` and `dataset` strings
44
+ from `sanity.config.*`, falling back to `sanity.cli.*`. Do not move the Studio.
45
+ - **Fresh workspace:** Create a Blueprint, an npm-workspace Studio, and a starter `set-slug`
46
+ document function.
47
+
48
+ Do not rewrite a Studio config merely to make adoption work unless the user asks. Dynamic
49
+ `projectId` or `dataset` values built from environment variables or imports cannot be detected.
50
+
51
+ For an existing Blueprint, inspect it with:
52
+
53
+ ```sh
54
+ npx @sanity/runtime-cli@blueprinit blueprints doctor
55
+ ```
56
+
57
+ ## Run unattended
58
+
59
+ When the organization and project IDs are known, run this from the target directory:
60
+
61
+ ```sh
62
+ npx @sanity/runtime-cli@blueprinit blueprinit --yes \
63
+ --organization-id <organization-id> \
64
+ --project-id <project-id>
65
+ ```
66
+
67
+ Replace both placeholders with real IDs. The project must belong to the organization. Do not guess
68
+ either value.
69
+
70
+ `--yes` skips confirmation and uses `studio` as the Studio name. Without explicit IDs, an
71
+ unattended run stops when the account has several organizations or projects. Ask the user for the
72
+ IDs or have them run the command interactively.
73
+
74
+ For interactive organization, project, confirmation, and Studio-name prompts, have the user run:
75
+
76
+ ```sh
77
+ npx @sanity/runtime-cli@blueprinit blueprinit
78
+ ```
79
+
80
+ There is no dataset flag. The command uses `production` when present, otherwise the first dataset
81
+ returned for the project. Report the selected dataset from the command output.
82
+
83
+ ## Review the result
84
+
85
+ A successful fresh run creates or updates:
86
+
87
+ ```text
88
+ .
89
+ ├── .sanity/blueprint.config.json
90
+ ├── sanity.blueprint.ts
91
+ ├── package.json
92
+ ├── functions/
93
+ │ └── set-slug/
94
+ └── studios/
95
+ └── studio/
96
+ ```
97
+
98
+ The command also creates or updates `.gitignore`. It preserves existing package metadata and adds
99
+ the required npm workspaces and `@sanity/blueprints` dependency.
100
+
101
+ An adopted Studio stays at the repository root. The command adds the Blueprint, Blueprint config,
102
+ dependency, and `.gitignore` entry, but does not generate the starter Function.
103
+
104
+ After the command exits:
105
+
106
+ 1. Confirm the output names the expected organization, project, and dataset.
107
+ 2. Confirm `.sanity/blueprint.config.json` exists. Its presence means Stack creation completed.
108
+ 3. Review `sanity.blueprint.ts`, `package.json`, `.gitignore`, and the working-tree diff.
109
+ 4. Report the Stack ID and every created or modified path.
110
+
111
+ Do not deploy as part of initialization unless the user separately asks for deployment. To continue
112
+ after reviewing the scaffold, install dependencies and preview the deployment:
113
+
114
+ ```sh
115
+ npm install
116
+ npx @sanity/runtime-cli@blueprinit blueprints plan
117
+ ```
118
+
119
+ Treat dependency installation and planning as separate follow-up actions when they were not part of
120
+ the user's request.
121
+
122
+ ## Handle failures
123
+
124
+ - **`No Sanity session found.`** Stop and ask the user to run `npx sanity login`. Authentication
125
+ fails before files are written.
126
+ - **Multiple organizations or projects found.** Rerun with the matching `--organization-id` and
127
+ `--project-id`. Selection fails before files are written.
128
+ - **No datasets found.** Ask the user to create or choose a project with a dataset. The command does
129
+ not create datasets.
130
+ - **Could not read `projectId` and `dataset`.** The detected Studio config does not contain both
131
+ values as string literals. Report the config file and let the user decide whether to change it.
132
+ - **Refusing to overwrite an existing path.** Inspect the reported Studio or Function directory.
133
+ Do not delete or replace it without the user's direction.
134
+ - **Stack quota or duplicate-name error.** Local scaffold files may already exist while
135
+ `.sanity/blueprint.config.json` does not. Stop and report the partial state. Do not fabricate a
136
+ config file or blindly rerun: the command has no partial-failure recovery flow, and the generated
137
+ Blueprint makes a rerun exit as already initialized.