@sanity/runtime-cli 14.8.2 → 14.8.4

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/14.8.2 linux-x64 node-v24.14.1
23
+ @sanity/runtime-cli/14.8.4 linux-x64 node-v24.14.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -101,7 +101,7 @@ EXAMPLES
101
101
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
102
102
  ```
103
103
 
104
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/add.ts)_
104
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/add.ts)_
105
105
 
106
106
  ## `sanity-run blueprints config`
107
107
 
@@ -140,7 +140,7 @@ EXAMPLES
140
140
  $ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
141
141
  ```
142
142
 
143
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/config.ts)_
143
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/config.ts)_
144
144
 
145
145
  ## `sanity-run blueprints deploy`
146
146
 
@@ -179,7 +179,7 @@ EXAMPLES
179
179
  $ sanity-run blueprints deploy --fn-installer npm
180
180
  ```
181
181
 
182
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/deploy.ts)_
182
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/deploy.ts)_
183
183
 
184
184
  ## `sanity-run blueprints destroy`
185
185
 
@@ -215,7 +215,7 @@ EXAMPLES
215
215
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
216
216
  ```
217
217
 
218
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/destroy.ts)_
218
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/destroy.ts)_
219
219
 
220
220
  ## `sanity-run blueprints doctor`
221
221
 
@@ -242,7 +242,7 @@ DESCRIPTION
242
242
  issues.
243
243
  ```
244
244
 
245
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/doctor.ts)_
245
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/doctor.ts)_
246
246
 
247
247
  ## `sanity-run blueprints info`
248
248
 
@@ -274,7 +274,7 @@ EXAMPLES
274
274
  $ sanity-run blueprints info --stack <name-or-id>
275
275
  ```
276
276
 
277
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/info.ts)_
277
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/info.ts)_
278
278
 
279
279
  ## `sanity-run blueprints init [DIR]`
280
280
 
@@ -328,7 +328,7 @@ EXAMPLES
328
328
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
329
329
  ```
330
330
 
331
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/init.ts)_
331
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/init.ts)_
332
332
 
333
333
  ## `sanity-run blueprints logs`
334
334
 
@@ -359,7 +359,7 @@ EXAMPLES
359
359
  $ sanity-run blueprints logs --watch
360
360
  ```
361
361
 
362
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/logs.ts)_
362
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/logs.ts)_
363
363
 
364
364
  ## `sanity-run blueprints plan`
365
365
 
@@ -387,7 +387,7 @@ EXAMPLES
387
387
  $ sanity-run blueprints plan
388
388
  ```
389
389
 
390
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/plan.ts)_
390
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/plan.ts)_
391
391
 
392
392
  ## `sanity-run blueprints stacks`
393
393
 
@@ -419,7 +419,7 @@ EXAMPLES
419
419
  $ sanity-run blueprints stacks --organization-id <organizationId>
420
420
  ```
421
421
 
422
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/stacks.ts)_
422
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/blueprints/stacks.ts)_
423
423
 
424
424
  ## `sanity-run functions add`
425
425
 
@@ -472,7 +472,7 @@ EXAMPLES
472
472
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
473
473
  ```
474
474
 
475
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/add.ts)_
475
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/add.ts)_
476
476
 
477
477
  ## `sanity-run functions dev`
478
478
 
@@ -508,7 +508,7 @@ EXAMPLES
508
508
  $ sanity-run functions dev --timeout 60
509
509
  ```
510
510
 
511
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/dev.ts)_
511
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/dev.ts)_
512
512
 
513
513
  ## `sanity-run functions env add NAME KEY VALUE`
514
514
 
@@ -539,7 +539,7 @@ EXAMPLES
539
539
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
540
540
  ```
541
541
 
542
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/env/add.ts)_
542
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/env/add.ts)_
543
543
 
544
544
  ## `sanity-run functions env list NAME`
545
545
 
@@ -567,7 +567,7 @@ EXAMPLES
567
567
  $ sanity-run functions env list MyFunction
568
568
  ```
569
569
 
570
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/env/list.ts)_
570
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/env/list.ts)_
571
571
 
572
572
  ## `sanity-run functions env remove NAME KEY`
573
573
 
@@ -597,7 +597,7 @@ EXAMPLES
597
597
  $ sanity-run functions env remove MyFunction API_URL
598
598
  ```
599
599
 
600
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/env/remove.ts)_
600
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/env/remove.ts)_
601
601
 
602
602
  ## `sanity-run functions logs [NAME]`
603
603
 
@@ -639,7 +639,7 @@ EXAMPLES
639
639
  $ sanity-run functions logs <name> --delete
640
640
  ```
641
641
 
642
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/logs.ts)_
642
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/logs.ts)_
643
643
 
644
644
  ## `sanity-run functions test [NAME]`
645
645
 
@@ -697,7 +697,7 @@ EXAMPLES
697
697
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
698
698
  ```
699
699
 
700
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/test.ts)_
700
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.4/src/commands/functions/test.ts)_
701
701
 
702
702
  ## `sanity-run help [COMMAND]`
703
703
 
@@ -35,8 +35,11 @@ export async function blueprintDeployCore(options) {
35
35
  log('Processing assets...');
36
36
  for (const resource of preDeployResources) {
37
37
  const preDeployResult = await preDeploy(resource, { auth, installer, log });
38
- if (preDeployResult.success === false) {
38
+ if (!preDeployResult.success)
39
39
  return preDeployResult;
40
+ const idx = validResources.indexOf(resource);
41
+ if (idx !== -1) {
42
+ validResources[idx] = preDeployResult.resource;
40
43
  }
41
44
  }
42
45
  }
@@ -152,9 +155,9 @@ async function preDeploy(resource, options) {
152
155
  clearTimeout(assetTimeoutTimer);
153
156
  }
154
157
  if (result.success && result.assetId) {
155
- const resourceWithAsset = { ...resource, src: result.assetId };
156
- fnSpinner.succeed(`${resourceWithAsset.name} ${niceId(result.assetId)}`);
157
- log(` Source: ${resourceWithAsset.src}`);
158
+ const updatedResource = { ...resource, src: result.assetId };
159
+ fnSpinner.succeed(`${updatedResource.name} ${niceId(result.assetId)}`);
160
+ log(` Source: ${updatedResource.src}`);
158
161
  if (result.hash) {
159
162
  if (result.hash.length > 24) {
160
163
  log.verbose(` Hash: ${result.hash.slice(0, 8)}...${result.hash.slice(-12)}`);
@@ -165,11 +168,9 @@ async function preDeploy(resource, options) {
165
168
  }
166
169
  if (result.exists)
167
170
  log.verbose(' Asset unchanged');
171
+ return { success: true, resource: updatedResource };
168
172
  }
169
- else {
170
- const errorMsg = `Failed uploading ${resource.name} asset, deploy has stopped`;
171
- fnSpinner.fail(errorMsg);
172
- return { success: false, error: result.error || 'Failed to process asset' };
173
- }
174
- return { success: true };
173
+ const errorMsg = `Failed uploading ${resource.name} asset, deploy has stopped`;
174
+ fnSpinner.fail(errorMsg);
175
+ return { success: false, error: result.error || 'Failed to process asset' };
175
176
  }
@@ -5,7 +5,7 @@ import ora from 'ora';
5
5
  import { readLocalBlueprint, } from '../../actions/blueprints/blueprint.js';
6
6
  import { getStack } from '../../actions/blueprints/stacks.js';
7
7
  import config, { RUNTIME_CLI_VERSION } from '../../config.js';
8
- import { check, filePathRelativeToCwd, niceId, severe, unsure, } from '../../utils/display/presenters.js';
8
+ import { check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
9
9
  import { styleText } from '../../utils/style-text.js';
10
10
  import { createTracedFetch } from '../../utils/traced-fetch.js';
11
11
  import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
@@ -31,13 +31,6 @@ function sourceLabel(source) {
31
31
  return 'unknown';
32
32
  }
33
33
  }
34
- function renderSection(emit, title, rows) {
35
- const pad = Math.max(...rows.map(([l]) => l.length)) + 3;
36
- emit(styleText('bold', title));
37
- for (const [label, value] of rows) {
38
- emit(` ${styleText('dim', label.padEnd(pad))}${value}`);
39
- }
40
- }
41
34
  export async function blueprintDoctorCore(options) {
42
35
  const { bin, log, token, validateResources, flags: { verbose: v, path: p, fix }, } = options;
43
36
  const path = p || cwd();
@@ -229,16 +222,16 @@ export async function blueprintDoctorCore(options) {
229
222
  // --- RENDER REPORT ---
230
223
  spinner.stop();
231
224
  // Environment (verbose)
232
- renderSection((msg) => log.verbose(msg), 'Environment', envRows);
225
+ log.verbose(renderSection('Environment', envRows));
233
226
  log.verbose('');
234
227
  // Configuration (verbose)
235
228
  if (configRows.length > 0) {
236
- renderSection((msg) => log.verbose(msg), 'Configuration', configRows);
229
+ log.verbose(renderSection('Configuration', configRows));
237
230
  log.verbose('');
238
231
  }
239
232
  // Deployment (verbose)
240
233
  if (stackRows.length > 0) {
241
- renderSection((msg) => log.verbose(msg), 'Deployment', stackRows);
234
+ log.verbose(renderSection('Deployment', stackRows));
242
235
  log.verbose('');
243
236
  }
244
237
  // Checks (always visible)
@@ -3,7 +3,7 @@ import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANI
3
3
  import { styleText } from '../style-text.js';
4
4
  import { isCorsOriginResource, isDatasetResource, isRobotResource, isRoleResource, isWebhookResource, } from '../types.js';
5
5
  import { formatDate, formatDuration } from './dates.js';
6
- import { niceId } from './presenters.js';
6
+ import { capitalize, niceId, renderSection } from './presenters.js';
7
7
  import { arrayifyCors, arrayifyDataset, arrayifyFunction, arrayifyRobot, arrayifyRole, arrayifyWebhook, } from './resources-formatting.js';
8
8
  const functionCategory = {
9
9
  label: 'Functions',
@@ -159,53 +159,45 @@ export function formatResourceTree(resources, verbose = false) {
159
159
  }
160
160
  export function formatStackInfo(stack, isCurrentStack = false) {
161
161
  const isStack = 'id' in stack; // type narrowing
162
- const isProjectBasedStack = isStack && stack.id === `ST-${stack.scopeId}`;
163
- const output = [];
164
- if (isStack) {
165
- let stackName = styleText('bold', `"${stack.name}"`);
166
- if (isCurrentStack)
167
- stackName = `${styleText('blue', stackName)} (current)`;
168
- if (isProjectBasedStack)
169
- stackName += ' (project-based)';
170
- output.push(`${stackName} ${niceId(stack.id)}`);
162
+ if (!isStack) {
163
+ return styleText('bold', 'Local Blueprint');
171
164
  }
172
- else {
173
- output.push('Local Blueprint');
165
+ const isProjectBasedStack = stack.id === `ST-${stack.scopeId}`;
166
+ let title = styleText('bold', `"${stack.name}"`);
167
+ if (isCurrentStack)
168
+ title = `${styleText('blue', title)} (current)`;
169
+ if (isProjectBasedStack)
170
+ title += ' (project-based)';
171
+ title = `${title} ${niceId(stack.id)}`;
172
+ const rows = [];
173
+ if (stack.scopeType && stack.scopeId) {
174
+ rows.push([capitalize(stack.scopeType), niceId(stack.scopeId)]);
174
175
  }
175
- const infoOutput = [];
176
- const resourceCount = 'resourceCount' in stack ? stack.resourceCount : stack.resources?.length;
177
- if (resourceCount != null) {
178
- infoOutput.push(`${resourceCount} resource${resourceCount === 1 ? '' : 's'}`);
176
+ if (stack.defaultProjectId) {
177
+ rows.push(['Default Project', niceId(stack.defaultProjectId)]);
179
178
  }
180
- else {
181
- infoOutput.push('No resources');
179
+ // Show resource count only for StackSummary (no resource tree follows)
180
+ if ('resourceCount' in stack) {
181
+ const count = stack.resourceCount;
182
+ rows.push(['Resources', `${count ?? 0}`]);
182
183
  }
183
- if (isStack) {
184
- if (stack.createdAt)
185
- infoOutput.push(`Created: ${formatDate(stack.createdAt)}`);
186
- if (stack.updatedAt)
187
- infoOutput.push(`Updated: ${formatDate(stack.updatedAt)}`);
188
- if (stack.recentOperation) {
189
- const operation = stack.recentOperation;
190
- const operationOutput = [];
191
- if (operation.id)
192
- operationOutput.push(`Recent Operation ${niceId(operation.id)}:`);
193
- if (operation.status) {
194
- const operationColor = operation.status === 'COMPLETED' ? 'green' : 'red';
195
- const status = operation.status || 'UNKNOWN';
196
- operationOutput.push(`Status: ${styleText(operationColor, status)}`);
197
- }
198
- if (operation.createdAt)
199
- operationOutput.push(`Started: ${formatDate(operation.createdAt)}`);
200
- if (operation.status === 'COMPLETED' && operation.completedAt && operation.createdAt) {
201
- operationOutput.push(`Completed: ${formatDate(operation.completedAt)}`);
202
- operationOutput.push(`Duration: ${styleText('yellow', formatDuration(operation.createdAt, operation.completedAt))}`);
203
- }
204
- infoOutput.push(operationOutput);
184
+ if (stack.createdAt)
185
+ rows.push(['Created', formatDate(stack.createdAt)]);
186
+ if (stack.updatedAt)
187
+ rows.push(['Updated', formatDate(stack.updatedAt)]);
188
+ if (stack.recentOperation) {
189
+ const op = stack.recentOperation;
190
+ const color = op.status === 'COMPLETED' ? 'green' : 'red';
191
+ const parts = [styleText(color, op.status || 'UNKNOWN')];
192
+ const time = op.completedAt || op.createdAt;
193
+ if (time)
194
+ parts.push(styleText('dim', formatDate(time)));
195
+ if (op.completedAt && op.createdAt) {
196
+ parts.push(styleText('yellow', `(${formatDuration(op.createdAt, op.completedAt)})`));
205
197
  }
198
+ rows.push(['Operation', parts.join(' ')]);
206
199
  }
207
- output.push(infoOutput);
208
- return treeify(output, { plain: true });
200
+ return renderSection(title, rows);
209
201
  }
210
202
  export function formatStacksListing(stacks, currentStackId) {
211
203
  if (!stacks || stacks.length === 0)
@@ -8,3 +8,5 @@ export declare function indent(str: string, spaces?: number): string;
8
8
  export declare function capitalize(str: string): string;
9
9
  export declare function filePathRelativeToCwd(filePath: string): string;
10
10
  export declare function labeledId(label: string | undefined, id: string | undefined): string;
11
+ export type Row = [label: string, value: string];
12
+ export declare function renderSection(title: string, rows: Row[]): string;
@@ -36,3 +36,11 @@ export function filePathRelativeToCwd(filePath) {
36
36
  export function labeledId(label, id) {
37
37
  return `${styleText('blue', capitalize(label || 'unknown'))} ${niceId(id || 'unknown')}`;
38
38
  }
39
+ export function renderSection(title, rows) {
40
+ const pad = Math.max(...rows.map(([l]) => l.length)) + 3;
41
+ const lines = [styleText('bold', title)];
42
+ for (const [label, value] of rows) {
43
+ lines.push(` ${styleText('dim', label.padEnd(pad))}${value}`);
44
+ }
45
+ return lines.join('\n');
46
+ }
@@ -2235,5 +2235,5 @@
2235
2235
  ]
2236
2236
  }
2237
2237
  },
2238
- "version": "14.8.2"
2238
+ "version": "14.8.4"
2239
2239
  }
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": "14.8.2",
4
+ "version": "14.8.4",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",