@sanity/runtime-cli 17.6.0-blueprinit.g77b7a64 → 17.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -19
- package/dist/actions/blueprints/pre-deploy.js +11 -18
- package/oclif.manifest.json +1 -130
- package/package.json +2 -2
- package/dist/actions/blueprinit/manifest.d.ts +0 -15
- package/dist/actions/blueprinit/manifest.js +0 -82
- package/dist/actions/blueprinit/studio.d.ts +0 -6
- package/dist/actions/blueprinit/studio.js +0 -43
- package/dist/actions/blueprinit/templates.d.ts +0 -34
- package/dist/actions/blueprinit/templates.js +0 -83
- package/dist/actions/blueprinit/workspace.d.ts +0 -16
- package/dist/actions/blueprinit/workspace.js +0 -143
- package/dist/actions/sanity/datasets.d.ts +0 -15
- package/dist/actions/sanity/datasets.js +0 -26
- package/dist/commands/init.d.ts +0 -17
- package/dist/commands/init.js +0 -59
- package/dist/cores/blueprinit/adopt.d.ts +0 -6
- package/dist/cores/blueprinit/adopt.js +0 -119
- package/dist/cores/blueprinit/finish.d.ts +0 -14
- package/dist/cores/blueprinit/finish.js +0 -64
- package/dist/cores/blueprinit/fresh.d.ts +0 -3
- package/dist/cores/blueprinit/fresh.js +0 -120
- package/dist/cores/blueprinit/preview.d.ts +0 -15
- package/dist/cores/blueprinit/preview.js +0 -14
- package/dist/cores/blueprinit/prompts.d.ts +0 -5
- package/dist/cores/blueprinit/prompts.js +0 -22
- package/dist/cores/blueprinit/selection.d.ts +0 -15
- package/dist/cores/blueprinit/selection.js +0 -90
- package/dist/cores/blueprinit/types.d.ts +0 -16
- package/dist/cores/blueprinit/types.js +0 -1
- package/dist/cores/blueprinit.d.ts +0 -7
- package/dist/cores/blueprinit.js +0 -48
- package/skills/init.md +0 -155
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ EXAMPLES
|
|
|
90
90
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
93
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/add.ts)_
|
|
94
94
|
|
|
95
95
|
## `sanity-run blueprints config`
|
|
96
96
|
|
|
@@ -127,7 +127,7 @@ EXAMPLES
|
|
|
127
127
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
130
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/config.ts)_
|
|
131
131
|
|
|
132
132
|
## `sanity-run blueprints deploy`
|
|
133
133
|
|
|
@@ -183,7 +183,7 @@ EXAMPLES
|
|
|
183
183
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
186
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/deploy.ts)_
|
|
187
187
|
|
|
188
188
|
## `sanity-run blueprints destroy`
|
|
189
189
|
|
|
@@ -221,7 +221,7 @@ EXAMPLES
|
|
|
221
221
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
224
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/destroy.ts)_
|
|
225
225
|
|
|
226
226
|
## `sanity-run blueprints doctor`
|
|
227
227
|
|
|
@@ -253,7 +253,7 @@ EXAMPLES
|
|
|
253
253
|
$ sanity-run blueprints doctor --fix
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
256
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/doctor.ts)_
|
|
257
257
|
|
|
258
258
|
## `sanity-run blueprints info`
|
|
259
259
|
|
|
@@ -291,7 +291,7 @@ EXAMPLES
|
|
|
291
291
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
294
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/info.ts)_
|
|
295
295
|
|
|
296
296
|
## `sanity-run blueprints init [DIR]`
|
|
297
297
|
|
|
@@ -355,7 +355,7 @@ EXAMPLES
|
|
|
355
355
|
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
358
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/init.ts)_
|
|
359
359
|
|
|
360
360
|
## `sanity-run blueprints logs`
|
|
361
361
|
|
|
@@ -401,7 +401,7 @@ EXAMPLES
|
|
|
401
401
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
402
402
|
```
|
|
403
403
|
|
|
404
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
404
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/logs.ts)_
|
|
405
405
|
|
|
406
406
|
## `sanity-run blueprints mint-deploy-token`
|
|
407
407
|
|
|
@@ -446,7 +446,7 @@ EXAMPLES
|
|
|
446
446
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
449
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/mint-deploy-token.ts)_
|
|
450
450
|
|
|
451
451
|
## `sanity-run blueprints plan`
|
|
452
452
|
|
|
@@ -479,7 +479,7 @@ EXAMPLES
|
|
|
479
479
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
480
480
|
```
|
|
481
481
|
|
|
482
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
482
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/plan.ts)_
|
|
483
483
|
|
|
484
484
|
## `sanity-run blueprints promote`
|
|
485
485
|
|
|
@@ -515,7 +515,7 @@ EXAMPLES
|
|
|
515
515
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
518
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/promote.ts)_
|
|
519
519
|
|
|
520
520
|
## `sanity-run blueprints stacks`
|
|
521
521
|
|
|
@@ -551,7 +551,7 @@ EXAMPLES
|
|
|
551
551
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
552
552
|
```
|
|
553
553
|
|
|
554
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
554
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/blueprints/stacks.ts)_
|
|
555
555
|
|
|
556
556
|
## `sanity-run functions add`
|
|
557
557
|
|
|
@@ -603,7 +603,7 @@ EXAMPLES
|
|
|
603
603
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
604
604
|
```
|
|
605
605
|
|
|
606
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
606
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/add.ts)_
|
|
607
607
|
|
|
608
608
|
## `sanity-run functions dev`
|
|
609
609
|
|
|
@@ -638,7 +638,7 @@ EXAMPLES
|
|
|
638
638
|
$ sanity-run functions dev --timeout 60
|
|
639
639
|
```
|
|
640
640
|
|
|
641
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
641
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/dev.ts)_
|
|
642
642
|
|
|
643
643
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
644
644
|
|
|
@@ -671,7 +671,7 @@ EXAMPLES
|
|
|
671
671
|
$ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
|
|
672
672
|
```
|
|
673
673
|
|
|
674
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
674
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/env/add.ts)_
|
|
675
675
|
|
|
676
676
|
## `sanity-run functions env list NAME`
|
|
677
677
|
|
|
@@ -701,7 +701,7 @@ EXAMPLES
|
|
|
701
701
|
$ sanity-run functions env list --stack <name-or-id> MyFunction
|
|
702
702
|
```
|
|
703
703
|
|
|
704
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
704
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/env/list.ts)_
|
|
705
705
|
|
|
706
706
|
## `sanity-run functions env remove NAME KEY`
|
|
707
707
|
|
|
@@ -733,7 +733,7 @@ EXAMPLES
|
|
|
733
733
|
$ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
|
|
734
734
|
```
|
|
735
735
|
|
|
736
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
736
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/env/remove.ts)_
|
|
737
737
|
|
|
738
738
|
## `sanity-run functions logs [NAME]`
|
|
739
739
|
|
|
@@ -773,7 +773,7 @@ EXAMPLES
|
|
|
773
773
|
$ sanity-run functions logs <name> --delete
|
|
774
774
|
```
|
|
775
775
|
|
|
776
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
776
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/logs.ts)_
|
|
777
777
|
|
|
778
778
|
## `sanity-run functions test [NAME]`
|
|
779
779
|
|
|
@@ -830,7 +830,7 @@ EXAMPLES
|
|
|
830
830
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
831
831
|
```
|
|
832
832
|
|
|
833
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.
|
|
833
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.1/src/commands/functions/test.ts)_
|
|
834
834
|
|
|
835
835
|
## `sanity-run help [COMMAND]`
|
|
836
836
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { env } from 'node:process';
|
|
2
1
|
import { resolveDeployedResources } from '../../utils/blueprints/resolve-deployed-resources.js';
|
|
3
2
|
import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
|
|
4
3
|
import { styleText } from '../../utils/style-text.js';
|
|
@@ -10,24 +9,18 @@ export async function preDeploy(options) {
|
|
|
10
9
|
const { resources, stackId, auth, blueprintFileDir, installer, logger } = options;
|
|
11
10
|
const hasAssetResources = resources.some(isAssetResource);
|
|
12
11
|
if (hasAssetResources) {
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
if (!preDeployStackResult.success) {
|
|
17
|
-
return preDeployStackResult;
|
|
18
|
-
}
|
|
19
|
-
/** Look up resources from the back-end and attach the externalId if possible */
|
|
20
|
-
const resolvedResources = await resolveDeployedResources({
|
|
21
|
-
resources,
|
|
22
|
-
stackId,
|
|
23
|
-
auth,
|
|
24
|
-
logger,
|
|
25
|
-
});
|
|
26
|
-
assetResources = resolvedResources.filter(isAssetResource);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
assetResources = resources.filter(isAssetResource);
|
|
12
|
+
const preDeployStackResult = await preDeployStack(options);
|
|
13
|
+
if (!preDeployStackResult.success) {
|
|
14
|
+
return preDeployStackResult;
|
|
30
15
|
}
|
|
16
|
+
/** Look up resources from the back-end and attach the externalId if possible */
|
|
17
|
+
const resolvedResources = await resolveDeployedResources({
|
|
18
|
+
resources,
|
|
19
|
+
stackId,
|
|
20
|
+
auth,
|
|
21
|
+
logger,
|
|
22
|
+
});
|
|
23
|
+
const assetResources = resolvedResources.filter(isAssetResource);
|
|
31
24
|
let processedAssets;
|
|
32
25
|
try {
|
|
33
26
|
processedAssets = await processAssets({
|
package/oclif.manifest.json
CHANGED
|
@@ -1,134 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"init": {
|
|
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
|
-
"<%= config.bin %> <%= command.id %> --project-id <id> --dataset <name> --yes"
|
|
11
|
-
],
|
|
12
|
-
"flags": {
|
|
13
|
-
"json": {
|
|
14
|
-
"description": "Format output as json",
|
|
15
|
-
"name": "json",
|
|
16
|
-
"allowNo": false,
|
|
17
|
-
"type": "boolean"
|
|
18
|
-
},
|
|
19
|
-
"path": {
|
|
20
|
-
"aliases": [
|
|
21
|
-
"blueprint-path"
|
|
22
|
-
],
|
|
23
|
-
"char": "p",
|
|
24
|
-
"description": "Path to a Blueprint file or directory containing one",
|
|
25
|
-
"env": "SANITY_BLUEPRINT_PATH",
|
|
26
|
-
"hidden": true,
|
|
27
|
-
"name": "path",
|
|
28
|
-
"hasDynamicHelp": false,
|
|
29
|
-
"multiple": false,
|
|
30
|
-
"type": "option"
|
|
31
|
-
},
|
|
32
|
-
"trace": {
|
|
33
|
-
"description": "Trace output",
|
|
34
|
-
"hidden": true,
|
|
35
|
-
"name": "trace",
|
|
36
|
-
"allowNo": false,
|
|
37
|
-
"type": "boolean"
|
|
38
|
-
},
|
|
39
|
-
"validate-resources": {
|
|
40
|
-
"description": "Validate resources",
|
|
41
|
-
"hidden": true,
|
|
42
|
-
"name": "validate-resources",
|
|
43
|
-
"allowNo": true,
|
|
44
|
-
"type": "boolean"
|
|
45
|
-
},
|
|
46
|
-
"verbose": {
|
|
47
|
-
"description": "Verbose output",
|
|
48
|
-
"hidden": true,
|
|
49
|
-
"name": "verbose",
|
|
50
|
-
"allowNo": false,
|
|
51
|
-
"type": "boolean"
|
|
52
|
-
},
|
|
53
|
-
"llms": {
|
|
54
|
-
"aliases": [
|
|
55
|
-
"skill"
|
|
56
|
-
],
|
|
57
|
-
"description": "Show agent-oriented guidance for this command",
|
|
58
|
-
"hidden": true,
|
|
59
|
-
"name": "llms",
|
|
60
|
-
"allowNo": false,
|
|
61
|
-
"type": "boolean"
|
|
62
|
-
},
|
|
63
|
-
"yes": {
|
|
64
|
-
"char": "y",
|
|
65
|
-
"description": "Skip confirmation prompts",
|
|
66
|
-
"name": "yes",
|
|
67
|
-
"allowNo": false,
|
|
68
|
-
"type": "boolean"
|
|
69
|
-
},
|
|
70
|
-
"organization-id": {
|
|
71
|
-
"aliases": [
|
|
72
|
-
"organization",
|
|
73
|
-
"organizationId",
|
|
74
|
-
"org"
|
|
75
|
-
],
|
|
76
|
-
"description": "Organization to use when the account has several",
|
|
77
|
-
"name": "organization-id",
|
|
78
|
-
"hasDynamicHelp": false,
|
|
79
|
-
"multiple": false,
|
|
80
|
-
"type": "option"
|
|
81
|
-
},
|
|
82
|
-
"project-id": {
|
|
83
|
-
"aliases": [
|
|
84
|
-
"project",
|
|
85
|
-
"projectId"
|
|
86
|
-
],
|
|
87
|
-
"description": "Project to use when the organization has several",
|
|
88
|
-
"name": "project-id",
|
|
89
|
-
"hasDynamicHelp": false,
|
|
90
|
-
"multiple": false,
|
|
91
|
-
"type": "option"
|
|
92
|
-
},
|
|
93
|
-
"dataset": {
|
|
94
|
-
"description": "Dataset to attach",
|
|
95
|
-
"name": "dataset",
|
|
96
|
-
"hasDynamicHelp": false,
|
|
97
|
-
"multiple": false,
|
|
98
|
-
"type": "option"
|
|
99
|
-
},
|
|
100
|
-
"stack-name": {
|
|
101
|
-
"description": "Name for the new organization-scoped Stack",
|
|
102
|
-
"name": "stack-name",
|
|
103
|
-
"hasDynamicHelp": false,
|
|
104
|
-
"multiple": false,
|
|
105
|
-
"type": "option"
|
|
106
|
-
},
|
|
107
|
-
"studio-name": {
|
|
108
|
-
"description": "Name and hosted slug for the Studio resource",
|
|
109
|
-
"name": "studio-name",
|
|
110
|
-
"hasDynamicHelp": false,
|
|
111
|
-
"multiple": false,
|
|
112
|
-
"type": "option"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"hasDynamicHelp": false,
|
|
116
|
-
"hidden": true,
|
|
117
|
-
"hiddenAliases": [],
|
|
118
|
-
"id": "init",
|
|
119
|
-
"pluginAlias": "@sanity/runtime-cli",
|
|
120
|
-
"pluginName": "@sanity/runtime-cli",
|
|
121
|
-
"pluginType": "core",
|
|
122
|
-
"strict": true,
|
|
123
|
-
"summary": "Experimental blueprints-first project init",
|
|
124
|
-
"enableJsonFlag": true,
|
|
125
|
-
"isESM": true,
|
|
126
|
-
"relativePath": [
|
|
127
|
-
"dist",
|
|
128
|
-
"commands",
|
|
129
|
-
"init.js"
|
|
130
|
-
]
|
|
131
|
-
},
|
|
132
3
|
"blueprints:add": {
|
|
133
4
|
"aliases": [],
|
|
134
5
|
"args": {
|
|
@@ -3256,5 +3127,5 @@
|
|
|
3256
3127
|
]
|
|
3257
3128
|
}
|
|
3258
3129
|
},
|
|
3259
|
-
"version": "17.6.
|
|
3130
|
+
"version": "17.6.1"
|
|
3260
3131
|
}
|
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.6.
|
|
4
|
+
"version": "17.6.1",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@oclif/plugin-help": "^6.2.56",
|
|
70
70
|
"@sanity-labs/design-tokens": "^0.0.2-alpha.2",
|
|
71
71
|
"@sanity-labs/oclif-plugin-skills-flag": "^0.2.1",
|
|
72
|
-
"@sanity/blueprints": "^0.23.
|
|
72
|
+
"@sanity/blueprints": "^0.23.2",
|
|
73
73
|
"@sanity/blueprints-parser": "^0.4.0",
|
|
74
74
|
"@sanity/cli-build": "^5.1.0",
|
|
75
75
|
"@sanity/cli-core": "^2.8.1",
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
studioOrigin: string;
|
|
11
|
-
withFunction: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function renderBlueprint(options: BlueprintManifestOptions): string;
|
|
14
|
-
export declare function hostedStudioOrigin(studioName: string, sanityEnv?: string): string;
|
|
15
|
-
export declare function slugify(value: string): string;
|
|
@@ -1,82 +0,0 @@
|
|
|
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, studioOrigin, withFunction, } = options;
|
|
6
|
-
const definers = [
|
|
7
|
-
'defineBlueprint',
|
|
8
|
-
'defineCorsOrigin',
|
|
9
|
-
'defineDataset',
|
|
10
|
-
'defineProject',
|
|
11
|
-
'defineStudio',
|
|
12
|
-
];
|
|
13
|
-
if (withFunction)
|
|
14
|
-
definers.splice(3, 0, 'defineDocumentFunction');
|
|
15
|
-
const project = quote(`$.resources.${projectName}.id`);
|
|
16
|
-
const inlineImport = `import {${definers.join(', ')}} from '@sanity/blueprints'`;
|
|
17
|
-
const imports = inlineImport.length > 100
|
|
18
|
-
? `import {\n${definers.map((definer) => ` ${definer},`).join('\n')}\n} from '@sanity/blueprints'`
|
|
19
|
-
: inlineImport;
|
|
20
|
-
const functionResource = withFunction
|
|
21
|
-
? ` defineDocumentFunction({
|
|
22
|
-
name: ${quote(STARTER_FUNCTION_NAME)},
|
|
23
|
-
displayName: 'Set slug',
|
|
24
|
-
project: ${project},
|
|
25
|
-
event: {
|
|
26
|
-
on: ['create', 'update'],
|
|
27
|
-
filter: "_type == '${STARTER_DOCUMENT_TYPE}' && !defined(slug.current)",
|
|
28
|
-
projection: '{_id, title, slug}',
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
`
|
|
32
|
-
: '';
|
|
33
|
-
return `${imports}
|
|
34
|
-
|
|
35
|
-
export default defineBlueprint({
|
|
36
|
-
resources: [
|
|
37
|
-
defineProject({
|
|
38
|
-
name: ${quote(projectName)},
|
|
39
|
-
displayName: ${quote(displayName)},
|
|
40
|
-
lifecycle: {
|
|
41
|
-
deletionPolicy: 'retain',
|
|
42
|
-
ownershipAction: {type: 'attach', id: ${quote(projectId)}},
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
defineDataset({
|
|
46
|
-
project: ${project},
|
|
47
|
-
name: ${quote(datasetName)},
|
|
48
|
-
lifecycle: {
|
|
49
|
-
deletionPolicy: 'retain',
|
|
50
|
-
ownershipAction: {
|
|
51
|
-
type: 'attach',
|
|
52
|
-
id: ${quote(datasetName)},
|
|
53
|
-
projectId: ${project},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
}),
|
|
57
|
-
defineCorsOrigin({
|
|
58
|
-
project: ${project},
|
|
59
|
-
name: ${quote(`${studioName}-cors`)},
|
|
60
|
-
origin: ${quote(studioOrigin)},
|
|
61
|
-
allowCredentials: true,
|
|
62
|
-
}),
|
|
63
|
-
defineStudio({
|
|
64
|
-
project: ${project},
|
|
65
|
-
name: ${quote(studioName)},
|
|
66
|
-
title: ${quote(displayName)},
|
|
67
|
-
src: ${quote(studioSrc)},
|
|
68
|
-
}),
|
|
69
|
-
${functionResource} ],
|
|
70
|
-
})
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
export function hostedStudioOrigin(studioName, sanityEnv) {
|
|
74
|
-
const hostname = sanityEnv?.toLowerCase() === 'staging' ? 'studio.sanity.work' : 'sanity.studio';
|
|
75
|
-
return `https://${studioName}.${hostname}`;
|
|
76
|
-
}
|
|
77
|
-
export function slugify(value) {
|
|
78
|
-
return value
|
|
79
|
-
.toLowerCase()
|
|
80
|
-
.replace(/[^a-z0-9]+/g, '-')
|
|
81
|
-
.replace(/^-+|-+$/g, '');
|
|
82
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface WorkspaceOptions {
|
|
2
|
-
dir: string;
|
|
3
|
-
projectId: string;
|
|
4
|
-
displayName: string;
|
|
5
|
-
datasetName: string;
|
|
6
|
-
stackName: string;
|
|
7
|
-
studioName: string;
|
|
8
|
-
studioOrigin: string;
|
|
9
|
-
blueprintsVersion: string;
|
|
10
|
-
}
|
|
11
|
-
export interface WorkspaceResult {
|
|
12
|
-
blueprintFilePath: string;
|
|
13
|
-
files: string[];
|
|
14
|
-
}
|
|
15
|
-
export declare function scaffoldWorkspace(options: WorkspaceOptions): WorkspaceResult;
|
|
16
|
-
export declare function adoptWorkspace(options: WorkspaceOptions): WorkspaceResult;
|