sonance-brand-mcp 1.3.2 → 1.3.3
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 +123 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -463,26 +463,132 @@ function runDevToolsInstaller() {
|
|
|
463
463
|
fs.writeFileSync(path.join(themeDir, "sonance-config.json"), JSON.stringify(initialConfig, null, 2), "utf-8");
|
|
464
464
|
console.log(" ✓ Created src/theme/ with initial files");
|
|
465
465
|
}
|
|
466
|
+
// Detect user's file paths
|
|
467
|
+
const globalsCssPaths = [
|
|
468
|
+
"src/app/globals.css",
|
|
469
|
+
"app/globals.css",
|
|
470
|
+
"src/styles/globals.css",
|
|
471
|
+
"styles/globals.css"
|
|
472
|
+
];
|
|
473
|
+
const layoutPaths = [
|
|
474
|
+
"src/app/layout.tsx",
|
|
475
|
+
"app/layout.tsx",
|
|
476
|
+
"src/app/layout.jsx",
|
|
477
|
+
"app/layout.jsx"
|
|
478
|
+
];
|
|
479
|
+
let detectedGlobalsCss = null;
|
|
480
|
+
let detectedLayout = null;
|
|
481
|
+
for (const cssPath of globalsCssPaths) {
|
|
482
|
+
if (fs.existsSync(path.join(targetDir, cssPath))) {
|
|
483
|
+
detectedGlobalsCss = cssPath;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
for (const layoutPath of layoutPaths) {
|
|
488
|
+
if (fs.existsSync(path.join(targetDir, layoutPath))) {
|
|
489
|
+
detectedLayout = layoutPath;
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// Track what was auto-configured vs needs manual setup
|
|
494
|
+
let cssAutoConfigured = false;
|
|
495
|
+
let layoutAutoConfigured = false;
|
|
496
|
+
const manualSteps = [];
|
|
497
|
+
// --- Auto-inject CSS imports into globals.css ---
|
|
498
|
+
if (detectedGlobalsCss) {
|
|
499
|
+
const globalsFullPath = path.join(targetDir, detectedGlobalsCss);
|
|
500
|
+
try {
|
|
501
|
+
let cssContent = fs.readFileSync(globalsFullPath, "utf-8");
|
|
502
|
+
const import1 = '@import "../styles/brand-overrides.css";';
|
|
503
|
+
const import2 = '@import "../theme/sonance-theme.css";';
|
|
504
|
+
// Prepend imports if not already present
|
|
505
|
+
const newImports = [];
|
|
506
|
+
if (!cssContent.includes("brand-overrides.css"))
|
|
507
|
+
newImports.push(import1);
|
|
508
|
+
if (!cssContent.includes("sonance-theme.css"))
|
|
509
|
+
newImports.push(import2);
|
|
510
|
+
if (newImports.length > 0) {
|
|
511
|
+
cssContent = newImports.join("\n") + "\n" + cssContent;
|
|
512
|
+
fs.writeFileSync(globalsFullPath, cssContent, "utf-8");
|
|
513
|
+
}
|
|
514
|
+
cssAutoConfigured = true;
|
|
515
|
+
}
|
|
516
|
+
catch (err) {
|
|
517
|
+
manualSteps.push(`Could not modify ${detectedGlobalsCss} - add CSS imports manually`);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
manualSteps.push("globals.css not found - create it and add:\n @import \"../styles/brand-overrides.css\";\n @import \"../theme/sonance-theme.css\";");
|
|
522
|
+
}
|
|
523
|
+
// --- Auto-inject into layout file ---
|
|
524
|
+
if (detectedLayout) {
|
|
525
|
+
const layoutFullPath = path.join(targetDir, detectedLayout);
|
|
526
|
+
try {
|
|
527
|
+
let layoutContent = fs.readFileSync(layoutFullPath, "utf-8");
|
|
528
|
+
let modified = false;
|
|
529
|
+
// Add import if not present
|
|
530
|
+
if (!layoutContent.includes("SonanceDevTools")) {
|
|
531
|
+
const importMatch = layoutContent.match(/^import .+$/gm);
|
|
532
|
+
if (importMatch && importMatch.length > 0) {
|
|
533
|
+
const lastImport = importMatch[importMatch.length - 1];
|
|
534
|
+
layoutContent = layoutContent.replace(lastImport, `${lastImport}\nimport { SonanceDevTools } from '@/components/dev-tools';`);
|
|
535
|
+
modified = true;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
// No imports found, add at the top
|
|
539
|
+
layoutContent = `import { SonanceDevTools } from '@/components/dev-tools';\n${layoutContent}`;
|
|
540
|
+
modified = true;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
// Add component before </body> if not present
|
|
544
|
+
if (!layoutContent.includes("<SonanceDevTools")) {
|
|
545
|
+
if (layoutContent.includes("</body>")) {
|
|
546
|
+
layoutContent = layoutContent.replace(/<\/body>/, ` {process.env.NODE_ENV === 'development' && <SonanceDevTools />}\n </body>`);
|
|
547
|
+
modified = true;
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
manualSteps.push("Could not find </body> tag - add DevTools component manually");
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (modified) {
|
|
554
|
+
fs.writeFileSync(layoutFullPath, layoutContent, "utf-8");
|
|
555
|
+
}
|
|
556
|
+
// Check if layout was fully configured
|
|
557
|
+
layoutAutoConfigured = layoutContent.includes("SonanceDevTools") && layoutContent.includes("<SonanceDevTools");
|
|
558
|
+
}
|
|
559
|
+
catch (err) {
|
|
560
|
+
manualSteps.push(`Could not modify ${detectedLayout} - add DevTools import and component manually`);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
manualSteps.push("layout.tsx not found - add to your layout:\n import { SonanceDevTools } from '@/components/dev-tools';\n {process.env.NODE_ENV === 'development' && <SonanceDevTools />}");
|
|
565
|
+
}
|
|
566
|
+
// --- Output results ---
|
|
466
567
|
console.log("");
|
|
467
568
|
console.log(" ✅ Sonance DevTools installed successfully!");
|
|
468
569
|
console.log("");
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
570
|
+
if (cssAutoConfigured) {
|
|
571
|
+
console.log(` ✓ Auto-configured ${detectedGlobalsCss}`);
|
|
572
|
+
}
|
|
573
|
+
if (layoutAutoConfigured) {
|
|
574
|
+
console.log(` ✓ Auto-configured ${detectedLayout}`);
|
|
575
|
+
}
|
|
576
|
+
if (manualSteps.length > 0) {
|
|
577
|
+
console.log("");
|
|
578
|
+
console.log(" ⚠️ Some files need manual setup:");
|
|
579
|
+
console.log("");
|
|
580
|
+
manualSteps.forEach((step, i) => {
|
|
581
|
+
console.log(` ${i + 1}. ${step}`);
|
|
582
|
+
console.log("");
|
|
583
|
+
});
|
|
584
|
+
console.log(" ─────────────────────────────────────────────────────────────────────");
|
|
585
|
+
console.log(" After completing the steps above, run your dev server.");
|
|
586
|
+
console.log(" ─────────────────────────────────────────────────────────────────────");
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
console.log("");
|
|
590
|
+
console.log(" 🚀 DONE! Run your dev server and look for the DevTools button.");
|
|
591
|
+
}
|
|
486
592
|
console.log("");
|
|
487
593
|
}
|
|
488
594
|
// Check for install-devtools command
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonance-brand-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "MCP Server for Sonance Brand Guidelines and Component Library - gives Claude instant access to brand colors, typography, and UI components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|