create-mastra 0.12.3 → 0.13.0-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/CHANGELOG.md +16 -0
- package/dist/index.js +29 -29
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# create-mastra
|
|
2
2
|
|
|
3
|
+
## 0.13.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
|
|
8
|
+
|
|
9
|
+
## 0.12.4-alpha.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix minor playground stuff for observability ([#7765](https://github.com/mastra-ai/mastra/pull/7765))
|
|
14
|
+
|
|
15
|
+
- Handle zod intersections in dynamic form ([#7768](https://github.com/mastra-ai/mastra/pull/7768))
|
|
16
|
+
|
|
17
|
+
- Playground ui -pass runtimeContext to client SDK get methods ([#7767](https://github.com/mastra-ai/mastra/pull/7767))
|
|
18
|
+
|
|
3
19
|
## 0.12.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -12,15 +12,15 @@ 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 fs5 from 'node:fs/promises';
|
|
16
16
|
import child_process from 'node:child_process';
|
|
17
17
|
import tty from 'node:tty';
|
|
18
18
|
import pino from 'pino';
|
|
19
19
|
import pretty from 'pino-pretty';
|
|
20
20
|
import { execa } from 'execa';
|
|
21
|
-
import
|
|
21
|
+
import fsExtra, { readJSON, ensureFile, writeJSON } from 'fs-extra/esm';
|
|
22
22
|
import prettier from 'prettier';
|
|
23
|
-
import fsExtra from 'fs-extra';
|
|
23
|
+
import fsExtra$1 from 'fs-extra';
|
|
24
24
|
|
|
25
25
|
var __filename = fileURLToPath(import.meta.url);
|
|
26
26
|
var __dirname = path3.dirname(__filename);
|
|
@@ -1214,7 +1214,7 @@ async function cloneTemplate(options) {
|
|
|
1214
1214
|
await updatePackageJson(projectPath, projectName);
|
|
1215
1215
|
const envExamplePath = path3.join(projectPath, ".env.example");
|
|
1216
1216
|
if (await fileExists(envExamplePath)) {
|
|
1217
|
-
await
|
|
1217
|
+
await fs5.copyFile(envExamplePath, path3.join(projectPath, ".env"));
|
|
1218
1218
|
}
|
|
1219
1219
|
spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
|
|
1220
1220
|
return projectPath;
|
|
@@ -1225,7 +1225,7 @@ async function cloneTemplate(options) {
|
|
|
1225
1225
|
}
|
|
1226
1226
|
async function directoryExists(dirPath) {
|
|
1227
1227
|
try {
|
|
1228
|
-
const stat = await
|
|
1228
|
+
const stat = await fs5.stat(dirPath);
|
|
1229
1229
|
return stat.isDirectory();
|
|
1230
1230
|
} catch {
|
|
1231
1231
|
return false;
|
|
@@ -1233,14 +1233,14 @@ async function directoryExists(dirPath) {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
async function fileExists(filePath) {
|
|
1235
1235
|
try {
|
|
1236
|
-
const stat = await
|
|
1236
|
+
const stat = await fs5.stat(filePath);
|
|
1237
1237
|
return stat.isFile();
|
|
1238
1238
|
} catch {
|
|
1239
1239
|
return false;
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
1242
1242
|
async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
1243
|
-
await
|
|
1243
|
+
await fs5.mkdir(targetPath, { recursive: true });
|
|
1244
1244
|
try {
|
|
1245
1245
|
const degitRepo = repoUrl.replace("https://github.com/", "");
|
|
1246
1246
|
const degitCommand = shellQuote.quote(["npx", "degit", degitRepo, targetPath]);
|
|
@@ -1255,7 +1255,7 @@ async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
|
1255
1255
|
});
|
|
1256
1256
|
const gitDir = path3.join(targetPath, ".git");
|
|
1257
1257
|
if (await directoryExists(gitDir)) {
|
|
1258
|
-
await
|
|
1258
|
+
await fs5.rm(gitDir, { recursive: true, force: true });
|
|
1259
1259
|
}
|
|
1260
1260
|
} catch (gitError) {
|
|
1261
1261
|
throw new Error(`Failed to clone repository: ${gitError instanceof Error ? gitError.message : "Unknown error"}`);
|
|
@@ -1265,10 +1265,10 @@ async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
|
1265
1265
|
async function updatePackageJson(projectPath, projectName) {
|
|
1266
1266
|
const packageJsonPath = path3.join(projectPath, "package.json");
|
|
1267
1267
|
try {
|
|
1268
|
-
const packageJsonContent = await
|
|
1268
|
+
const packageJsonContent = await fs5.readFile(packageJsonPath, "utf-8");
|
|
1269
1269
|
const packageJson = JSON.parse(packageJsonContent);
|
|
1270
1270
|
packageJson.name = projectName;
|
|
1271
|
-
await
|
|
1271
|
+
await fs5.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
1272
1272
|
} catch (error) {
|
|
1273
1273
|
logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1274
1274
|
}
|
|
@@ -1411,11 +1411,11 @@ var DepsService = class {
|
|
|
1411
1411
|
try {
|
|
1412
1412
|
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1413
1413
|
try {
|
|
1414
|
-
await
|
|
1414
|
+
await fs5.access(packageJsonPath);
|
|
1415
1415
|
} catch {
|
|
1416
1416
|
return "No package.json file found in the current directory";
|
|
1417
1417
|
}
|
|
1418
|
-
const packageJson = JSON.parse(await
|
|
1418
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf-8"));
|
|
1419
1419
|
for (const dependency of dependencies) {
|
|
1420
1420
|
if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
|
|
1421
1421
|
return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
|
|
@@ -1430,7 +1430,7 @@ var DepsService = class {
|
|
|
1430
1430
|
async getProjectName() {
|
|
1431
1431
|
try {
|
|
1432
1432
|
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1433
|
-
const packageJson = await
|
|
1433
|
+
const packageJson = await fs5.readFile(packageJsonPath, "utf-8");
|
|
1434
1434
|
const pkg = JSON.parse(packageJson);
|
|
1435
1435
|
return pkg.name;
|
|
1436
1436
|
} catch (err) {
|
|
@@ -1438,12 +1438,12 @@ var DepsService = class {
|
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
1440
1440
|
async addScriptsToPackageJson(scripts) {
|
|
1441
|
-
const packageJson = JSON.parse(await
|
|
1441
|
+
const packageJson = JSON.parse(await fs5.readFile("package.json", "utf-8"));
|
|
1442
1442
|
packageJson.scripts = {
|
|
1443
1443
|
...packageJson.scripts,
|
|
1444
1444
|
...scripts
|
|
1445
1445
|
};
|
|
1446
|
-
await
|
|
1446
|
+
await fs5.writeFile("package.json", JSON.stringify(packageJson, null, 2));
|
|
1447
1447
|
}
|
|
1448
1448
|
};
|
|
1449
1449
|
var args = ["-y", "@mastra/mcp-docs-server"];
|
|
@@ -1636,12 +1636,12 @@ var FileService = class {
|
|
|
1636
1636
|
console.log(`${outputFilePath} already exists`);
|
|
1637
1637
|
return false;
|
|
1638
1638
|
}
|
|
1639
|
-
await
|
|
1639
|
+
await fsExtra.outputFile(outputFilePath, fileString);
|
|
1640
1640
|
return true;
|
|
1641
1641
|
}
|
|
1642
1642
|
async setupEnvFile({ dbUrl }) {
|
|
1643
1643
|
const envPath = path3.join(process.cwd(), ".env.development");
|
|
1644
|
-
await
|
|
1644
|
+
await fsExtra.ensureFile(envPath);
|
|
1645
1645
|
const fileEnvService = new FileEnvService(envPath);
|
|
1646
1646
|
await fileEnvService.setEnvValue("DB_URL", dbUrl);
|
|
1647
1647
|
}
|
|
@@ -1754,8 +1754,8 @@ export const weatherAgent = new Agent({
|
|
|
1754
1754
|
parser: "typescript",
|
|
1755
1755
|
singleQuote: true
|
|
1756
1756
|
});
|
|
1757
|
-
await
|
|
1758
|
-
await
|
|
1757
|
+
await fs5.writeFile(destPath, "");
|
|
1758
|
+
await fs5.writeFile(destPath, formattedContent);
|
|
1759
1759
|
}
|
|
1760
1760
|
async function writeWorkflowSample(destPath) {
|
|
1761
1761
|
const content = `import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
@@ -1948,7 +1948,7 @@ export { weatherWorkflow };`;
|
|
|
1948
1948
|
semi: true,
|
|
1949
1949
|
singleQuote: true
|
|
1950
1950
|
});
|
|
1951
|
-
await
|
|
1951
|
+
await fs5.writeFile(destPath, formattedContent);
|
|
1952
1952
|
}
|
|
1953
1953
|
async function writeToolSample(destPath) {
|
|
1954
1954
|
const fileService = new FileService();
|
|
@@ -1968,7 +1968,7 @@ async function writeCodeSampleForComponents(llmprovider, component, destPath, im
|
|
|
1968
1968
|
}
|
|
1969
1969
|
var createComponentsDir = async (dirPath, component) => {
|
|
1970
1970
|
const componentPath = dirPath + `/${component}`;
|
|
1971
|
-
await
|
|
1971
|
+
await fsExtra.ensureDir(componentPath);
|
|
1972
1972
|
};
|
|
1973
1973
|
var writeIndexFile = async ({
|
|
1974
1974
|
dirPath,
|
|
@@ -1979,13 +1979,13 @@ var writeIndexFile = async ({
|
|
|
1979
1979
|
const indexPath = dirPath + "/index.ts";
|
|
1980
1980
|
const destPath = path3.join(indexPath);
|
|
1981
1981
|
try {
|
|
1982
|
-
await
|
|
1982
|
+
await fs5.writeFile(destPath, "");
|
|
1983
1983
|
const filteredExports = [
|
|
1984
1984
|
addWorkflow ? `workflows: { weatherWorkflow },` : "",
|
|
1985
1985
|
addAgent ? `agents: { weatherAgent },` : ""
|
|
1986
1986
|
].filter(Boolean);
|
|
1987
1987
|
if (!addExample) {
|
|
1988
|
-
await
|
|
1988
|
+
await fs5.writeFile(
|
|
1989
1989
|
destPath,
|
|
1990
1990
|
`
|
|
1991
1991
|
import { Mastra } from '@mastra/core';
|
|
@@ -1995,7 +1995,7 @@ export const mastra = new Mastra()
|
|
|
1995
1995
|
);
|
|
1996
1996
|
return;
|
|
1997
1997
|
}
|
|
1998
|
-
await
|
|
1998
|
+
await fs5.writeFile(
|
|
1999
1999
|
destPath,
|
|
2000
2000
|
`
|
|
2001
2001
|
import { Mastra } from '@mastra/core/mastra';
|
|
@@ -2057,10 +2057,10 @@ var createMastraDir = async (directory) => {
|
|
|
2057
2057
|
let dir = directory.trim().split("/").filter((item) => item !== "");
|
|
2058
2058
|
const dirPath = path3.join(process.cwd(), ...dir, "mastra");
|
|
2059
2059
|
try {
|
|
2060
|
-
await
|
|
2060
|
+
await fs5.access(dirPath);
|
|
2061
2061
|
return { ok: false };
|
|
2062
2062
|
} catch {
|
|
2063
|
-
await
|
|
2063
|
+
await fsExtra.ensureDir(dirPath);
|
|
2064
2064
|
return { ok: true, dirPath };
|
|
2065
2065
|
}
|
|
2066
2066
|
};
|
|
@@ -2342,7 +2342,7 @@ var createMastraProject = async ({
|
|
|
2342
2342
|
try {
|
|
2343
2343
|
s2.start("Creating project");
|
|
2344
2344
|
try {
|
|
2345
|
-
await
|
|
2345
|
+
await fs5.mkdir(projectName);
|
|
2346
2346
|
} catch (error) {
|
|
2347
2347
|
if (error instanceof Error && "code" in error && error.code === "EEXIST") {
|
|
2348
2348
|
s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
|
|
@@ -2642,13 +2642,13 @@ async function getPackageVersion() {
|
|
|
2642
2642
|
const __filename = fileURLToPath(import.meta.url);
|
|
2643
2643
|
const __dirname = dirname(__filename);
|
|
2644
2644
|
const pkgJsonPath = path3.join(__dirname, "..", "package.json");
|
|
2645
|
-
const content = await fsExtra.readJSON(pkgJsonPath);
|
|
2645
|
+
const content = await fsExtra$1.readJSON(pkgJsonPath);
|
|
2646
2646
|
return content.version;
|
|
2647
2647
|
}
|
|
2648
2648
|
async function getCreateVersionTag() {
|
|
2649
2649
|
try {
|
|
2650
2650
|
const pkgPath = fileURLToPath(import.meta.resolve("create-mastra/package.json"));
|
|
2651
|
-
const json = await fsExtra.readJSON(pkgPath);
|
|
2651
|
+
const json = await fsExtra$1.readJSON(pkgPath);
|
|
2652
2652
|
const { stdout } = await execa("npm", ["dist-tag", "create-mastra"]);
|
|
2653
2653
|
const tagLine = stdout.split("\n").find((distLine) => distLine.endsWith(`: ${json.version}`));
|
|
2654
2654
|
const tag = tagLine ? tagLine.split(":")[0].trim() : "latest";
|