@sanity/cli 5.0.0-next-major.20251215221718 → 5.0.0-next-major.20251216092850
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/lib/_chunks-cjs/cli.js +90 -26
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +8 -8
package/lib/_chunks-cjs/cli.js
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
42792
|
-
const editorNames = new Intl.ListFormat("en").format(mcpConfigured
|
|
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" })))
|
|
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);
|
|
@@ -42862,8 +42915,8 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
|
|
|
42862
42915
|
if (print(`\u2705 ${chalk2.green.bold("Success!")} Your custom app has been scaffolded.`), isCurrentDir || print(goToProjectDir), print(
|
|
42863
42916
|
`
|
|
42864
42917
|
${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
|
|
42866
|
-
const editorNames = new Intl.ListFormat("en").format(mcpConfigured
|
|
42918
|
+
), 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) {
|
|
42919
|
+
const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
|
|
42867
42920
|
print(
|
|
42868
42921
|
`
|
|
42869
42922
|
Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
|
|
@@ -42873,9 +42926,9 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
|
|
|
42873
42926
|
`), 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
42927
|
} else {
|
|
42875
42928
|
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
|
|
42877
|
-
), mcpConfigured
|
|
42878
|
-
const editorNames = new Intl.ListFormat("en").format(mcpConfigured
|
|
42929
|
+
`Get started by running ${chalk2.cyan(devCommand)} to launch your Studio's development server`
|
|
42930
|
+
), mcpConfigured.length > 0) {
|
|
42931
|
+
const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
|
|
42879
42932
|
print(
|
|
42880
42933
|
`
|
|
42881
42934
|
Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
|
|
@@ -43598,7 +43651,11 @@ ${err.message}`));
|
|
|
43598
43651
|
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
43652
|
print(`Opening ${url}`), await open(url);
|
|
43600
43653
|
}
|
|
43601
|
-
},
|
|
43654
|
+
}, MCPConfigureTrace = telemetry.defineTrace({
|
|
43655
|
+
name: "CLI MCP Configure Completed",
|
|
43656
|
+
version: 1,
|
|
43657
|
+
description: "User completed MCP configuration via CLI"
|
|
43658
|
+
}), helpText$8 = `
|
|
43602
43659
|
Examples
|
|
43603
43660
|
# Configure Sanity MCP server for detected AI editors
|
|
43604
43661
|
sanity mcp configure
|
|
@@ -43609,12 +43666,19 @@ Examples
|
|
|
43609
43666
|
signature: "",
|
|
43610
43667
|
description: "Configure Sanity MCP server for AI editors (Cursor, VS Code, Claude Code)",
|
|
43611
43668
|
async action(args, context) {
|
|
43612
|
-
const { output } = context;
|
|
43669
|
+
const { output, telemetry: telemetry2 } = context, trace = telemetry2.trace(MCPConfigureTrace);
|
|
43613
43670
|
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.")
|
|
43671
|
+
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({
|
|
43672
|
+
detectedEditors: [],
|
|
43673
|
+
configuredEditors: []
|
|
43674
|
+
}), trace.complete();
|
|
43615
43675
|
return;
|
|
43616
43676
|
}
|
|
43617
|
-
await setupMCP(context, { mcp: !0 });
|
|
43677
|
+
const mcpResult = await setupMCP(context, { mcp: !0 });
|
|
43678
|
+
trace.log({
|
|
43679
|
+
detectedEditors: mcpResult.detectedEditors,
|
|
43680
|
+
configuredEditors: mcpResult.configuredEditors
|
|
43681
|
+
}), mcpResult.error && trace.error(mcpResult.error), trace.complete();
|
|
43618
43682
|
}
|
|
43619
43683
|
}, mcpGroup = {
|
|
43620
43684
|
name: "mcp",
|