create-mastra 0.3.2-alpha.1 → 0.3.3-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 +58 -26
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1001,29 +1001,55 @@ function getPackageManagerInstallCommand(pm) {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
1003
|
var args = ["-y", "@mastra/mcp-docs-server@latest"];
|
|
1004
|
-
var
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1004
|
+
var createMcpConfig = (editor) => {
|
|
1005
|
+
if (editor === "vscode") {
|
|
1006
|
+
return {
|
|
1007
|
+
servers: {
|
|
1008
|
+
mastra: process.platform === `win32` ? {
|
|
1009
|
+
command: "cmd",
|
|
1010
|
+
args: ["/c", "npx", ...args],
|
|
1011
|
+
type: "stdio"
|
|
1012
|
+
} : {
|
|
1013
|
+
command: "npx",
|
|
1014
|
+
args,
|
|
1015
|
+
type: "stdio"
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1013
1019
|
}
|
|
1020
|
+
return {
|
|
1021
|
+
mcpServers: {
|
|
1022
|
+
mastra: process.platform === `win32` ? {
|
|
1023
|
+
command: "cmd",
|
|
1024
|
+
args: ["/c", "npx", ...args]
|
|
1025
|
+
} : {
|
|
1026
|
+
command: "npx",
|
|
1027
|
+
args
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1014
1031
|
};
|
|
1015
|
-
function makeConfig(original) {
|
|
1032
|
+
function makeConfig(original, editor) {
|
|
1033
|
+
if (editor === "vscode") {
|
|
1034
|
+
return {
|
|
1035
|
+
...original,
|
|
1036
|
+
servers: {
|
|
1037
|
+
...original?.servers || {},
|
|
1038
|
+
...createMcpConfig(editor).servers
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1016
1042
|
return {
|
|
1017
1043
|
...original,
|
|
1018
1044
|
mcpServers: {
|
|
1019
1045
|
...original?.mcpServers || {},
|
|
1020
|
-
...
|
|
1046
|
+
...createMcpConfig(editor).mcpServers
|
|
1021
1047
|
}
|
|
1022
1048
|
};
|
|
1023
1049
|
}
|
|
1024
|
-
async function writeMergedConfig(configPath) {
|
|
1050
|
+
async function writeMergedConfig(configPath, editor) {
|
|
1025
1051
|
const configExists = existsSync(configPath);
|
|
1026
|
-
const config = makeConfig(configExists ? await readJSON(configPath) : {});
|
|
1052
|
+
const config = makeConfig(configExists ? await readJSON(configPath) : {}, editor);
|
|
1027
1053
|
await ensureFile(configPath);
|
|
1028
1054
|
await writeJSON(configPath, config, {
|
|
1029
1055
|
spaces: 2
|
|
@@ -1031,26 +1057,27 @@ async function writeMergedConfig(configPath) {
|
|
|
1031
1057
|
}
|
|
1032
1058
|
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1033
1059
|
var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
directory
|
|
1037
|
-
}) {
|
|
1060
|
+
path.join(process.cwd(), ".vscode", "mcp.json");
|
|
1061
|
+
async function installMastraDocsMCPServer({ editor, directory }) {
|
|
1038
1062
|
if (editor === `cursor`) {
|
|
1039
|
-
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
|
|
1063
|
+
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
|
|
1064
|
+
}
|
|
1065
|
+
if (editor === `vscode`) {
|
|
1066
|
+
await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
|
|
1040
1067
|
}
|
|
1041
1068
|
if (editor === `cursor-global`) {
|
|
1042
1069
|
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1043
1070
|
if (alreadyInstalled) {
|
|
1044
1071
|
return;
|
|
1045
1072
|
}
|
|
1046
|
-
await writeMergedConfig(cursorGlobalMCPConfigPath);
|
|
1073
|
+
await writeMergedConfig(cursorGlobalMCPConfigPath, "cursor-global");
|
|
1047
1074
|
}
|
|
1048
1075
|
if (editor === `windsurf`) {
|
|
1049
1076
|
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1050
1077
|
if (alreadyInstalled) {
|
|
1051
1078
|
return;
|
|
1052
1079
|
}
|
|
1053
|
-
await writeMergedConfig(windsurfGlobalMCPConfigPath);
|
|
1080
|
+
await writeMergedConfig(windsurfGlobalMCPConfigPath, editor);
|
|
1054
1081
|
}
|
|
1055
1082
|
}
|
|
1056
1083
|
async function globalMCPIsAlreadyInstalled(editor) {
|
|
@@ -1864,6 +1891,7 @@ var createMastraProject = async ({
|
|
|
1864
1891
|
s2.message("Creating project");
|
|
1865
1892
|
await exec3(`npm init -y`);
|
|
1866
1893
|
await exec3(`npm pkg set type="module"`);
|
|
1894
|
+
await exec3(`npm pkg set engines.node=">=20.9.0"`);
|
|
1867
1895
|
const depsService = new DepsService();
|
|
1868
1896
|
await depsService.addScriptsToPackageJson({
|
|
1869
1897
|
dev: "mastra dev",
|
|
@@ -1935,16 +1963,18 @@ var create = async (args2) => {
|
|
|
1935
1963
|
components,
|
|
1936
1964
|
llmProvider,
|
|
1937
1965
|
addExample,
|
|
1938
|
-
llmApiKey
|
|
1966
|
+
llmApiKey,
|
|
1967
|
+
configureEditorWithDocsMCP: args2.mcpServer
|
|
1939
1968
|
});
|
|
1940
1969
|
postCreate({ projectName });
|
|
1941
1970
|
};
|
|
1942
1971
|
var postCreate = ({ projectName }) => {
|
|
1972
|
+
const packageManager = getPackageManager();
|
|
1943
1973
|
ge(`
|
|
1944
1974
|
${color2.green("To start your project:")}
|
|
1945
1975
|
|
|
1946
1976
|
${color2.cyan("cd")} ${projectName}
|
|
1947
|
-
${color2.cyan(
|
|
1977
|
+
${color2.cyan(`${packageManager} run dev`)}
|
|
1948
1978
|
`);
|
|
1949
1979
|
};
|
|
1950
1980
|
|
|
@@ -1989,16 +2019,17 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
|
|
|
1989
2019
|
program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
|
|
1990
2020
|
"-p, --project-name <string>",
|
|
1991
2021
|
"Project name that will be used in package.json and as the project directory name."
|
|
1992
|
-
).option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras)").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").action(async (projectNameArg, args) => {
|
|
2022
|
+
).option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras)").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").option("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)").action(async (projectNameArg, args) => {
|
|
1993
2023
|
const projectName = projectNameArg || args.projectName;
|
|
1994
2024
|
const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
|
|
1995
2025
|
if (args.default) {
|
|
1996
2026
|
await create({
|
|
1997
2027
|
components: ["agents", "tools", "workflows"],
|
|
1998
2028
|
llmProvider: "openai",
|
|
1999
|
-
addExample:
|
|
2029
|
+
addExample: true,
|
|
2000
2030
|
createVersionTag,
|
|
2001
|
-
timeout
|
|
2031
|
+
timeout,
|
|
2032
|
+
mcpServer: args.mcp
|
|
2002
2033
|
});
|
|
2003
2034
|
return;
|
|
2004
2035
|
}
|
|
@@ -2010,7 +2041,8 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
|
|
|
2010
2041
|
createVersionTag,
|
|
2011
2042
|
timeout,
|
|
2012
2043
|
projectName,
|
|
2013
|
-
directory: args.dir
|
|
2044
|
+
directory: args.dir,
|
|
2045
|
+
mcpServer: args.mcp
|
|
2014
2046
|
});
|
|
2015
2047
|
});
|
|
2016
2048
|
program.parse(process.argv);
|