create-mcp-use-app 0.4.3-canary.0 → 0.4.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/dist/index.js +34 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,12 +40,22 @@ function renderLogo() {
|
|
|
40
40
|
var packageJson = JSON.parse(
|
|
41
41
|
readFileSync(join(__dirname, "../package.json"), "utf-8")
|
|
42
42
|
);
|
|
43
|
-
function getCurrentPackageVersions() {
|
|
43
|
+
function getCurrentPackageVersions(isDevelopment = false, useCanary = false) {
|
|
44
44
|
const versions = {};
|
|
45
45
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if (isDevelopment) {
|
|
47
|
+
versions["mcp-use"] = "workspace:*";
|
|
48
|
+
versions["@mcp-use/cli"] = "workspace:*";
|
|
49
|
+
versions["@mcp-use/inspector"] = "workspace:*";
|
|
50
|
+
} else if (useCanary) {
|
|
51
|
+
versions["mcp-use"] = "canary";
|
|
52
|
+
versions["@mcp-use/cli"] = "canary";
|
|
53
|
+
versions["@mcp-use/inspector"] = "canary";
|
|
54
|
+
} else {
|
|
55
|
+
versions["mcp-use"] = "latest";
|
|
56
|
+
versions["@mcp-use/cli"] = "latest";
|
|
57
|
+
versions["@mcp-use/inspector"] = "latest";
|
|
58
|
+
}
|
|
49
59
|
} catch (error) {
|
|
50
60
|
if (process.env.NODE_ENV === "development") {
|
|
51
61
|
console.warn("\u26A0\uFE0F Could not read workspace package versions, using defaults");
|
|
@@ -57,26 +67,29 @@ function getCurrentPackageVersions() {
|
|
|
57
67
|
}
|
|
58
68
|
return versions;
|
|
59
69
|
}
|
|
60
|
-
function processTemplateFile(filePath, versions, isDevelopment = false) {
|
|
70
|
+
function processTemplateFile(filePath, versions, isDevelopment = false, useCanary = false) {
|
|
61
71
|
const content = readFileSync(filePath, "utf-8");
|
|
62
72
|
let processedContent = content;
|
|
63
|
-
for (const [packageName] of Object.entries(versions)) {
|
|
73
|
+
for (const [packageName, version] of Object.entries(versions)) {
|
|
64
74
|
const placeholder = `{{${packageName}_version}}`;
|
|
65
|
-
|
|
66
|
-
processedContent = processedContent.replace(new RegExp(placeholder, "g"), versionPrefix);
|
|
75
|
+
processedContent = processedContent.replace(new RegExp(placeholder, "g"), version);
|
|
67
76
|
}
|
|
68
77
|
if (isDevelopment) {
|
|
69
78
|
processedContent = processedContent.replace(/"mcp-use": "\^[^"]+"/, '"mcp-use": "workspace:*"');
|
|
70
79
|
processedContent = processedContent.replace(/"@mcp-use\/cli": "\^[^"]+"/, '"@mcp-use/cli": "workspace:*"');
|
|
71
80
|
processedContent = processedContent.replace(/"@mcp-use\/inspector": "\^[^"]+"/, '"@mcp-use/inspector": "workspace:*"');
|
|
81
|
+
} else if (useCanary) {
|
|
82
|
+
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "canary"`);
|
|
83
|
+
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "canary"`);
|
|
84
|
+
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "canary"`);
|
|
72
85
|
} else {
|
|
73
|
-
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "
|
|
74
|
-
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "
|
|
75
|
-
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "
|
|
86
|
+
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "${versions["mcp-use"] || "latest"}"`);
|
|
87
|
+
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "${versions["@mcp-use/cli"] || "latest"}"`);
|
|
88
|
+
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "${versions["@mcp-use/inspector"] || "latest"}"`);
|
|
76
89
|
}
|
|
77
90
|
return processedContent;
|
|
78
91
|
}
|
|
79
|
-
program.name("create-mcp-use-app").description("Create a new MCP server project").version(packageJson.version).argument("[project-name]", "Name of the MCP server project").option("-t, --template <template>", "Template to use", "simple").option("--no-install", "Skip installing dependencies").option("--dev", "Use workspace dependencies for development").action(async (projectName, options) => {
|
|
92
|
+
program.name("create-mcp-use-app").description("Create a new MCP server project").version(packageJson.version).argument("[project-name]", "Name of the MCP server project").option("-t, --template <template>", "Template to use", "simple").option("--no-install", "Skip installing dependencies").option("--dev", "Use workspace dependencies for development").option("--canary", "Use canary versions of packages").action(async (projectName, options) => {
|
|
80
93
|
try {
|
|
81
94
|
let selectedTemplate = options.template;
|
|
82
95
|
if (!projectName) {
|
|
@@ -114,8 +127,8 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
114
127
|
}
|
|
115
128
|
mkdirSync(projectPath, { recursive: true });
|
|
116
129
|
const validatedTemplate = validateTemplateName(selectedTemplate);
|
|
117
|
-
const versions = getCurrentPackageVersions();
|
|
118
|
-
await copyTemplate(projectPath, validatedTemplate, versions, options.dev);
|
|
130
|
+
const versions = getCurrentPackageVersions(options.dev, options.canary);
|
|
131
|
+
await copyTemplate(projectPath, validatedTemplate, versions, options.dev, options.canary);
|
|
119
132
|
updatePackageJson(projectPath, sanitizedProjectName);
|
|
120
133
|
if (options.install) {
|
|
121
134
|
const spinner = ora("Installing packages...").start();
|
|
@@ -137,6 +150,8 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
137
150
|
console.log(chalk.green("\u2705 MCP server created successfully!"));
|
|
138
151
|
if (options.dev) {
|
|
139
152
|
console.log(chalk.yellow("\u{1F527} Development mode: Using workspace dependencies"));
|
|
153
|
+
} else if (options.canary) {
|
|
154
|
+
console.log(chalk.blue("\u{1F680} Canary mode: Using canary versions of packages"));
|
|
140
155
|
}
|
|
141
156
|
console.log("");
|
|
142
157
|
console.log(chalk.bold("\u{1F4C1} Project structure:"));
|
|
@@ -188,7 +203,7 @@ function validateTemplateName(template) {
|
|
|
188
203
|
}
|
|
189
204
|
return sanitized;
|
|
190
205
|
}
|
|
191
|
-
async function copyTemplate(projectPath, template, versions, isDevelopment = false) {
|
|
206
|
+
async function copyTemplate(projectPath, template, versions, isDevelopment = false, useCanary = false) {
|
|
192
207
|
const templatePath = join(__dirname, "templates", template);
|
|
193
208
|
if (!existsSync(templatePath)) {
|
|
194
209
|
console.error(chalk.red(`\u274C Template "${template}" not found!`));
|
|
@@ -203,19 +218,19 @@ async function copyTemplate(projectPath, template, versions, isDevelopment = fal
|
|
|
203
218
|
console.log('\u{1F4A1} Tip: Use "uiresource" template for UI resources and advanced server examples');
|
|
204
219
|
process.exit(1);
|
|
205
220
|
}
|
|
206
|
-
copyDirectoryWithProcessing(templatePath, projectPath, versions, isDevelopment);
|
|
221
|
+
copyDirectoryWithProcessing(templatePath, projectPath, versions, isDevelopment, useCanary);
|
|
207
222
|
}
|
|
208
|
-
function copyDirectoryWithProcessing(src, dest, versions, isDevelopment) {
|
|
223
|
+
function copyDirectoryWithProcessing(src, dest, versions, isDevelopment, useCanary = false) {
|
|
209
224
|
const entries = readdirSync(src, { withFileTypes: true });
|
|
210
225
|
for (const entry of entries) {
|
|
211
226
|
const srcPath = join(src, entry.name);
|
|
212
227
|
const destPath = join(dest, entry.name);
|
|
213
228
|
if (entry.isDirectory()) {
|
|
214
229
|
mkdirSync(destPath, { recursive: true });
|
|
215
|
-
copyDirectoryWithProcessing(srcPath, destPath, versions, isDevelopment);
|
|
230
|
+
copyDirectoryWithProcessing(srcPath, destPath, versions, isDevelopment, useCanary);
|
|
216
231
|
} else {
|
|
217
232
|
if (entry.name === "package.json" || entry.name.endsWith(".json")) {
|
|
218
|
-
const processedContent = processTemplateFile(srcPath, versions, isDevelopment);
|
|
233
|
+
const processedContent = processTemplateFile(srcPath, versions, isDevelopment, useCanary);
|
|
219
234
|
writeFileSync(destPath, processedContent);
|
|
220
235
|
} else {
|
|
221
236
|
copyFileSync(srcPath, destPath);
|