create-mastra 0.2.1 → 0.2.2-alpha.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.
package/dist/index.js CHANGED
@@ -995,14 +995,6 @@ function getPackageManagerInstallCommand(pm) {
995
995
  return "install";
996
996
  }
997
997
  }
998
- function installMastraDocsMCPServer({
999
- editor,
1000
- directory
1001
- }) {
1002
- if (!editor) return;
1003
- if (editor === `cursor`) return installCursorMCP(directory);
1004
- if (editor === `windsurf`) return installWindsurfMCP();
1005
- }
1006
998
  var args = ["-y", "@mastra/mcp-docs-server@latest"];
1007
999
  var mcpConfig = {
1008
1000
  mcpServers: {
@@ -1032,24 +1024,30 @@ async function writeMergedConfig(configPath) {
1032
1024
  spaces: 2
1033
1025
  });
1034
1026
  }
1035
- async function installCursorMCP(directory) {
1036
- const configPath = path.join(directory, ".cursor", "mcp.json");
1037
- await writeMergedConfig(configPath);
1027
+ var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1028
+ async function installMastraDocsMCPServer({
1029
+ editor,
1030
+ directory
1031
+ }) {
1032
+ if (editor === `cursor`) await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
1033
+ const windsurfIsInstalled = await globalWindsurfMCPIsAlreadyInstalled();
1034
+ if (editor === `windsurf` && !windsurfIsInstalled) await writeMergedConfig(windsurfGlobalMCPConfigPath);
1038
1035
  }
1039
- async function installWindsurfMCP() {
1040
- const configPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1041
- const confirm2 = await le({
1042
- message: `Windsurf only supports a global MCP config (at ${configPath}) is it ok to add/update that global config?
1043
- This means the Mastra docs MCP server will be available in all your Windsurf projects.`,
1044
- options: [
1045
- { value: "skip", label: "No, skip for now" },
1046
- { value: "yes", label: "Yes, I understand" }
1047
- ]
1048
- });
1049
- if (confirm2 !== `yes`) {
1050
- return void 0;
1036
+ async function globalWindsurfMCPIsAlreadyInstalled() {
1037
+ if (!existsSync(windsurfGlobalMCPConfigPath)) {
1038
+ return false;
1039
+ }
1040
+ try {
1041
+ const configContents = await readJSON(windsurfGlobalMCPConfigPath);
1042
+ if (!configContents?.mcpServers) return false;
1043
+ const hasMastraMCP = Object.values(configContents.mcpServers).some(
1044
+ (server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
1045
+ );
1046
+ return hasMastraMCP;
1047
+ } catch (e) {
1048
+ console.error(e);
1049
+ return false;
1051
1050
  }
1052
- await writeMergedConfig(configPath);
1053
1051
  }
1054
1052
  var EnvService = class {
1055
1053
  };
@@ -1593,15 +1591,25 @@ var interactivePrompt = async () => {
1593
1591
  initialValue: false
1594
1592
  }),
1595
1593
  configureEditorWithDocsMCP: async () => {
1594
+ const windsurfIsAlreadyInstalled = await globalWindsurfMCPIsAlreadyInstalled();
1596
1595
  const editor = await le({
1597
1596
  message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
1598
1597
  options: [
1599
1598
  { value: "skip", label: "Skip for now", hint: "default" },
1600
1599
  { value: "cursor", label: "Cursor" },
1601
- { value: "windsurf", label: "Windsurf" }
1600
+ {
1601
+ value: "windsurf",
1602
+ label: "Windsurf",
1603
+ hint: windsurfIsAlreadyInstalled ? `Already installed` : void 0
1604
+ }
1602
1605
  ]
1603
1606
  });
1604
1607
  if (editor === `skip`) return void 0;
1608
+ if (editor === `windsurf` && windsurfIsAlreadyInstalled) {
1609
+ v.message(`
1610
+ Windsurf is already installed, skipping.`);
1611
+ return void 0;
1612
+ }
1605
1613
  if (editor === `cursor`) {
1606
1614
  v.message(
1607
1615
  `
@@ -1609,6 +1617,19 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
1609
1617
  `
1610
1618
  );
1611
1619
  }
1620
+ if (editor === `windsurf`) {
1621
+ const confirm2 = await le({
1622
+ message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
1623
+ This means the Mastra docs MCP server will be available in all your Windsurf projects.`,
1624
+ options: [
1625
+ { value: "yes", label: "Yes, I understand" },
1626
+ { value: "skip", label: "No, skip for now" }
1627
+ ]
1628
+ });
1629
+ if (confirm2 !== `yes`) {
1630
+ return void 0;
1631
+ }
1632
+ }
1612
1633
  return editor;
1613
1634
  }
1614
1635
  },