@sanity/runtime-cli 14.8.6 → 14.10.0

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 (43) hide show
  1. package/README.md +43 -35
  2. package/dist/baseCommands.d.ts +21 -8
  3. package/dist/baseCommands.js +54 -15
  4. package/dist/commands/blueprints/add.js +3 -3
  5. package/dist/commands/blueprints/config.js +4 -4
  6. package/dist/commands/blueprints/deploy.d.ts +1 -0
  7. package/dist/commands/blueprints/deploy.js +10 -5
  8. package/dist/commands/blueprints/destroy.js +5 -5
  9. package/dist/commands/blueprints/doctor.d.ts +1 -1
  10. package/dist/commands/blueprints/doctor.js +7 -5
  11. package/dist/commands/blueprints/info.js +5 -5
  12. package/dist/commands/blueprints/init.js +4 -4
  13. package/dist/commands/blueprints/logs.js +6 -6
  14. package/dist/commands/blueprints/plan.js +5 -5
  15. package/dist/commands/blueprints/promote.js +8 -6
  16. package/dist/commands/blueprints/stacks.js +5 -5
  17. package/dist/commands/functions/add.js +3 -3
  18. package/dist/commands/functions/build.js +4 -4
  19. package/dist/commands/functions/dev.js +5 -5
  20. package/dist/commands/functions/env/add.js +4 -4
  21. package/dist/commands/functions/env/list.js +4 -4
  22. package/dist/commands/functions/env/remove.js +4 -4
  23. package/dist/commands/functions/logs.js +4 -4
  24. package/dist/commands/functions/test.js +4 -4
  25. package/dist/constants.d.ts +1 -0
  26. package/dist/constants.js +2 -0
  27. package/dist/cores/blueprints/config.js +0 -1
  28. package/dist/cores/blueprints/deploy.d.ts +1 -0
  29. package/dist/cores/blueprints/deploy.js +30 -4
  30. package/dist/cores/blueprints/destroy.js +18 -3
  31. package/dist/cores/blueprints/doctor.js +11 -2
  32. package/dist/cores/blueprints/plan.js +18 -10
  33. package/dist/cores/blueprints/promote.js +11 -3
  34. package/dist/cores/blueprints/stacks.js +14 -3
  35. package/dist/cores/functions/test.js +7 -1
  36. package/dist/cores/index.d.ts +6 -0
  37. package/dist/cores/index.js +0 -3
  38. package/dist/utils/display/blueprints-formatting.js +4 -1
  39. package/dist/utils/display/resources-formatting.js +8 -3
  40. package/dist/utils/invoke-local.js +1 -1
  41. package/dist/utils/types.d.ts +5 -2
  42. package/oclif.manifest.json +22 -10
  43. package/package.json +1 -1
@@ -142,9 +142,15 @@ export async function functionTestCore(options) {
142
142
  });
143
143
  if (error) {
144
144
  spinner.fail('Function execution failed.');
145
+ const errorMessage = error.stack || error.message || error.name;
146
+ const isTimeout = error.message?.includes('Timeout');
145
147
  return {
146
148
  success: false,
147
- error: error.stack || error.message || error.name,
149
+ error: errorMessage,
150
+ ref: isTimeout ? 'https://www.sanity.io/docs/help/functions-timeout' : undefined,
151
+ suggestions: isTimeout
152
+ ? ['Increase the timeout in your Blueprint function configuration.']
153
+ : undefined,
148
154
  };
149
155
  }
150
156
  spinner.succeed('Function execution succeeded.');
@@ -35,6 +35,12 @@ export type CoreResult = {
35
35
  success: false;
36
36
  /** The error message, if the operation failed. */
37
37
  error: string;
38
+ /** Actionable suggestions displayed to the user via oclif's PrettyPrintableError. */
39
+ suggestions?: string[];
40
+ /** A URL for more information about the error. */
41
+ ref?: string;
42
+ /** A machine-readable error code. */
43
+ code?: string;
38
44
  streaming?: never;
39
45
  json?: never;
40
46
  } | {
@@ -42,7 +42,6 @@ export async function initDeployedBlueprintConfig(config) {
42
42
  }
43
43
  const { scopeType, scopeId, stackId: blueprintStackId } = config.blueprint;
44
44
  if (!scopeType || !scopeId) {
45
- config.log(`Incomplete configuration. Run \`${config.bin} blueprints doctor\` for diagnostics.`);
46
45
  return { ok: false, error: 'Missing scope configuration for Blueprint' };
47
46
  }
48
47
  const auth = { token: config.token, scopeType, scopeId };
@@ -51,14 +50,12 @@ export async function initDeployedBlueprintConfig(config) {
51
50
  stackId = await resolveStackIdByNameOrId(config.stackOverride, auth, config.log);
52
51
  }
53
52
  if (!stackId) {
54
- config.log(`Incomplete configuration. Run \`${config.bin} blueprints doctor\` for diagnostics.`);
55
53
  return { ok: false, error: 'Missing Stack deployment configuration for Blueprint' };
56
54
  }
57
55
  const spinner = config.log.ora('Loading Stack deployment...').start();
58
56
  const stackResponse = await getStack({ stackId, auth, logger: config.log });
59
57
  if (!stackResponse.ok) {
60
58
  spinner.fail('Could not load Stack deployment');
61
- config.log(`Run \`${config.bin} blueprints doctor\` for diagnostics.`);
62
59
  return { ok: false, error: 'Missing Stack deployment' };
63
60
  }
64
61
  spinner.stop().clear();
@@ -1,5 +1,5 @@
1
1
  import { treeify } from 'array-treeify';
2
- import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
2
+ import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
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';
@@ -28,6 +28,7 @@ const RESOURCE_CATEGORIES = {
28
28
  [SANITY_FUNCTION_DOCUMENT]: functionCategory,
29
29
  [SANITY_FUNCTION_MEDIA_LIBRARY_ASSET]: functionCategory,
30
30
  [SANITY_FUNCTION_SCHEDULED]: functionCategory,
31
+ [SANITY_FUNCTION_SYNC_TAG_INVALIDATE]: functionCategory,
31
32
  [SANITY_PROJECT]: {
32
33
  label: 'Projects',
33
34
  displayNameAttribute: 'displayName',
@@ -196,6 +197,8 @@ export function formatStackInfo(stack, isCurrentStack = false) {
196
197
  parts.push(styleText('yellow', `(${formatDuration(op.createdAt, op.completedAt)})`));
197
198
  }
198
199
  rows.push(['Operation', parts.join(' ')]);
200
+ if (op.userMessage)
201
+ rows.push([' Message', `"${op.userMessage}"`]);
199
202
  }
200
203
  return renderSection(title, rows);
201
204
  }
@@ -19,15 +19,20 @@ function arrayifyEvent(event) {
19
19
  }
20
20
  }
21
21
  else {
22
- if (event.on) {
22
+ if ('on' in event && event.on) {
23
23
  details.push(formatLabeledValue('on', event.on.map((o) => `"${o}"`).join(', ')));
24
24
  }
25
- if (event.filter) {
25
+ if ('filter' in event && event.filter) {
26
26
  details.push(formatLabeledValue('filter', event.filter));
27
27
  }
28
- if (event.projection) {
28
+ if ('projection' in event && event.projection) {
29
29
  details.push(formatLabeledValue('projection', event.projection));
30
30
  }
31
+ // TODO: expose event.resource details once we are ready
32
+ // https://linear.app/sanity/issue/RUN-1246/cli-should-show-eventresource-details-in-blueprints-infoplans
33
+ // if (event.resource) {
34
+ // details.push(formatLabeledValue('resource', JSON.stringify(event.resource)))
35
+ // }
31
36
  }
32
37
  return details;
33
38
  }
@@ -150,7 +150,7 @@ export default async function invoke(resource, payload, context, options) {
150
150
  });
151
151
  timer = setTimeout(() => {
152
152
  shutdown();
153
- reject(new Error(`Timeout: The process exceeded your current timeout limit of ${timeout} seconds. Learn to adjust your Blueprint's timeout settings here: https://www.sanity.io/docs/help/functions-timeout`));
153
+ reject(new Error(`Timeout: Function exceeded the ${timeout}-second time limit.`));
154
154
  }, timeout * 1000);
155
155
  const payload = {
156
156
  data: { ...filteredData },
@@ -1,4 +1,4 @@
1
- import { type BlueprintCorsOriginResource, type BlueprintDatasetResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentWebhookResource, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintProjectResource, type BlueprintResource, type BlueprintRobotResource, type BlueprintRoleResource, type BlueprintScheduledFunctionResource } from '@sanity/blueprints';
1
+ import { type BlueprintCorsOriginResource, type BlueprintDatasetResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentWebhookResource, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintProjectResource, type BlueprintResource, type BlueprintRobotResource, type BlueprintRoleResource, type BlueprintScheduledFunctionResource, type BlueprintSyncTagInvalidateFunctionResource } from '@sanity/blueprints';
2
2
  export type ScopeType = 'organization' | 'project';
3
3
  /** Result utility type */
4
4
  export type Result<T, E = string> = {
@@ -15,7 +15,7 @@ export interface ActionResponse {
15
15
  }
16
16
  /** @internal */
17
17
  export type FunctionGroqResource = BlueprintDocumentFunctionResource | BlueprintMediaLibraryAssetFunctionResource;
18
- export type FunctionResource = FunctionGroqResource | BlueprintScheduledFunctionResource;
18
+ export type FunctionResource = FunctionGroqResource | BlueprintScheduledFunctionResource | BlueprintSyncTagInvalidateFunctionResource;
19
19
  export interface StudioResource extends BlueprintResource {
20
20
  type: 'sanity.studio';
21
21
  src: string;
@@ -72,6 +72,8 @@ export interface StackOperation {
72
72
  status: string;
73
73
  createdAt?: string;
74
74
  completedAt?: string;
75
+ userMessage?: string;
76
+ systemMessage?: string;
75
77
  }
76
78
  /** @internal */
77
79
  export interface StackMutation {
@@ -81,6 +83,7 @@ export interface StackMutation {
81
83
  document: {
82
84
  resources?: BlueprintResource[];
83
85
  };
86
+ userMessage?: string;
84
87
  }
85
88
  /** @internal */
86
89
  export interface BuildPayloadOptions {
@@ -314,9 +314,10 @@
314
314
  "blueprints:deploy": {
315
315
  "aliases": [],
316
316
  "args": {},
317
- "description": "Pushes your local Blueprint configuration to the remote Stack; provisioning, updating, or destroying resources as needed. This is the primary command for applying infrastructure changes.\n\nBefore deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack status or 'blueprints logs' to monitor activity.\n\nUse --no-wait to queue the deployment and return immediately without waiting for completion.\n\nUse --fn-installer to force which package manager to use when deploying functions.\n\nSet SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for processing resource assets.",
317
+ "description": "Applies your local Blueprint to the remote Stack, creating, updating, or removing resources as needed. This is the primary command for applying infrastructure changes.\n\nBefore deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack status or 'blueprints logs' to monitor activity.\n\nUse --no-wait to queue the deployment and return immediately without waiting for completion.\n\nUse --fn-installer to force which package manager to use when deploying functions.\n\nSet SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for processing resource assets.",
318
318
  "examples": [
319
319
  "<%= config.bin %> <%= command.id %>",
320
+ "<%= config.bin %> <%= command.id %> --message \"Enable staging dataset\"",
320
321
  "<%= config.bin %> <%= command.id %> --no-wait",
321
322
  "<%= config.bin %> <%= command.id %> --fn-installer npm"
322
323
  ],
@@ -368,6 +369,14 @@
368
369
  "multiple": false,
369
370
  "type": "option"
370
371
  },
372
+ "message": {
373
+ "char": "m",
374
+ "description": "Message describing the deployment (e.g. reason for change)",
375
+ "name": "message",
376
+ "hasDynamicHelp": false,
377
+ "multiple": false,
378
+ "type": "option"
379
+ },
371
380
  "fn-installer": {
372
381
  "aliases": [
373
382
  "function-installer",
@@ -536,7 +545,7 @@
536
545
  "pluginName": "@sanity/runtime-cli",
537
546
  "pluginType": "core",
538
547
  "strict": true,
539
- "summary": "Destroy the remote Stack deployment and its resources (will not delete local files)",
548
+ "summary": "Destroy a remote Stack deployment and its resources",
540
549
  "enableJsonFlag": true,
541
550
  "isESM": true,
542
551
  "relativePath": [
@@ -550,7 +559,10 @@
550
559
  "aliases": [],
551
560
  "args": {},
552
561
  "description": "Analyzes your local Blueprint and remote Stack configuration for common issues, such as missing authentication, invalid project references, or misconfigured resources.\n\nRun this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected issues.",
553
- "examples": [],
562
+ "examples": [
563
+ "<%= config.bin %> <%= command.id %>",
564
+ "<%= config.bin %> <%= command.id %> --fix"
565
+ ],
554
566
  "flags": {
555
567
  "json": {
556
568
  "description": "Format output as json",
@@ -681,7 +693,7 @@
681
693
  "pluginName": "@sanity/runtime-cli",
682
694
  "pluginType": "core",
683
695
  "strict": true,
684
- "summary": "Show information about the local Blueprint's remote Stack deployment",
696
+ "summary": "Display the status and resources of the remote Stack deployment",
685
697
  "enableJsonFlag": true,
686
698
  "isESM": true,
687
699
  "relativePath": [
@@ -841,7 +853,7 @@
841
853
  "pluginName": "@sanity/runtime-cli",
842
854
  "pluginType": "core",
843
855
  "strict": true,
844
- "summary": "Initialize a local Blueprint and optionally provision a remote Stack deployment",
856
+ "summary": "Initialize a Blueprint and create a remote Stack",
845
857
  "enableJsonFlag": true,
846
858
  "isESM": true,
847
859
  "relativePath": [
@@ -998,7 +1010,7 @@
998
1010
  "pluginName": "@sanity/runtime-cli",
999
1011
  "pluginType": "core",
1000
1012
  "strict": true,
1001
- "summary": "Enumerate resources to be deployed to the remote Stack - will not modify any resources",
1013
+ "summary": "Preview changes that will be applied to the remote Stack",
1002
1014
  "enableJsonFlag": true,
1003
1015
  "isESM": true,
1004
1016
  "relativePath": [
@@ -1011,7 +1023,7 @@
1011
1023
  "blueprints:promote": {
1012
1024
  "aliases": [],
1013
1025
  "args": {},
1014
- "description": "EXPERIMENTAL! Promotes a Stack, changing its scope from project to organization. This is a one-way trip.",
1026
+ "description": "Promotes a deployed Stack to organization scope, enabling management of org-level resources. Promotion cannot be reversed.\n\nYour local Blueprint configuration will be updated to reflect the new scope.",
1015
1027
  "examples": [
1016
1028
  "<%= config.bin %> <%= command.id %>",
1017
1029
  "<%= config.bin %> <%= command.id %> --stack <name-or-id>"
@@ -1081,7 +1093,7 @@
1081
1093
  "pluginName": "@sanity/runtime-cli",
1082
1094
  "pluginType": "core",
1083
1095
  "strict": true,
1084
- "summary": "Promote a Stack deployment to a broader scope",
1096
+ "summary": "Promote a Stack from project scope to organization scope",
1085
1097
  "enableJsonFlag": true,
1086
1098
  "isESM": true,
1087
1099
  "relativePath": [
@@ -1177,7 +1189,7 @@
1177
1189
  "pluginName": "@sanity/runtime-cli",
1178
1190
  "pluginType": "core",
1179
1191
  "strict": true,
1180
- "summary": "List all remote Stack deployments (defaults to the current Blueprint's project scope)",
1192
+ "summary": "List remote Stack deployments for your project or organization",
1181
1193
  "enableJsonFlag": true,
1182
1194
  "isESM": true,
1183
1195
  "relativePath": [
@@ -2235,5 +2247,5 @@
2235
2247
  ]
2236
2248
  }
2237
2249
  },
2238
- "version": "14.8.6"
2250
+ "version": "14.10.0"
2239
2251
  }
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.6",
4
+ "version": "14.10.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",