create-mastra 0.18.2 → 0.18.3
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 +12 -0
- package/dist/index.js +60 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# create-mastra
|
|
2
2
|
|
|
3
|
+
## 0.18.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: detect bun runtime and cleanup on failure ([#10307](https://github.com/mastra-ai/mastra/pull/10307))
|
|
8
|
+
|
|
9
|
+
## 0.18.3-alpha.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix: detect bun runtime and cleanup on failure ([#10307](https://github.com/mastra-ai/mastra/pull/10307))
|
|
14
|
+
|
|
3
15
|
## 0.18.2
|
|
4
16
|
|
|
5
17
|
## 0.18.2-alpha.0
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,12 @@ import os from 'node:os';
|
|
|
7
7
|
import path, { dirname } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
import { PostHog } from 'posthog-node';
|
|
10
|
+
import fs4 from 'node:fs/promises';
|
|
10
11
|
import util, { stripVTControlCharacters } from 'node:util';
|
|
11
12
|
import y$1, { stdout, stdin } from 'node:process';
|
|
12
13
|
import * as g from 'node:readline';
|
|
13
14
|
import g__default from 'node:readline';
|
|
14
15
|
import { Writable } from 'node:stream';
|
|
15
|
-
import fs4 from 'node:fs/promises';
|
|
16
16
|
import child_process from 'node:child_process';
|
|
17
17
|
import tty from 'node:tty';
|
|
18
18
|
import fsExtra, { readJSON, ensureFile, writeJSON } from 'fs-extra/esm';
|
|
@@ -2123,6 +2123,9 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
|
|
|
2123
2123
|
function getPackageManager() {
|
|
2124
2124
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
2125
2125
|
const execPath = process.env.npm_execpath || "";
|
|
2126
|
+
if (userAgent.includes("bun")) {
|
|
2127
|
+
return "bun";
|
|
2128
|
+
}
|
|
2126
2129
|
if (userAgent.includes("yarn")) {
|
|
2127
2130
|
return "yarn";
|
|
2128
2131
|
}
|
|
@@ -2132,6 +2135,9 @@ function getPackageManager() {
|
|
|
2132
2135
|
if (userAgent.includes("npm")) {
|
|
2133
2136
|
return "npm";
|
|
2134
2137
|
}
|
|
2138
|
+
if (execPath.includes("bun")) {
|
|
2139
|
+
return "bun";
|
|
2140
|
+
}
|
|
2135
2141
|
if (execPath.includes("yarn")) {
|
|
2136
2142
|
return "yarn";
|
|
2137
2143
|
}
|
|
@@ -2405,6 +2411,32 @@ var execWithTimeout = async (command, timeoutMs) => {
|
|
|
2405
2411
|
throw error;
|
|
2406
2412
|
}
|
|
2407
2413
|
};
|
|
2414
|
+
async function getInitCommand(pm) {
|
|
2415
|
+
switch (pm) {
|
|
2416
|
+
case "npm":
|
|
2417
|
+
return "npm init -y";
|
|
2418
|
+
case "pnpm":
|
|
2419
|
+
return "pnpm init";
|
|
2420
|
+
case "yarn":
|
|
2421
|
+
return "yarn init -y";
|
|
2422
|
+
case "bun":
|
|
2423
|
+
return "bun init -y";
|
|
2424
|
+
default:
|
|
2425
|
+
return "npm init -y";
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
async function initializePackageJson(pm) {
|
|
2429
|
+
const initCommand = await getInitCommand(pm);
|
|
2430
|
+
await exec3(initCommand);
|
|
2431
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
2432
|
+
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf-8"));
|
|
2433
|
+
packageJson.type = "module";
|
|
2434
|
+
packageJson.engines = {
|
|
2435
|
+
...packageJson.engines,
|
|
2436
|
+
node: ">=22.13.0"
|
|
2437
|
+
};
|
|
2438
|
+
await fs4.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
2439
|
+
}
|
|
2408
2440
|
async function installMastraDependency(pm, dependency, versionTag, isDev, timeout) {
|
|
2409
2441
|
let installCommand = getPackageManagerAddCommand(pm);
|
|
2410
2442
|
if (isDev) {
|
|
@@ -2459,10 +2491,13 @@ var createMastraProject = async ({
|
|
|
2459
2491
|
});
|
|
2460
2492
|
}
|
|
2461
2493
|
const s2 = Y();
|
|
2494
|
+
const originalCwd = process.cwd();
|
|
2495
|
+
let projectPath = null;
|
|
2462
2496
|
try {
|
|
2463
2497
|
s2.start("Creating project");
|
|
2464
2498
|
try {
|
|
2465
2499
|
await fs4.mkdir(projectName);
|
|
2500
|
+
projectPath = path.resolve(originalCwd, projectName);
|
|
2466
2501
|
} catch (error) {
|
|
2467
2502
|
if (error instanceof Error && "code" in error && error.code === "EEXIST") {
|
|
2468
2503
|
s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
|
|
@@ -2477,9 +2512,7 @@ var createMastraProject = async ({
|
|
|
2477
2512
|
const installCommand = getPackageManagerAddCommand(pm);
|
|
2478
2513
|
s2.message("Initializing project structure");
|
|
2479
2514
|
try {
|
|
2480
|
-
await
|
|
2481
|
-
await exec3(`npm pkg set type="module"`);
|
|
2482
|
-
await exec3(`npm pkg set engines.node=">=20.9.0"`);
|
|
2515
|
+
await initializePackageJson(pm);
|
|
2483
2516
|
const depsService = new DepsService();
|
|
2484
2517
|
await depsService.addScriptsToPackageJson({
|
|
2485
2518
|
dev: "mastra dev",
|
|
@@ -2558,6 +2591,16 @@ var createMastraProject = async ({
|
|
|
2558
2591
|
s2.stop();
|
|
2559
2592
|
const errorMessage = error instanceof Error ? error.message : "An unexpected error occurred";
|
|
2560
2593
|
xe(`Project creation failed: ${errorMessage}`);
|
|
2594
|
+
if (projectPath && fs3__default__default.existsSync(projectPath)) {
|
|
2595
|
+
try {
|
|
2596
|
+
process.chdir(originalCwd);
|
|
2597
|
+
await fs4.rm(projectPath, { recursive: true, force: true });
|
|
2598
|
+
} catch (cleanupError) {
|
|
2599
|
+
console.error(
|
|
2600
|
+
`Warning: Failed to clean up project directory: ${cleanupError instanceof Error ? cleanupError.message : "Unknown error"}`
|
|
2601
|
+
);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2561
2604
|
process.exit(1);
|
|
2562
2605
|
}
|
|
2563
2606
|
};
|
|
@@ -2735,6 +2778,7 @@ async function createFromTemplate(args2) {
|
|
|
2735
2778
|
}
|
|
2736
2779
|
projectName = response;
|
|
2737
2780
|
}
|
|
2781
|
+
let projectPath = null;
|
|
2738
2782
|
try {
|
|
2739
2783
|
const analytics = args2.injectedAnalytics || getAnalytics();
|
|
2740
2784
|
if (analytics) {
|
|
@@ -2743,7 +2787,7 @@ async function createFromTemplate(args2) {
|
|
|
2743
2787
|
template_title: selectedTemplate.title
|
|
2744
2788
|
});
|
|
2745
2789
|
}
|
|
2746
|
-
|
|
2790
|
+
projectPath = await cloneTemplate({
|
|
2747
2791
|
template: selectedTemplate,
|
|
2748
2792
|
projectName
|
|
2749
2793
|
});
|
|
@@ -2756,6 +2800,17 @@ async function createFromTemplate(args2) {
|
|
|
2756
2800
|
`);
|
|
2757
2801
|
postCreate({ projectName });
|
|
2758
2802
|
} catch (error) {
|
|
2803
|
+
if (projectPath) {
|
|
2804
|
+
try {
|
|
2805
|
+
if (fs3__default__default.existsSync(projectPath)) {
|
|
2806
|
+
await fs4.rm(projectPath, { recursive: true, force: true });
|
|
2807
|
+
}
|
|
2808
|
+
} catch (cleanupError) {
|
|
2809
|
+
console.error(
|
|
2810
|
+
`Warning: Failed to clean up project directory: ${cleanupError instanceof Error ? cleanupError.message : "Unknown error"}`
|
|
2811
|
+
);
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2759
2814
|
M.error(`Failed to create project from template: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2760
2815
|
throw error;
|
|
2761
2816
|
}
|