create-mcp-use-app 0.4.4-canary.1 → 0.4.5-canary.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
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import inquirer from "inquirer";
|
|
7
|
-
import { spawn } from "child_process";
|
|
8
|
-
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
|
|
7
|
+
import { execSync, spawn } from "child_process";
|
|
8
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
9
9
|
import { dirname, join, resolve } from "path";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import ora from "ora";
|
|
@@ -64,6 +64,50 @@ function getInstallCommand(packageManager) {
|
|
|
64
64
|
return "npm install";
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
function isInGitRepository() {
|
|
68
|
+
try {
|
|
69
|
+
execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
|
|
70
|
+
return true;
|
|
71
|
+
} catch (_) {
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
function isDefaultBranchSet() {
|
|
76
|
+
try {
|
|
77
|
+
execSync("git config init.defaultBranch", { stdio: "ignore" });
|
|
78
|
+
return true;
|
|
79
|
+
} catch (_) {
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function tryGitInit(root) {
|
|
84
|
+
let didInit = false;
|
|
85
|
+
try {
|
|
86
|
+
execSync("git --version", { stdio: "ignore" });
|
|
87
|
+
if (isInGitRepository()) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
execSync("git init", { cwd: root, stdio: "ignore" });
|
|
91
|
+
didInit = true;
|
|
92
|
+
if (!isDefaultBranchSet()) {
|
|
93
|
+
execSync("git checkout -b main", { cwd: root, stdio: "ignore" });
|
|
94
|
+
}
|
|
95
|
+
execSync("git add -A", { cwd: root, stdio: "ignore" });
|
|
96
|
+
execSync('git commit -m "Initial commit from create-mcp-use-app"', {
|
|
97
|
+
cwd: root,
|
|
98
|
+
stdio: "ignore"
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
if (didInit) {
|
|
103
|
+
try {
|
|
104
|
+
rmSync(join(root, ".git"), { recursive: true, force: true });
|
|
105
|
+
} catch (_) {
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
67
111
|
var program = new Command();
|
|
68
112
|
function renderLogo() {
|
|
69
113
|
console.log(chalk.cyan("\u259B\u259B\u258C\u259B\u2598\u259B\u258C\u2584\u2596\u258C\u258C\u259B\u2598\u2588\u258C"));
|
|
@@ -122,7 +166,7 @@ function processTemplateFile(filePath, versions, isDevelopment = false, useCanar
|
|
|
122
166
|
}
|
|
123
167
|
return processedContent;
|
|
124
168
|
}
|
|
125
|
-
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").option("--yarn", "Use yarn as package manager").option("--npm", "Use npm as package manager").option("--pnpm", "Use pnpm as package manager").action(async (projectName, options) => {
|
|
169
|
+
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("--no-git", "Skip initializing a git repository").option("--dev", "Use workspace dependencies for development").option("--canary", "Use canary versions of packages").option("--yarn", "Use yarn as package manager").option("--npm", "Use npm as package manager").option("--pnpm", "Use pnpm as package manager").action(async (projectName, options) => {
|
|
126
170
|
try {
|
|
127
171
|
let selectedTemplate = options.template;
|
|
128
172
|
if (!projectName) {
|
|
@@ -235,6 +279,9 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
235
279
|
console.log('\u26A0\uFE0F Please run "npm install", "yarn install", or "pnpm install" manually');
|
|
236
280
|
}
|
|
237
281
|
}
|
|
282
|
+
if (options.git) {
|
|
283
|
+
tryGitInit(projectPath);
|
|
284
|
+
}
|
|
238
285
|
console.log("");
|
|
239
286
|
console.log(chalk.green("\u2705 MCP server created successfully!"));
|
|
240
287
|
if (options.dev) {
|
|
@@ -360,12 +407,21 @@ async function promptForProjectName() {
|
|
|
360
407
|
}
|
|
361
408
|
async function promptForTemplate() {
|
|
362
409
|
const templatesDir = join(__dirname, "templates");
|
|
363
|
-
const availableTemplates =
|
|
364
|
-
const templateDescriptions = {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
410
|
+
const availableTemplates = readdirSync(templatesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name).sort();
|
|
411
|
+
const templateDescriptions = {};
|
|
412
|
+
for (const template2 of availableTemplates) {
|
|
413
|
+
const packageJsonPath = join(templatesDir, template2, "package.json");
|
|
414
|
+
if (existsSync(packageJsonPath)) {
|
|
415
|
+
try {
|
|
416
|
+
const packageJson2 = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
417
|
+
templateDescriptions[template2] = packageJson2.description || "MCP server template";
|
|
418
|
+
} catch (error) {
|
|
419
|
+
templateDescriptions[template2] = "MCP server template";
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
templateDescriptions[template2] = "MCP server template";
|
|
423
|
+
}
|
|
424
|
+
}
|
|
369
425
|
const { template } = await inquirer.prompt([
|
|
370
426
|
{
|
|
371
427
|
type: "list",
|
|
@@ -179,15 +179,17 @@ server.prompt({
|
|
|
179
179
|
{ name: 'code', type: 'string', required: true }
|
|
180
180
|
],
|
|
181
181
|
cb: async (params: Record<string, any>) => {
|
|
182
|
-
const code = params
|
|
182
|
+
const { code } = params
|
|
183
183
|
return {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
text: `Please review this code:\n\n${code}`
|
|
184
|
+
messages: [{
|
|
185
|
+
role: 'user',
|
|
186
|
+
content: {type: 'text', text: `Please review this code:\n\n${code}`}
|
|
187
187
|
}]
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
})
|
|
191
191
|
|
|
192
|
+
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3000
|
|
193
|
+
console.log(`Server running on port ${PORT}`)
|
|
192
194
|
// Start the server
|
|
193
|
-
server.listen(
|
|
195
|
+
server.listen(PORT)
|