@sanity/cli 4.22.0-next.26 → 4.22.0-next.28
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 +83 -25
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +7 -7
package/lib/_chunks-cjs/cli.js
CHANGED
|
@@ -42108,22 +42108,56 @@ async function writeMCPConfig(editor2, token2) {
|
|
|
42108
42108
|
}
|
|
42109
42109
|
async function setupMCP(context, options2) {
|
|
42110
42110
|
const { output, prompt: prompt2 } = context;
|
|
42111
|
+
if (options2.mcp === !1)
|
|
42112
|
+
return output.warn("Skipping MCP configuration due to --no-mcp flag"), {
|
|
42113
|
+
detectedEditors: [],
|
|
42114
|
+
configuredEditors: [],
|
|
42115
|
+
skipped: !0
|
|
42116
|
+
};
|
|
42117
|
+
const detected = await detectAvailableEditors(), detectedEditors = detected.map((e) => e.name);
|
|
42118
|
+
if (detected.length === 0)
|
|
42119
|
+
return output.warn("No supported AI editors detected (Cursor, VS Code, Claude Code)"), {
|
|
42120
|
+
detectedEditors,
|
|
42121
|
+
configuredEditors: [],
|
|
42122
|
+
skipped: !0
|
|
42123
|
+
};
|
|
42124
|
+
const editorsWithExisting = await getEditorsWithExistingConfig(detected), selected = await promptForMCPSetup(prompt2, detected, editorsWithExisting);
|
|
42125
|
+
if (!selected || selected.length === 0)
|
|
42126
|
+
return {
|
|
42127
|
+
detectedEditors,
|
|
42128
|
+
configuredEditors: [],
|
|
42129
|
+
skipped: !0
|
|
42130
|
+
};
|
|
42131
|
+
let token2;
|
|
42132
|
+
try {
|
|
42133
|
+
token2 = await createMCPToken(context.apiClient);
|
|
42134
|
+
} catch (error2) {
|
|
42135
|
+
const err = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
42136
|
+
return output.warn(`Could not configure MCP: ${err.message}`), output.warn("You can set up MCP manually later using https://mcp.sanity.io"), {
|
|
42137
|
+
detectedEditors,
|
|
42138
|
+
configuredEditors: [],
|
|
42139
|
+
skipped: !1,
|
|
42140
|
+
error: err
|
|
42141
|
+
};
|
|
42142
|
+
}
|
|
42111
42143
|
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
42144
|
for (const editor2 of selected)
|
|
42122
42145
|
await writeMCPConfig(editor2, token2);
|
|
42123
|
-
return output.success(`MCP configured for ${selected.map((e) => e.name).join(", ")}`), selected;
|
|
42124
42146
|
} catch (error2) {
|
|
42125
|
-
|
|
42147
|
+
const err = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
42148
|
+
return output.warn(`Could not configure MCP: ${err.message}`), output.warn("You can set up MCP manually later using https://mcp.sanity.io"), {
|
|
42149
|
+
detectedEditors,
|
|
42150
|
+
configuredEditors: [],
|
|
42151
|
+
skipped: !1,
|
|
42152
|
+
error: err
|
|
42153
|
+
};
|
|
42126
42154
|
}
|
|
42155
|
+
const configuredEditors = selected.map((e) => e.name);
|
|
42156
|
+
return output.success(`MCP configured for ${configuredEditors.join(", ")}`), {
|
|
42157
|
+
detectedEditors,
|
|
42158
|
+
configuredEditors,
|
|
42159
|
+
skipped: !1
|
|
42160
|
+
};
|
|
42127
42161
|
}
|
|
42128
42162
|
const authorType = `import {UserIcon} from '@sanity/icons'
|
|
42129
42163
|
import {defineArrayMember, defineField, defineType} from 'sanity'
|
|
@@ -42690,7 +42724,7 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
|
42690
42724
|
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
42725
|
}
|
|
42692
42726
|
}
|
|
42693
|
-
let useTypeScript = flagOrDefault("typescript", !0), mcpConfigured =
|
|
42727
|
+
let useTypeScript = flagOrDefault("typescript", !0), mcpConfigured = [];
|
|
42694
42728
|
if (initNext) {
|
|
42695
42729
|
shouldPromptFor("typescript") && (useTypeScript = await promptForTypeScript(prompt2)), trace.log({ step: "useTypeScript", selectedOption: useTypeScript ? "yes" : "no" });
|
|
42696
42730
|
const fileExtension = useTypeScript ? "ts" : "js";
|
|
@@ -42765,7 +42799,13 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
|
42765
42799
|
print(`Failed to add ${nextjsLocalDevOrigin} to CORS origins`, error2);
|
|
42766
42800
|
});
|
|
42767
42801
|
}
|
|
42768
|
-
|
|
42802
|
+
const mcpResult2 = await setupMCP(context, { mcp: cliFlags.mcp });
|
|
42803
|
+
trace.log({
|
|
42804
|
+
step: "mcpSetup",
|
|
42805
|
+
detectedEditors: mcpResult2.detectedEditors,
|
|
42806
|
+
configuredEditors: mcpResult2.configuredEditors,
|
|
42807
|
+
skipped: mcpResult2.skipped
|
|
42808
|
+
}), mcpResult2.error && trace.error(mcpResult2.error), mcpConfigured = mcpResult2.configuredEditors;
|
|
42769
42809
|
const chosen = await resolvePackageManager(workDir);
|
|
42770
42810
|
trace.log({ step: "selectPackageManager", selectedOption: chosen });
|
|
42771
42811
|
const packages = ["@sanity/vision@4", "sanity@4", "@sanity/image-url@1", "styled-components@6"];
|
|
@@ -42788,8 +42828,8 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
|
42788
42828
|
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
42829
|
`
|
|
42790
42830
|
${chalk2.green("Success!")} Your Sanity configuration files has been added to this project`
|
|
42791
|
-
), mcpConfigured
|
|
42792
|
-
const editorNames = new Intl.ListFormat("en").format(mcpConfigured
|
|
42831
|
+
), mcpConfigured.length > 0) {
|
|
42832
|
+
const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
|
|
42793
42833
|
print(
|
|
42794
42834
|
`
|
|
42795
42835
|
Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
|
|
@@ -42827,7 +42867,14 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
|
|
|
42827
42867
|
const template = templates[templateName];
|
|
42828
42868
|
if (!remoteTemplateInfo && !template)
|
|
42829
42869
|
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" })))
|
|
42870
|
+
!remoteTemplateInfo && template && (template.typescriptOnly === !0 ? useTypeScript = !0 : shouldPromptFor("typescript") && (useTypeScript = await promptForTypeScript(prompt2), trace.log({ step: "useTypeScript", selectedOption: useTypeScript ? "yes" : "no" })));
|
|
42871
|
+
const mcpResult = await setupMCP(context, { mcp: cliFlags.mcp });
|
|
42872
|
+
trace.log({
|
|
42873
|
+
step: "mcpSetup",
|
|
42874
|
+
detectedEditors: mcpResult.detectedEditors,
|
|
42875
|
+
configuredEditors: mcpResult.configuredEditors,
|
|
42876
|
+
skipped: mcpResult.skipped
|
|
42877
|
+
}), mcpResult.error && trace.error(mcpResult.error), mcpConfigured = mcpResult.configuredEditors;
|
|
42831
42878
|
let autoUpdates = !0;
|
|
42832
42879
|
typeof cliFlags["auto-updates"] == "boolean" && (autoUpdates = cliFlags["auto-updates"]);
|
|
42833
42880
|
const shouldImport = !unattended && template?.datasetUrl && await promptForDatasetImport(template.importPrompt);
|
|
@@ -42862,8 +42909,8 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
|
|
|
42862
42909
|
if (print(`\u2705 ${chalk2.green.bold("Success!")} Your custom app has been scaffolded.`), isCurrentDir || print(goToProjectDir), print(
|
|
42863
42910
|
`
|
|
42864
42911
|
${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
|
|
42912
|
+
), 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) {
|
|
42913
|
+
const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
|
|
42867
42914
|
print(
|
|
42868
42915
|
`
|
|
42869
42916
|
Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
|
|
@@ -42873,9 +42920,9 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
|
|
|
42873
42920
|
`), 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
42921
|
} else {
|
|
42875
42922
|
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
|
|
42923
|
+
`Get started by running ${chalk2.cyan(devCommand)} to launch your Studio's development server`
|
|
42924
|
+
), mcpConfigured.length > 0) {
|
|
42925
|
+
const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
|
|
42879
42926
|
print(
|
|
42880
42927
|
`
|
|
42881
42928
|
Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
|
|
@@ -43598,7 +43645,11 @@ ${err.message}`));
|
|
|
43598
43645
|
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
43646
|
print(`Opening ${url}`), await open(url);
|
|
43600
43647
|
}
|
|
43601
|
-
},
|
|
43648
|
+
}, MCPConfigureTrace = telemetry.defineTrace({
|
|
43649
|
+
name: "CLI MCP Configure Completed",
|
|
43650
|
+
version: 1,
|
|
43651
|
+
description: "User completed MCP configuration via CLI"
|
|
43652
|
+
}), helpText$8 = `
|
|
43602
43653
|
Examples
|
|
43603
43654
|
# Configure Sanity MCP server for detected AI editors
|
|
43604
43655
|
sanity mcp configure
|
|
@@ -43609,12 +43660,19 @@ Examples
|
|
|
43609
43660
|
signature: "",
|
|
43610
43661
|
description: "Configure Sanity MCP server for AI editors (Cursor, VS Code, Claude Code)",
|
|
43611
43662
|
async action(args, context) {
|
|
43612
|
-
const { output } = context;
|
|
43663
|
+
const { output, telemetry: telemetry2 } = context, trace = telemetry2.trace(MCPConfigureTrace);
|
|
43613
43664
|
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.")
|
|
43665
|
+
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({
|
|
43666
|
+
detectedEditors: [],
|
|
43667
|
+
configuredEditors: []
|
|
43668
|
+
}), trace.complete();
|
|
43615
43669
|
return;
|
|
43616
43670
|
}
|
|
43617
|
-
await setupMCP(context, { mcp: !0 });
|
|
43671
|
+
const mcpResult = await setupMCP(context, { mcp: !0 });
|
|
43672
|
+
trace.log({
|
|
43673
|
+
detectedEditors: mcpResult.detectedEditors,
|
|
43674
|
+
configuredEditors: mcpResult.configuredEditors
|
|
43675
|
+
}), mcpResult.error && trace.error(mcpResult.error), trace.complete();
|
|
43618
43676
|
}
|
|
43619
43677
|
}, mcpGroup = {
|
|
43620
43678
|
name: "mcp",
|