create-mastra 0.10.1-alpha.5 → 0.10.2-alpha.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.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { randomUUID } from 'node:crypto';
4
4
  import * as fs3__default from 'node:fs';
5
5
  import fs3__default__default, { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
6
  import os from 'node:os';
7
- import path, { dirname } from 'node:path';
7
+ import path2, { dirname } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { PostHog } from 'posthog-node';
10
10
  import h, { stdin, stdout } from 'node:process';
@@ -22,7 +22,7 @@ import pretty from 'pino-pretty';
22
22
  import fsExtra from 'fs-extra';
23
23
 
24
24
  var __filename = fileURLToPath(import.meta.url);
25
- var __dirname = path.dirname(__filename);
25
+ var __dirname = path2.dirname(__filename);
26
26
  var PosthogAnalytics = class {
27
27
  sessionId;
28
28
  client;
@@ -34,7 +34,7 @@ var PosthogAnalytics = class {
34
34
  host = "https://app.posthog.com"
35
35
  }) {
36
36
  this.version = version;
37
- const cliConfigPath = path.join(__dirname, "mastra-cli.json");
37
+ const cliConfigPath = path2.join(__dirname, "mastra-cli.json");
38
38
  if (existsSync(cliConfigPath)) {
39
39
  try {
40
40
  const { distinctId, sessionId } = JSON.parse(readFileSync(cliConfigPath, "utf-8"));
@@ -62,7 +62,7 @@ var PosthogAnalytics = class {
62
62
  }
63
63
  writeCliConfig({ distinctId, sessionId }) {
64
64
  try {
65
- writeFileSync(path.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
65
+ writeFileSync(path2.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
66
66
  } catch {
67
67
  }
68
68
  }
@@ -1151,11 +1151,11 @@ var DepsService = class {
1151
1151
  findLockFile(dir) {
1152
1152
  const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
1153
1153
  for (const file of lockFiles) {
1154
- if (fs3__default__default.existsSync(path.join(dir, file))) {
1154
+ if (fs3__default__default.existsSync(path2.join(dir, file))) {
1155
1155
  return file;
1156
1156
  }
1157
1157
  }
1158
- const parentDir = path.resolve(dir, "..");
1158
+ const parentDir = path2.resolve(dir, "..");
1159
1159
  if (parentDir !== dir) {
1160
1160
  return this.findLockFile(parentDir);
1161
1161
  }
@@ -1192,7 +1192,7 @@ var DepsService = class {
1192
1192
  }
1193
1193
  async checkDependencies(dependencies) {
1194
1194
  try {
1195
- const packageJsonPath = path.join(process.cwd(), "package.json");
1195
+ const packageJsonPath = path2.join(process.cwd(), "package.json");
1196
1196
  try {
1197
1197
  await fs4.access(packageJsonPath);
1198
1198
  } catch {
@@ -1212,7 +1212,7 @@ var DepsService = class {
1212
1212
  }
1213
1213
  async getProjectName() {
1214
1214
  try {
1215
- const packageJsonPath = path.join(process.cwd(), "package.json");
1215
+ const packageJsonPath = path2.join(process.cwd(), "package.json");
1216
1216
  const packageJson = await fs4.readFile(packageJsonPath, "utf-8");
1217
1217
  const pkg = JSON.parse(packageJson);
1218
1218
  return pkg.name;
@@ -1223,7 +1223,7 @@ var DepsService = class {
1223
1223
  async getPackageVersion() {
1224
1224
  const __filename = fileURLToPath(import.meta.url);
1225
1225
  const __dirname = dirname(__filename);
1226
- const pkgJsonPath = path.join(__dirname, "..", "package.json");
1226
+ const pkgJsonPath = path2.join(__dirname, "..", "package.json");
1227
1227
  const content = await fsExtra3.readJSON(pkgJsonPath);
1228
1228
  return content.version;
1229
1229
  }
@@ -1326,15 +1326,19 @@ async function writeMergedConfig(configPath, editor) {
1326
1326
  spaces: 2
1327
1327
  });
1328
1328
  }
1329
- var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1330
- var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
1331
- path.join(process.cwd(), ".vscode", "mcp.json");
1329
+ var windsurfGlobalMCPConfigPath = path2.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1330
+ var cursorGlobalMCPConfigPath = path2.join(os.homedir(), ".cursor", "mcp.json");
1331
+ path2.join(process.cwd(), ".vscode", "mcp.json");
1332
+ var vscodeGlobalMCPConfigPath = path2.join(
1333
+ os.homedir(),
1334
+ process.platform === "win32" ? path2.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path2.join("Library", "Application Support", "Code", "User", "settings.json") : path2.join(".config", "Code", "User", "settings.json")
1335
+ );
1332
1336
  async function installMastraDocsMCPServer({ editor, directory }) {
1333
1337
  if (editor === `cursor`) {
1334
- await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
1338
+ await writeMergedConfig(path2.join(directory, ".cursor", "mcp.json"), "cursor");
1335
1339
  }
1336
1340
  if (editor === `vscode`) {
1337
- await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
1341
+ await writeMergedConfig(path2.join(directory, ".vscode", "mcp.json"), "vscode");
1338
1342
  }
1339
1343
  if (editor === `cursor-global`) {
1340
1344
  const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
@@ -1357,12 +1361,21 @@ async function globalMCPIsAlreadyInstalled(editor) {
1357
1361
  configPath = windsurfGlobalMCPConfigPath;
1358
1362
  } else if (editor === "cursor-global") {
1359
1363
  configPath = cursorGlobalMCPConfigPath;
1364
+ } else if (editor === "vscode") {
1365
+ configPath = vscodeGlobalMCPConfigPath;
1360
1366
  }
1361
1367
  if (!configPath || !existsSync(configPath)) {
1362
1368
  return false;
1363
1369
  }
1364
1370
  try {
1365
1371
  const configContents = await readJSON(configPath);
1372
+ if (editor === "vscode") {
1373
+ if (!configContents?.servers) return false;
1374
+ const hasMastraMCP2 = Object.values(configContents.servers).some(
1375
+ (server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
1376
+ );
1377
+ return hasMastraMCP2;
1378
+ }
1366
1379
  if (!configContents?.mcpServers) return false;
1367
1380
  const hasMastraMCP = Object.values(configContents.mcpServers).some(
1368
1381
  (server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
@@ -1444,8 +1457,8 @@ var FileService = class {
1444
1457
  */
1445
1458
  async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
1446
1459
  const __filename = fileURLToPath(import.meta.url);
1447
- const __dirname = path.dirname(__filename);
1448
- const filePath = path.resolve(__dirname, "starter-files", inputFile);
1460
+ const __dirname = path2.dirname(__filename);
1461
+ const filePath = path2.resolve(__dirname, "starter-files", inputFile);
1449
1462
  const fileString = fs3__default__default.readFileSync(filePath, "utf8");
1450
1463
  if (fs3__default__default.existsSync(outputFilePath) && !replaceIfExists) {
1451
1464
  console.log(`${outputFilePath} already exists`);
@@ -1455,7 +1468,7 @@ var FileService = class {
1455
1468
  return true;
1456
1469
  }
1457
1470
  async setupEnvFile({ dbUrl }) {
1458
- const envPath = path.join(process.cwd(), ".env.development");
1471
+ const envPath = path2.join(process.cwd(), ".env.development");
1459
1472
  await fsExtra3.ensureFile(envPath);
1460
1473
  const fileEnvService = new FileEnvService(envPath);
1461
1474
  await fileEnvService.setEnvValue("DB_URL", dbUrl);
@@ -1790,7 +1803,7 @@ var writeIndexFile = async ({
1790
1803
  addWorkflow
1791
1804
  }) => {
1792
1805
  const indexPath = dirPath + "/index.ts";
1793
- const destPath = path.join(indexPath);
1806
+ const destPath = path2.join(indexPath);
1794
1807
  try {
1795
1808
  await fs4.writeFile(destPath, "");
1796
1809
  const filteredExports = [
@@ -1865,7 +1878,7 @@ var writeAPIKey = async ({
1865
1878
  };
1866
1879
  var createMastraDir = async (directory) => {
1867
1880
  let dir = directory.trim().split("/").filter((item) => item !== "");
1868
- const dirPath = path.join(process.cwd(), ...dir, "mastra");
1881
+ const dirPath = path2.join(process.cwd(), ...dir, "mastra");
1869
1882
  try {
1870
1883
  await fs4.access(dirPath);
1871
1884
  return { ok: false };
@@ -1939,6 +1952,7 @@ var interactivePrompt = async () => {
1939
1952
  configureEditorWithDocsMCP: async () => {
1940
1953
  const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
1941
1954
  const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
1955
+ const vscodeIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`vscode`);
1942
1956
  const editor = await le({
1943
1957
  message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
1944
1958
  options: [
@@ -1957,6 +1971,11 @@ var interactivePrompt = async () => {
1957
1971
  value: "windsurf",
1958
1972
  label: "Windsurf",
1959
1973
  hint: windsurfIsAlreadyInstalled ? `Already installed` : void 0
1974
+ },
1975
+ {
1976
+ value: "vscode",
1977
+ label: "VSCode",
1978
+ hint: vscodeIsAlreadyInstalled ? `Already installed` : void 0
1960
1979
  }
1961
1980
  ]
1962
1981
  });
@@ -1966,6 +1985,11 @@ var interactivePrompt = async () => {
1966
1985
  Windsurf is already installed, skipping.`);
1967
1986
  return void 0;
1968
1987
  }
1988
+ if (editor === `vscode` && vscodeIsAlreadyInstalled) {
1989
+ v.message(`
1990
+ VSCode is already installed, skipping.`);
1991
+ return void 0;
1992
+ }
1969
1993
  if (editor === `cursor`) {
1970
1994
  v.message(
1971
1995
  `
@@ -2258,7 +2282,7 @@ var postCreate = ({ projectName }) => {
2258
2282
  async function getPackageVersion() {
2259
2283
  const __filename = fileURLToPath(import.meta.url);
2260
2284
  const __dirname = dirname(__filename);
2261
- const pkgJsonPath = path.join(__dirname, "..", "package.json");
2285
+ const pkgJsonPath = path2.join(__dirname, "..", "package.json");
2262
2286
  const content = await fsExtra.readJSON(pkgJsonPath);
2263
2287
  return content.version;
2264
2288
  }