mastra 0.10.6-alpha.1 → 0.10.6-alpha.2

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.
@@ -1053,7 +1053,6 @@ var execWithTimeout = async (command, timeoutMs) => {
1053
1053
  throw error;
1054
1054
  }
1055
1055
  } catch (error) {
1056
- console.error(error);
1057
1056
  throw error;
1058
1057
  }
1059
1058
  };
@@ -1065,11 +1064,18 @@ async function installMastraDependency(pm, dependency, versionTag, isDev, timeou
1065
1064
  try {
1066
1065
  await execWithTimeout(`${pm} ${installCommand} ${dependency}${versionTag}`, timeout);
1067
1066
  } catch (err) {
1068
- console.log("err", err);
1069
1067
  if (versionTag === "@latest") {
1070
- throw err;
1068
+ throw new Error(
1069
+ `Failed to install ${dependency}@latest: ${err instanceof Error ? err.message : "Unknown error"}`
1070
+ );
1071
+ }
1072
+ try {
1073
+ await execWithTimeout(`${pm} ${installCommand} ${dependency}@latest`, timeout);
1074
+ } catch (fallbackErr) {
1075
+ throw new Error(
1076
+ `Failed to install ${dependency} (tried ${versionTag} and @latest): ${fallbackErr instanceof Error ? fallbackErr.message : "Unknown error"}`
1077
+ );
1071
1078
  }
1072
- await execWithTimeout(`${pm} ${installCommand} ${dependency}@latest`, timeout);
1073
1079
  }
1074
1080
  }
1075
1081
  var createMastraProject = async ({
@@ -1088,36 +1094,44 @@ var createMastraProject = async ({
1088
1094
  process.exit(0);
1089
1095
  }
1090
1096
  const s2 = p.spinner();
1091
- s2.start("Creating project");
1092
1097
  try {
1093
- await fs4.mkdir(projectName);
1094
- } catch (error) {
1095
- if (error instanceof Error && "code" in error && error.code === "EEXIST") {
1096
- s2.stop(
1097
- `A directory named "${projectName}" already exists. Please choose a different name or delete the existing directory.`
1098
+ s2.start("Creating project");
1099
+ try {
1100
+ await fs4.mkdir(projectName);
1101
+ } catch (error) {
1102
+ if (error instanceof Error && "code" in error && error.code === "EEXIST") {
1103
+ s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
1104
+ process.exit(1);
1105
+ }
1106
+ throw new Error(
1107
+ `Failed to create project directory: ${error instanceof Error ? error.message : "Unknown error"}`
1098
1108
  );
1099
- process.exit(1);
1100
1109
  }
1101
- throw error;
1102
- }
1103
- process.chdir(projectName);
1104
- const pm = getPackageManager();
1105
- const installCommand = getPackageManagerInstallCommand(pm);
1106
- s2.message("Creating project");
1107
- await exec3(`npm init -y`);
1108
- await exec3(`npm pkg set type="module"`);
1109
- await exec3(`npm pkg set engines.node=">=20.9.0"`);
1110
- const depsService = new DepsService();
1111
- await depsService.addScriptsToPackageJson({
1112
- dev: "mastra dev",
1113
- build: "mastra build",
1114
- start: "mastra start"
1115
- });
1116
- s2.stop("Project created");
1117
- s2.start(`Installing ${pm} dependencies`);
1118
- await exec3(`${pm} ${installCommand} zod`);
1119
- await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
1120
- await exec3(`echo '{
1110
+ process.chdir(projectName);
1111
+ const pm = getPackageManager();
1112
+ const installCommand = getPackageManagerInstallCommand(pm);
1113
+ s2.message("Initializing project structure");
1114
+ try {
1115
+ await exec3(`npm init -y`);
1116
+ await exec3(`npm pkg set type="module"`);
1117
+ await exec3(`npm pkg set engines.node=">=20.9.0"`);
1118
+ const depsService = new DepsService();
1119
+ await depsService.addScriptsToPackageJson({
1120
+ dev: "mastra dev",
1121
+ build: "mastra build",
1122
+ start: "mastra start"
1123
+ });
1124
+ } catch (error) {
1125
+ throw new Error(
1126
+ `Failed to initialize project structure: ${error instanceof Error ? error.message : "Unknown error"}`
1127
+ );
1128
+ }
1129
+ s2.stop("Project structure created");
1130
+ s2.start(`Installing ${pm} dependencies`);
1131
+ try {
1132
+ await exec3(`${pm} ${installCommand} zod`);
1133
+ await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
1134
+ await exec3(`echo '{
1121
1135
  "compilerOptions": {
1122
1136
  "target": "ES2022",
1123
1137
  "module": "ES2022",
@@ -1133,29 +1147,54 @@ var createMastraProject = async ({
1133
1147
  "src/**/*"
1134
1148
  ]
1135
1149
  }' > tsconfig.json`);
1136
- s2.stop(`${pm} dependencies installed`);
1137
- s2.start("Installing mastra");
1138
- const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
1139
- await installMastraDependency(pm, "mastra", versionTag, true, timeout);
1140
- s2.stop("mastra installed");
1141
- s2.start("Installing dependencies");
1142
- await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
1143
- await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
1144
- await installMastraDependency(pm, "@mastra/memory", versionTag, false, timeout);
1145
- s2.stop("Dependencies installed");
1146
- s2.start("Adding .gitignore");
1147
- await exec3(`echo output.txt >> .gitignore`);
1148
- await exec3(`echo node_modules >> .gitignore`);
1149
- await exec3(`echo dist >> .gitignore`);
1150
- await exec3(`echo .mastra >> .gitignore`);
1151
- await exec3(`echo .env.development >> .gitignore`);
1152
- await exec3(`echo .env >> .gitignore`);
1153
- await exec3(`echo *.db >> .gitignore`);
1154
- await exec3(`echo *.db-* >> .gitignore`);
1155
- s2.stop(".gitignore added");
1156
- p.outro("Project created successfully");
1157
- console.log("");
1158
- return { projectName };
1150
+ } catch (error) {
1151
+ throw new Error(
1152
+ `Failed to install basic dependencies: ${error instanceof Error ? error.message : "Unknown error"}`
1153
+ );
1154
+ }
1155
+ s2.stop(`${pm} dependencies installed`);
1156
+ s2.start("Installing mastra");
1157
+ const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
1158
+ try {
1159
+ await installMastraDependency(pm, "mastra", versionTag, true, timeout);
1160
+ } catch (error) {
1161
+ throw new Error(`Failed to install Mastra CLI: ${error instanceof Error ? error.message : "Unknown error"}`);
1162
+ }
1163
+ s2.stop("mastra installed");
1164
+ s2.start("Installing dependencies");
1165
+ try {
1166
+ await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
1167
+ await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
1168
+ await installMastraDependency(pm, "@mastra/memory", versionTag, false, timeout);
1169
+ } catch (error) {
1170
+ throw new Error(
1171
+ `Failed to install Mastra dependencies: ${error instanceof Error ? error.message : "Unknown error"}`
1172
+ );
1173
+ }
1174
+ s2.stop("Mastra dependencies installed");
1175
+ s2.start("Adding .gitignore");
1176
+ try {
1177
+ await exec3(`echo output.txt >> .gitignore`);
1178
+ await exec3(`echo node_modules >> .gitignore`);
1179
+ await exec3(`echo dist >> .gitignore`);
1180
+ await exec3(`echo .mastra >> .gitignore`);
1181
+ await exec3(`echo .env.development >> .gitignore`);
1182
+ await exec3(`echo .env >> .gitignore`);
1183
+ await exec3(`echo *.db >> .gitignore`);
1184
+ await exec3(`echo *.db-* >> .gitignore`);
1185
+ } catch (error) {
1186
+ throw new Error(`Failed to create .gitignore: ${error instanceof Error ? error.message : "Unknown error"}`);
1187
+ }
1188
+ s2.stop(".gitignore added");
1189
+ p.outro("Project created successfully");
1190
+ console.log("");
1191
+ return { projectName };
1192
+ } catch (error) {
1193
+ s2.stop();
1194
+ const errorMessage = error instanceof Error ? error.message : "An unexpected error occurred";
1195
+ p.cancel(`Project creation failed: ${errorMessage}`);
1196
+ process.exit(1);
1197
+ }
1159
1198
  };
1160
1199
 
1161
1200
  // src/commands/create/create.ts
@@ -1 +1 @@
1
- export { create } from '../../chunk-DJA4WBIU.js';
1
+ export { create } from '../../chunk-25NEZQOD.js';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #! /usr/bin/env node
2
2
  import { PosthogAnalytics } from './chunk-7OXWUU2Q.js';
3
3
  export { PosthogAnalytics } from './chunk-7OXWUU2Q.js';
4
- import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService } from './chunk-DJA4WBIU.js';
5
- export { create } from './chunk-DJA4WBIU.js';
4
+ import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService } from './chunk-25NEZQOD.js';
5
+ export { create } from './chunk-25NEZQOD.js';
6
6
  import { Command } from 'commander';
7
7
  import { config } from 'dotenv';
8
8
  import { join, dirname } from 'path';
@@ -114,7 +114,7 @@ async function build({
114
114
  const rootDir = root || process.cwd();
115
115
  const mastraDir = dir2 ? dir2.startsWith("/") ? dir2 : join(rootDir, dir2) : join(rootDir, "src", "mastra");
116
116
  const outputDirectory = join(rootDir, ".mastra");
117
- const defaultToolsPath = join(mastraDir, "tools/**/*");
117
+ const defaultToolsPath = join(mastraDir, "tools/**/*.{js,ts}");
118
118
  const discoveredTools = [defaultToolsPath, ...tools ?? []];
119
119
  try {
120
120
  const fs2 = new FileService();
@@ -454,7 +454,7 @@ async function dev({
454
454
  const rootDir = root || process.cwd();
455
455
  const mastraDir = dir2 ? dir2.startsWith("/") ? dir2 : join(process.cwd(), dir2) : join(process.cwd(), "src", "mastra");
456
456
  const dotMastraPath = join(rootDir, ".mastra");
457
- const defaultToolsPath = join(mastraDir, "tools/**/*");
457
+ const defaultToolsPath = join(mastraDir, "tools/**/*.{js,ts}");
458
458
  const discoveredTools = [defaultToolsPath, ...tools || []];
459
459
  const fileService = new FileService$1();
460
460
  const entryFile = fileService.getFirstExistingFile([join(mastraDir, "index.ts"), join(mastraDir, "index.js")]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastra",
3
- "version": "0.10.6-alpha.1",
3
+ "version": "0.10.6-alpha.2",
4
4
  "license": "Elastic-2.0",
5
5
  "description": "cli for mastra",
6
6
  "type": "module",
@@ -58,8 +58,8 @@
58
58
  "yocto-spinner": "^0.1.2",
59
59
  "zod": "^3.25.57",
60
60
  "zod-to-json-schema": "^3.24.5",
61
- "@mastra/deployer": "^0.10.6-alpha.0",
62
61
  "@mastra/loggers": "^0.10.2",
62
+ "@mastra/deployer": "^0.10.6-alpha.1",
63
63
  "@mastra/mcp": "^0.10.4-alpha.0"
64
64
  },
65
65
  "devDependencies": {
@@ -79,9 +79,9 @@
79
79
  "typescript": "^5.8.3",
80
80
  "vitest": "^3.2.3",
81
81
  "@internal/lint": "0.0.12",
82
- "@mastra/client-js": "0.10.5-alpha.0",
83
- "@mastra/core": "0.10.6-alpha.0",
84
- "@mastra/playground-ui": "5.1.6-alpha.0"
82
+ "@mastra/client-js": "0.10.5-alpha.1",
83
+ "@mastra/core": "0.10.6-alpha.1",
84
+ "@mastra/playground-ui": "5.1.6-alpha.1"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@mastra/core": "^0.10.2-alpha.0"