create-catalyst-app 0.1.0-canary.8 → 0.1.0-canary.9
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/package.json +1 -1
- package/scripts/cli.cjs +62 -9
package/package.json
CHANGED
package/scripts/cli.cjs
CHANGED
|
@@ -43,11 +43,6 @@ const program = new Commander.Command()
|
|
|
43
43
|
return
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
if (process.argv.includes("mcp-setup")) {
|
|
47
|
-
execSync(` cd ${projectName} && node node_modules/catalyst-core/mcp_v2/setup.js`, { stdio: "inherit" })
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
|
|
51
46
|
console.log(cyan(`Using create-catalyst-app version ${bold(packageJson.version)}`))
|
|
52
47
|
|
|
53
48
|
// Use options provided through commander or prompt the user
|
|
@@ -123,10 +118,6 @@ const program = new Commander.Command()
|
|
|
123
118
|
})
|
|
124
119
|
}
|
|
125
120
|
|
|
126
|
-
if (mcpSupport) {
|
|
127
|
-
execSync(` cd ${projectName} && node node_modules/catalyst-core/mcp_v2/setup.js`, { stdio: "inherit" })
|
|
128
|
-
}
|
|
129
|
-
|
|
130
121
|
execSync(
|
|
131
122
|
`cd ${projectName} && git add . && git commit -m "initial commit from Create Catalyst App"`,
|
|
132
123
|
{
|
|
@@ -148,6 +139,11 @@ const program = new Commander.Command()
|
|
|
148
139
|
|
|
149
140
|
console.log("\nWe suggest you to begin, by running")
|
|
150
141
|
console.log(` ${cyan("cd")} ${projectName} && ${cyan("npm start")} \n\n`)
|
|
142
|
+
|
|
143
|
+
if (mcpSupport) {
|
|
144
|
+
const newMcpDir = path.join(process.cwd(), projectName, "node_modules/catalyst-core/mcp_v2")
|
|
145
|
+
runMcpSetup(newMcpDir, path.join(process.cwd(), projectName))
|
|
146
|
+
}
|
|
151
147
|
} catch (error) {
|
|
152
148
|
console.error(`Error: ${error.message}`)
|
|
153
149
|
process.exit(1)
|
|
@@ -220,8 +216,65 @@ const program = new Commander.Command()
|
|
|
220
216
|
})
|
|
221
217
|
.allowUnknownOption()
|
|
222
218
|
|
|
219
|
+
program
|
|
220
|
+
.command("catalyst-mcp")
|
|
221
|
+
.description("Set up MCP server in an existing catalyst project")
|
|
222
|
+
.action(() => {
|
|
223
|
+
try {
|
|
224
|
+
const mcpDir = path.join(process.cwd(), "node_modules/catalyst-core/mcp_v2")
|
|
225
|
+
const setupPath = path.join(mcpDir, "setup.js")
|
|
226
|
+
|
|
227
|
+
if (!fs.existsSync(setupPath)) {
|
|
228
|
+
console.log(cyan("mcp_v2 not found in catalyst-core. Downloading from GitHub..."))
|
|
229
|
+
const catalystCoreDir = path.join(process.cwd(), "node_modules/catalyst-core")
|
|
230
|
+
const tarballUrl = "https://github.com/tata1mg/catalyst-core/archive/refs/heads/main.tar.gz"
|
|
231
|
+
const tarballPath = path.join(catalystCoreDir, "_mcp_v2_tarball.tar.gz")
|
|
232
|
+
execSync(`curl -fsSL "${tarballUrl}" -o "${tarballPath}"`, { stdio: "inherit" })
|
|
233
|
+
fs.mkdirSync(mcpDir, { recursive: true })
|
|
234
|
+
execSync(
|
|
235
|
+
`tar -xzf "${tarballPath}" -C "${mcpDir}" --strip-components=2 "catalyst-core-main/mcp_v2"`,
|
|
236
|
+
{ stdio: "inherit" }
|
|
237
|
+
)
|
|
238
|
+
fs.unlinkSync(tarballPath)
|
|
239
|
+
console.log(cyan("mcp_v2 downloaded successfully."))
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
runMcpSetup(mcpDir)
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error(red("An error occurred:"), error.message)
|
|
245
|
+
process.exit(1)
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
|
|
223
249
|
program.parse(process.argv)
|
|
224
250
|
|
|
251
|
+
function runMcpSetup(mcpDir, cwd = process.cwd()) {
|
|
252
|
+
const pkgPath = path.join(mcpDir, "package.json")
|
|
253
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
|
|
254
|
+
pkg.dependencies["better-sqlite3"] = "^12.8.0"
|
|
255
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2))
|
|
256
|
+
|
|
257
|
+
const mcpNodeModules = path.join(mcpDir, "node_modules")
|
|
258
|
+
let needsInstall = !fs.existsSync(mcpNodeModules)
|
|
259
|
+
|
|
260
|
+
if (!needsInstall) {
|
|
261
|
+
try {
|
|
262
|
+
execSync(`node -e "require('better-sqlite3')"`, { cwd: mcpDir, stdio: "pipe" })
|
|
263
|
+
} catch {
|
|
264
|
+
console.log(cyan("Detected incompatible better-sqlite3 build. Reinstalling..."))
|
|
265
|
+
fs.rmSync(mcpNodeModules, { recursive: true, force: true })
|
|
266
|
+
needsInstall = true
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (needsInstall) {
|
|
271
|
+
console.log(cyan("Installing mcp_v2 dependencies..."))
|
|
272
|
+
execSync("npm install", { cwd: mcpDir, stdio: "inherit" })
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
execSync(`node ${path.join(mcpDir, "setup.js")}`, { cwd, stdio: "inherit" })
|
|
276
|
+
}
|
|
277
|
+
|
|
225
278
|
async function promptStateManagement() {
|
|
226
279
|
const response = await prompts({
|
|
227
280
|
type: "select",
|