create-mcp-use-app 0.4.4 → 0.4.5

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.
Files changed (2) hide show
  1. package/dist/index.js +50 -3
  2. package/package.json +1 -1
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mcp-use-app",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "description": "Create MCP-Use apps with one command",
6
6
  "author": "mcp-use, Inc.",