create-mastra 0.0.0-unified-sidebar-20251010130811 → 0.0.0-usechat-duplicate-20251016110554
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/CHANGELOG.md +45 -1
- package/README.md +10 -32
- package/dist/index.js +328 -325
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
4
|
+
import * as fs3__default from 'node:fs';
|
|
5
|
+
import fs3__default__default, { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
6
|
import os from 'node:os';
|
|
7
|
-
import
|
|
7
|
+
import path, { dirname } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
import { PostHog } from 'posthog-node';
|
|
10
10
|
import util, { stripVTControlCharacters } from 'node:util';
|
|
@@ -12,18 +12,18 @@ import y$1, { stdout, stdin } from 'node:process';
|
|
|
12
12
|
import * as g from 'node:readline';
|
|
13
13
|
import g__default from 'node:readline';
|
|
14
14
|
import { Writable } from 'node:stream';
|
|
15
|
-
import
|
|
15
|
+
import fs4 from 'node:fs/promises';
|
|
16
16
|
import child_process from 'node:child_process';
|
|
17
17
|
import tty from 'node:tty';
|
|
18
|
-
import pino from 'pino';
|
|
19
|
-
import pretty from 'pino-pretty';
|
|
20
|
-
import { execa } from 'execa';
|
|
21
18
|
import fsExtra, { readJSON, ensureFile, writeJSON } from 'fs-extra/esm';
|
|
22
19
|
import prettier from 'prettier';
|
|
20
|
+
import { execa } from 'execa';
|
|
21
|
+
import pino from 'pino';
|
|
22
|
+
import pretty from 'pino-pretty';
|
|
23
23
|
import fsExtra$1 from 'fs-extra';
|
|
24
24
|
|
|
25
25
|
var __filename = fileURLToPath(import.meta.url);
|
|
26
|
-
var __dirname =
|
|
26
|
+
var __dirname = path.dirname(__filename);
|
|
27
27
|
var analyticsInstance = null;
|
|
28
28
|
function getAnalytics() {
|
|
29
29
|
return analyticsInstance;
|
|
@@ -39,7 +39,7 @@ var PosthogAnalytics = class {
|
|
|
39
39
|
host = "https://app.posthog.com"
|
|
40
40
|
}) {
|
|
41
41
|
this.version = version;
|
|
42
|
-
const cliConfigPath =
|
|
42
|
+
const cliConfigPath = path.join(__dirname, "mastra-cli.json");
|
|
43
43
|
if (existsSync(cliConfigPath)) {
|
|
44
44
|
try {
|
|
45
45
|
const { distinctId, sessionId } = JSON.parse(readFileSync(cliConfigPath, "utf-8"));
|
|
@@ -67,7 +67,7 @@ var PosthogAnalytics = class {
|
|
|
67
67
|
}
|
|
68
68
|
writeCliConfig({ distinctId, sessionId }) {
|
|
69
69
|
try {
|
|
70
|
-
writeFileSync(
|
|
70
|
+
writeFileSync(path.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
|
|
71
71
|
} catch {
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -422,7 +422,7 @@ ${color2.gray(d)} ${t}
|
|
|
422
422
|
`):process.stdout.write(`${w} ${l}
|
|
423
423
|
`),E(),s();};return {start:H,stop:N,message:(m="")=>{l=R(m??l);}}},Ce=async(t,n)=>{const r={},i=Object.keys(t);for(const s of i){const c=t[s],a=await c({results:r})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&pD(a)){r[s]="canceled",n.onCancel({results:r});continue}r[s]=a;}return r};
|
|
424
424
|
|
|
425
|
-
var shellQuote
|
|
425
|
+
var shellQuote = {};
|
|
426
426
|
|
|
427
427
|
var quote;
|
|
428
428
|
var hasRequiredQuote;
|
|
@@ -688,16 +688,16 @@ function requireParse () {
|
|
|
688
688
|
var hasRequiredShellQuote;
|
|
689
689
|
|
|
690
690
|
function requireShellQuote () {
|
|
691
|
-
if (hasRequiredShellQuote) return shellQuote
|
|
691
|
+
if (hasRequiredShellQuote) return shellQuote;
|
|
692
692
|
hasRequiredShellQuote = 1;
|
|
693
693
|
|
|
694
|
-
shellQuote
|
|
695
|
-
shellQuote
|
|
696
|
-
return shellQuote
|
|
694
|
+
shellQuote.quote = requireQuote();
|
|
695
|
+
shellQuote.parse = requireParse();
|
|
696
|
+
return shellQuote;
|
|
697
697
|
}
|
|
698
698
|
|
|
699
699
|
var shellQuoteExports = requireShellQuote();
|
|
700
|
-
var
|
|
700
|
+
var shellQuote2 = /*@__PURE__*/getDefaultExportFromCjs(shellQuoteExports);
|
|
701
701
|
|
|
702
702
|
// eslint-disable-next-line no-warning-comments
|
|
703
703
|
// TODO: Use a better method when it's added to Node.js (https://github.com/nodejs/node/pull/40240)
|
|
@@ -1173,279 +1173,6 @@ var PinoLogger = class extends MastraLogger {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
};
|
|
1175
1175
|
|
|
1176
|
-
function getPackageManager() {
|
|
1177
|
-
const userAgent = process.env.npm_config_user_agent || "";
|
|
1178
|
-
const execPath = process.env.npm_execpath || "";
|
|
1179
|
-
if (userAgent.includes("yarn")) {
|
|
1180
|
-
return "yarn";
|
|
1181
|
-
}
|
|
1182
|
-
if (userAgent.includes("pnpm")) {
|
|
1183
|
-
return "pnpm";
|
|
1184
|
-
}
|
|
1185
|
-
if (userAgent.includes("npm")) {
|
|
1186
|
-
return "npm";
|
|
1187
|
-
}
|
|
1188
|
-
if (execPath.includes("yarn")) {
|
|
1189
|
-
return "yarn";
|
|
1190
|
-
}
|
|
1191
|
-
if (execPath.includes("pnpm")) {
|
|
1192
|
-
return "pnpm";
|
|
1193
|
-
}
|
|
1194
|
-
if (execPath.includes("npm")) {
|
|
1195
|
-
return "npm";
|
|
1196
|
-
}
|
|
1197
|
-
return "npm";
|
|
1198
|
-
}
|
|
1199
|
-
var logger = new PinoLogger({
|
|
1200
|
-
name: "Mastra CLI",
|
|
1201
|
-
level: "info"
|
|
1202
|
-
});
|
|
1203
|
-
var exec = util.promisify(child_process.exec);
|
|
1204
|
-
async function cloneTemplate(options) {
|
|
1205
|
-
const { template, projectName, targetDir } = options;
|
|
1206
|
-
const projectPath = targetDir ? path3.resolve(targetDir, projectName) : path3.resolve(projectName);
|
|
1207
|
-
const spinner5 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
|
|
1208
|
-
try {
|
|
1209
|
-
if (await directoryExists(projectPath)) {
|
|
1210
|
-
spinner5.error(`Directory ${projectName} already exists`);
|
|
1211
|
-
throw new Error(`Directory ${projectName} already exists`);
|
|
1212
|
-
}
|
|
1213
|
-
await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
|
|
1214
|
-
await updatePackageJson(projectPath, projectName);
|
|
1215
|
-
const envExamplePath = path3.join(projectPath, ".env.example");
|
|
1216
|
-
if (await fileExists(envExamplePath)) {
|
|
1217
|
-
await fs5.copyFile(envExamplePath, path3.join(projectPath, ".env"));
|
|
1218
|
-
}
|
|
1219
|
-
spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
|
|
1220
|
-
return projectPath;
|
|
1221
|
-
} catch (error) {
|
|
1222
|
-
spinner5.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1223
|
-
throw error;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
async function directoryExists(dirPath) {
|
|
1227
|
-
try {
|
|
1228
|
-
const stat = await fs5.stat(dirPath);
|
|
1229
|
-
return stat.isDirectory();
|
|
1230
|
-
} catch {
|
|
1231
|
-
return false;
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
async function fileExists(filePath) {
|
|
1235
|
-
try {
|
|
1236
|
-
const stat = await fs5.stat(filePath);
|
|
1237
|
-
return stat.isFile();
|
|
1238
|
-
} catch {
|
|
1239
|
-
return false;
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
1243
|
-
await fs5.mkdir(targetPath, { recursive: true });
|
|
1244
|
-
try {
|
|
1245
|
-
const degitRepo = repoUrl.replace("https://github.com/", "");
|
|
1246
|
-
const degitCommand = shellQuote.quote(["npx", "degit", degitRepo, targetPath]);
|
|
1247
|
-
await exec(degitCommand, {
|
|
1248
|
-
cwd: process.cwd()
|
|
1249
|
-
});
|
|
1250
|
-
} catch {
|
|
1251
|
-
try {
|
|
1252
|
-
const gitCommand = shellQuote.quote(["git", "clone", repoUrl, targetPath]);
|
|
1253
|
-
await exec(gitCommand, {
|
|
1254
|
-
cwd: process.cwd()
|
|
1255
|
-
});
|
|
1256
|
-
const gitDir = path3.join(targetPath, ".git");
|
|
1257
|
-
if (await directoryExists(gitDir)) {
|
|
1258
|
-
await fs5.rm(gitDir, { recursive: true, force: true });
|
|
1259
|
-
}
|
|
1260
|
-
} catch (gitError) {
|
|
1261
|
-
throw new Error(`Failed to clone repository: ${gitError instanceof Error ? gitError.message : "Unknown error"}`);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
async function updatePackageJson(projectPath, projectName) {
|
|
1266
|
-
const packageJsonPath = path3.join(projectPath, "package.json");
|
|
1267
|
-
try {
|
|
1268
|
-
const packageJsonContent = await fs5.readFile(packageJsonPath, "utf-8");
|
|
1269
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
1270
|
-
packageJson.name = projectName;
|
|
1271
|
-
await fs5.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
1272
|
-
} catch (error) {
|
|
1273
|
-
logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
async function installDependencies(projectPath, packageManager) {
|
|
1277
|
-
const spinner5 = yoctoSpinner({ text: "Installing dependencies..." }).start();
|
|
1278
|
-
try {
|
|
1279
|
-
const pm = packageManager || getPackageManager();
|
|
1280
|
-
const installCommand = shellQuote.quote([pm, "install"]);
|
|
1281
|
-
await exec(installCommand, {
|
|
1282
|
-
cwd: projectPath
|
|
1283
|
-
});
|
|
1284
|
-
spinner5.success("Dependencies installed successfully");
|
|
1285
|
-
} catch (error) {
|
|
1286
|
-
spinner5.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1287
|
-
throw error;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
var TEMPLATES_API_URL = process.env.MASTRA_TEMPLATES_API_URL || "https://mastra.ai/api/templates.json";
|
|
1291
|
-
async function loadTemplates() {
|
|
1292
|
-
try {
|
|
1293
|
-
const response = await fetch(TEMPLATES_API_URL);
|
|
1294
|
-
if (!response.ok) {
|
|
1295
|
-
throw new Error(`Failed to fetch templates: ${response.statusText}`);
|
|
1296
|
-
}
|
|
1297
|
-
const templates = await response.json();
|
|
1298
|
-
return templates;
|
|
1299
|
-
} catch (error) {
|
|
1300
|
-
console.error("Error loading templates:", error);
|
|
1301
|
-
throw new Error("Failed to load templates. Please check your internet connection and try again.");
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
function pluralize(count, singular, plural) {
|
|
1305
|
-
return count === 1 ? singular : plural || `${singular}s`;
|
|
1306
|
-
}
|
|
1307
|
-
async function selectTemplate(templates) {
|
|
1308
|
-
const choices = templates.map((template) => {
|
|
1309
|
-
const parts = [];
|
|
1310
|
-
if (template.agents?.length) {
|
|
1311
|
-
parts.push(`${template.agents.length} ${pluralize(template.agents.length, "agent")}`);
|
|
1312
|
-
}
|
|
1313
|
-
if (template.tools?.length) {
|
|
1314
|
-
parts.push(`${template.tools.length} ${pluralize(template.tools.length, "tool")}`);
|
|
1315
|
-
}
|
|
1316
|
-
if (template.workflows?.length) {
|
|
1317
|
-
parts.push(`${template.workflows.length} ${pluralize(template.workflows.length, "workflow")}`);
|
|
1318
|
-
}
|
|
1319
|
-
if (template.mcp?.length) {
|
|
1320
|
-
parts.push(`${template.mcp.length} ${pluralize(template.mcp.length, "MCP server")}`);
|
|
1321
|
-
}
|
|
1322
|
-
if (template.networks?.length) {
|
|
1323
|
-
parts.push(`${template.networks.length} ${pluralize(template.networks.length, "agent network")}`);
|
|
1324
|
-
}
|
|
1325
|
-
return {
|
|
1326
|
-
value: template,
|
|
1327
|
-
label: template.title,
|
|
1328
|
-
hint: parts.join(", ") || "Template components"
|
|
1329
|
-
};
|
|
1330
|
-
});
|
|
1331
|
-
const selected = await ve({
|
|
1332
|
-
message: "Select a template:",
|
|
1333
|
-
options: choices
|
|
1334
|
-
});
|
|
1335
|
-
if (pD(selected)) {
|
|
1336
|
-
return null;
|
|
1337
|
-
}
|
|
1338
|
-
return selected;
|
|
1339
|
-
}
|
|
1340
|
-
function findTemplateByName(templates, templateName) {
|
|
1341
|
-
let template = templates.find((t) => t.slug === templateName);
|
|
1342
|
-
if (template) return template;
|
|
1343
|
-
const slugWithPrefix = `template-${templateName}`;
|
|
1344
|
-
template = templates.find((t) => t.slug === slugWithPrefix);
|
|
1345
|
-
if (template) return template;
|
|
1346
|
-
template = templates.find((t) => t.title.toLowerCase() === templateName.toLowerCase());
|
|
1347
|
-
if (template) return template;
|
|
1348
|
-
return null;
|
|
1349
|
-
}
|
|
1350
|
-
function getDefaultProjectName(template) {
|
|
1351
|
-
return template.slug.replace(/^template-/, "");
|
|
1352
|
-
}
|
|
1353
|
-
function getPackageManagerAddCommand(pm) {
|
|
1354
|
-
switch (pm) {
|
|
1355
|
-
case "npm":
|
|
1356
|
-
return "install --audit=false --fund=false --loglevel=error --progress=false --update-notifier=false";
|
|
1357
|
-
case "yarn":
|
|
1358
|
-
return "add";
|
|
1359
|
-
case "pnpm":
|
|
1360
|
-
return "add --loglevel=error";
|
|
1361
|
-
case "bun":
|
|
1362
|
-
return "add";
|
|
1363
|
-
default:
|
|
1364
|
-
return "add";
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
var DepsService = class {
|
|
1368
|
-
packageManager;
|
|
1369
|
-
constructor() {
|
|
1370
|
-
this.packageManager = this.getPackageManager();
|
|
1371
|
-
}
|
|
1372
|
-
findLockFile(dir) {
|
|
1373
|
-
const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
|
|
1374
|
-
for (const file of lockFiles) {
|
|
1375
|
-
if (fs4__default__default.existsSync(path3.join(dir, file))) {
|
|
1376
|
-
return file;
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
const parentDir = path3.resolve(dir, "..");
|
|
1380
|
-
if (parentDir !== dir) {
|
|
1381
|
-
return this.findLockFile(parentDir);
|
|
1382
|
-
}
|
|
1383
|
-
return null;
|
|
1384
|
-
}
|
|
1385
|
-
getPackageManager() {
|
|
1386
|
-
const lockFile = this.findLockFile(process.cwd());
|
|
1387
|
-
switch (lockFile) {
|
|
1388
|
-
case "pnpm-lock.yaml":
|
|
1389
|
-
return "pnpm";
|
|
1390
|
-
case "package-lock.json":
|
|
1391
|
-
return "npm";
|
|
1392
|
-
case "yarn.lock":
|
|
1393
|
-
return "yarn";
|
|
1394
|
-
case "bun.lock":
|
|
1395
|
-
return "bun";
|
|
1396
|
-
default:
|
|
1397
|
-
return "npm";
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
async installPackages(packages) {
|
|
1401
|
-
const pm = this.packageManager;
|
|
1402
|
-
const installCommand = getPackageManagerAddCommand(pm);
|
|
1403
|
-
const packageList = packages.join(" ");
|
|
1404
|
-
return execa(`${pm} ${installCommand} ${packageList}`, {
|
|
1405
|
-
all: true,
|
|
1406
|
-
shell: true,
|
|
1407
|
-
stdio: "inherit"
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
async checkDependencies(dependencies) {
|
|
1411
|
-
try {
|
|
1412
|
-
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1413
|
-
try {
|
|
1414
|
-
await fs5.access(packageJsonPath);
|
|
1415
|
-
} catch {
|
|
1416
|
-
return "No package.json file found in the current directory";
|
|
1417
|
-
}
|
|
1418
|
-
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf-8"));
|
|
1419
|
-
for (const dependency of dependencies) {
|
|
1420
|
-
if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
|
|
1421
|
-
return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
return "ok";
|
|
1425
|
-
} catch (err) {
|
|
1426
|
-
console.error(err);
|
|
1427
|
-
return "Could not check dependencies";
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
async getProjectName() {
|
|
1431
|
-
try {
|
|
1432
|
-
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1433
|
-
const packageJson = await fs5.readFile(packageJsonPath, "utf-8");
|
|
1434
|
-
const pkg = JSON.parse(packageJson);
|
|
1435
|
-
return pkg.name;
|
|
1436
|
-
} catch (err) {
|
|
1437
|
-
throw err;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
async addScriptsToPackageJson(scripts) {
|
|
1441
|
-
const packageJson = JSON.parse(await fs5.readFile("package.json", "utf-8"));
|
|
1442
|
-
packageJson.scripts = {
|
|
1443
|
-
...packageJson.scripts,
|
|
1444
|
-
...scripts
|
|
1445
|
-
};
|
|
1446
|
-
await fs5.writeFile("package.json", JSON.stringify(packageJson, null, 2));
|
|
1447
|
-
}
|
|
1448
|
-
};
|
|
1449
1176
|
var args = ["-y", "@mastra/mcp-docs-server"];
|
|
1450
1177
|
var createMcpConfig = (editor) => {
|
|
1451
1178
|
if (editor === "vscode") {
|
|
@@ -1498,19 +1225,19 @@ async function writeMergedConfig(configPath, editor) {
|
|
|
1498
1225
|
spaces: 2
|
|
1499
1226
|
});
|
|
1500
1227
|
}
|
|
1501
|
-
var windsurfGlobalMCPConfigPath =
|
|
1502
|
-
var cursorGlobalMCPConfigPath =
|
|
1503
|
-
|
|
1504
|
-
var vscodeGlobalMCPConfigPath =
|
|
1228
|
+
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1229
|
+
var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
1230
|
+
path.join(process.cwd(), ".vscode", "mcp.json");
|
|
1231
|
+
var vscodeGlobalMCPConfigPath = path.join(
|
|
1505
1232
|
os.homedir(),
|
|
1506
|
-
process.platform === "win32" ?
|
|
1233
|
+
process.platform === "win32" ? path.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path.join("Library", "Application Support", "Code", "User", "settings.json") : path.join(".config", "Code", "User", "settings.json")
|
|
1507
1234
|
);
|
|
1508
1235
|
async function installMastraDocsMCPServer({ editor, directory }) {
|
|
1509
1236
|
if (editor === `cursor`) {
|
|
1510
|
-
await writeMergedConfig(
|
|
1237
|
+
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
|
|
1511
1238
|
}
|
|
1512
1239
|
if (editor === `vscode`) {
|
|
1513
|
-
await writeMergedConfig(
|
|
1240
|
+
await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
|
|
1514
1241
|
}
|
|
1515
1242
|
if (editor === `cursor-global`) {
|
|
1516
1243
|
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
@@ -1558,6 +1285,102 @@ async function globalMCPIsAlreadyInstalled(editor) {
|
|
|
1558
1285
|
return false;
|
|
1559
1286
|
}
|
|
1560
1287
|
}
|
|
1288
|
+
function getPackageManagerAddCommand(pm) {
|
|
1289
|
+
switch (pm) {
|
|
1290
|
+
case "npm":
|
|
1291
|
+
return "install --audit=false --fund=false --loglevel=error --progress=false --update-notifier=false";
|
|
1292
|
+
case "yarn":
|
|
1293
|
+
return "add";
|
|
1294
|
+
case "pnpm":
|
|
1295
|
+
return "add --loglevel=error";
|
|
1296
|
+
case "bun":
|
|
1297
|
+
return "add";
|
|
1298
|
+
default:
|
|
1299
|
+
return "add";
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
var DepsService = class {
|
|
1303
|
+
packageManager;
|
|
1304
|
+
constructor() {
|
|
1305
|
+
this.packageManager = this.getPackageManager();
|
|
1306
|
+
}
|
|
1307
|
+
findLockFile(dir) {
|
|
1308
|
+
const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
|
|
1309
|
+
for (const file of lockFiles) {
|
|
1310
|
+
if (fs3__default__default.existsSync(path.join(dir, file))) {
|
|
1311
|
+
return file;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
const parentDir = path.resolve(dir, "..");
|
|
1315
|
+
if (parentDir !== dir) {
|
|
1316
|
+
return this.findLockFile(parentDir);
|
|
1317
|
+
}
|
|
1318
|
+
return null;
|
|
1319
|
+
}
|
|
1320
|
+
getPackageManager() {
|
|
1321
|
+
const lockFile = this.findLockFile(process.cwd());
|
|
1322
|
+
switch (lockFile) {
|
|
1323
|
+
case "pnpm-lock.yaml":
|
|
1324
|
+
return "pnpm";
|
|
1325
|
+
case "package-lock.json":
|
|
1326
|
+
return "npm";
|
|
1327
|
+
case "yarn.lock":
|
|
1328
|
+
return "yarn";
|
|
1329
|
+
case "bun.lock":
|
|
1330
|
+
return "bun";
|
|
1331
|
+
default:
|
|
1332
|
+
return "npm";
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
async installPackages(packages) {
|
|
1336
|
+
const pm = this.packageManager;
|
|
1337
|
+
const installCommand = getPackageManagerAddCommand(pm);
|
|
1338
|
+
const packageList = packages.join(" ");
|
|
1339
|
+
return execa(`${pm} ${installCommand} ${packageList}`, {
|
|
1340
|
+
all: true,
|
|
1341
|
+
shell: true,
|
|
1342
|
+
stdio: "inherit"
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
async checkDependencies(dependencies) {
|
|
1346
|
+
try {
|
|
1347
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
1348
|
+
try {
|
|
1349
|
+
await fs4.access(packageJsonPath);
|
|
1350
|
+
} catch {
|
|
1351
|
+
return "No package.json file found in the current directory";
|
|
1352
|
+
}
|
|
1353
|
+
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf-8"));
|
|
1354
|
+
for (const dependency of dependencies) {
|
|
1355
|
+
if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
|
|
1356
|
+
return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return "ok";
|
|
1360
|
+
} catch (err) {
|
|
1361
|
+
console.error(err);
|
|
1362
|
+
return "Could not check dependencies";
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
async getProjectName() {
|
|
1366
|
+
try {
|
|
1367
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
1368
|
+
const packageJson = await fs4.readFile(packageJsonPath, "utf-8");
|
|
1369
|
+
const pkg = JSON.parse(packageJson);
|
|
1370
|
+
return pkg.name;
|
|
1371
|
+
} catch (err) {
|
|
1372
|
+
throw err;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
async addScriptsToPackageJson(scripts) {
|
|
1376
|
+
const packageJson = JSON.parse(await fs4.readFile("package.json", "utf-8"));
|
|
1377
|
+
packageJson.scripts = {
|
|
1378
|
+
...packageJson.scripts,
|
|
1379
|
+
...scripts
|
|
1380
|
+
};
|
|
1381
|
+
await fs4.writeFile("package.json", JSON.stringify(packageJson, null, 2));
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1561
1384
|
var EnvService = class {
|
|
1562
1385
|
};
|
|
1563
1386
|
var FileEnvService = class extends EnvService {
|
|
@@ -1568,7 +1391,7 @@ var FileEnvService = class extends EnvService {
|
|
|
1568
1391
|
}
|
|
1569
1392
|
readFile(filePath) {
|
|
1570
1393
|
return new Promise((resolve, reject) => {
|
|
1571
|
-
|
|
1394
|
+
fs3__default.readFile(filePath, "utf8", (err, data) => {
|
|
1572
1395
|
if (err) reject(err);
|
|
1573
1396
|
else resolve(data);
|
|
1574
1397
|
});
|
|
@@ -1576,7 +1399,7 @@ var FileEnvService = class extends EnvService {
|
|
|
1576
1399
|
}
|
|
1577
1400
|
writeFile({ filePath, data }) {
|
|
1578
1401
|
return new Promise((resolve, reject) => {
|
|
1579
|
-
|
|
1402
|
+
fs3__default.writeFile(filePath, data, "utf8", (err) => {
|
|
1580
1403
|
if (err) reject(err);
|
|
1581
1404
|
else resolve();
|
|
1582
1405
|
});
|
|
@@ -1629,10 +1452,10 @@ var FileService = class {
|
|
|
1629
1452
|
*/
|
|
1630
1453
|
async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
|
|
1631
1454
|
const __filename = fileURLToPath(import.meta.url);
|
|
1632
|
-
const __dirname =
|
|
1633
|
-
const filePath =
|
|
1634
|
-
const fileString =
|
|
1635
|
-
if (
|
|
1455
|
+
const __dirname = path.dirname(__filename);
|
|
1456
|
+
const filePath = path.resolve(__dirname, "starter-files", inputFile);
|
|
1457
|
+
const fileString = fs3__default__default.readFileSync(filePath, "utf8");
|
|
1458
|
+
if (fs3__default__default.existsSync(outputFilePath) && !replaceIfExists) {
|
|
1636
1459
|
console.info(`${outputFilePath} already exists`);
|
|
1637
1460
|
return false;
|
|
1638
1461
|
}
|
|
@@ -1640,14 +1463,14 @@ var FileService = class {
|
|
|
1640
1463
|
return true;
|
|
1641
1464
|
}
|
|
1642
1465
|
async setupEnvFile({ dbUrl }) {
|
|
1643
|
-
const envPath =
|
|
1466
|
+
const envPath = path.join(process.cwd(), ".env.development");
|
|
1644
1467
|
await fsExtra.ensureFile(envPath);
|
|
1645
1468
|
const fileEnvService = new FileEnvService(envPath);
|
|
1646
1469
|
await fileEnvService.setEnvValue("DB_URL", dbUrl);
|
|
1647
1470
|
}
|
|
1648
1471
|
getFirstExistingFile(files) {
|
|
1649
1472
|
for (const f of files) {
|
|
1650
|
-
if (
|
|
1473
|
+
if (fs3__default__default.existsSync(f)) {
|
|
1651
1474
|
return f;
|
|
1652
1475
|
}
|
|
1653
1476
|
}
|
|
@@ -1657,14 +1480,14 @@ var FileService = class {
|
|
|
1657
1480
|
filePath,
|
|
1658
1481
|
replacements
|
|
1659
1482
|
}) {
|
|
1660
|
-
let fileContent =
|
|
1483
|
+
let fileContent = fs3__default__default.readFileSync(filePath, "utf8");
|
|
1661
1484
|
replacements.forEach(({ search, replace }) => {
|
|
1662
1485
|
fileContent = fileContent.replaceAll(search, replace);
|
|
1663
1486
|
});
|
|
1664
|
-
|
|
1487
|
+
fs3__default__default.writeFileSync(filePath, fileContent);
|
|
1665
1488
|
}
|
|
1666
1489
|
};
|
|
1667
|
-
var
|
|
1490
|
+
var exec = util.promisify(child_process.exec);
|
|
1668
1491
|
var getModelIdentifier = (llmProvider) => {
|
|
1669
1492
|
if (llmProvider === "openai") {
|
|
1670
1493
|
return `'openai/gpt-4o-mini'`;
|
|
@@ -1718,8 +1541,8 @@ export const weatherAgent = new Agent({
|
|
|
1718
1541
|
parser: "typescript",
|
|
1719
1542
|
singleQuote: true
|
|
1720
1543
|
});
|
|
1721
|
-
await
|
|
1722
|
-
await
|
|
1544
|
+
await fs4.writeFile(destPath, "");
|
|
1545
|
+
await fs4.writeFile(destPath, formattedContent);
|
|
1723
1546
|
}
|
|
1724
1547
|
async function writeWorkflowSample(destPath) {
|
|
1725
1548
|
const content = `import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
@@ -1912,7 +1735,7 @@ export { weatherWorkflow };`;
|
|
|
1912
1735
|
semi: true,
|
|
1913
1736
|
singleQuote: true
|
|
1914
1737
|
});
|
|
1915
|
-
await
|
|
1738
|
+
await fs4.writeFile(destPath, formattedContent);
|
|
1916
1739
|
}
|
|
1917
1740
|
async function writeToolSample(destPath) {
|
|
1918
1741
|
const fileService = new FileService();
|
|
@@ -1941,15 +1764,15 @@ var writeIndexFile = async ({
|
|
|
1941
1764
|
addWorkflow
|
|
1942
1765
|
}) => {
|
|
1943
1766
|
const indexPath = dirPath + "/index.ts";
|
|
1944
|
-
const destPath =
|
|
1767
|
+
const destPath = path.join(indexPath);
|
|
1945
1768
|
try {
|
|
1946
|
-
await
|
|
1769
|
+
await fs4.writeFile(destPath, "");
|
|
1947
1770
|
const filteredExports = [
|
|
1948
1771
|
addWorkflow ? `workflows: { weatherWorkflow },` : "",
|
|
1949
1772
|
addAgent ? `agents: { weatherAgent },` : ""
|
|
1950
1773
|
].filter(Boolean);
|
|
1951
1774
|
if (!addExample) {
|
|
1952
|
-
await
|
|
1775
|
+
await fs4.writeFile(
|
|
1953
1776
|
destPath,
|
|
1954
1777
|
`
|
|
1955
1778
|
import { Mastra } from '@mastra/core';
|
|
@@ -1959,7 +1782,7 @@ export const mastra = new Mastra()
|
|
|
1959
1782
|
);
|
|
1960
1783
|
return;
|
|
1961
1784
|
}
|
|
1962
|
-
await
|
|
1785
|
+
await fs4.writeFile(
|
|
1963
1786
|
destPath,
|
|
1964
1787
|
`
|
|
1965
1788
|
import { Mastra } from '@mastra/core/mastra';
|
|
@@ -2019,15 +1842,15 @@ var getAPIKey = async (provider) => {
|
|
|
2019
1842
|
var writeAPIKey = async ({ provider, apiKey }) => {
|
|
2020
1843
|
const envFileName = apiKey ? ".env" : ".env.example";
|
|
2021
1844
|
const key = await getAPIKey(provider);
|
|
2022
|
-
const escapedKey =
|
|
2023
|
-
const escapedApiKey =
|
|
2024
|
-
await
|
|
1845
|
+
const escapedKey = shellQuote2.quote([key]);
|
|
1846
|
+
const escapedApiKey = shellQuote2.quote([apiKey ? apiKey : "your-api-key"]);
|
|
1847
|
+
await exec(`echo ${escapedKey}=${escapedApiKey} >> ${envFileName}`);
|
|
2025
1848
|
};
|
|
2026
1849
|
var createMastraDir = async (directory) => {
|
|
2027
1850
|
let dir = directory.trim().split("/").filter((item) => item !== "");
|
|
2028
|
-
const dirPath =
|
|
1851
|
+
const dirPath = path.join(process.cwd(), ...dir, "mastra");
|
|
2029
1852
|
try {
|
|
2030
|
-
await
|
|
1853
|
+
await fs4.access(dirPath);
|
|
2031
1854
|
return { ok: false };
|
|
2032
1855
|
} catch {
|
|
2033
1856
|
await fsExtra.ensureDir(dirPath);
|
|
@@ -2173,13 +1996,193 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
|
|
|
2173
1996
|
);
|
|
2174
1997
|
return mastraProject;
|
|
2175
1998
|
};
|
|
1999
|
+
function getPackageManager() {
|
|
2000
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
2001
|
+
const execPath = process.env.npm_execpath || "";
|
|
2002
|
+
if (userAgent.includes("yarn")) {
|
|
2003
|
+
return "yarn";
|
|
2004
|
+
}
|
|
2005
|
+
if (userAgent.includes("pnpm")) {
|
|
2006
|
+
return "pnpm";
|
|
2007
|
+
}
|
|
2008
|
+
if (userAgent.includes("npm")) {
|
|
2009
|
+
return "npm";
|
|
2010
|
+
}
|
|
2011
|
+
if (execPath.includes("yarn")) {
|
|
2012
|
+
return "yarn";
|
|
2013
|
+
}
|
|
2014
|
+
if (execPath.includes("pnpm")) {
|
|
2015
|
+
return "pnpm";
|
|
2016
|
+
}
|
|
2017
|
+
if (execPath.includes("npm")) {
|
|
2018
|
+
return "npm";
|
|
2019
|
+
}
|
|
2020
|
+
return "npm";
|
|
2021
|
+
}
|
|
2022
|
+
var logger = createLogger(false);
|
|
2023
|
+
function createLogger(debug = false) {
|
|
2024
|
+
return new PinoLogger({
|
|
2025
|
+
name: "Mastra CLI",
|
|
2026
|
+
level: debug ? "debug" : "info"
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
var exec2 = util.promisify(child_process.exec);
|
|
2030
|
+
async function cloneTemplate(options) {
|
|
2031
|
+
const { template, projectName, targetDir } = options;
|
|
2032
|
+
const projectPath = targetDir ? path.resolve(targetDir, projectName) : path.resolve(projectName);
|
|
2033
|
+
const spinner5 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
|
|
2034
|
+
try {
|
|
2035
|
+
if (await directoryExists(projectPath)) {
|
|
2036
|
+
spinner5.error(`Directory ${projectName} already exists`);
|
|
2037
|
+
throw new Error(`Directory ${projectName} already exists`);
|
|
2038
|
+
}
|
|
2039
|
+
await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
|
|
2040
|
+
await updatePackageJson(projectPath, projectName);
|
|
2041
|
+
const envExamplePath = path.join(projectPath, ".env.example");
|
|
2042
|
+
if (await fileExists(envExamplePath)) {
|
|
2043
|
+
await fs4.copyFile(envExamplePath, path.join(projectPath, ".env"));
|
|
2044
|
+
}
|
|
2045
|
+
spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
|
|
2046
|
+
return projectPath;
|
|
2047
|
+
} catch (error) {
|
|
2048
|
+
spinner5.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2049
|
+
throw error;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
async function directoryExists(dirPath) {
|
|
2053
|
+
try {
|
|
2054
|
+
const stat = await fs4.stat(dirPath);
|
|
2055
|
+
return stat.isDirectory();
|
|
2056
|
+
} catch {
|
|
2057
|
+
return false;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
async function fileExists(filePath) {
|
|
2061
|
+
try {
|
|
2062
|
+
const stat = await fs4.stat(filePath);
|
|
2063
|
+
return stat.isFile();
|
|
2064
|
+
} catch {
|
|
2065
|
+
return false;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
2069
|
+
await fs4.mkdir(targetPath, { recursive: true });
|
|
2070
|
+
try {
|
|
2071
|
+
const degitRepo = repoUrl.replace("https://github.com/", "");
|
|
2072
|
+
const degitCommand = shellQuote2.quote(["npx", "degit", degitRepo, targetPath]);
|
|
2073
|
+
await exec2(degitCommand, {
|
|
2074
|
+
cwd: process.cwd()
|
|
2075
|
+
});
|
|
2076
|
+
} catch {
|
|
2077
|
+
try {
|
|
2078
|
+
const gitCommand = shellQuote2.quote(["git", "clone", repoUrl, targetPath]);
|
|
2079
|
+
await exec2(gitCommand, {
|
|
2080
|
+
cwd: process.cwd()
|
|
2081
|
+
});
|
|
2082
|
+
const gitDir = path.join(targetPath, ".git");
|
|
2083
|
+
if (await directoryExists(gitDir)) {
|
|
2084
|
+
await fs4.rm(gitDir, { recursive: true, force: true });
|
|
2085
|
+
}
|
|
2086
|
+
} catch (gitError) {
|
|
2087
|
+
throw new Error(`Failed to clone repository: ${gitError instanceof Error ? gitError.message : "Unknown error"}`);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
async function updatePackageJson(projectPath, projectName) {
|
|
2092
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
2093
|
+
try {
|
|
2094
|
+
const packageJsonContent = await fs4.readFile(packageJsonPath, "utf-8");
|
|
2095
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
2096
|
+
packageJson.name = projectName;
|
|
2097
|
+
await fs4.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
2098
|
+
} catch (error) {
|
|
2099
|
+
logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
async function installDependencies(projectPath, packageManager) {
|
|
2103
|
+
const spinner5 = yoctoSpinner({ text: "Installing dependencies..." }).start();
|
|
2104
|
+
try {
|
|
2105
|
+
const pm = packageManager || getPackageManager();
|
|
2106
|
+
const installCommand = shellQuote2.quote([pm, "install"]);
|
|
2107
|
+
await exec2(installCommand, {
|
|
2108
|
+
cwd: projectPath
|
|
2109
|
+
});
|
|
2110
|
+
spinner5.success("Dependencies installed successfully");
|
|
2111
|
+
} catch (error) {
|
|
2112
|
+
spinner5.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2113
|
+
throw error;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
var TEMPLATES_API_URL = process.env.MASTRA_TEMPLATES_API_URL || "https://mastra.ai/api/templates.json";
|
|
2117
|
+
async function loadTemplates() {
|
|
2118
|
+
try {
|
|
2119
|
+
const response = await fetch(TEMPLATES_API_URL);
|
|
2120
|
+
if (!response.ok) {
|
|
2121
|
+
throw new Error(`Failed to fetch templates: ${response.statusText}`);
|
|
2122
|
+
}
|
|
2123
|
+
const templates = await response.json();
|
|
2124
|
+
return templates;
|
|
2125
|
+
} catch (error) {
|
|
2126
|
+
console.error("Error loading templates:", error);
|
|
2127
|
+
throw new Error("Failed to load templates. Please check your internet connection and try again.");
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
function pluralize(count, singular, plural) {
|
|
2131
|
+
return count === 1 ? singular : plural || `${singular}s`;
|
|
2132
|
+
}
|
|
2133
|
+
async function selectTemplate(templates) {
|
|
2134
|
+
const choices = templates.map((template) => {
|
|
2135
|
+
const parts = [];
|
|
2136
|
+
if (template.agents?.length) {
|
|
2137
|
+
parts.push(`${template.agents.length} ${pluralize(template.agents.length, "agent")}`);
|
|
2138
|
+
}
|
|
2139
|
+
if (template.tools?.length) {
|
|
2140
|
+
parts.push(`${template.tools.length} ${pluralize(template.tools.length, "tool")}`);
|
|
2141
|
+
}
|
|
2142
|
+
if (template.workflows?.length) {
|
|
2143
|
+
parts.push(`${template.workflows.length} ${pluralize(template.workflows.length, "workflow")}`);
|
|
2144
|
+
}
|
|
2145
|
+
if (template.mcp?.length) {
|
|
2146
|
+
parts.push(`${template.mcp.length} ${pluralize(template.mcp.length, "MCP server")}`);
|
|
2147
|
+
}
|
|
2148
|
+
if (template.networks?.length) {
|
|
2149
|
+
parts.push(`${template.networks.length} ${pluralize(template.networks.length, "agent network")}`);
|
|
2150
|
+
}
|
|
2151
|
+
return {
|
|
2152
|
+
value: template,
|
|
2153
|
+
label: template.title,
|
|
2154
|
+
hint: parts.join(", ") || "Template components"
|
|
2155
|
+
};
|
|
2156
|
+
});
|
|
2157
|
+
const selected = await ve({
|
|
2158
|
+
message: "Select a template:",
|
|
2159
|
+
options: choices
|
|
2160
|
+
});
|
|
2161
|
+
if (pD(selected)) {
|
|
2162
|
+
return null;
|
|
2163
|
+
}
|
|
2164
|
+
return selected;
|
|
2165
|
+
}
|
|
2166
|
+
function findTemplateByName(templates, templateName) {
|
|
2167
|
+
let template = templates.find((t) => t.slug === templateName);
|
|
2168
|
+
if (template) return template;
|
|
2169
|
+
const slugWithPrefix = `template-${templateName}`;
|
|
2170
|
+
template = templates.find((t) => t.slug === slugWithPrefix);
|
|
2171
|
+
if (template) return template;
|
|
2172
|
+
template = templates.find((t) => t.title.toLowerCase() === templateName.toLowerCase());
|
|
2173
|
+
if (template) return template;
|
|
2174
|
+
return null;
|
|
2175
|
+
}
|
|
2176
|
+
function getDefaultProjectName(template) {
|
|
2177
|
+
return template.slug.replace(/^template-/, "");
|
|
2178
|
+
}
|
|
2176
2179
|
var s = Y();
|
|
2177
2180
|
var init = async ({
|
|
2178
|
-
directory,
|
|
2179
|
-
addExample = false,
|
|
2181
|
+
directory = "src/",
|
|
2180
2182
|
components,
|
|
2181
2183
|
llmProvider = "openai",
|
|
2182
2184
|
llmApiKey,
|
|
2185
|
+
addExample = false,
|
|
2183
2186
|
configureEditorWithDocsMCP
|
|
2184
2187
|
}) => {
|
|
2185
2188
|
s.start("Initializing Mastra");
|
|
@@ -2310,7 +2313,7 @@ var createMastraProject = async ({
|
|
|
2310
2313
|
defaultValue: "my-mastra-app",
|
|
2311
2314
|
validate: (value) => {
|
|
2312
2315
|
if (value.length === 0) return "Project name cannot be empty";
|
|
2313
|
-
if (
|
|
2316
|
+
if (fs3__default__default.existsSync(value)) {
|
|
2314
2317
|
return `A directory named "${value}" already exists. Please choose a different name.`;
|
|
2315
2318
|
}
|
|
2316
2319
|
}
|
|
@@ -2330,7 +2333,7 @@ var createMastraProject = async ({
|
|
|
2330
2333
|
try {
|
|
2331
2334
|
s2.start("Creating project");
|
|
2332
2335
|
try {
|
|
2333
|
-
await
|
|
2336
|
+
await fs4.mkdir(projectName);
|
|
2334
2337
|
} catch (error) {
|
|
2335
2338
|
if (error instanceof Error && "code" in error && error.code === "EEXIST") {
|
|
2336
2339
|
s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
|
|
@@ -2362,7 +2365,7 @@ var createMastraProject = async ({
|
|
|
2362
2365
|
s2.stop("Project structure created");
|
|
2363
2366
|
s2.start(`Installing ${pm} dependencies`);
|
|
2364
2367
|
try {
|
|
2365
|
-
await exec3(`${pm} ${installCommand} zod@^
|
|
2368
|
+
await exec3(`${pm} ${installCommand} zod@^4`);
|
|
2366
2369
|
await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
|
|
2367
2370
|
await exec3(`echo '{
|
|
2368
2371
|
"compilerOptions": {
|
|
@@ -2632,7 +2635,7 @@ async function createFromTemplate(args2) {
|
|
|
2632
2635
|
async function getPackageVersion() {
|
|
2633
2636
|
const __filename = fileURLToPath(import.meta.url);
|
|
2634
2637
|
const __dirname = dirname(__filename);
|
|
2635
|
-
const pkgJsonPath =
|
|
2638
|
+
const pkgJsonPath = path.join(__dirname, "..", "package.json");
|
|
2636
2639
|
const content = await fsExtra$1.readJSON(pkgJsonPath);
|
|
2637
2640
|
return content.version;
|
|
2638
2641
|
}
|