openuispec 0.1.36 → 0.1.37
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/cli/init.ts +27 -33
- package/package.json +1 -1
package/cli/init.ts
CHANGED
|
@@ -471,11 +471,18 @@ export function updateRules(): void {
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
// Ensure MCP server is configured
|
|
474
|
+
configureMcp(cwd, true);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// ── shared MCP config ───────────────────────────────────────────────
|
|
478
|
+
|
|
479
|
+
const EXPECTED_MCP_CONFIG = {
|
|
480
|
+
command: "openuispec",
|
|
481
|
+
args: ["mcp"],
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
function configureMcp(cwd: string, showRestart: boolean, quiet: boolean = false): void {
|
|
474
485
|
const claudeJsonPath = join(cwd, ".claude.json");
|
|
475
|
-
const mcpConfig = {
|
|
476
|
-
command: "npx",
|
|
477
|
-
args: ["openuispec-mcp"],
|
|
478
|
-
};
|
|
479
486
|
|
|
480
487
|
try {
|
|
481
488
|
let claudeJson: Record<string, any> = {};
|
|
@@ -484,15 +491,25 @@ export function updateRules(): void {
|
|
|
484
491
|
} catch {
|
|
485
492
|
// file doesn't exist or isn't valid JSON — start fresh
|
|
486
493
|
}
|
|
494
|
+
|
|
487
495
|
if (!claudeJson.mcpServers) claudeJson.mcpServers = {};
|
|
488
|
-
|
|
489
|
-
|
|
496
|
+
|
|
497
|
+
const existing = claudeJson.mcpServers.openuispec;
|
|
498
|
+
const needsUpdate =
|
|
499
|
+
!existing ||
|
|
500
|
+
existing.command !== EXPECTED_MCP_CONFIG.command ||
|
|
501
|
+
JSON.stringify(existing.args) !== JSON.stringify(EXPECTED_MCP_CONFIG.args);
|
|
502
|
+
|
|
503
|
+
if (needsUpdate) {
|
|
504
|
+
claudeJson.mcpServers.openuispec = { ...EXPECTED_MCP_CONFIG };
|
|
490
505
|
writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2) + "\n");
|
|
491
|
-
console.log(` create .claude.json (MCP server configured)`);
|
|
492
|
-
console.log(`\n Restart Claude Code to activate the MCP server.`);
|
|
506
|
+
if (!quiet) console.log(` ${existing ? "update" : "create"} .claude.json (MCP server configured)`);
|
|
507
|
+
if (showRestart) console.log(`\n Restart Claude Code to activate the MCP server.`);
|
|
508
|
+
} else {
|
|
509
|
+
if (!quiet) console.log(` skip .claude.json (openuispec MCP already configured)`);
|
|
493
510
|
}
|
|
494
511
|
} catch {
|
|
495
|
-
|
|
512
|
+
if (!quiet) console.log(` skip .claude.json (could not configure MCP server)`);
|
|
496
513
|
}
|
|
497
514
|
}
|
|
498
515
|
|
|
@@ -761,30 +778,7 @@ export async function init(argv: string[] = []): Promise<void> {
|
|
|
761
778
|
|
|
762
779
|
// ── MCP server configuration ────────────────────────────────────
|
|
763
780
|
|
|
764
|
-
|
|
765
|
-
const mcpConfig = {
|
|
766
|
-
command: "openuispec",
|
|
767
|
-
args: ["mcp"],
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
try {
|
|
771
|
-
let claudeJson: Record<string, any> = {};
|
|
772
|
-
try {
|
|
773
|
-
claudeJson = JSON.parse(readFileSync(claudeJsonPath, "utf-8"));
|
|
774
|
-
} catch {
|
|
775
|
-
// file doesn't exist or isn't valid JSON — start fresh
|
|
776
|
-
}
|
|
777
|
-
if (!claudeJson.mcpServers) claudeJson.mcpServers = {};
|
|
778
|
-
if (!claudeJson.mcpServers.openuispec) {
|
|
779
|
-
claudeJson.mcpServers.openuispec = mcpConfig;
|
|
780
|
-
writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2) + "\n");
|
|
781
|
-
if (!quiet) console.log(` create .claude.json (MCP server configured)`);
|
|
782
|
-
} else {
|
|
783
|
-
if (!quiet) console.log(` skip .claude.json (openuispec MCP already configured)`);
|
|
784
|
-
}
|
|
785
|
-
} catch {
|
|
786
|
-
if (!quiet) console.log(` skip .claude.json (could not configure MCP server)`);
|
|
787
|
-
}
|
|
781
|
+
configureMcp(cwd, false, quiet);
|
|
788
782
|
|
|
789
783
|
if (answers.configureTargets) {
|
|
790
784
|
if (!quiet) console.log("\nConfiguring target stacks...\n");
|