@codebakers/cli 1.0.7 → 1.0.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/dist/index.js +7 -94
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,10 +14,9 @@ import chalk2 from "chalk";
|
|
|
14
14
|
import inquirer from "inquirer";
|
|
15
15
|
import chalk from "chalk";
|
|
16
16
|
import ora from "ora";
|
|
17
|
-
import { writeFile, mkdir
|
|
17
|
+
import { writeFile, mkdir } from "fs/promises";
|
|
18
18
|
import { existsSync } from "fs";
|
|
19
19
|
import { join } from "path";
|
|
20
|
-
import { homedir } from "os";
|
|
21
20
|
|
|
22
21
|
// src/utils/api.ts
|
|
23
22
|
import nodeFetch from "node-fetch";
|
|
@@ -199,30 +198,12 @@ Validation failed: ${validation.error || "Unknown error"}`));
|
|
|
199
198
|
}
|
|
200
199
|
console.log(chalk.bold.green("\n\u{1F389} Setup complete!\n"));
|
|
201
200
|
if (ide === "claude-code") {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
} else {
|
|
209
|
-
console.log(chalk.yellow("\n\u26A0 Could not auto-configure MCP server.\n"));
|
|
210
|
-
console.log(chalk.dim("Please add CodeBakers manually:"));
|
|
211
|
-
console.log(chalk.dim(""));
|
|
212
|
-
console.log(chalk.dim("Option 1 - In Claude Code chat, type:"));
|
|
213
|
-
console.log(chalk.cyan(" /mcp add codebakers npx -y @codebakers/cli serve"));
|
|
214
|
-
console.log(chalk.dim(""));
|
|
215
|
-
console.log(chalk.dim("Option 2 - Create .mcp.json in your project root:"));
|
|
216
|
-
console.log(chalk.cyan(` {
|
|
217
|
-
"mcpServers": {
|
|
218
|
-
"codebakers": {
|
|
219
|
-
"command": "npx",
|
|
220
|
-
"args": ["-y", "@codebakers/cli", "serve"]
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}`));
|
|
224
|
-
console.log(chalk.dim("\nThen restart Claude Code.\n"));
|
|
225
|
-
}
|
|
201
|
+
console.log(chalk.green("\u2713 CodeBakers is ready! Start coding.\n"));
|
|
202
|
+
console.log(chalk.bold("Try it now:"));
|
|
203
|
+
console.log(chalk.cyan(' "Add a contact form to my app"\n'));
|
|
204
|
+
console.log(chalk.dim("What happens:"));
|
|
205
|
+
console.log(chalk.dim(" Your prompt \u2192 CodeBakers patterns \u2192 Production-ready code"));
|
|
206
|
+
console.log(chalk.dim(" with validation, error handling, loading states, and tests.\n"));
|
|
226
207
|
} else if (ide) {
|
|
227
208
|
console.log(chalk.dim(`Pattern file created. Restart ${IDE_CONFIGS[ide].description} to load it.
|
|
228
209
|
`));
|
|
@@ -328,74 +309,6 @@ message: |
|
|
|
328
309
|
${router.split("\n").map((line) => " " + line).join("\n")}
|
|
329
310
|
`;
|
|
330
311
|
}
|
|
331
|
-
async function configureMcpServer() {
|
|
332
|
-
const locations = [
|
|
333
|
-
// Project-level .mcp.json (preferred for portability)
|
|
334
|
-
join(process.cwd(), ".mcp.json"),
|
|
335
|
-
// User-level Claude settings
|
|
336
|
-
join(homedir(), ".claude", "settings.json"),
|
|
337
|
-
// Alternative user-level location
|
|
338
|
-
join(homedir(), ".claude.json")
|
|
339
|
-
];
|
|
340
|
-
const mcpConfig = {
|
|
341
|
-
codebakers: {
|
|
342
|
-
command: "npx",
|
|
343
|
-
args: ["-y", "@codebakers/cli", "serve"]
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
const projectMcpPath = locations[0];
|
|
347
|
-
try {
|
|
348
|
-
let existingConfig = {};
|
|
349
|
-
if (existsSync(projectMcpPath)) {
|
|
350
|
-
try {
|
|
351
|
-
const content = await readFile(projectMcpPath, "utf-8");
|
|
352
|
-
existingConfig = JSON.parse(content);
|
|
353
|
-
} catch {
|
|
354
|
-
existingConfig = {};
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
const newConfig = {
|
|
358
|
-
...existingConfig,
|
|
359
|
-
mcpServers: {
|
|
360
|
-
...existingConfig.mcpServers || {},
|
|
361
|
-
...mcpConfig
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
await writeFile(projectMcpPath, JSON.stringify(newConfig, null, 2), "utf-8");
|
|
365
|
-
console.log(chalk.dim(` Created/updated ${projectMcpPath}`));
|
|
366
|
-
return true;
|
|
367
|
-
} catch (error) {
|
|
368
|
-
}
|
|
369
|
-
for (const settingsPath of locations.slice(1)) {
|
|
370
|
-
try {
|
|
371
|
-
const dir = join(settingsPath, "..");
|
|
372
|
-
if (!existsSync(dir)) {
|
|
373
|
-
await mkdir(dir, { recursive: true });
|
|
374
|
-
}
|
|
375
|
-
let existingConfig = {};
|
|
376
|
-
if (existsSync(settingsPath)) {
|
|
377
|
-
try {
|
|
378
|
-
const content = await readFile(settingsPath, "utf-8");
|
|
379
|
-
existingConfig = JSON.parse(content);
|
|
380
|
-
} catch {
|
|
381
|
-
existingConfig = {};
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
const newConfig = {
|
|
385
|
-
...existingConfig,
|
|
386
|
-
mcpServers: {
|
|
387
|
-
...existingConfig.mcpServers || {},
|
|
388
|
-
...mcpConfig
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
await writeFile(settingsPath, JSON.stringify(newConfig, null, 2), "utf-8");
|
|
392
|
-
console.log(chalk.dim(` Created/updated ${settingsPath}`));
|
|
393
|
-
return true;
|
|
394
|
-
} catch {
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
312
|
|
|
400
313
|
// src/commands/serve.ts
|
|
401
314
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|