@sanity/runtime-cli 10.3.2 → 10.4.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 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/10.3.2 linux-x64 node-v22.18.0
23
+ @sanity/runtime-cli/10.4.1 linux-x64 node-v22.18.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -53,8 +53,8 @@ Add a Resource to a Blueprint
53
53
  ```
54
54
  USAGE
55
55
  $ sanity-run blueprints add TYPE [--example <value> | -n <value> | --fn-type
56
- document-publish|document-create|document-delete|document-update | --language ts|js | --javascript | --fn-helpers |
57
- --fn-installer skip|npm|pnpm|yarn] [-i | ]
56
+ document-create|document-delete|document-update|document-publish... | --language ts|js | --javascript | --fn-helpers
57
+ | --fn-installer skip|npm|pnpm|yarn] [-i | ]
58
58
 
59
59
  ARGUMENTS
60
60
  TYPE (function) Type of Resource to add (e.g. function)
@@ -66,8 +66,9 @@ FLAGS
66
66
  --[no-]fn-helpers Add helpers to the new Function
67
67
  --fn-installer=<option> How to install the @sanity/functions helpers
68
68
  <options: skip|npm|pnpm|yarn>
69
- --fn-type=<option> Type of new Function
70
- <options: document-publish|document-create|document-delete|document-update>
69
+ --fn-type=<option>... Document change event(s) that should trigger the function; you can specify multiple
70
+ events by specifying this flag multiple times
71
+ <options: document-create|document-delete|document-update|document-publish>
71
72
  --javascript Use JavaScript instead of TypeScript
72
73
  --language=<option> [default: ts] Language of the new Function
73
74
  <options: ts|js>
@@ -82,12 +83,12 @@ EXAMPLES
82
83
 
83
84
  $ sanity-run blueprints add function --name my-function
84
85
 
85
- $ sanity-run blueprints add function --name my-function --fn-type document-publish
86
+ $ sanity-run blueprints add function --name my-function --fn-type document-create
86
87
 
87
- $ sanity-run blueprints add function --name my-function --fn-type document-update --lang js
88
+ $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
88
89
  ```
89
90
 
90
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/add.ts)_
91
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/add.ts)_
91
92
 
92
93
  ## `sanity-run blueprints config`
93
94
 
@@ -118,7 +119,7 @@ EXAMPLES
118
119
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
119
120
  ```
120
121
 
121
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/config.ts)_
122
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/config.ts)_
122
123
 
123
124
  ## `sanity-run blueprints deploy`
124
125
 
@@ -140,7 +141,7 @@ EXAMPLES
140
141
  $ sanity-run blueprints deploy --no-wait
141
142
  ```
142
143
 
143
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/deploy.ts)_
144
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/deploy.ts)_
144
145
 
145
146
  ## `sanity-run blueprints destroy`
146
147
 
@@ -165,7 +166,7 @@ EXAMPLES
165
166
  $ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
166
167
  ```
167
168
 
168
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/destroy.ts)_
169
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/destroy.ts)_
169
170
 
170
171
  ## `sanity-run blueprints info`
171
172
 
@@ -187,7 +188,7 @@ EXAMPLES
187
188
  $ sanity-run blueprints info --stack-id <stackId>
188
189
  ```
189
190
 
190
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/info.ts)_
191
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/info.ts)_
191
192
 
192
193
  ## `sanity-run blueprints init [DIR]`
193
194
 
@@ -225,7 +226,7 @@ EXAMPLES
225
226
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
226
227
  ```
227
228
 
228
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/init.ts)_
229
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/init.ts)_
229
230
 
230
231
  ## `sanity-run blueprints logs`
231
232
 
@@ -247,7 +248,7 @@ EXAMPLES
247
248
  $ sanity-run blueprints logs --watch
248
249
  ```
249
250
 
250
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/logs.ts)_
251
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/logs.ts)_
251
252
 
252
253
  ## `sanity-run blueprints plan`
253
254
 
@@ -264,7 +265,7 @@ EXAMPLES
264
265
  $ sanity-run blueprints plan
265
266
  ```
266
267
 
267
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/plan.ts)_
268
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/plan.ts)_
268
269
 
269
270
  ## `sanity-run blueprints stacks`
270
271
 
@@ -286,7 +287,7 @@ EXAMPLES
286
287
  $ sanity-run blueprints stacks --project-id <projectId>
287
288
  ```
288
289
 
289
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/blueprints/stacks.ts)_
290
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/blueprints/stacks.ts)_
290
291
 
291
292
  ## `sanity-run functions dev`
292
293
 
@@ -306,7 +307,7 @@ EXAMPLES
306
307
  $ sanity-run functions dev --port 8974
307
308
  ```
308
309
 
309
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/functions/dev.ts)_
310
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/functions/dev.ts)_
310
311
 
311
312
  ## `sanity-run functions env add NAME KEY VALUE`
312
313
 
@@ -328,7 +329,7 @@ EXAMPLES
328
329
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
329
330
  ```
330
331
 
331
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/functions/env/add.ts)_
332
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/functions/env/add.ts)_
332
333
 
333
334
  ## `sanity-run functions env list NAME`
334
335
 
@@ -348,7 +349,7 @@ EXAMPLES
348
349
  $ sanity-run functions env list MyFunction
349
350
  ```
350
351
 
351
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/functions/env/list.ts)_
352
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/functions/env/list.ts)_
352
353
 
353
354
  ## `sanity-run functions env remove NAME KEY`
354
355
 
@@ -369,7 +370,7 @@ EXAMPLES
369
370
  $ sanity-run functions env remove MyFunction API_URL
370
371
  ```
371
372
 
372
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/functions/env/remove.ts)_
373
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/functions/env/remove.ts)_
373
374
 
374
375
  ## `sanity-run functions logs NAME`
375
376
 
@@ -403,7 +404,7 @@ EXAMPLES
403
404
  $ sanity-run functions logs <name> --delete
404
405
  ```
405
406
 
406
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/functions/logs.ts)_
407
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/functions/logs.ts)_
407
408
 
408
409
  ## `sanity-run functions test NAME`
409
410
 
@@ -438,7 +439,7 @@ EXAMPLES
438
439
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
439
440
  ```
440
441
 
441
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v10.3.2/src/commands/functions/test.ts)_
442
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v10.4.1/src/commands/functions/test.ts)_
442
443
 
443
444
  ## `sanity-run help [COMMAND]`
444
445
 
@@ -1,7 +1,7 @@
1
1
  import type { FunctionResource } from '../../utils/types.js';
2
2
  interface FunctionResourceOptions {
3
3
  name: string;
4
- type: string;
4
+ type: string[];
5
5
  lang: string;
6
6
  blueprintFilePath?: string;
7
7
  addHelpers?: boolean;
@@ -56,16 +56,16 @@ export async function createFunctionResource(options) {
56
56
  }
57
57
  }
58
58
  // type looks like 'document-publish'
59
- const typeParts = type.split('-');
59
+ const typeParts = type[0].split('-');
60
60
  const typeName = typeParts[0];
61
- const eventOn = typeParts[1];
61
+ const eventsOn = type.map((t) => t.split('-')[1]);
62
62
  // Create resource definition
63
63
  const resourceJson = {
64
64
  name,
65
65
  src: `functions/${name}`,
66
66
  type: `sanity.function.${typeName}`,
67
67
  event: {
68
- on: [eventOn],
68
+ on: eventsOn,
69
69
  },
70
70
  };
71
71
  // Add to blueprint or return for manual addition
@@ -8,7 +8,7 @@ export default class AddCommand extends BlueprintCommand<typeof AddCommand> {
8
8
  static flags: {
9
9
  example: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- 'fn-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'fn-type': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
12
  language: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
13
  javascript: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
14
  'fn-helpers': import("@oclif/core/interfaces").BooleanFlag<boolean>;
@@ -7,8 +7,8 @@ export default class AddCommand extends BlueprintCommand {
7
7
  '<%= config.bin %> <%= command.id %> function',
8
8
  '<%= config.bin %> <%= command.id %> function --helpers',
9
9
  '<%= config.bin %> <%= command.id %> function --name my-function',
10
- '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish',
11
- '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-update --lang js',
10
+ '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-create',
11
+ '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-create --fn-type document-update --lang js',
12
12
  ];
13
13
  static args = {
14
14
  type: Args.string({
@@ -28,9 +28,11 @@ export default class AddCommand extends BlueprintCommand {
28
28
  char: 'n',
29
29
  }),
30
30
  'fn-type': Flags.string({
31
- description: 'Type of new Function',
32
- options: ['document-publish', 'document-create', 'document-delete', 'document-update'],
31
+ description: 'Document change event(s) that should trigger the function; you can specify multiple events by specifying this flag multiple times',
32
+ options: ['document-create', 'document-delete', 'document-update', 'document-publish'],
33
33
  aliases: ['function-type'],
34
+ multiple: true,
35
+ multipleNonGreedy: true,
34
36
  dependsOn: ['name'],
35
37
  }),
36
38
  language: Flags.string({
@@ -8,7 +8,7 @@ export interface BlueprintAddOptions extends CoreConfig {
8
8
  flags: {
9
9
  example?: string;
10
10
  name?: string;
11
- 'fn-type'?: string;
11
+ 'fn-type'?: string | string[];
12
12
  language?: string;
13
13
  javascript?: boolean;
14
14
  'fn-helpers'?: boolean;
@@ -8,11 +8,11 @@ import { createFunctionResource } from '../../actions/blueprints/resources.js';
8
8
  import { verifyExampleExists, writeExample } from '../../actions/sanity/examples.js';
9
9
  import { check, indent, warn } from '../../utils/display/presenters.js';
10
10
  import { validateFunctionName } from '../../utils/validate/resource.js';
11
- const generateFunctionBlueprintResourceTemplate = (fnName, eventName) => `
11
+ const generateFunctionBlueprintResourceTemplate = (fnName, eventNames) => `
12
12
  export default defineBlueprint({
13
13
  resources: [
14
14
  // ...
15
- defineDocumentFunction({name: '${fnName}', event: {on: ['${eventName}']}}), // ← add this line
15
+ defineDocumentFunction({name: '${fnName}', event: {on: [${eventNames.map((e) => `'${e.replace('document-', '')}'`).join(', ')}]}}), // ← add this line
16
16
  ],
17
17
  })
18
18
  `;
@@ -114,9 +114,23 @@ export async function blueprintAddCore(options) {
114
114
  error: `Function "${chalk.bold(fnName)}" already exists.`,
115
115
  };
116
116
  }
117
- const fnType = flagFnType || (await promptForFunctionType());
117
+ let fnTypes;
118
+ if (flagFnType) {
119
+ if (Array.isArray(flagFnType)) {
120
+ fnTypes = flagFnType;
121
+ }
122
+ else {
123
+ fnTypes = [flagFnType];
124
+ }
125
+ }
126
+ else {
127
+ fnTypes = await promptForFunctionType();
128
+ }
118
129
  const fnLang = flagFnLang || (await promptForFunctionLang());
119
- if (!['document-publish', 'document-create', 'document-delete', 'document-update'].includes(fnType)) {
130
+ if (fnTypes.length === 0) {
131
+ throw new Error('At least one function type must be provided.');
132
+ }
133
+ if (!fnTypes.every((evt) => ['document-publish', 'document-create', 'document-delete', 'document-update'].includes(evt))) {
120
134
  throw new Error('Invalid function type. Must be one of: document-publish, document-create, document-delete, document-update');
121
135
  }
122
136
  let addHelpers;
@@ -150,7 +164,7 @@ export async function blueprintAddCore(options) {
150
164
  const { filePath, resourceAdded, resource } = await createFunctionResource({
151
165
  blueprintFilePath,
152
166
  name: fnName,
153
- type: fnType,
167
+ type: fnTypes,
154
168
  lang: fnLang,
155
169
  addHelpers,
156
170
  installCommand,
@@ -163,7 +177,7 @@ export async function blueprintAddCore(options) {
163
177
  case '.ts':
164
178
  case '.js':
165
179
  case '.mjs': {
166
- log(highlight(generateFunctionBlueprintResourceTemplate(fnName, fnType.split('-')[1])));
180
+ log(highlight(generateFunctionBlueprintResourceTemplate(fnName, fnTypes)));
167
181
  break;
168
182
  }
169
183
  default:
@@ -200,16 +214,25 @@ async function promptForFunctionName() {
200
214
  async function promptForFunctionType() {
201
215
  const { functionType } = await inquirer.prompt([
202
216
  {
203
- type: 'list',
217
+ type: 'checkbox',
204
218
  name: 'functionType',
205
- message: 'Choose function type:',
219
+ message: 'Choose document change events to trigger your function:',
206
220
  choices: [
207
- { name: 'Document Publish', value: 'document-publish' },
208
221
  { name: 'Document Create', value: 'document-create' },
209
- { name: 'Document Delete', value: 'document-delete' },
210
222
  { name: 'Document Update', value: 'document-update' },
223
+ { name: 'Document Delete', value: 'document-delete' },
224
+ {
225
+ name: 'Document Publish (Deprecated - use Create + Update instead)',
226
+ value: 'document-publish',
227
+ },
211
228
  ],
212
- default: 'document-publish',
229
+ default: ['document-create', 'document-update'],
230
+ validate(choices) {
231
+ if (choices.length === 0) {
232
+ return 'You must choose at least one function type / document change event';
233
+ }
234
+ return true;
235
+ },
213
236
  },
214
237
  ]);
215
238
  return functionType;
@@ -1174,21 +1174,37 @@ toggle-switch[checked]::part(track) {
1174
1174
  background-color: var(--color-interactive-primary-active-bg);
1175
1175
  }
1176
1176
 
1177
- /* Default sidebar with resize enabled */
1177
+ /* Default sidebar */
1178
1178
  #sidebar {
1179
- resize: horizontal;
1179
+ transition:
1180
+ width 0.3s ease-in-out,
1181
+ min-width 0.3s ease-in-out;
1180
1182
  }
1181
1183
 
1182
1184
  /* Navigation collapse functionality */
1183
1185
  #nav-toggle:checked ~ #sidebar {
1184
1186
  width: 40px !important;
1185
1187
  min-width: 40px !important;
1186
- resize: none;
1188
+ }
1189
+
1190
+ #nav-toggle ~ #sidebar h4,
1191
+ #nav-toggle ~ #sidebar function-list {
1192
+ opacity: 1;
1193
+ transition: opacity 0.3s ease-in 0.1s;
1194
+ pointer-events: auto;
1187
1195
  }
1188
1196
 
1189
1197
  #nav-toggle:checked ~ #sidebar h4,
1190
1198
  #nav-toggle:checked ~ #sidebar function-list {
1191
- display: none;
1199
+ opacity: 0;
1200
+ transition: opacity 0.2s ease-out;
1201
+ pointer-events: none;
1202
+ }
1203
+
1204
+ /* Ensure toggle button stays visible during animations */
1205
+ #sidebar #nav-toggle-label {
1206
+ opacity: 1;
1207
+ pointer-events: auto;
1192
1208
  }
1193
1209
 
1194
1210
  /* Dynamic icons based on state */
@@ -1196,10 +1212,17 @@ toggle-switch[checked]::part(track) {
1196
1212
  content: '‹'; /* Left-pointing angle when expanded (click to collapse) */
1197
1213
  font-size: 16px;
1198
1214
  font-weight: bold;
1215
+ transition: transform 0.2s ease-in-out;
1216
+ display: inline-block;
1199
1217
  }
1200
1218
 
1201
1219
  #nav-toggle:checked ~ #sidebar #nav-toggle-label::before {
1202
- content: '›'; /* Right-pointing angle when collapsed (click to expand) */
1220
+ transform: rotate(180deg);
1221
+ }
1222
+
1223
+ /* Add transitions to body grid layout */
1224
+ body {
1225
+ transition: grid-template-columns 0.3s ease-in-out;
1203
1226
  }
1204
1227
 
1205
1228
  /* Adjust body grid when nav is collapsed - use :has() selector */
@@ -1208,6 +1231,10 @@ body:has(#nav-toggle:checked) {
1208
1231
  }
1209
1232
 
1210
1233
  @media (min-width: 40em) {
1234
+ body {
1235
+ transition: grid-template 0.3s ease-in-out;
1236
+ }
1237
+
1211
1238
  body:has(#nav-toggle:checked) {
1212
1239
  grid-template:
1213
1240
  'header header' min-content
@@ -17,8 +17,8 @@
17
17
  "<%= config.bin %> <%= command.id %> function",
18
18
  "<%= config.bin %> <%= command.id %> function --helpers",
19
19
  "<%= config.bin %> <%= command.id %> function --name my-function",
20
- "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish",
21
- "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-update --lang js"
20
+ "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-create",
21
+ "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-create --fn-type document-update --lang js"
22
22
  ],
23
23
  "flags": {
24
24
  "example": {
@@ -54,15 +54,15 @@
54
54
  "dependsOn": [
55
55
  "name"
56
56
  ],
57
- "description": "Type of new Function",
57
+ "description": "Document change event(s) that should trigger the function; you can specify multiple events by specifying this flag multiple times",
58
58
  "name": "fn-type",
59
59
  "hasDynamicHelp": false,
60
- "multiple": false,
60
+ "multiple": true,
61
61
  "options": [
62
- "document-publish",
63
62
  "document-create",
64
63
  "document-delete",
65
- "document-update"
64
+ "document-update",
65
+ "document-publish"
66
66
  ],
67
67
  "type": "option"
68
68
  },
@@ -907,5 +907,5 @@
907
907
  ]
908
908
  }
909
909
  },
910
- "version": "10.3.2"
910
+ "version": "10.4.1"
911
911
  }
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": "10.3.2",
4
+ "version": "10.4.1",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",