create-mastra 0.16.0 → 0.17.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/CHANGELOG.md +16 -0
- package/dist/index.js +328 -328
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
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,282 +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 = createLogger(false);
|
|
1200
|
-
function createLogger(debug = false) {
|
|
1201
|
-
return new PinoLogger({
|
|
1202
|
-
name: "Mastra CLI",
|
|
1203
|
-
level: debug ? "debug" : "info"
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
var exec = util.promisify(child_process.exec);
|
|
1207
|
-
async function cloneTemplate(options) {
|
|
1208
|
-
const { template, projectName, targetDir } = options;
|
|
1209
|
-
const projectPath = targetDir ? path3.resolve(targetDir, projectName) : path3.resolve(projectName);
|
|
1210
|
-
const spinner5 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
|
|
1211
|
-
try {
|
|
1212
|
-
if (await directoryExists(projectPath)) {
|
|
1213
|
-
spinner5.error(`Directory ${projectName} already exists`);
|
|
1214
|
-
throw new Error(`Directory ${projectName} already exists`);
|
|
1215
|
-
}
|
|
1216
|
-
await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
|
|
1217
|
-
await updatePackageJson(projectPath, projectName);
|
|
1218
|
-
const envExamplePath = path3.join(projectPath, ".env.example");
|
|
1219
|
-
if (await fileExists(envExamplePath)) {
|
|
1220
|
-
await fs5.copyFile(envExamplePath, path3.join(projectPath, ".env"));
|
|
1221
|
-
}
|
|
1222
|
-
spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
|
|
1223
|
-
return projectPath;
|
|
1224
|
-
} catch (error) {
|
|
1225
|
-
spinner5.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1226
|
-
throw error;
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
async function directoryExists(dirPath) {
|
|
1230
|
-
try {
|
|
1231
|
-
const stat = await fs5.stat(dirPath);
|
|
1232
|
-
return stat.isDirectory();
|
|
1233
|
-
} catch {
|
|
1234
|
-
return false;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
async function fileExists(filePath) {
|
|
1238
|
-
try {
|
|
1239
|
-
const stat = await fs5.stat(filePath);
|
|
1240
|
-
return stat.isFile();
|
|
1241
|
-
} catch {
|
|
1242
|
-
return false;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
1246
|
-
await fs5.mkdir(targetPath, { recursive: true });
|
|
1247
|
-
try {
|
|
1248
|
-
const degitRepo = repoUrl.replace("https://github.com/", "");
|
|
1249
|
-
const degitCommand = shellQuote.quote(["npx", "degit", degitRepo, targetPath]);
|
|
1250
|
-
await exec(degitCommand, {
|
|
1251
|
-
cwd: process.cwd()
|
|
1252
|
-
});
|
|
1253
|
-
} catch {
|
|
1254
|
-
try {
|
|
1255
|
-
const gitCommand = shellQuote.quote(["git", "clone", repoUrl, targetPath]);
|
|
1256
|
-
await exec(gitCommand, {
|
|
1257
|
-
cwd: process.cwd()
|
|
1258
|
-
});
|
|
1259
|
-
const gitDir = path3.join(targetPath, ".git");
|
|
1260
|
-
if (await directoryExists(gitDir)) {
|
|
1261
|
-
await fs5.rm(gitDir, { recursive: true, force: true });
|
|
1262
|
-
}
|
|
1263
|
-
} catch (gitError) {
|
|
1264
|
-
throw new Error(`Failed to clone repository: ${gitError instanceof Error ? gitError.message : "Unknown error"}`);
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
async function updatePackageJson(projectPath, projectName) {
|
|
1269
|
-
const packageJsonPath = path3.join(projectPath, "package.json");
|
|
1270
|
-
try {
|
|
1271
|
-
const packageJsonContent = await fs5.readFile(packageJsonPath, "utf-8");
|
|
1272
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
1273
|
-
packageJson.name = projectName;
|
|
1274
|
-
await fs5.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
1275
|
-
} catch (error) {
|
|
1276
|
-
logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
async function installDependencies(projectPath, packageManager) {
|
|
1280
|
-
const spinner5 = yoctoSpinner({ text: "Installing dependencies..." }).start();
|
|
1281
|
-
try {
|
|
1282
|
-
const pm = packageManager || getPackageManager();
|
|
1283
|
-
const installCommand = shellQuote.quote([pm, "install"]);
|
|
1284
|
-
await exec(installCommand, {
|
|
1285
|
-
cwd: projectPath
|
|
1286
|
-
});
|
|
1287
|
-
spinner5.success("Dependencies installed successfully");
|
|
1288
|
-
} catch (error) {
|
|
1289
|
-
spinner5.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1290
|
-
throw error;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
var TEMPLATES_API_URL = process.env.MASTRA_TEMPLATES_API_URL || "https://mastra.ai/api/templates.json";
|
|
1294
|
-
async function loadTemplates() {
|
|
1295
|
-
try {
|
|
1296
|
-
const response = await fetch(TEMPLATES_API_URL);
|
|
1297
|
-
if (!response.ok) {
|
|
1298
|
-
throw new Error(`Failed to fetch templates: ${response.statusText}`);
|
|
1299
|
-
}
|
|
1300
|
-
const templates = await response.json();
|
|
1301
|
-
return templates;
|
|
1302
|
-
} catch (error) {
|
|
1303
|
-
console.error("Error loading templates:", error);
|
|
1304
|
-
throw new Error("Failed to load templates. Please check your internet connection and try again.");
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
function pluralize(count, singular, plural) {
|
|
1308
|
-
return count === 1 ? singular : plural || `${singular}s`;
|
|
1309
|
-
}
|
|
1310
|
-
async function selectTemplate(templates) {
|
|
1311
|
-
const choices = templates.map((template) => {
|
|
1312
|
-
const parts = [];
|
|
1313
|
-
if (template.agents?.length) {
|
|
1314
|
-
parts.push(`${template.agents.length} ${pluralize(template.agents.length, "agent")}`);
|
|
1315
|
-
}
|
|
1316
|
-
if (template.tools?.length) {
|
|
1317
|
-
parts.push(`${template.tools.length} ${pluralize(template.tools.length, "tool")}`);
|
|
1318
|
-
}
|
|
1319
|
-
if (template.workflows?.length) {
|
|
1320
|
-
parts.push(`${template.workflows.length} ${pluralize(template.workflows.length, "workflow")}`);
|
|
1321
|
-
}
|
|
1322
|
-
if (template.mcp?.length) {
|
|
1323
|
-
parts.push(`${template.mcp.length} ${pluralize(template.mcp.length, "MCP server")}`);
|
|
1324
|
-
}
|
|
1325
|
-
if (template.networks?.length) {
|
|
1326
|
-
parts.push(`${template.networks.length} ${pluralize(template.networks.length, "agent network")}`);
|
|
1327
|
-
}
|
|
1328
|
-
return {
|
|
1329
|
-
value: template,
|
|
1330
|
-
label: template.title,
|
|
1331
|
-
hint: parts.join(", ") || "Template components"
|
|
1332
|
-
};
|
|
1333
|
-
});
|
|
1334
|
-
const selected = await ve({
|
|
1335
|
-
message: "Select a template:",
|
|
1336
|
-
options: choices
|
|
1337
|
-
});
|
|
1338
|
-
if (pD(selected)) {
|
|
1339
|
-
return null;
|
|
1340
|
-
}
|
|
1341
|
-
return selected;
|
|
1342
|
-
}
|
|
1343
|
-
function findTemplateByName(templates, templateName) {
|
|
1344
|
-
let template = templates.find((t) => t.slug === templateName);
|
|
1345
|
-
if (template) return template;
|
|
1346
|
-
const slugWithPrefix = `template-${templateName}`;
|
|
1347
|
-
template = templates.find((t) => t.slug === slugWithPrefix);
|
|
1348
|
-
if (template) return template;
|
|
1349
|
-
template = templates.find((t) => t.title.toLowerCase() === templateName.toLowerCase());
|
|
1350
|
-
if (template) return template;
|
|
1351
|
-
return null;
|
|
1352
|
-
}
|
|
1353
|
-
function getDefaultProjectName(template) {
|
|
1354
|
-
return template.slug.replace(/^template-/, "");
|
|
1355
|
-
}
|
|
1356
|
-
function getPackageManagerAddCommand(pm) {
|
|
1357
|
-
switch (pm) {
|
|
1358
|
-
case "npm":
|
|
1359
|
-
return "install --audit=false --fund=false --loglevel=error --progress=false --update-notifier=false";
|
|
1360
|
-
case "yarn":
|
|
1361
|
-
return "add";
|
|
1362
|
-
case "pnpm":
|
|
1363
|
-
return "add --loglevel=error";
|
|
1364
|
-
case "bun":
|
|
1365
|
-
return "add";
|
|
1366
|
-
default:
|
|
1367
|
-
return "add";
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
var DepsService = class {
|
|
1371
|
-
packageManager;
|
|
1372
|
-
constructor() {
|
|
1373
|
-
this.packageManager = this.getPackageManager();
|
|
1374
|
-
}
|
|
1375
|
-
findLockFile(dir) {
|
|
1376
|
-
const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
|
|
1377
|
-
for (const file of lockFiles) {
|
|
1378
|
-
if (fs4__default__default.existsSync(path3.join(dir, file))) {
|
|
1379
|
-
return file;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
const parentDir = path3.resolve(dir, "..");
|
|
1383
|
-
if (parentDir !== dir) {
|
|
1384
|
-
return this.findLockFile(parentDir);
|
|
1385
|
-
}
|
|
1386
|
-
return null;
|
|
1387
|
-
}
|
|
1388
|
-
getPackageManager() {
|
|
1389
|
-
const lockFile = this.findLockFile(process.cwd());
|
|
1390
|
-
switch (lockFile) {
|
|
1391
|
-
case "pnpm-lock.yaml":
|
|
1392
|
-
return "pnpm";
|
|
1393
|
-
case "package-lock.json":
|
|
1394
|
-
return "npm";
|
|
1395
|
-
case "yarn.lock":
|
|
1396
|
-
return "yarn";
|
|
1397
|
-
case "bun.lock":
|
|
1398
|
-
return "bun";
|
|
1399
|
-
default:
|
|
1400
|
-
return "npm";
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
async installPackages(packages) {
|
|
1404
|
-
const pm = this.packageManager;
|
|
1405
|
-
const installCommand = getPackageManagerAddCommand(pm);
|
|
1406
|
-
const packageList = packages.join(" ");
|
|
1407
|
-
return execa(`${pm} ${installCommand} ${packageList}`, {
|
|
1408
|
-
all: true,
|
|
1409
|
-
shell: true,
|
|
1410
|
-
stdio: "inherit"
|
|
1411
|
-
});
|
|
1412
|
-
}
|
|
1413
|
-
async checkDependencies(dependencies) {
|
|
1414
|
-
try {
|
|
1415
|
-
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1416
|
-
try {
|
|
1417
|
-
await fs5.access(packageJsonPath);
|
|
1418
|
-
} catch {
|
|
1419
|
-
return "No package.json file found in the current directory";
|
|
1420
|
-
}
|
|
1421
|
-
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf-8"));
|
|
1422
|
-
for (const dependency of dependencies) {
|
|
1423
|
-
if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
|
|
1424
|
-
return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
return "ok";
|
|
1428
|
-
} catch (err) {
|
|
1429
|
-
console.error(err);
|
|
1430
|
-
return "Could not check dependencies";
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
async getProjectName() {
|
|
1434
|
-
try {
|
|
1435
|
-
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1436
|
-
const packageJson = await fs5.readFile(packageJsonPath, "utf-8");
|
|
1437
|
-
const pkg = JSON.parse(packageJson);
|
|
1438
|
-
return pkg.name;
|
|
1439
|
-
} catch (err) {
|
|
1440
|
-
throw err;
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
async addScriptsToPackageJson(scripts) {
|
|
1444
|
-
const packageJson = JSON.parse(await fs5.readFile("package.json", "utf-8"));
|
|
1445
|
-
packageJson.scripts = {
|
|
1446
|
-
...packageJson.scripts,
|
|
1447
|
-
...scripts
|
|
1448
|
-
};
|
|
1449
|
-
await fs5.writeFile("package.json", JSON.stringify(packageJson, null, 2));
|
|
1450
|
-
}
|
|
1451
|
-
};
|
|
1452
1176
|
var args = ["-y", "@mastra/mcp-docs-server"];
|
|
1453
1177
|
var createMcpConfig = (editor) => {
|
|
1454
1178
|
if (editor === "vscode") {
|
|
@@ -1501,19 +1225,19 @@ async function writeMergedConfig(configPath, editor) {
|
|
|
1501
1225
|
spaces: 2
|
|
1502
1226
|
});
|
|
1503
1227
|
}
|
|
1504
|
-
var windsurfGlobalMCPConfigPath =
|
|
1505
|
-
var cursorGlobalMCPConfigPath =
|
|
1506
|
-
|
|
1507
|
-
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(
|
|
1508
1232
|
os.homedir(),
|
|
1509
|
-
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")
|
|
1510
1234
|
);
|
|
1511
1235
|
async function installMastraDocsMCPServer({ editor, directory }) {
|
|
1512
1236
|
if (editor === `cursor`) {
|
|
1513
|
-
await writeMergedConfig(
|
|
1237
|
+
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
|
|
1514
1238
|
}
|
|
1515
1239
|
if (editor === `vscode`) {
|
|
1516
|
-
await writeMergedConfig(
|
|
1240
|
+
await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
|
|
1517
1241
|
}
|
|
1518
1242
|
if (editor === `cursor-global`) {
|
|
1519
1243
|
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
@@ -1561,6 +1285,102 @@ async function globalMCPIsAlreadyInstalled(editor) {
|
|
|
1561
1285
|
return false;
|
|
1562
1286
|
}
|
|
1563
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
|
+
};
|
|
1564
1384
|
var EnvService = class {
|
|
1565
1385
|
};
|
|
1566
1386
|
var FileEnvService = class extends EnvService {
|
|
@@ -1571,7 +1391,7 @@ var FileEnvService = class extends EnvService {
|
|
|
1571
1391
|
}
|
|
1572
1392
|
readFile(filePath) {
|
|
1573
1393
|
return new Promise((resolve, reject) => {
|
|
1574
|
-
|
|
1394
|
+
fs3__default.readFile(filePath, "utf8", (err, data) => {
|
|
1575
1395
|
if (err) reject(err);
|
|
1576
1396
|
else resolve(data);
|
|
1577
1397
|
});
|
|
@@ -1579,7 +1399,7 @@ var FileEnvService = class extends EnvService {
|
|
|
1579
1399
|
}
|
|
1580
1400
|
writeFile({ filePath, data }) {
|
|
1581
1401
|
return new Promise((resolve, reject) => {
|
|
1582
|
-
|
|
1402
|
+
fs3__default.writeFile(filePath, data, "utf8", (err) => {
|
|
1583
1403
|
if (err) reject(err);
|
|
1584
1404
|
else resolve();
|
|
1585
1405
|
});
|
|
@@ -1632,10 +1452,10 @@ var FileService = class {
|
|
|
1632
1452
|
*/
|
|
1633
1453
|
async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
|
|
1634
1454
|
const __filename = fileURLToPath(import.meta.url);
|
|
1635
|
-
const __dirname =
|
|
1636
|
-
const filePath =
|
|
1637
|
-
const fileString =
|
|
1638
|
-
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) {
|
|
1639
1459
|
console.info(`${outputFilePath} already exists`);
|
|
1640
1460
|
return false;
|
|
1641
1461
|
}
|
|
@@ -1643,14 +1463,14 @@ var FileService = class {
|
|
|
1643
1463
|
return true;
|
|
1644
1464
|
}
|
|
1645
1465
|
async setupEnvFile({ dbUrl }) {
|
|
1646
|
-
const envPath =
|
|
1466
|
+
const envPath = path.join(process.cwd(), ".env.development");
|
|
1647
1467
|
await fsExtra.ensureFile(envPath);
|
|
1648
1468
|
const fileEnvService = new FileEnvService(envPath);
|
|
1649
1469
|
await fileEnvService.setEnvValue("DB_URL", dbUrl);
|
|
1650
1470
|
}
|
|
1651
1471
|
getFirstExistingFile(files) {
|
|
1652
1472
|
for (const f of files) {
|
|
1653
|
-
if (
|
|
1473
|
+
if (fs3__default__default.existsSync(f)) {
|
|
1654
1474
|
return f;
|
|
1655
1475
|
}
|
|
1656
1476
|
}
|
|
@@ -1660,14 +1480,14 @@ var FileService = class {
|
|
|
1660
1480
|
filePath,
|
|
1661
1481
|
replacements
|
|
1662
1482
|
}) {
|
|
1663
|
-
let fileContent =
|
|
1483
|
+
let fileContent = fs3__default__default.readFileSync(filePath, "utf8");
|
|
1664
1484
|
replacements.forEach(({ search, replace }) => {
|
|
1665
1485
|
fileContent = fileContent.replaceAll(search, replace);
|
|
1666
1486
|
});
|
|
1667
|
-
|
|
1487
|
+
fs3__default__default.writeFileSync(filePath, fileContent);
|
|
1668
1488
|
}
|
|
1669
1489
|
};
|
|
1670
|
-
var
|
|
1490
|
+
var exec = util.promisify(child_process.exec);
|
|
1671
1491
|
var getModelIdentifier = (llmProvider) => {
|
|
1672
1492
|
if (llmProvider === "openai") {
|
|
1673
1493
|
return `'openai/gpt-4o-mini'`;
|
|
@@ -1721,8 +1541,8 @@ export const weatherAgent = new Agent({
|
|
|
1721
1541
|
parser: "typescript",
|
|
1722
1542
|
singleQuote: true
|
|
1723
1543
|
});
|
|
1724
|
-
await
|
|
1725
|
-
await
|
|
1544
|
+
await fs4.writeFile(destPath, "");
|
|
1545
|
+
await fs4.writeFile(destPath, formattedContent);
|
|
1726
1546
|
}
|
|
1727
1547
|
async function writeWorkflowSample(destPath) {
|
|
1728
1548
|
const content = `import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
@@ -1915,7 +1735,7 @@ export { weatherWorkflow };`;
|
|
|
1915
1735
|
semi: true,
|
|
1916
1736
|
singleQuote: true
|
|
1917
1737
|
});
|
|
1918
|
-
await
|
|
1738
|
+
await fs4.writeFile(destPath, formattedContent);
|
|
1919
1739
|
}
|
|
1920
1740
|
async function writeToolSample(destPath) {
|
|
1921
1741
|
const fileService = new FileService();
|
|
@@ -1944,15 +1764,15 @@ var writeIndexFile = async ({
|
|
|
1944
1764
|
addWorkflow
|
|
1945
1765
|
}) => {
|
|
1946
1766
|
const indexPath = dirPath + "/index.ts";
|
|
1947
|
-
const destPath =
|
|
1767
|
+
const destPath = path.join(indexPath);
|
|
1948
1768
|
try {
|
|
1949
|
-
await
|
|
1769
|
+
await fs4.writeFile(destPath, "");
|
|
1950
1770
|
const filteredExports = [
|
|
1951
1771
|
addWorkflow ? `workflows: { weatherWorkflow },` : "",
|
|
1952
1772
|
addAgent ? `agents: { weatherAgent },` : ""
|
|
1953
1773
|
].filter(Boolean);
|
|
1954
1774
|
if (!addExample) {
|
|
1955
|
-
await
|
|
1775
|
+
await fs4.writeFile(
|
|
1956
1776
|
destPath,
|
|
1957
1777
|
`
|
|
1958
1778
|
import { Mastra } from '@mastra/core';
|
|
@@ -1962,7 +1782,7 @@ export const mastra = new Mastra()
|
|
|
1962
1782
|
);
|
|
1963
1783
|
return;
|
|
1964
1784
|
}
|
|
1965
|
-
await
|
|
1785
|
+
await fs4.writeFile(
|
|
1966
1786
|
destPath,
|
|
1967
1787
|
`
|
|
1968
1788
|
import { Mastra } from '@mastra/core/mastra';
|
|
@@ -2022,15 +1842,15 @@ var getAPIKey = async (provider) => {
|
|
|
2022
1842
|
var writeAPIKey = async ({ provider, apiKey }) => {
|
|
2023
1843
|
const envFileName = apiKey ? ".env" : ".env.example";
|
|
2024
1844
|
const key = await getAPIKey(provider);
|
|
2025
|
-
const escapedKey =
|
|
2026
|
-
const escapedApiKey =
|
|
2027
|
-
await
|
|
1845
|
+
const escapedKey = shellQuote2.quote([key]);
|
|
1846
|
+
const escapedApiKey = shellQuote2.quote([apiKey ? apiKey : "your-api-key"]);
|
|
1847
|
+
await exec(`echo ${escapedKey}=${escapedApiKey} >> ${envFileName}`);
|
|
2028
1848
|
};
|
|
2029
1849
|
var createMastraDir = async (directory) => {
|
|
2030
1850
|
let dir = directory.trim().split("/").filter((item) => item !== "");
|
|
2031
|
-
const dirPath =
|
|
1851
|
+
const dirPath = path.join(process.cwd(), ...dir, "mastra");
|
|
2032
1852
|
try {
|
|
2033
|
-
await
|
|
1853
|
+
await fs4.access(dirPath);
|
|
2034
1854
|
return { ok: false };
|
|
2035
1855
|
} catch {
|
|
2036
1856
|
await fsExtra.ensureDir(dirPath);
|
|
@@ -2176,13 +1996,193 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
|
|
|
2176
1996
|
);
|
|
2177
1997
|
return mastraProject;
|
|
2178
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
|
+
}
|
|
2179
2179
|
var s = Y();
|
|
2180
2180
|
var init = async ({
|
|
2181
|
-
directory,
|
|
2182
|
-
addExample = false,
|
|
2181
|
+
directory = "src/",
|
|
2183
2182
|
components,
|
|
2184
2183
|
llmProvider = "openai",
|
|
2185
2184
|
llmApiKey,
|
|
2185
|
+
addExample = false,
|
|
2186
2186
|
configureEditorWithDocsMCP
|
|
2187
2187
|
}) => {
|
|
2188
2188
|
s.start("Initializing Mastra");
|
|
@@ -2313,7 +2313,7 @@ var createMastraProject = async ({
|
|
|
2313
2313
|
defaultValue: "my-mastra-app",
|
|
2314
2314
|
validate: (value) => {
|
|
2315
2315
|
if (value.length === 0) return "Project name cannot be empty";
|
|
2316
|
-
if (
|
|
2316
|
+
if (fs3__default__default.existsSync(value)) {
|
|
2317
2317
|
return `A directory named "${value}" already exists. Please choose a different name.`;
|
|
2318
2318
|
}
|
|
2319
2319
|
}
|
|
@@ -2333,7 +2333,7 @@ var createMastraProject = async ({
|
|
|
2333
2333
|
try {
|
|
2334
2334
|
s2.start("Creating project");
|
|
2335
2335
|
try {
|
|
2336
|
-
await
|
|
2336
|
+
await fs4.mkdir(projectName);
|
|
2337
2337
|
} catch (error) {
|
|
2338
2338
|
if (error instanceof Error && "code" in error && error.code === "EEXIST") {
|
|
2339
2339
|
s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
|
|
@@ -2365,7 +2365,7 @@ var createMastraProject = async ({
|
|
|
2365
2365
|
s2.stop("Project structure created");
|
|
2366
2366
|
s2.start(`Installing ${pm} dependencies`);
|
|
2367
2367
|
try {
|
|
2368
|
-
await exec3(`${pm} ${installCommand} zod@^
|
|
2368
|
+
await exec3(`${pm} ${installCommand} zod@^4`);
|
|
2369
2369
|
await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
|
|
2370
2370
|
await exec3(`echo '{
|
|
2371
2371
|
"compilerOptions": {
|
|
@@ -2635,7 +2635,7 @@ async function createFromTemplate(args2) {
|
|
|
2635
2635
|
async function getPackageVersion() {
|
|
2636
2636
|
const __filename = fileURLToPath(import.meta.url);
|
|
2637
2637
|
const __dirname = dirname(__filename);
|
|
2638
|
-
const pkgJsonPath =
|
|
2638
|
+
const pkgJsonPath = path.join(__dirname, "..", "package.json");
|
|
2639
2639
|
const content = await fsExtra$1.readJSON(pkgJsonPath);
|
|
2640
2640
|
return content.version;
|
|
2641
2641
|
}
|