create-mastra 0.15.0 → 0.15.1-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 +8 -0
- package/dist/index.js +67 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# create-mastra
|
|
2
2
|
|
|
3
|
+
## 0.15.1-alpha.1
|
|
4
|
+
|
|
5
|
+
## 0.15.1-alpha.0
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Improve the overall flow of the `create-mastra` CLI by first asking all questions and then creating the project structure. If you skip entering an API key during the wizard, the `your-api-key` placeholder will now be added to an `.env.example` file instead of `.env`. ([#8603](https://github.com/mastra-ai/mastra/pull/8603))
|
|
10
|
+
|
|
3
11
|
## 0.15.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -2005,13 +2005,21 @@ ${addAgent ? `import { weatherAgent } from './agents/weather-agent';` : ""}
|
|
|
2005
2005
|
export const mastra = new Mastra({
|
|
2006
2006
|
${filteredExports.join("\n ")}
|
|
2007
2007
|
storage: new LibSQLStore({
|
|
2008
|
-
// stores
|
|
2008
|
+
// stores observability, scores, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
2009
2009
|
url: ":memory:",
|
|
2010
2010
|
}),
|
|
2011
2011
|
logger: new PinoLogger({
|
|
2012
2012
|
name: 'Mastra',
|
|
2013
2013
|
level: 'info',
|
|
2014
2014
|
}),
|
|
2015
|
+
telemetry: {
|
|
2016
|
+
// Telemetry is deprecated and will be removed in the Nov 4th release
|
|
2017
|
+
enabled: false,
|
|
2018
|
+
},
|
|
2019
|
+
observability: {
|
|
2020
|
+
// Enables DefaultExporter and CloudExporter for AI tracing
|
|
2021
|
+
default: { enabled: true },
|
|
2022
|
+
},
|
|
2015
2023
|
});
|
|
2016
2024
|
`
|
|
2017
2025
|
);
|
|
@@ -2042,14 +2050,12 @@ var getAPIKey = async (provider) => {
|
|
|
2042
2050
|
return key;
|
|
2043
2051
|
}
|
|
2044
2052
|
};
|
|
2045
|
-
var writeAPIKey = async ({
|
|
2046
|
-
|
|
2047
|
-
apiKey = "your-api-key"
|
|
2048
|
-
}) => {
|
|
2053
|
+
var writeAPIKey = async ({ provider, apiKey }) => {
|
|
2054
|
+
const envFileName = apiKey ? ".env" : ".env.example";
|
|
2049
2055
|
const key = await getAPIKey(provider);
|
|
2050
2056
|
const escapedKey = shellQuote.quote([key]);
|
|
2051
|
-
const escapedApiKey = shellQuote.quote([apiKey]);
|
|
2052
|
-
await exec2(`echo ${escapedKey}=${escapedApiKey} >>
|
|
2057
|
+
const escapedApiKey = shellQuote.quote([apiKey ? apiKey : "your-api-key"]);
|
|
2058
|
+
await exec2(`echo ${escapedKey}=${escapedApiKey} >> ${envFileName}`);
|
|
2053
2059
|
};
|
|
2054
2060
|
var createMastraDir = async (directory) => {
|
|
2055
2061
|
let dir = directory.trim().split("/").filter((item) => item !== "");
|
|
@@ -2070,8 +2076,19 @@ var writeCodeSample = async (dirPath, component, llmProvider, importComponents)
|
|
|
2070
2076
|
throw err;
|
|
2071
2077
|
}
|
|
2072
2078
|
};
|
|
2073
|
-
var
|
|
2074
|
-
|
|
2079
|
+
var LLM_PROVIDERS = [
|
|
2080
|
+
{ value: "openai", label: "OpenAI", hint: "recommended" },
|
|
2081
|
+
{ value: "anthropic", label: "Anthropic" },
|
|
2082
|
+
{ value: "groq", label: "Groq" },
|
|
2083
|
+
{ value: "google", label: "Google" },
|
|
2084
|
+
{ value: "cerebras", label: "Cerebras" },
|
|
2085
|
+
{ value: "mistral", label: "Mistral" }
|
|
2086
|
+
];
|
|
2087
|
+
var interactivePrompt = async (args2 = {}) => {
|
|
2088
|
+
const { skip = {}, options: { showBanner = true } = {} } = args2;
|
|
2089
|
+
if (showBanner) {
|
|
2090
|
+
Ie(color2.inverse(" Mastra Init "));
|
|
2091
|
+
}
|
|
2075
2092
|
const mastraProject = await Ce(
|
|
2076
2093
|
{
|
|
2077
2094
|
directory: () => he({
|
|
@@ -2079,20 +2096,15 @@ var interactivePrompt = async () => {
|
|
|
2079
2096
|
placeholder: "src/",
|
|
2080
2097
|
defaultValue: "src/"
|
|
2081
2098
|
}),
|
|
2082
|
-
llmProvider: () => ve({
|
|
2083
|
-
message: "Select default provider:",
|
|
2084
|
-
options:
|
|
2085
|
-
{ value: "openai", label: "OpenAI", hint: "recommended" },
|
|
2086
|
-
{ value: "anthropic", label: "Anthropic" },
|
|
2087
|
-
{ value: "groq", label: "Groq" },
|
|
2088
|
-
{ value: "google", label: "Google" },
|
|
2089
|
-
{ value: "cerebras", label: "Cerebras" },
|
|
2090
|
-
{ value: "mistral", label: "Mistral" }
|
|
2091
|
-
]
|
|
2099
|
+
llmProvider: () => skip?.llmProvider ? void 0 : ve({
|
|
2100
|
+
message: "Select a default provider:",
|
|
2101
|
+
options: LLM_PROVIDERS
|
|
2092
2102
|
}),
|
|
2093
2103
|
llmApiKey: async ({ results: { llmProvider } }) => {
|
|
2104
|
+
if (skip?.llmApiKey) return void 0;
|
|
2105
|
+
const llmName = LLM_PROVIDERS.find((p6) => p6.value === llmProvider)?.label || "provider";
|
|
2094
2106
|
const keyChoice = await ve({
|
|
2095
|
-
message: `Enter your ${
|
|
2107
|
+
message: `Enter your ${llmName} API key?`,
|
|
2096
2108
|
options: [
|
|
2097
2109
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
2098
2110
|
{ value: "enter", label: "Enter API key" }
|
|
@@ -2102,7 +2114,10 @@ var interactivePrompt = async () => {
|
|
|
2102
2114
|
if (keyChoice === "enter") {
|
|
2103
2115
|
return he({
|
|
2104
2116
|
message: "Enter your API key:",
|
|
2105
|
-
placeholder: "sk-..."
|
|
2117
|
+
placeholder: "sk-...",
|
|
2118
|
+
validate: (value) => {
|
|
2119
|
+
if (value.length === 0) return "API key cannot be empty";
|
|
2120
|
+
}
|
|
2106
2121
|
});
|
|
2107
2122
|
}
|
|
2108
2123
|
return void 0;
|
|
@@ -2112,7 +2127,7 @@ var interactivePrompt = async () => {
|
|
|
2112
2127
|
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
2113
2128
|
const vscodeIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`vscode`);
|
|
2114
2129
|
const editor = await ve({
|
|
2115
|
-
message: `Make your
|
|
2130
|
+
message: `Make your IDE into a Mastra expert? (Installs Mastra's MCP server)`,
|
|
2116
2131
|
options: [
|
|
2117
2132
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
2118
2133
|
{
|
|
@@ -2324,18 +2339,34 @@ async function installMastraDependency(pm, dependency, versionTag, isDev, timeou
|
|
|
2324
2339
|
var createMastraProject = async ({
|
|
2325
2340
|
projectName: name,
|
|
2326
2341
|
createVersionTag,
|
|
2327
|
-
timeout
|
|
2342
|
+
timeout,
|
|
2343
|
+
llmProvider,
|
|
2344
|
+
llmApiKey,
|
|
2345
|
+
needsInteractive
|
|
2328
2346
|
}) => {
|
|
2329
2347
|
Ie(color2.inverse(" Mastra Create "));
|
|
2330
2348
|
const projectName = name ?? await he({
|
|
2331
2349
|
message: "What do you want to name your project?",
|
|
2332
2350
|
placeholder: "my-mastra-app",
|
|
2333
|
-
defaultValue: "my-mastra-app"
|
|
2351
|
+
defaultValue: "my-mastra-app",
|
|
2352
|
+
validate: (value) => {
|
|
2353
|
+
if (value.length === 0) return "Project name cannot be empty";
|
|
2354
|
+
if (fs4__default__default.existsSync(value)) {
|
|
2355
|
+
return `A directory named "${value}" already exists. Please choose a different name.`;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2334
2358
|
});
|
|
2335
2359
|
if (pD(projectName)) {
|
|
2336
2360
|
xe("Operation cancelled");
|
|
2337
2361
|
process.exit(0);
|
|
2338
2362
|
}
|
|
2363
|
+
let result;
|
|
2364
|
+
if (needsInteractive) {
|
|
2365
|
+
result = await interactivePrompt({
|
|
2366
|
+
options: { showBanner: false },
|
|
2367
|
+
skip: { llmProvider: llmProvider !== void 0, llmApiKey: llmApiKey !== void 0 }
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2339
2370
|
const s2 = Y();
|
|
2340
2371
|
try {
|
|
2341
2372
|
s2.start("Creating project");
|
|
@@ -2396,15 +2427,15 @@ var createMastraProject = async ({
|
|
|
2396
2427
|
);
|
|
2397
2428
|
}
|
|
2398
2429
|
s2.stop(`${pm} dependencies installed`);
|
|
2399
|
-
s2.start("Installing
|
|
2430
|
+
s2.start("Installing Mastra CLI");
|
|
2400
2431
|
const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
|
|
2401
2432
|
try {
|
|
2402
2433
|
await installMastraDependency(pm, "mastra", versionTag, true, timeout);
|
|
2403
2434
|
} catch (error) {
|
|
2404
2435
|
throw new Error(`Failed to install Mastra CLI: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2405
2436
|
}
|
|
2406
|
-
s2.stop("
|
|
2407
|
-
s2.start("Installing dependencies");
|
|
2437
|
+
s2.stop("Mastra CLI installed");
|
|
2438
|
+
s2.start("Installing Mastra dependencies");
|
|
2408
2439
|
try {
|
|
2409
2440
|
await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
|
|
2410
2441
|
await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
|
|
@@ -2431,7 +2462,7 @@ var createMastraProject = async ({
|
|
|
2431
2462
|
s2.stop(".gitignore added");
|
|
2432
2463
|
Se("Project created successfully");
|
|
2433
2464
|
console.info("");
|
|
2434
|
-
return { projectName };
|
|
2465
|
+
return { projectName, result };
|
|
2435
2466
|
} catch (error) {
|
|
2436
2467
|
s2.stop();
|
|
2437
2468
|
const errorMessage = error instanceof Error ? error.message : "An unexpected error occurred";
|
|
@@ -2444,14 +2475,17 @@ var create = async (args2) => {
|
|
|
2444
2475
|
await createFromTemplate({ ...args2, injectedAnalytics: args2.analytics });
|
|
2445
2476
|
return;
|
|
2446
2477
|
}
|
|
2447
|
-
const
|
|
2478
|
+
const needsInteractive = args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0;
|
|
2479
|
+
const { projectName, result } = await createMastraProject({
|
|
2448
2480
|
projectName: args2?.projectName,
|
|
2449
2481
|
createVersionTag: args2?.createVersionTag,
|
|
2450
|
-
timeout: args2?.timeout
|
|
2482
|
+
timeout: args2?.timeout,
|
|
2483
|
+
llmProvider: args2?.llmProvider,
|
|
2484
|
+
llmApiKey: args2?.llmApiKey,
|
|
2485
|
+
needsInteractive
|
|
2451
2486
|
});
|
|
2452
2487
|
const directory = args2.directory || "src/";
|
|
2453
|
-
if (
|
|
2454
|
-
const result = await interactivePrompt();
|
|
2488
|
+
if (needsInteractive && result) {
|
|
2455
2489
|
await init({
|
|
2456
2490
|
...result,
|
|
2457
2491
|
llmApiKey: result?.llmApiKey,
|
|
@@ -2701,7 +2735,7 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
|
|
|
2701
2735
|
components: args.components ? args.components.split(",") : [],
|
|
2702
2736
|
llmProvider: args.llm,
|
|
2703
2737
|
addExample: args.example,
|
|
2704
|
-
llmApiKey: args
|
|
2738
|
+
llmApiKey: args.llmApiKey,
|
|
2705
2739
|
createVersionTag,
|
|
2706
2740
|
timeout,
|
|
2707
2741
|
projectName,
|