@sanity/runtime-cli 12.4.0 → 13.0.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.
Files changed (113) hide show
  1. package/README.md +176 -63
  2. package/dist/actions/blueprints/assets.d.ts +3 -1
  3. package/dist/actions/blueprints/assets.js +8 -4
  4. package/dist/actions/blueprints/blueprint.d.ts +2 -1
  5. package/dist/actions/blueprints/blueprint.js +3 -1
  6. package/dist/actions/blueprints/config.d.ts +5 -2
  7. package/dist/actions/blueprints/config.js +4 -4
  8. package/dist/actions/blueprints/logs-streaming.d.ts +4 -2
  9. package/dist/actions/blueprints/logs-streaming.js +5 -2
  10. package/dist/actions/blueprints/logs.d.ts +2 -1
  11. package/dist/actions/blueprints/logs.js +4 -2
  12. package/dist/actions/blueprints/resources.d.ts +2 -1
  13. package/dist/actions/blueprints/resources.js +2 -2
  14. package/dist/actions/blueprints/stacks.d.ts +12 -6
  15. package/dist/actions/blueprints/stacks.js +18 -11
  16. package/dist/actions/functions/dev.d.ts +2 -1
  17. package/dist/actions/functions/dev.js +2 -2
  18. package/dist/actions/functions/env/list.d.ts +2 -1
  19. package/dist/actions/functions/env/list.js +4 -2
  20. package/dist/actions/functions/env/remove.d.ts +2 -1
  21. package/dist/actions/functions/env/remove.js +4 -2
  22. package/dist/actions/functions/env/update.d.ts +2 -1
  23. package/dist/actions/functions/env/update.js +4 -2
  24. package/dist/actions/functions/logs.d.ts +4 -3
  25. package/dist/actions/functions/logs.js +10 -6
  26. package/dist/actions/node.d.ts +2 -1
  27. package/dist/actions/node.js +2 -2
  28. package/dist/actions/sanity/examples.d.ts +5 -2
  29. package/dist/actions/sanity/examples.js +6 -6
  30. package/dist/actions/sanity/projects.d.ts +7 -3
  31. package/dist/actions/sanity/projects.js +11 -7
  32. package/dist/baseCommands.d.ts +4 -0
  33. package/dist/baseCommands.js +8 -2
  34. package/dist/commands/blueprints/add.d.ts +1 -0
  35. package/dist/commands/blueprints/add.js +12 -8
  36. package/dist/commands/blueprints/config.d.ts +1 -0
  37. package/dist/commands/blueprints/config.js +10 -4
  38. package/dist/commands/blueprints/deploy.d.ts +1 -0
  39. package/dist/commands/blueprints/deploy.js +8 -2
  40. package/dist/commands/blueprints/destroy.d.ts +1 -0
  41. package/dist/commands/blueprints/destroy.js +8 -2
  42. package/dist/commands/blueprints/doctor.d.ts +1 -0
  43. package/dist/commands/blueprints/doctor.js +7 -2
  44. package/dist/commands/blueprints/info.d.ts +1 -0
  45. package/dist/commands/blueprints/info.js +9 -3
  46. package/dist/commands/blueprints/init.d.ts +1 -0
  47. package/dist/commands/blueprints/init.js +20 -11
  48. package/dist/commands/blueprints/logs.d.ts +1 -0
  49. package/dist/commands/blueprints/logs.js +8 -2
  50. package/dist/commands/blueprints/plan.d.ts +1 -0
  51. package/dist/commands/blueprints/plan.js +6 -2
  52. package/dist/commands/blueprints/stacks.d.ts +1 -0
  53. package/dist/commands/blueprints/stacks.js +8 -4
  54. package/dist/commands/functions/add.d.ts +1 -0
  55. package/dist/commands/functions/add.js +8 -2
  56. package/dist/commands/functions/dev.d.ts +1 -0
  57. package/dist/commands/functions/dev.js +14 -3
  58. package/dist/commands/functions/env/add.d.ts +2 -1
  59. package/dist/commands/functions/env/add.js +6 -2
  60. package/dist/commands/functions/env/list.d.ts +2 -1
  61. package/dist/commands/functions/env/list.js +6 -2
  62. package/dist/commands/functions/env/remove.d.ts +2 -1
  63. package/dist/commands/functions/env/remove.js +6 -2
  64. package/dist/commands/functions/logs.d.ts +2 -1
  65. package/dist/commands/functions/logs.js +7 -4
  66. package/dist/commands/functions/test.d.ts +2 -1
  67. package/dist/commands/functions/test.js +6 -2
  68. package/dist/cores/blueprints/config.js +9 -9
  69. package/dist/cores/blueprints/deploy.js +14 -16
  70. package/dist/cores/blueprints/destroy.js +6 -6
  71. package/dist/cores/blueprints/doctor.js +20 -27
  72. package/dist/cores/blueprints/info.js +3 -3
  73. package/dist/cores/blueprints/init.d.ts +3 -3
  74. package/dist/cores/blueprints/init.js +15 -8
  75. package/dist/cores/blueprints/logs.js +6 -7
  76. package/dist/cores/blueprints/plan.js +1 -0
  77. package/dist/cores/blueprints/stacks.js +4 -4
  78. package/dist/cores/functions/add.js +8 -3
  79. package/dist/cores/functions/dev.js +2 -2
  80. package/dist/cores/functions/env/add.js +3 -4
  81. package/dist/cores/functions/env/list.js +3 -4
  82. package/dist/cores/functions/env/remove.js +3 -4
  83. package/dist/cores/functions/index.d.ts +3 -9
  84. package/dist/cores/functions/logs.js +8 -9
  85. package/dist/cores/functions/test.js +7 -8
  86. package/dist/cores/index.d.ts +4 -7
  87. package/dist/cores/index.js +3 -3
  88. package/dist/index.d.ts +18 -2
  89. package/dist/index.js +20 -2
  90. package/dist/server/app.d.ts +2 -1
  91. package/dist/server/app.js +4 -4
  92. package/dist/server/handlers/invoke.d.ts +2 -1
  93. package/dist/server/handlers/invoke.js +2 -2
  94. package/dist/server/static/components/response-panel.js +3 -0
  95. package/dist/server/static/components/rule-panel.js +9 -1
  96. package/dist/utils/display/prompt.d.ts +5 -2
  97. package/dist/utils/display/prompt.js +5 -4
  98. package/dist/utils/functions/fetch-document.d.ts +3 -2
  99. package/dist/utils/functions/fetch-document.js +7 -6
  100. package/dist/utils/index.d.ts +2 -0
  101. package/dist/utils/index.js +2 -0
  102. package/dist/utils/logger.d.ts +13 -0
  103. package/dist/utils/logger.js +61 -0
  104. package/dist/utils/other/github.d.ts +2 -1
  105. package/dist/utils/other/github.js +4 -2
  106. package/dist/utils/other/npmjs.d.ts +2 -1
  107. package/dist/utils/other/npmjs.js +4 -2
  108. package/dist/utils/traced-fetch.d.ts +35 -0
  109. package/dist/utils/traced-fetch.js +238 -0
  110. package/dist/utils/validated-token.d.ts +3 -2
  111. package/dist/utils/validated-token.js +6 -4
  112. package/oclif.manifest.json +175 -38
  113. package/package.json +13 -5
@@ -1,6 +1,7 @@
1
1
  // * https://oclif.io/docs/base_class
2
2
  import { Command, CommandHelp, Flags as OclifFlags } from '@oclif/core';
3
3
  import { initBlueprintConfig, initDeployedBlueprintConfig } from './cores/index.js';
4
+ import { Logger } from './utils/logger.js';
4
5
  const hidden = true;
5
6
  export const baseFlags = {
6
7
  json: OclifFlags.boolean({
@@ -12,6 +13,11 @@ export const baseFlags = {
12
13
  description: 'Path to the directory containing the Blueprint',
13
14
  hidden,
14
15
  }),
16
+ trace: OclifFlags.boolean({
17
+ description: 'Trace output',
18
+ default: false,
19
+ hidden,
20
+ }),
15
21
  verbose: OclifFlags.boolean({
16
22
  description: 'Verbose output',
17
23
  default: false,
@@ -104,7 +110,7 @@ export class LocalBlueprintCommand extends RuntimeCommand {
104
110
  await super.init();
105
111
  const result = await initBlueprintConfig({
106
112
  bin: this.config.bin,
107
- log: (msg) => this.log(msg),
113
+ log: Logger(this.log.bind(this), this.flags),
108
114
  });
109
115
  if (!result.ok) {
110
116
  this.error(result.error);
@@ -139,7 +145,7 @@ export class DeployedStackCommand extends LocalBlueprintCommand {
139
145
  const result = await initDeployedBlueprintConfig({
140
146
  bin: this.config.bin,
141
147
  blueprint: this.blueprint,
142
- log: (msg) => this.log(msg),
148
+ log: Logger(this.log.bind(this), this.flags),
143
149
  token: this.sanityToken,
144
150
  validateToken: false,
145
151
  });
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { LocalBlueprintCommand } from '../../baseCommands.js';
7
7
  export default class AddCommand extends LocalBlueprintCommand<typeof AddCommand> {
8
+ static summary: string;
8
9
  static description: string;
9
10
  static examples: string[];
10
11
  static args: {
@@ -6,13 +6,17 @@
6
6
  import { Args, Flags } from '@oclif/core';
7
7
  import { LocalBlueprintCommand } from '../../baseCommands.js';
8
8
  import { functionAddCore } from '../../cores/functions/index.js';
9
+ import { Logger } from '../../utils/logger.js';
9
10
  // import {warn} from '../../utils/display/presenters.js'
10
11
  export default class AddCommand extends LocalBlueprintCommand {
11
12
  // static state = 'deprecated'
12
13
  // static deprecationOptions = {
13
14
  // message: '`blueprints add` is deprecated. Use `functions add` instead.',
14
15
  // }
15
- static description = 'Add a Resource to a Blueprint';
16
+ static summary = 'Add a function resource to a Blueprint';
17
+ static description = `Scaffolds a new Sanity Function in your Blueprint. Functions are serverless handlers triggered by document events (create, update, delete, publish) or media library events.
18
+
19
+ After adding a function, use 'functions dev' to test locally, then 'blueprints deploy' to publish it.`;
16
20
  static examples = [
17
21
  '<%= config.bin %> <%= command.id %> function',
18
22
  '<%= config.bin %> <%= command.id %> function --helpers',
@@ -22,19 +26,19 @@ export default class AddCommand extends LocalBlueprintCommand {
22
26
  ];
23
27
  static args = {
24
28
  type: Args.string({
25
- description: 'Type of Resource to add (e.g. function)',
29
+ description: 'Type of resource to add (only "function" is supported)',
26
30
  options: ['function'],
27
31
  required: true,
28
32
  }),
29
33
  };
30
34
  static flags = {
31
35
  example: Flags.string({
32
- description: 'Example to use for the Resource',
36
+ description: 'Example to use for the function resource. Discover examples at https://www.sanity.io/exchange/type=recipes/by=sanity',
33
37
  aliases: ['recipe'],
34
38
  exclusive: ['name', 'fn-type', 'language', 'javascript', 'fn-helpers', 'fn-installer'],
35
39
  }),
36
40
  name: Flags.string({
37
- description: 'Name of the Resource to add',
41
+ description: 'Name of the resource to add',
38
42
  char: 'n',
39
43
  }),
40
44
  'fn-type': Flags.string({
@@ -54,7 +58,7 @@ export default class AddCommand extends LocalBlueprintCommand {
54
58
  dependsOn: ['name'],
55
59
  }),
56
60
  language: Flags.string({
57
- description: 'Language of the new Function',
61
+ description: 'Language of the new function',
58
62
  aliases: ['function-language', 'fn-language', 'lang'],
59
63
  options: ['ts', 'js'],
60
64
  default: 'ts',
@@ -65,12 +69,12 @@ export default class AddCommand extends LocalBlueprintCommand {
65
69
  exclusive: ['language'],
66
70
  }),
67
71
  'fn-helpers': Flags.boolean({
68
- description: 'Add helpers to the new Function',
72
+ description: 'Add helpers to the new function',
69
73
  aliases: ['function-helpers', 'helpers'],
70
74
  allowNo: true,
71
75
  }),
72
76
  'fn-installer': Flags.string({
73
- description: 'How to install the @sanity/functions helpers',
77
+ description: 'Which package manager to use when installing the @sanity/functions helpers',
74
78
  aliases: ['function-installer', 'installer'],
75
79
  options: ['skip', 'npm', 'pnpm', 'yarn'],
76
80
  }),
@@ -92,7 +96,7 @@ export default class AddCommand extends LocalBlueprintCommand {
92
96
  // )
93
97
  const { success, error } = await functionAddCore({
94
98
  bin,
95
- log: (msg) => this.log(msg),
99
+ log: Logger(this.log.bind(this), this.flags),
96
100
  blueprint,
97
101
  flags: {
98
102
  example: flags.example,
@@ -1,5 +1,6 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  export default class ConfigCommand extends LocalBlueprintCommand<typeof ConfigCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,8 +1,14 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { blueprintConfigCore } from '../../cores/blueprints/config.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class ConfigCommand extends LocalBlueprintCommand {
5
- static description = 'View or edit Blueprint configuration';
6
+ static summary = 'View or edit the local Blueprint configuration';
7
+ static description = `Manages the local Blueprint configuration, which links your Blueprint to a Sanity project and Stack.
8
+
9
+ Without flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with ID flags to update values directly (useful for scripting and automation).
10
+
11
+ If you need to switch your Blueprint to a different Stack, use --edit --stack-id.`;
6
12
  static examples = [
7
13
  '<%= config.bin %> <%= command.id %>',
8
14
  '<%= config.bin %> <%= command.id %> --edit',
@@ -16,12 +22,12 @@ export default class ConfigCommand extends LocalBlueprintCommand {
16
22
  default: false,
17
23
  }),
18
24
  'project-id': Flags.string({
19
- description: 'Directly set the Project ID in the configuration. Requires --edit flag',
25
+ description: 'Directly set the project ID in the configuration. Requires --edit flag',
20
26
  aliases: ['project', 'projectId'],
21
27
  dependsOn: ['edit'],
22
28
  }),
23
29
  'organization-id': Flags.string({
24
- description: 'Directly set the Organization ID in the configuration. Requires --edit flag',
30
+ description: 'Directly set the organization ID in the configuration. Requires --edit flag',
25
31
  aliases: ['organization', 'organizationId', 'org'],
26
32
  dependsOn: ['edit'],
27
33
  }),
@@ -34,7 +40,7 @@ export default class ConfigCommand extends LocalBlueprintCommand {
34
40
  async run() {
35
41
  const { success, error } = await blueprintConfigCore({
36
42
  bin: this.config.bin,
37
- log: (message) => this.log(message),
43
+ log: Logger(this.log.bind(this), this.flags),
38
44
  blueprint: this.blueprint,
39
45
  token: this.sanityToken,
40
46
  flags: this.flags,
@@ -1,5 +1,6 @@
1
1
  import { DeployedStackCommand } from '../../baseCommands.js';
2
2
  export default class DeployCommand extends DeployedStackCommand<typeof DeployCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,8 +1,14 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { DeployedStackCommand } from '../../baseCommands.js';
3
3
  import { blueprintDeployCore } from '../../cores/blueprints/deploy.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class DeployCommand extends DeployedStackCommand {
5
- static description = 'Deploy a Blueprint';
6
+ static summary = 'Deploy the local Blueprint to the remote Stack';
7
+ static 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.
8
+
9
+ Before deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack status or 'blueprints logs' to monitor activity.
10
+
11
+ Use --no-wait to queue the deployment and return immediately without waiting for completion.`;
6
12
  static examples = [
7
13
  '<%= config.bin %> <%= command.id %>',
8
14
  '<%= config.bin %> <%= command.id %> --no-wait',
@@ -16,7 +22,7 @@ export default class DeployCommand extends DeployedStackCommand {
16
22
  async run() {
17
23
  const { success, error } = await blueprintDeployCore({
18
24
  bin: this.config.bin,
19
- log: (message) => this.log(message),
25
+ log: Logger(this.log.bind(this), this.flags),
20
26
  auth: this.auth,
21
27
  stackId: this.stackId,
22
28
  scopeType: this.scopeType,
@@ -1,5 +1,6 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  export default class DestroyCommand extends LocalBlueprintCommand<typeof DestroyCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,8 +1,14 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { blueprintDestroyCore } from '../../cores/blueprints/destroy.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class DestroyCommand extends LocalBlueprintCommand {
5
- static description = 'Destroy a Blueprint Stack deployment and its resources (will not delete local files)';
6
+ static summary = 'Destroy the remote Stack deployment and its resources (will not delete local files)';
7
+ static description = `Permanently removes the remote Stack and all its provisioned resources. Your local Blueprint files remain untouched, allowing you to redeploy later with 'blueprints init' + 'blueprints deploy'.
8
+
9
+ This is a destructive operation. You will be prompted to confirm unless --force is specified.
10
+
11
+ Use this to clean up test environments or decommission a Stack you no longer need.`;
6
12
  static examples = [
7
13
  '<%= config.bin %> <%= command.id %>',
8
14
  '<%= config.bin %> <%= command.id %> --stack-id <stackId> --project-id <projectId> --force --no-wait',
@@ -37,7 +43,7 @@ export default class DestroyCommand extends LocalBlueprintCommand {
37
43
  async run() {
38
44
  const { success, error } = await blueprintDestroyCore({
39
45
  bin: this.config.bin,
40
- log: (message) => this.log(message),
46
+ log: Logger(this.log.bind(this), this.flags),
41
47
  token: this.sanityToken,
42
48
  blueprint: this.blueprint,
43
49
  flags: this.flags,
@@ -1,5 +1,6 @@
1
1
  import { RuntimeCommand } from '../../baseCommands.js';
2
2
  export default class DoctorCommand extends RuntimeCommand<typeof DoctorCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: never[];
5
6
  static flags: {
@@ -2,8 +2,13 @@ import { Flags } from '@oclif/core';
2
2
  import { baseFlags, RuntimeCommand, unhide } from '../../baseCommands.js';
3
3
  import config from '../../config.js';
4
4
  import { blueprintDoctorCore } from '../../cores/blueprints/doctor.js';
5
+ import { Logger } from '../../utils/logger.js';
5
6
  export default class DoctorCommand extends RuntimeCommand {
6
- static description = 'Diagnose potential issues with Blueprint configuration';
7
+ static summary = 'Diagnose potential issues with local Blueprint and remote Stack configuration';
8
+ static description = `Analyzes your local Blueprint and remote Stack configuration for common issues, such as missing authentication, invalid project references, or misconfigured resources.
9
+
10
+ Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected issues.`;
11
+ // TODO: add "Supports --json for programmatic consumption of diagnostic results." to help text
7
12
  static examples = [];
8
13
  static flags = {
9
14
  path: unhide(baseFlags.path),
@@ -18,7 +23,7 @@ export default class DoctorCommand extends RuntimeCommand {
18
23
  const { token } = config;
19
24
  const result = await blueprintDoctorCore({
20
25
  bin: this.config.bin,
21
- log: (message) => this.log(message),
26
+ log: Logger(this.log.bind(this), this.flags),
22
27
  token,
23
28
  flags: this.flags,
24
29
  });
@@ -1,5 +1,6 @@
1
1
  import { DeployedStackCommand } from '../../baseCommands.js';
2
2
  export default class InfoCommand extends DeployedStackCommand<typeof InfoCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,21 +1,27 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { DeployedStackCommand } from '../../baseCommands.js';
3
3
  import { blueprintInfoCore } from '../../cores/blueprints/info.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class InfoCommand extends DeployedStackCommand {
5
- static description = 'Show information about a Blueprint Stack deployment';
6
+ static summary = "Show information about the local Blueprint's remote Stack deployment";
7
+ static description = `Displays the current state and metadata of your remote Stack deployment, including deployed resources, status, and configuration.
8
+
9
+ Use this command to verify a deployment succeeded, check what resources are live, or confirm which Stack your local Blueprint is connected to.
10
+
11
+ Run 'blueprints stacks' to see all available Stacks in your project or organization.`;
6
12
  static examples = [
7
13
  '<%= config.bin %> <%= command.id %>',
8
14
  '<%= config.bin %> <%= command.id %> --id <stackId>',
9
15
  ];
10
16
  static flags = {
11
17
  id: Flags.string({
12
- description: 'Stack ID to show info for (defaults to current Stack)',
18
+ description: 'Stack ID to show info for (defaults to the current Stack)',
13
19
  }),
14
20
  };
15
21
  async run() {
16
22
  const { success, error } = await blueprintInfoCore({
17
23
  bin: this.config.bin,
18
- log: (message) => this.log(message),
24
+ log: Logger(this.log.bind(this), this.flags),
19
25
  auth: this.auth,
20
26
  stackId: this.stackId,
21
27
  deployedStack: this.deployedStack,
@@ -1,5 +1,6 @@
1
1
  import { RuntimeCommand } from '../../baseCommands.js';
2
2
  export default class InitCommand extends RuntimeCommand<typeof InitCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static args: {
@@ -1,9 +1,17 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { baseFlags, RuntimeCommand, unhide } from '../../baseCommands.js';
3
3
  import { blueprintInitCore } from '../../cores/blueprints/init.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
5
6
  export default class InitCommand extends RuntimeCommand {
6
- static description = 'Initialize a new Blueprint Stack deployment';
7
+ static summary = 'Initialize a local Blueprint and optionally provision a remote Stack deployment';
8
+ static description = `A Blueprint is your local infrastructure-as-code configuration that defines Sanity resources (datasets, functions, etc.). A Stack is the remote deployment target where your Blueprint is applied.
9
+ [NOTE: Currently, accounts are limited to three (3) Stacks per project scope.]
10
+
11
+ This is typically the first command you run in a new project. It creates a local Blueprint manifest file (sanity.blueprint.ts, .js, or .json) and provisions a new remote Stack.
12
+ Additionally, a Blueprint configuration file is created in .sanity/ containing the scope and Stack IDs. This is .gitignored by default.
13
+
14
+ After initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.`;
7
15
  static examples = [
8
16
  '<%= config.bin %> <%= command.id %>',
9
17
  '<%= config.bin %> <%= command.id %> [directory]',
@@ -13,51 +21,52 @@ export default class InitCommand extends RuntimeCommand {
13
21
  ];
14
22
  static args = {
15
23
  dir: Args.string({
16
- description: 'Directory to create the Blueprint in',
24
+ description: 'Directory to create the local Blueprint in',
17
25
  }),
18
26
  };
19
27
  static flags = {
20
28
  dir: Flags.string({
21
- description: 'Directory to create the Blueprint in',
29
+ description: 'Directory to create the local Blueprint in',
22
30
  }),
23
31
  example: Flags.string({
24
- description: 'Example to use for the Blueprint',
32
+ description: 'Example to use for the local Blueprint',
25
33
  aliases: ['recipe'],
26
34
  exclusive: ['blueprint-type', 'stack-id', 'stack-name'], // set automatically
27
35
  }),
28
36
  'blueprint-type': Flags.string({
29
- description: 'Blueprint manifest type to use for the Blueprint',
37
+ description: 'Blueprint manifest type to use for the local Blueprint',
30
38
  options: ['json', 'js', 'ts'],
31
39
  aliases: ['type'],
32
40
  }),
33
41
  'project-id': Flags.string({
34
- description: 'Sanity Project ID to use for the Blueprint',
42
+ description: 'Sanity project ID used to scope local Blueprint and remote Stack',
35
43
  aliases: ['project', 'projectId'],
36
44
  }),
37
45
  'organization-id': Flags.string({
38
- description: 'Sanity Organization ID to use for the Blueprint',
46
+ description: 'Sanity organization ID used to scope local Blueprint and remote Stack',
39
47
  aliases: ['organization', 'organizationId', 'org'],
40
48
  }),
41
49
  'stack-id': Flags.string({
42
- description: 'Existing Stack ID to use for the Blueprint',
50
+ description: 'Existing Stack ID used to scope local Blueprint',
43
51
  aliases: ['stack', 'stackId'],
44
52
  dependsOn: ['project-id'],
45
53
  exclusive: ['stack-name'],
46
54
  }),
47
55
  'stack-name': Flags.string({
48
- description: 'Name to use for a NEW Stack',
56
+ description: 'Name to use for a new Stack provisioned during initialization',
49
57
  aliases: ['name'],
50
58
  exclusive: ['stack-id'],
51
59
  }),
52
60
  verbose: unhide(baseFlags.verbose),
53
61
  };
54
62
  async run() {
55
- const result = await validTokenOrErrorMessage();
63
+ const log = Logger(this.log.bind(this), this.flags);
64
+ const result = await validTokenOrErrorMessage(log);
56
65
  if (!result.ok)
57
66
  this.error(result.error.message);
58
67
  const { success, error } = await blueprintInitCore({
59
68
  bin: this.config.bin,
60
- log: (message) => this.log(message),
69
+ log,
61
70
  token: result.value,
62
71
  args: this.args,
63
72
  flags: this.flags,
@@ -1,5 +1,6 @@
1
1
  import { DeployedStackCommand } from '../../baseCommands.js';
2
2
  export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,8 +1,14 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { DeployedStackCommand } from '../../baseCommands.js';
3
3
  import { blueprintLogsCore } from '../../cores/blueprints/logs.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class LogsCommand extends DeployedStackCommand {
5
- static description = 'Display logs for a Blueprint Stack deployment';
6
+ static summary = "Display logs for the current Blueprint's Stack deployment";
7
+ static description = `Retrieves Stack deployment logs, useful for debugging and monitoring deployment activity.
8
+
9
+ Use --watch (-w) to stream logs in real-time.
10
+
11
+ If you're not seeing expected logs, verify your Stack is deployed with 'blueprints info'.`;
6
12
  static examples = [
7
13
  '<%= config.bin %> <%= command.id %>',
8
14
  '<%= config.bin %> <%= command.id %> --watch',
@@ -17,7 +23,7 @@ export default class LogsCommand extends DeployedStackCommand {
17
23
  async run() {
18
24
  const { success, streaming, error } = await blueprintLogsCore({
19
25
  bin: this.config.bin,
20
- log: (message) => this.log(message),
26
+ log: Logger(this.log.bind(this), this.flags),
21
27
  auth: this.auth,
22
28
  stackId: this.stackId,
23
29
  deployedStack: this.deployedStack,
@@ -1,5 +1,6 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  export default class PlanCommand extends LocalBlueprintCommand<typeof PlanCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  run(): Promise<void>;
@@ -1,12 +1,16 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  import { blueprintPlanCore } from '../../cores/blueprints/plan.js';
3
+ import { Logger } from '../../utils/logger.js';
3
4
  export default class PlanCommand extends LocalBlueprintCommand {
4
- static description = 'Enumerate resources to be deployed - will not modify any resources';
5
+ static summary = 'Enumerate resources to be deployed to the remote Stack - will not modify any resources';
6
+ static description = `Use this command to preview what changes will be applied to your remote Stack before deploying. This is a safe, read-only operation—no resources are created, modified, or deleted.
7
+
8
+ Run 'blueprints plan' after making local changes to your Blueprint manifest to verify the expected diff. When ready, run 'blueprints deploy' to apply changes.`;
5
9
  static examples = ['<%= config.bin %> <%= command.id %>'];
6
10
  async run() {
7
11
  const { success, error } = await blueprintPlanCore({
8
12
  bin: this.config.bin,
9
- log: (message) => this.log(message),
13
+ log: Logger(this.log.bind(this), this.flags),
10
14
  token: this.sanityToken,
11
15
  blueprint: this.blueprint,
12
16
  flags: this.flags,
@@ -1,5 +1,6 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  export default class StacksCommand extends LocalBlueprintCommand<typeof StacksCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,8 +1,12 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { blueprintStacksCore } from '../../cores/blueprints/stacks.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class StacksCommand extends LocalBlueprintCommand {
5
- static description = 'List all Blueprint Stacks';
6
+ static summary = "List all remote Stack deployments (defaults to the current Blueprint's project scope)";
7
+ static description = `Shows all Stacks associated with a project or organization. By default, lists Stacks scoped to the local Blueprint.
8
+
9
+ Use this to discover existing Stacks you can scope a local Blueprint to (using 'blueprints config --edit'), or to audit what's deployed across your project.`;
6
10
  static examples = [
7
11
  '<%= config.bin %> <%= command.id %>',
8
12
  '<%= config.bin %> <%= command.id %> --project-id <projectId>',
@@ -10,12 +14,12 @@ export default class StacksCommand extends LocalBlueprintCommand {
10
14
  ];
11
15
  static flags = {
12
16
  'project-id': Flags.string({
13
- description: 'Project ID to show stacks for',
17
+ description: 'Project ID to show Stack deployments for',
14
18
  aliases: ['projectId', 'project'],
15
19
  exclusive: ['organization-id'],
16
20
  }),
17
21
  'organization-id': Flags.string({
18
- description: 'Organization ID to show stacks for',
22
+ description: 'Organization ID to show Stack deployments for',
19
23
  aliases: ['organizationId', 'organization', 'org'],
20
24
  exclusive: ['project-id'],
21
25
  }),
@@ -23,7 +27,7 @@ export default class StacksCommand extends LocalBlueprintCommand {
23
27
  async run() {
24
28
  const { success, error } = await blueprintStacksCore({
25
29
  bin: this.config.bin,
26
- log: (message) => this.log(message),
30
+ log: Logger(this.log.bind(this), this.flags),
27
31
  token: this.sanityToken,
28
32
  blueprint: this.blueprint,
29
33
  flags: this.flags,
@@ -1,5 +1,6 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  export default class AddCommand extends LocalBlueprintCommand<typeof AddCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,8 +1,14 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { functionAddCore } from '../../cores/functions/index.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class AddCommand extends LocalBlueprintCommand {
5
- static description = 'Add a Function to your Blueprint';
6
+ static summary = 'Add a Function to your Blueprint';
7
+ static description = `Scaffolds a new Function in the functions/ folder and templates a resource for your Blueprint manifest.
8
+
9
+ Functions are serverless handlers triggered by document events (create, update, delete, publish) or media library events.
10
+
11
+ After adding, use 'functions dev' to test locally, then 'blueprints deploy' to publish.`;
6
12
  static examples = [
7
13
  '<%= config.bin %> <%= command.id %>',
8
14
  '<%= config.bin %> <%= command.id %> --helpers',
@@ -63,7 +69,7 @@ export default class AddCommand extends LocalBlueprintCommand {
63
69
  async run() {
64
70
  const { success, error } = await functionAddCore({
65
71
  bin: this.config.bin,
66
- log: (msg) => this.log(msg),
72
+ log: Logger(this.log.bind(this), this.flags),
67
73
  blueprint: this.blueprint,
68
74
  flags: this.flags,
69
75
  });
@@ -1,5 +1,6 @@
1
1
  import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  export default class DevCommand extends LocalBlueprintCommand<typeof DevCommand> {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
@@ -1,9 +1,20 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { functionDevCore } from '../../cores/functions/dev.js';
4
+ import { Logger } from '../../utils/logger.js';
4
5
  export default class DevCommand extends LocalBlueprintCommand {
5
- static description = 'Start the Sanity Function emulator';
6
- static examples = ['<%= config.bin %> <%= command.id %> --host 127.0.0.1 --port 8974'];
6
+ static summary = 'Start the Sanity Function emulator';
7
+ static description = `Runs a local, web-based development server to test your functions before deploying.
8
+
9
+ Open the emulator in your browser to interactively test your functions with the payload editor.
10
+
11
+ Optionally, set the host and port with the --host and --port flags. Function timeout can be configured with the --timeout flag.
12
+
13
+ To invoke a function with the CLI, use 'functions test'.`;
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %> --host 127.0.0.1 --port 8974',
16
+ '<%= config.bin %> <%= command.id %> --timeout 60',
17
+ ];
7
18
  static flags = {
8
19
  host: Flags.string({
9
20
  char: 'h',
@@ -25,7 +36,7 @@ export default class DevCommand extends LocalBlueprintCommand {
25
36
  const { flags } = await this.parse(DevCommand);
26
37
  const { success, error, streaming } = await functionDevCore({
27
38
  bin: this.config.bin,
28
- log: (msg) => this.log(msg),
39
+ log: Logger(this.log.bind(this), this.flags),
29
40
  flags,
30
41
  });
31
42
  if (!success)
@@ -1,11 +1,12 @@
1
1
  import { DeployedStackCommand } from '../../../baseCommands.js';
2
2
  export default class EnvAddCommand extends DeployedStackCommand<typeof EnvAddCommand> {
3
+ static summary: string;
4
+ static description: string;
3
5
  static args: {
4
6
  name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
7
  key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
8
  value: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
9
  };
8
- static description: string;
9
10
  static examples: string[];
10
11
  run(): Promise<void>;
11
12
  }
@@ -1,20 +1,24 @@
1
1
  import { Args } from '@oclif/core';
2
2
  import { DeployedStackCommand } from '../../../baseCommands.js';
3
3
  import { functionEnvAddCore } from '../../../cores/functions/env/add.js';
4
+ import { Logger } from '../../../utils/logger.js';
4
5
  export default class EnvAddCommand extends DeployedStackCommand {
6
+ static summary = 'Add or set an environment variable for a deployed function';
7
+ static description = `Sets an environment variable in a deployed Sanity Function. If the variable already exists, its value is updated.
8
+
9
+ Environment variables are useful for API keys, configuration values, and other secrets that shouldn't be hardcoded. Changes take effect on the next function invocation.`;
5
10
  static args = {
6
11
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
7
12
  key: Args.string({ description: 'The name of the environment variable', required: true }),
8
13
  value: Args.string({ description: 'The value of the environment variable', required: true }),
9
14
  };
10
- static description = 'Add or set the value of an environment variable for a Sanity function';
11
15
  static examples = [
12
16
  '<%= config.bin %> <%= command.id %> MyFunction API_URL https://api.example.com/',
13
17
  ];
14
18
  async run() {
15
19
  const { success, error } = await functionEnvAddCore({
16
20
  bin: this.config.bin,
17
- log: (msg) => this.log(msg),
21
+ log: Logger(this.log.bind(this), this.flags),
18
22
  args: this.args,
19
23
  auth: this.auth,
20
24
  blueprint: this.blueprint,