create-mastra 0.1.1 → 0.1.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/starter-files/config.ts +28 -0
- package/starter-files/mastra-pg.docker-compose.yaml +15 -0
- package/starter-files/tools.ts +95 -0
- package/starter-files/workflow.ts +183 -0
package/dist/index.js
CHANGED
|
@@ -1348,6 +1348,38 @@ var init = async ({
|
|
|
1348
1348
|
}
|
|
1349
1349
|
};
|
|
1350
1350
|
var exec3 = util.promisify(child_process.exec);
|
|
1351
|
+
var execWithTimeout = async (command, timeoutMs = 18e4) => {
|
|
1352
|
+
try {
|
|
1353
|
+
const promise = exec3(command, { killSignal: "SIGTERM" });
|
|
1354
|
+
let timeoutId;
|
|
1355
|
+
const timeout = new Promise((_, reject) => {
|
|
1356
|
+
timeoutId = setTimeout(() => reject(new Error("Command timed out")), timeoutMs);
|
|
1357
|
+
});
|
|
1358
|
+
try {
|
|
1359
|
+
const result = await Promise.race([promise, timeout]);
|
|
1360
|
+
clearTimeout(timeoutId);
|
|
1361
|
+
return result;
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
clearTimeout(timeoutId);
|
|
1364
|
+
if (error instanceof Error && error.message === "Command timed out") {
|
|
1365
|
+
throw new Error("Something went wrong during installation, please try again.");
|
|
1366
|
+
}
|
|
1367
|
+
throw error;
|
|
1368
|
+
}
|
|
1369
|
+
} catch (error) {
|
|
1370
|
+
console.error(error);
|
|
1371
|
+
throw error;
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
function getPackageManager() {
|
|
1375
|
+
const userAgent = process.env.npm_config_user_agent || `npm`;
|
|
1376
|
+
if (userAgent.includes(`pnpm/`)) {
|
|
1377
|
+
return `pnpm`;
|
|
1378
|
+
} else if (userAgent.includes(`yarn/`)) {
|
|
1379
|
+
return `yarn`;
|
|
1380
|
+
}
|
|
1381
|
+
return `npm`;
|
|
1382
|
+
}
|
|
1351
1383
|
var createMastraProject = async () => {
|
|
1352
1384
|
pe(color2.inverse("Mastra Create"));
|
|
1353
1385
|
const projectName = await ae({
|
|
@@ -1373,6 +1405,7 @@ var createMastraProject = async () => {
|
|
|
1373
1405
|
throw error;
|
|
1374
1406
|
}
|
|
1375
1407
|
process.chdir(projectName);
|
|
1408
|
+
const pm = getPackageManager();
|
|
1376
1409
|
s2.message("Creating project");
|
|
1377
1410
|
await exec3(`npm init -y`);
|
|
1378
1411
|
await exec3(`npm pkg set type="module"`);
|
|
@@ -1381,9 +1414,9 @@ var createMastraProject = async () => {
|
|
|
1381
1414
|
dev: "mastra dev"
|
|
1382
1415
|
});
|
|
1383
1416
|
s2.stop("Project created");
|
|
1384
|
-
s2.start(
|
|
1385
|
-
await exec3(
|
|
1386
|
-
await exec3(
|
|
1417
|
+
s2.start(`Installing ${pm} dependencies`);
|
|
1418
|
+
await exec3(`${pm} i zod`);
|
|
1419
|
+
await exec3(`${pm} i typescript tsx @types/node --save-dev`);
|
|
1387
1420
|
await exec3(`echo '{
|
|
1388
1421
|
"compilerOptions": {
|
|
1389
1422
|
"target": "ES2022",
|
|
@@ -1404,12 +1437,12 @@ var createMastraProject = async () => {
|
|
|
1404
1437
|
".mastra"
|
|
1405
1438
|
]
|
|
1406
1439
|
}' > tsconfig.json`);
|
|
1407
|
-
s2.stop(
|
|
1440
|
+
s2.stop(`${pm} dependencies installed`);
|
|
1408
1441
|
s2.start("Installing mastra");
|
|
1409
|
-
await
|
|
1442
|
+
await execWithTimeout(`${pm} i -D mastra@latest`);
|
|
1410
1443
|
s2.stop("mastra installed");
|
|
1411
1444
|
s2.start("Installing @mastra/core");
|
|
1412
|
-
await
|
|
1445
|
+
await execWithTimeout(`${pm} i @mastra/core@latest`);
|
|
1413
1446
|
s2.stop("@mastra/core installed");
|
|
1414
1447
|
s2.start("Adding .gitignore");
|
|
1415
1448
|
await exec3(`echo output.txt >> .gitignore`);
|