@sanity/cli 4.22.0-next.8 → 4.22.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.
@@ -4009,17 +4009,23 @@ Examples:
4009
4009
  }, helpText$p = `
4010
4010
  Options
4011
4011
  --verbose Provide detailed information about issues
4012
+ --fix Interactively update the Blueprint configuration to fix issues
4012
4013
 
4013
4014
  Examples:
4014
4015
  # Check the health of the current Blueprint project
4015
4016
  sanity blueprints doctor --verbose
4017
+
4018
+ # Fix issues in the current Blueprint project
4019
+ sanity blueprints doctor --fix
4016
4020
  `, defaultFlags$a = {
4021
+ // path: undefined,
4022
+ fix: !1,
4017
4023
  verbose: !1
4018
4024
  }, doctorBlueprintsCommand = {
4019
4025
  name: "doctor",
4020
4026
  group: "blueprints",
4021
4027
  helpText: helpText$p,
4022
- signature: "[--verbose]",
4028
+ signature: "[--verbose] [--fix]",
4023
4029
  description: "Diagnose potential issues with Blueprint configuration",
4024
4030
  async action(args, context) {
4025
4031
  const { apiClient, output } = context, flags = { ...defaultFlags$a, ...args.extOptions }, client2 = apiClient({
@@ -42108,22 +42114,56 @@ async function writeMCPConfig(editor2, token2) {
42108
42114
  }
42109
42115
  async function setupMCP(context, options2) {
42110
42116
  const { output, prompt: prompt2 } = context;
42117
+ if (options2.mcp === !1)
42118
+ return output.warn("Skipping MCP configuration due to --no-mcp flag"), {
42119
+ detectedEditors: [],
42120
+ configuredEditors: [],
42121
+ skipped: !0
42122
+ };
42123
+ const detected = await detectAvailableEditors(), detectedEditors = detected.map((e) => e.name);
42124
+ if (detected.length === 0)
42125
+ return output.warn("No supported AI editors detected (Cursor, VS Code, Claude Code)"), {
42126
+ detectedEditors,
42127
+ configuredEditors: [],
42128
+ skipped: !0
42129
+ };
42130
+ const editorsWithExisting = await getEditorsWithExistingConfig(detected), selected = await promptForMCPSetup(prompt2, detected, editorsWithExisting);
42131
+ if (!selected || selected.length === 0)
42132
+ return {
42133
+ detectedEditors,
42134
+ configuredEditors: [],
42135
+ skipped: !0
42136
+ };
42137
+ let token2;
42138
+ try {
42139
+ token2 = await createMCPToken(context.apiClient);
42140
+ } catch (error2) {
42141
+ const err = error2 instanceof Error ? error2 : new Error(String(error2));
42142
+ return output.warn(`Could not configure MCP: ${err.message}`), output.warn("You can set up MCP manually later using https://mcp.sanity.io"), {
42143
+ detectedEditors,
42144
+ configuredEditors: [],
42145
+ skipped: !1,
42146
+ error: err
42147
+ };
42148
+ }
42111
42149
  try {
42112
- if (options2.mcp === !1)
42113
- return output.warn("Skipping MCP configuration due to --no-mcp flag"), null;
42114
- const detected = await detectAvailableEditors();
42115
- if (detected.length === 0)
42116
- return output.warn("No supported AI editors detected (Cursor, VS Code, Claude Code)"), null;
42117
- const editorsWithExisting = await getEditorsWithExistingConfig(detected), selected = await promptForMCPSetup(prompt2, detected, editorsWithExisting);
42118
- if (!selected || selected.length === 0)
42119
- return null;
42120
- const token2 = await createMCPToken(context.apiClient);
42121
42150
  for (const editor2 of selected)
42122
42151
  await writeMCPConfig(editor2, token2);
42123
- return output.success(`MCP configured for ${selected.map((e) => e.name).join(", ")}`), selected;
42124
42152
  } catch (error2) {
42125
- return output.warn(`Could not configure MCP: ${error2 instanceof Error ? error2.message : `${error2}`}`), output.warn("You can set up MCP manually later using https://mcp.sanity.io"), null;
42153
+ const err = error2 instanceof Error ? error2 : new Error(String(error2));
42154
+ return output.warn(`Could not configure MCP: ${err.message}`), output.warn("You can set up MCP manually later using https://mcp.sanity.io"), {
42155
+ detectedEditors,
42156
+ configuredEditors: [],
42157
+ skipped: !1,
42158
+ error: err
42159
+ };
42126
42160
  }
42161
+ const configuredEditors = selected.map((e) => e.name);
42162
+ return output.success(`MCP configured for ${configuredEditors.join(", ")}`), {
42163
+ detectedEditors,
42164
+ configuredEditors,
42165
+ skipped: !1
42166
+ };
42127
42167
  }
42128
42168
  const authorType = `import {UserIcon} from '@sanity/icons'
42129
42169
  import {defineArrayMember, defineField, defineType} from 'sanity'
@@ -42690,7 +42730,7 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
42690
42730
  semver__default.default.coerce(detectedFramework?.detectedVersion)?.major === 15 && isUsingReact19 && (warn("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E"), warn("\u2502 \u2502"), warn("\u2502 It looks like you are using Next.js 15 and React 19 \u2502"), warn("\u2502 Please read our compatibility guide. \u2502"), warn("\u2502 https://www.sanity.io/help/react-19 \u2502"), warn("\u2502 \u2502"), warn("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"));
42691
42731
  }
42692
42732
  }
42693
- let useTypeScript = flagOrDefault("typescript", !0), mcpConfigured = null;
42733
+ let useTypeScript = flagOrDefault("typescript", !0), mcpConfigured = [];
42694
42734
  if (initNext) {
42695
42735
  shouldPromptFor("typescript") && (useTypeScript = await promptForTypeScript(prompt2)), trace.log({ step: "useTypeScript", selectedOption: useTypeScript ? "yes" : "no" });
42696
42736
  const fileExtension = useTypeScript ? "ts" : "js";
@@ -42765,7 +42805,13 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
42765
42805
  print(`Failed to add ${nextjsLocalDevOrigin} to CORS origins`, error2);
42766
42806
  });
42767
42807
  }
42768
- mcpConfigured = await setupMCP(context, { mcp: cliFlags.mcp });
42808
+ const mcpResult2 = await setupMCP(context, { mcp: cliFlags.mcp });
42809
+ trace.log({
42810
+ step: "mcpSetup",
42811
+ detectedEditors: mcpResult2.detectedEditors,
42812
+ configuredEditors: mcpResult2.configuredEditors,
42813
+ skipped: mcpResult2.skipped
42814
+ }), mcpResult2.error && trace.error(mcpResult2.error), mcpConfigured = mcpResult2.configuredEditors;
42769
42815
  const chosen = await resolvePackageManager(workDir);
42770
42816
  trace.log({ step: "selectPackageManager", selectedOption: chosen });
42771
42817
  const packages = ["@sanity/vision@4", "sanity@4", "@sanity/image-url@1", "styled-components@6"];
@@ -42788,8 +42834,8 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
42788
42834
  if (chosen === "npm" ? await execa("npm", ["install", "--legacy-peer-deps", "next-sanity@11"], execOptions) : chosen === "yarn" ? await execa("npx", ["install-peerdeps", "--yarn", "next-sanity@11"], execOptions) : chosen === "pnpm" && await execa("pnpm", ["install", "next-sanity@11"], execOptions), print(
42789
42835
  `
42790
42836
  ${chalk2.green("Success!")} Your Sanity configuration files has been added to this project`
42791
- ), mcpConfigured && mcpConfigured.length > 0) {
42792
- const editorNames = new Intl.ListFormat("en").format(mcpConfigured.map((e) => e.name));
42837
+ ), mcpConfigured.length > 0) {
42838
+ const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
42793
42839
  print(
42794
42840
  `
42795
42841
  Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
@@ -42827,7 +42873,14 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
42827
42873
  const template = templates[templateName];
42828
42874
  if (!remoteTemplateInfo && !template)
42829
42875
  throw new Error(`Template "${templateName}" not found`);
42830
- !remoteTemplateInfo && template && (template.typescriptOnly === !0 ? useTypeScript = !0 : shouldPromptFor("typescript") && (useTypeScript = await promptForTypeScript(prompt2), trace.log({ step: "useTypeScript", selectedOption: useTypeScript ? "yes" : "no" }))), mcpConfigured = await setupMCP(context, { mcp: cliFlags.mcp });
42876
+ !remoteTemplateInfo && template && (template.typescriptOnly === !0 ? useTypeScript = !0 : shouldPromptFor("typescript") && (useTypeScript = await promptForTypeScript(prompt2), trace.log({ step: "useTypeScript", selectedOption: useTypeScript ? "yes" : "no" })));
42877
+ const mcpResult = await setupMCP(context, { mcp: cliFlags.mcp });
42878
+ trace.log({
42879
+ step: "mcpSetup",
42880
+ detectedEditors: mcpResult.detectedEditors,
42881
+ configuredEditors: mcpResult.configuredEditors,
42882
+ skipped: mcpResult.skipped
42883
+ }), mcpResult.error && trace.error(mcpResult.error), mcpConfigured = mcpResult.configuredEditors;
42831
42884
  let autoUpdates = !0;
42832
42885
  typeof cliFlags["auto-updates"] == "boolean" && (autoUpdates = cliFlags["auto-updates"]);
42833
42886
  const shouldImport = !unattended && template?.datasetUrl && await promptForDatasetImport(template.importPrompt);
@@ -42857,13 +42910,14 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
42857
42910
  pnpm: "pnpm dev",
42858
42911
  bun: "bun dev",
42859
42912
  manual: "npm run dev"
42860
- }[pkgManager], isCurrentDir = outputPath === process.cwd(), goToProjectDir = `(${chalk2.cyan(`cd ${outputPath}`)} to navigate to your new project directory)`;
42913
+ }[pkgManager], isCurrentDir = outputPath === process.cwd(), goToProjectDir = `
42914
+ (${chalk2.cyan(`cd ${outputPath}`)} to navigate to your new project directory)`;
42861
42915
  if (isAppTemplate) {
42862
42916
  if (print(`\u2705 ${chalk2.green.bold("Success!")} Your custom app has been scaffolded.`), isCurrentDir || print(goToProjectDir), print(
42863
42917
  `
42864
42918
  ${chalk2.bold("Next")}, configure the project(s) and dataset(s) your app should work with.`
42865
- ), print("\nGet started in `src/App.tsx`, or refer to our documentation for a walkthrough:"), print(chalk2.blue.underline("https://www.sanity.io/docs/app-sdk/sdk-configuration")), mcpConfigured && mcpConfigured.length > 0) {
42866
- const editorNames = new Intl.ListFormat("en").format(mcpConfigured.map((e) => e.name));
42919
+ ), print("\nGet started in `src/App.tsx`, or refer to our documentation for a walkthrough:"), print(chalk2.blue.underline("https://www.sanity.io/docs/app-sdk/sdk-configuration")), mcpConfigured.length > 0) {
42920
+ const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
42867
42921
  print(
42868
42922
  `
42869
42923
  Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
@@ -42873,13 +42927,18 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
42873
42927
  `), print("Other helpful commands:"), print("npx sanity docs to open the documentation in a browser"), print("npx sanity dev to start the development server for your app"), print("npx sanity deploy to deploy your app");
42874
42928
  } else {
42875
42929
  if (print(`\u2705 ${chalk2.green.bold("Success!")} Your Studio has been created.`), isCurrentDir || print(goToProjectDir), print(
42876
- `Get started by running ${chalk2.cyan(devCommand)} to launch your Studio\u2019s development server`
42877
- ), mcpConfigured && mcpConfigured.length > 0) {
42878
- const editorNames = new Intl.ListFormat("en").format(mcpConfigured.map((e) => e.name));
42930
+ `
42931
+ Get started by running ${chalk2.cyan(devCommand)} to launch your Studio's development server`
42932
+ ), mcpConfigured.length > 0) {
42933
+ const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
42879
42934
  print(
42880
42935
  `
42881
- Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
42882
- ), print(`Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`);
42936
+ To set up your project with the MCP server, restart ${editorNames} and type ${chalk2.cyan('"Get started with Sanity"')} in the chat`
42937
+ ), print(`
42938
+ Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`), print(
42939
+ `
42940
+ Have feedback? Tell us in the community: ${chalk2.cyan("https://www.sanity.io/community/join")}`
42941
+ );
42883
42942
  }
42884
42943
  print(`
42885
42944
  `), print("Other helpful commands:"), print("npx sanity docs to open the documentation in a browser"), print("npx sanity manage to open the project settings in a browser"), print("npx sanity help to explore the CLI manual");
@@ -43598,7 +43657,11 @@ ${err.message}`));
43598
43657
  const { output, cliConfig } = context, { print } = output, projectId = cliConfig?.api?.projectId, url = projectId ? `https://www.sanity.io/manage/project/${projectId}` : "https://www.sanity.io/manage/";
43599
43658
  print(`Opening ${url}`), await open(url);
43600
43659
  }
43601
- }, helpText$8 = `
43660
+ }, MCPConfigureTrace = telemetry.defineTrace({
43661
+ name: "CLI MCP Configure Completed",
43662
+ version: 1,
43663
+ description: "User completed MCP configuration via CLI"
43664
+ }), helpText$8 = `
43602
43665
  Examples
43603
43666
  # Configure Sanity MCP server for detected AI editors
43604
43667
  sanity mcp configure
@@ -43609,12 +43672,19 @@ Examples
43609
43672
  signature: "",
43610
43673
  description: "Configure Sanity MCP server for AI editors (Cursor, VS Code, Claude Code)",
43611
43674
  async action(args, context) {
43612
- const { output } = context;
43675
+ const { output, telemetry: telemetry2 } = context, trace = telemetry2.trace(MCPConfigureTrace);
43613
43676
  if ((await detectAvailableEditors()).length === 0) {
43614
- output.print("No supported AI editors detected (Cursor, VS Code, Claude Code)."), output.print("Visit https://mcp.sanity.io for manual setup instructions.");
43677
+ output.print("No supported AI editors detected (Cursor, VS Code, Claude Code)."), output.print("Visit https://mcp.sanity.io for manual setup instructions."), trace.log({
43678
+ detectedEditors: [],
43679
+ configuredEditors: []
43680
+ }), trace.complete();
43615
43681
  return;
43616
43682
  }
43617
- await setupMCP(context, { mcp: !0 });
43683
+ const mcpResult = await setupMCP(context, { mcp: !0 });
43684
+ trace.log({
43685
+ detectedEditors: mcpResult.detectedEditors,
43686
+ configuredEditors: mcpResult.configuredEditors
43687
+ }), mcpResult.error && trace.error(mcpResult.error), trace.complete();
43618
43688
  }
43619
43689
  }, mcpGroup = {
43620
43690
  name: "mcp",