@sanity/runtime-cli 17.8.0 → 17.9.0-blueprinit.g14aaebd
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 +28 -22
- package/dist/actions/blueprinit/manifest.d.ts +46 -0
- package/dist/actions/blueprinit/manifest.js +121 -0
- package/dist/actions/blueprinit/quote.d.ts +6 -0
- package/dist/actions/blueprinit/quote.js +8 -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 +73 -0
- package/dist/actions/blueprinit/templates.js +138 -0
- package/dist/actions/blueprinit/versions.d.ts +8 -0
- package/dist/actions/blueprinit/versions.js +11 -0
- package/dist/actions/blueprinit/workspace.d.ts +27 -0
- package/dist/actions/blueprinit/workspace.js +145 -0
- package/dist/actions/blueprints/pre-deploy.js +2 -0
- package/dist/actions/blueprints/stacks.d.ts +3 -0
- package/dist/actions/blueprints/stacks.js +1 -0
- package/dist/actions/sanity/create-project.d.ts +19 -0
- package/dist/actions/sanity/create-project.js +32 -0
- package/dist/actions/sanity/datasets.d.ts +15 -0
- package/dist/actions/sanity/datasets.js +26 -0
- package/dist/actions/sanity/projects.d.ts +11 -0
- package/dist/actions/sanity/projects.js +48 -22
- package/dist/baseCommands.d.ts +6 -0
- package/dist/baseCommands.js +9 -1
- package/dist/commands/blueprints/stacks.d.ts +2 -1
- package/dist/commands/blueprints/stacks.js +14 -6
- package/dist/commands/functions/test.d.ts +1 -0
- package/dist/commands/functions/test.js +5 -0
- package/dist/commands/init.d.ts +21 -0
- package/dist/commands/init.js +82 -0
- package/dist/cores/blueprinit/adopt.d.ts +6 -0
- package/dist/cores/blueprinit/adopt.js +137 -0
- package/dist/cores/blueprinit/columns.d.ts +26 -0
- package/dist/cores/blueprinit/columns.js +27 -0
- package/dist/cores/blueprinit/finish.d.ts +15 -0
- package/dist/cores/blueprinit/finish.js +72 -0
- package/dist/cores/blueprinit/fresh.d.ts +3 -0
- package/dist/cores/blueprinit/fresh.js +219 -0
- package/dist/cores/blueprinit/naming.d.ts +27 -0
- package/dist/cores/blueprinit/naming.js +43 -0
- package/dist/cores/blueprinit/preview.d.ts +34 -0
- package/dist/cores/blueprinit/preview.js +110 -0
- package/dist/cores/blueprinit/project-choice.d.ts +28 -0
- package/dist/cores/blueprinit/project-choice.js +82 -0
- package/dist/cores/blueprinit/prompts.d.ts +13 -0
- package/dist/cores/blueprinit/prompts.js +42 -0
- package/dist/cores/blueprinit/results.d.ts +8 -0
- package/dist/cores/blueprinit/results.js +4 -0
- package/dist/cores/blueprinit/selection.d.ts +15 -0
- package/dist/cores/blueprinit/selection.js +90 -0
- package/dist/cores/blueprinit/stack-name.d.ts +39 -0
- package/dist/cores/blueprinit/stack-name.js +56 -0
- package/dist/cores/blueprinit/target.d.ts +33 -0
- package/dist/cores/blueprinit/target.js +80 -0
- package/dist/cores/blueprinit/types.d.ts +20 -0
- package/dist/cores/blueprinit/types.js +1 -0
- package/dist/cores/blueprinit.d.ts +7 -0
- package/dist/cores/blueprinit.js +64 -0
- package/dist/cores/blueprints/stacks.d.ts +8 -3
- package/dist/cores/blueprints/stacks.js +282 -85
- package/dist/cores/functions/test.d.ts +2 -19
- package/dist/cores/functions/test.js +63 -138
- package/dist/server/app.js +4 -6
- package/dist/server/static/components/payload-panel.js +1 -1
- package/dist/utils/display/intro.d.ts +6 -0
- package/dist/utils/display/intro.js +63 -0
- package/dist/utils/display/prompt.d.ts +4 -1
- package/dist/utils/display/prompt.js +16 -2
- package/dist/utils/functions/child-process-wrapper.js +3 -2
- package/dist/utils/functions/child-runtime/durable.d.ts +2 -2
- package/dist/utils/functions/child-runtime/durable.js +53 -3
- package/dist/utils/functions/durable-logs.d.ts +16 -0
- package/dist/utils/functions/durable-logs.js +52 -0
- package/dist/utils/functions/invoke/local.js +16 -8
- package/dist/utils/functions/invoke/resolve-invoke-type.d.ts +51 -0
- package/dist/utils/functions/invoke/resolve-invoke-type.js +131 -0
- package/dist/utils/types.d.ts +39 -6
- package/oclif.manifest.json +177 -5
- package/package.json +1 -1
- package/skills/blueprints-stacks.md +14 -2
- package/skills/init.md +199 -0
package/skills/init.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# init
|
|
2
|
+
|
|
3
|
+
Use `init` 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
|
+
`init` uses an existing Sanity organization. It uses a project that exists, or creates one with
|
|
12
|
+
`--create-project`. It writes local Blueprint files, then creates an empty organization-scoped
|
|
13
|
+
Stack. The generated Blueprint attaches the project and declares resources for a later deployment.
|
|
14
|
+
|
|
15
|
+
The dataset works one of two ways:
|
|
16
|
+
|
|
17
|
+
- **Existing project:** the user picks one of its datasets, and the Blueprint attaches it.
|
|
18
|
+
- **New project:** a new project has no datasets, so the Blueprint creates one. Its name comes from
|
|
19
|
+
`--dataset` and defaults to `production`. It does not exist until `blueprints deploy` runs.
|
|
20
|
+
|
|
21
|
+
It does not create an organization. It does not deploy the attached resources, CORS origin, Studio,
|
|
22
|
+
or Function. Those changes happen only if `blueprints deploy` is run later.
|
|
23
|
+
|
|
24
|
+
## Inspect the target directory
|
|
25
|
+
|
|
26
|
+
Pass the directory as an argument, or run the command from the directory that should contain the
|
|
27
|
+
Blueprint. Without an argument an interactive run asks where the files go; an unattended run keeps
|
|
28
|
+
the current directory.
|
|
29
|
+
|
|
30
|
+
Before running:
|
|
31
|
+
|
|
32
|
+
1. Check the working tree and existing files. Do not discard unrelated user changes.
|
|
33
|
+
2. Look for a root `sanity.blueprint.*` file. If one exists, use the existing Blueprint instead of
|
|
34
|
+
initializing again.
|
|
35
|
+
3. Look for a root `sanity.config.*` file. Its presence selects the Studio adoption flow.
|
|
36
|
+
4. Confirm the user asked to initialize this directory. The command writes files and creates a
|
|
37
|
+
remote Stack.
|
|
38
|
+
5. Confirm the user is signed in. If needed, have them run:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npx sanity login
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The account must have at least one organization. A run against an existing project also needs one
|
|
45
|
+
project in the selected organization and one dataset in that project. A run with `--create-project`
|
|
46
|
+
needs neither.
|
|
47
|
+
|
|
48
|
+
Interactive runs show the Blueprint resources, hosted Studio URL, local changes, and remote actions
|
|
49
|
+
before the confirmation prompt. Everything the Blueprint declares stays pending until a later
|
|
50
|
+
deployment.
|
|
51
|
+
|
|
52
|
+
A run that creates a project makes two remote changes rather than one: the project, then the Stack.
|
|
53
|
+
Both happen after the confirmation, so a cancelled run creates nothing. The project is created
|
|
54
|
+
before any file is written, because the generated Studio config needs its ID.
|
|
55
|
+
|
|
56
|
+
## Choose the flow
|
|
57
|
+
|
|
58
|
+
- **Existing Blueprint with a configured Stack:** Exit without changes and use
|
|
59
|
+
`blueprints config --edit` or `blueprints doctor`.
|
|
60
|
+
- **Existing Blueprint without a configured Stack:** Finish setup with `blueprints init`; it can
|
|
61
|
+
connect the existing manifest without rewriting it.
|
|
62
|
+
- **Root Studio config:** Adopt the Studio in place. Read literal `projectId` and `dataset` strings
|
|
63
|
+
from `sanity.config.*`, falling back to `sanity.cli.*`. Do not move the Studio.
|
|
64
|
+
- **Fresh workspace:** Create a Blueprint, an npm-workspace Studio, and a starter `set-slug`
|
|
65
|
+
document function.
|
|
66
|
+
|
|
67
|
+
Do not rewrite a Studio config merely to make adoption work unless the user asks. Dynamic
|
|
68
|
+
`projectId` or `dataset` values built from environment variables or imports cannot be detected.
|
|
69
|
+
|
|
70
|
+
For an existing Blueprint, inspect it with:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npx @sanity/runtime-cli@blueprinit blueprints doctor
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Run unattended
|
|
77
|
+
|
|
78
|
+
When the organization and project IDs are known, run this from the target directory:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npx @sanity/runtime-cli@blueprinit init --yes \
|
|
82
|
+
--organization-id <organization-id> \
|
|
83
|
+
--project-id <project-id> \
|
|
84
|
+
--dataset <dataset-name>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
To create the project instead, replace `--project-id` with `--create-project`:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npx @sanity/runtime-cli@blueprinit init --yes \
|
|
91
|
+
--organization-id <organization-id> \
|
|
92
|
+
--create-project "<project display name>" \
|
|
93
|
+
--dataset <dataset-name>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`--create-project` and `--project-id` cannot both be passed. With `--create-project`, `--dataset`
|
|
97
|
+
names a dataset to create and defaults to `production`.
|
|
98
|
+
|
|
99
|
+
Replace all placeholders with real values. The project must belong to the organization, and the
|
|
100
|
+
dataset must belong to the project. Do not guess any value.
|
|
101
|
+
|
|
102
|
+
`--yes` skips confirmation. Without explicit values, an unattended run stops when the account has
|
|
103
|
+
several organizations, projects, or datasets. Ask the user for the missing value or have them run
|
|
104
|
+
the command interactively.
|
|
105
|
+
|
|
106
|
+
Use `--stack-name <name>` and `--studio-name <name>` when those generated names need to be stable.
|
|
107
|
+
The command normalizes both names to lowercase kebab case.
|
|
108
|
+
|
|
109
|
+
The Stack name defaults to `<project>-<dataset>` and is also the hosted Studio slug, so it must be
|
|
110
|
+
available across every Sanity organization. No API reports whether a slug is free, so a taken one
|
|
111
|
+
fails during `blueprints deploy`.
|
|
112
|
+
|
|
113
|
+
The Studio name is a Blueprint-local resource name and its directory under `studios/`. It defaults
|
|
114
|
+
to `studio`. Every other generated name carries its resource type, so the defaults cannot collide.
|
|
115
|
+
A dataset named `studio`, or `--studio-name production` against a `production` dataset, does
|
|
116
|
+
collide; the command names the repeated value and writes nothing.
|
|
117
|
+
|
|
118
|
+
When `SANITY_INTERNAL_ENV=staging`, the generated Studio URL and CORS origin use
|
|
119
|
+
`https://<stack-name>.studio.sanity.work`. Other environments use
|
|
120
|
+
`https://<stack-name>.sanity.studio`.
|
|
121
|
+
|
|
122
|
+
For interactive organization, project, dataset, Stack-name, and confirmation prompts, have the
|
|
123
|
+
user run:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
npx @sanity/runtime-cli@blueprinit init
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
When the project has several datasets, the interactive command prompts for one and lists
|
|
130
|
+
`production` first. Report the selected dataset from the command output.
|
|
131
|
+
|
|
132
|
+
## Review the result
|
|
133
|
+
|
|
134
|
+
A successful fresh run creates or updates:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
.
|
|
138
|
+
├── .sanity/blueprint.config.json
|
|
139
|
+
├── sanity.blueprint.ts
|
|
140
|
+
├── package.json
|
|
141
|
+
├── functions/
|
|
142
|
+
│ └── set-slug/
|
|
143
|
+
└── studios/
|
|
144
|
+
└── studio/
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The command also creates or updates `.gitignore`. It preserves existing package metadata and adds
|
|
148
|
+
the required npm workspaces and `@sanity/blueprints` dependency.
|
|
149
|
+
|
|
150
|
+
The generated Studio matches `sanity init`: the same `sanity`, `@sanity/vision`, `react`,
|
|
151
|
+
`react-dom`, `styled-components`, `@types/react`, and `typescript` versions, the same
|
|
152
|
+
`tsconfig.json`, and `visionTool()` beside `structureTool()`. `sanity` and `@sanity/vision` are
|
|
153
|
+
resolved from the registry at scaffold time, so no version is written into this repository.
|
|
154
|
+
The Studio has no `deploy` script, because the Blueprint deploys it.
|
|
155
|
+
|
|
156
|
+
An adopted Studio stays at the repository root. The command adds the Blueprint, Blueprint config,
|
|
157
|
+
dependency, and `.gitignore` entry, but does not generate the starter Function.
|
|
158
|
+
|
|
159
|
+
After the command exits:
|
|
160
|
+
|
|
161
|
+
1. Confirm the output names the expected organization, project, and dataset.
|
|
162
|
+
2. Confirm `.sanity/blueprint.config.json` exists. Its presence means Stack creation completed.
|
|
163
|
+
3. Review `sanity.blueprint.ts`, including the Studio slug and credentialed CORS origin, plus
|
|
164
|
+
`package.json`, `.gitignore`, and the working-tree diff.
|
|
165
|
+
4. Report the Stack ID and every created or modified path.
|
|
166
|
+
|
|
167
|
+
Do not deploy as part of initialization unless the user separately asks for deployment. To continue
|
|
168
|
+
after reviewing the scaffold, install dependencies and preview the deployment:
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
npm install
|
|
172
|
+
npx @sanity/runtime-cli@blueprinit blueprints plan
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Treat dependency installation and planning as separate follow-up actions when they were not part of
|
|
176
|
+
the user's request.
|
|
177
|
+
|
|
178
|
+
## Handle failures
|
|
179
|
+
|
|
180
|
+
- **`No Sanity session found.`** Stop and ask the user to run `npx sanity login`. Authentication
|
|
181
|
+
fails before files are written.
|
|
182
|
+
- **Multiple organizations or projects found.** Rerun with the matching `--organization-id` and
|
|
183
|
+
`--project-id`. Selection fails before files are written.
|
|
184
|
+
- **No datasets found.** Ask the user to choose a project with a dataset, or to create a project
|
|
185
|
+
with `--create-project`, which makes the Blueprint create the dataset too.
|
|
186
|
+
- **No projects found in an organization.** In an unattended run, pass `--create-project <name>`.
|
|
187
|
+
- **Dataset name is not valid.** The projects API allows 2 to 64 characters from `a-z`, `0-9`, `-`,
|
|
188
|
+
and `_`, starting with a letter or a digit. Report the rule and ask for another name. Do not
|
|
189
|
+
rewrite the name the user gave.
|
|
190
|
+
- **Could not create project.** Nothing was written. Report the API message. A quota error needs a
|
|
191
|
+
plan change or another organization.
|
|
192
|
+
- **Could not read `projectId` and `dataset`.** The detected Studio config does not contain both
|
|
193
|
+
values as string literals. Pass explicit `--project-id` and `--dataset` values or report the config
|
|
194
|
+
file and let the user decide whether to change it.
|
|
195
|
+
- **Refusing to overwrite an existing path.** Inspect the reported Studio or Function directory.
|
|
196
|
+
Do not delete or replace it without the user's direction.
|
|
197
|
+
- **Stack quota or duplicate-name error.** Local scaffold files may already exist while
|
|
198
|
+
`.sanity/blueprint.config.json` does not. Resolve the Stack error, then run the recovery command
|
|
199
|
+
printed by `init`, which is `blueprints init`. It connects the existing manifest without rewriting it.
|