@sanity/cli 5.3.0-next.5 → 5.3.0-next.50

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.
@@ -19588,7 +19588,30 @@ const cliPackageManager = {
19588
19588
  getInstallCommand,
19589
19589
  getPackageManagerChoice,
19590
19590
  installNewPackages
19591
- };
19591
+ }, DEFAULT_MESSAGE = 'To set up your project with the MCP server, restart {{editorNames}} and type **"Get started with Sanity"** in the chat.';
19592
+ function applyCyanFormatting(text, chalk2) {
19593
+ return text.replace(/\*\*([^*]+)\*\*/g, (_, content) => chalk2.cyan(content));
19594
+ }
19595
+ function interpolateTemplate(template, editorNames) {
19596
+ return template.replace(/\{\{editorNames\}\}/g, editorNames);
19597
+ }
19598
+ async function fetchPostInitPrompt({
19599
+ client: client2,
19600
+ editorNames,
19601
+ chalk: chalk2
19602
+ }) {
19603
+ try {
19604
+ const template = (await client2.request({
19605
+ method: "GET",
19606
+ uri: "/journey/mcp/post-init-prompt",
19607
+ timeout: 1e3
19608
+ }))?.message || DEFAULT_MESSAGE, interpolated = interpolateTemplate(template, editorNames);
19609
+ return applyCyanFormatting(interpolated, chalk2);
19610
+ } catch {
19611
+ const interpolated = interpolateTemplate(DEFAULT_MESSAGE, editorNames);
19612
+ return applyCyanFormatting(interpolated, chalk2);
19613
+ }
19614
+ }
19592
19615
  var ini = {}, hasRequiredIni;
19593
19616
  function requireIni() {
19594
19617
  if (hasRequiredIni) return ini;
@@ -23447,7 +23470,7 @@ function isGithubRepoShorthand(value) {
23447
23470
  return URL.canParse(value) ? !1 : /^[\w-]+\/[\w-.]+(\/[@\w-.]+)*$/.test(value);
23448
23471
  }
23449
23472
  function isGithubRepoUrl(value) {
23450
- if (URL.canParse(value) === !1)
23473
+ if (!URL.canParse(value))
23451
23474
  return !1;
23452
23475
  const url = new URL(value), pathSegments = url.pathname.slice(1).split("/");
23453
23476
  return url.protocol === "https:" && url.hostname === "github.com" && // The pathname must have at least 2 segments. If it has more than 2, the
@@ -34206,7 +34229,7 @@ export default defineCliConfig({
34206
34229
  deployment: {
34207
34230
  /**
34208
34231
  * Enable auto-updates for studios.
34209
- * Learn more at https://www.sanity.io/docs/cli#auto-updates
34232
+ * Learn more at https://www.sanity.io/docs/studio/latest-version-of-sanity#k47faf43faf56
34210
34233
  */
34211
34234
  autoUpdates: __BOOL__autoUpdates__,
34212
34235
  }
@@ -39625,7 +39648,7 @@ async function bootstrapRemoteTemplate(opts, context) {
39625
39648
  fs: new distExports.LocalFileSystemDetector(packagePath),
39626
39649
  frameworkList: frameworksExports.frameworks
39627
39650
  }), port = getDefaultPortForFramework(packageFramework?.slug);
39628
- corsAdded.includes(port) === !1 && (getCliConfig.debug("Setting CORS origin to http://localhost:%d", port), await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient), corsAdded.push(port)), getCliConfig.debug("Applying environment variables to %s", pkg);
39651
+ corsAdded.includes(port) && (getCliConfig.debug("Setting CORS origin to http://localhost:%d", port), await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient), corsAdded.push(port)), getCliConfig.debug("Applying environment variables to %s", pkg);
39629
39652
  const envName = packageFramework?.slug === "nextjs" ? ".env.local" : ".env";
39630
39653
  await applyEnvVariables(packagePath, { ...variables, readToken, writeToken }, envName);
39631
39654
  }
@@ -40597,12 +40620,14 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
40597
40620
  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(
40598
40621
  `
40599
40622
  ${chalk2.green("Success!")} Your Sanity configuration files has been added to this project`
40600
- ), mcpConfigured.length > 0) {
40601
- const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
40602
- print(
40623
+ ), mcpConfigured && mcpConfigured.length > 0) {
40624
+ const message = await getPostInitMCPPrompt(mcpConfigured);
40625
+ print(`
40626
+ ${message}`), print(`
40627
+ Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`), print(
40603
40628
  `
40604
- Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
40605
- ), print(`Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`);
40629
+ Have feedback? Tell us in the community: ${chalk2.cyan("https://www.sanity.io/community/join")}`
40630
+ );
40606
40631
  }
40607
40632
  return;
40608
40633
  }
@@ -40679,12 +40704,14 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
40679
40704
  if (print(`\u2705 ${chalk2.green.bold("Success!")} Your custom app has been scaffolded.`), isCurrentDir || print(goToProjectDir), print(
40680
40705
  `
40681
40706
  ${chalk2.bold("Next")}, configure the project(s) and dataset(s) your app should work with.`
40682
- ), 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) {
40683
- const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
40684
- print(
40707
+ ), 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) {
40708
+ const message = await getPostInitMCPPrompt(mcpConfigured);
40709
+ print(`
40710
+ ${message}`), print(`
40711
+ Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`), print(
40685
40712
  `
40686
- Sanity MCP server has been configured for ${editorNames}. You might need to restart your editor for this to take effect.`
40687
- ), print(`Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`);
40713
+ Have feedback? Tell us in the community: ${chalk2.cyan("https://www.sanity.io/community/join")}`
40714
+ );
40688
40715
  }
40689
40716
  print(`
40690
40717
  `), print("Other helpful commands:"), print("npx sanity docs browse 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");
@@ -40692,12 +40719,10 @@ Sanity MCP server has been configured for ${editorNames}. You might need to rest
40692
40719
  if (print(`\u2705 ${chalk2.green.bold("Success!")} Your Studio has been created.`), isCurrentDir || print(goToProjectDir), print(
40693
40720
  `
40694
40721
  Get started by running ${chalk2.cyan(devCommand)} to launch your Studio's development server`
40695
- ), mcpConfigured.length > 0) {
40696
- const editorNames = new Intl.ListFormat("en").format(mcpConfigured);
40697
- print(
40698
- `
40699
- To set up your project with the MCP server, restart ${editorNames} and type ${chalk2.cyan('"Get started with Sanity"')} in the chat`
40700
- ), print(`
40722
+ ), mcpConfigured && mcpConfigured.length > 0) {
40723
+ const message = await getPostInitMCPPrompt(mcpConfigured);
40724
+ print(`
40725
+ ${message}`), print(`
40701
40726
  Learn more: ${chalk2.cyan("https://mcp.sanity.io")}`), print(
40702
40727
  `
40703
40728
  Have feedback? Tell us in the community: ${chalk2.cyan("https://www.sanity.io/community/join")}`
@@ -40760,6 +40785,14 @@ Join the Sanity community: ${chalk2.cyan("https://www.sanity.io/community/join")
40760
40785
  datasetName: dataset.datasetName
40761
40786
  };
40762
40787
  }
40788
+ async function getPostInitMCPPrompt(editorsNames) {
40789
+ const promptClient = apiClient({ requireUser: !1, requireProject: !1 });
40790
+ return fetchPostInitPrompt({
40791
+ client: promptClient,
40792
+ editorNames: new Intl.ListFormat("en").format(editorsNames),
40793
+ chalk: chalk2
40794
+ });
40795
+ }
40763
40796
  async function getOrCreateProject() {
40764
40797
  const client2 = apiClient({ requireUser: !0, requireProject: !1 });
40765
40798
  let projects, organizations;