sonance-brand-mcp 1.3.3 → 1.3.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.
- package/dist/index.js +150 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -274,6 +274,20 @@ const BUNDLED_ASSETS = path.join(__dirname, "assets");
|
|
|
274
274
|
const IS_BUNDLED = fs.existsSync(BUNDLED_ASSETS);
|
|
275
275
|
// Development paths (when running from source)
|
|
276
276
|
const DEV_PROJECT_ROOT = path.resolve(__dirname, "../..");
|
|
277
|
+
/**
|
|
278
|
+
* Calculate relative path from one file to another for CSS imports
|
|
279
|
+
*/
|
|
280
|
+
function getRelativeImportPath(fromFile, toFile) {
|
|
281
|
+
const fromDir = path.dirname(fromFile);
|
|
282
|
+
let relativePath = path.relative(fromDir, toFile);
|
|
283
|
+
// Ensure forward slashes for CSS imports (Windows compatibility)
|
|
284
|
+
relativePath = relativePath.replace(/\\/g, '/');
|
|
285
|
+
// CSS imports need ./ prefix for same-level or relative paths
|
|
286
|
+
if (!relativePath.startsWith('.')) {
|
|
287
|
+
relativePath = './' + relativePath;
|
|
288
|
+
}
|
|
289
|
+
return relativePath;
|
|
290
|
+
}
|
|
277
291
|
/**
|
|
278
292
|
* Run the installer for DevTools Plugin (copies files to user project)
|
|
279
293
|
*/
|
|
@@ -499,8 +513,11 @@ function runDevToolsInstaller() {
|
|
|
499
513
|
const globalsFullPath = path.join(targetDir, detectedGlobalsCss);
|
|
500
514
|
try {
|
|
501
515
|
let cssContent = fs.readFileSync(globalsFullPath, "utf-8");
|
|
502
|
-
|
|
503
|
-
const
|
|
516
|
+
// Calculate correct relative paths from globals.css to the target files
|
|
517
|
+
const stylesTarget = path.join(targetDir, "src/styles/brand-overrides.css");
|
|
518
|
+
const themeTarget = path.join(targetDir, "src/theme/sonance-theme.css");
|
|
519
|
+
const import1 = `@import "${getRelativeImportPath(globalsFullPath, stylesTarget)}";`;
|
|
520
|
+
const import2 = `@import "${getRelativeImportPath(globalsFullPath, themeTarget)}";`;
|
|
504
521
|
// Prepend imports if not already present
|
|
505
522
|
const newImports = [];
|
|
506
523
|
if (!cssContent.includes("brand-overrides.css"))
|
|
@@ -518,7 +535,7 @@ function runDevToolsInstaller() {
|
|
|
518
535
|
}
|
|
519
536
|
}
|
|
520
537
|
else {
|
|
521
|
-
manualSteps.push("globals.css not found -
|
|
538
|
+
manualSteps.push("globals.css not found - add these imports to your main CSS file:\n @import \"[path-to]/src/styles/brand-overrides.css\";\n @import \"[path-to]/src/theme/sonance-theme.css\";\n (adjust the path based on your CSS file location)");
|
|
522
539
|
}
|
|
523
540
|
// --- Auto-inject into layout file ---
|
|
524
541
|
if (detectedLayout) {
|
|
@@ -591,11 +608,141 @@ function runDevToolsInstaller() {
|
|
|
591
608
|
}
|
|
592
609
|
console.log("");
|
|
593
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* Run the uninstaller for DevTools Plugin (removes files and imports)
|
|
613
|
+
*/
|
|
614
|
+
function runDevToolsUninstaller() {
|
|
615
|
+
console.log("");
|
|
616
|
+
console.log(" ┌─────────────────────────────────────────────────┐");
|
|
617
|
+
console.log(" │ │");
|
|
618
|
+
console.log(" │ 🧹 Sonance DevTools - Uninstaller │");
|
|
619
|
+
console.log(" │ │");
|
|
620
|
+
console.log(" └─────────────────────────────────────────────────┘");
|
|
621
|
+
console.log("");
|
|
622
|
+
const targetDir = process.cwd();
|
|
623
|
+
let removedItems = [];
|
|
624
|
+
let errors = [];
|
|
625
|
+
// Detect file paths (same logic as installer)
|
|
626
|
+
const globalsCssPaths = [
|
|
627
|
+
"src/app/globals.css",
|
|
628
|
+
"app/globals.css",
|
|
629
|
+
"src/styles/globals.css",
|
|
630
|
+
"styles/globals.css"
|
|
631
|
+
];
|
|
632
|
+
const layoutPaths = [
|
|
633
|
+
"src/app/layout.tsx",
|
|
634
|
+
"app/layout.tsx",
|
|
635
|
+
"src/app/layout.jsx",
|
|
636
|
+
"app/layout.jsx"
|
|
637
|
+
];
|
|
638
|
+
// --- 1. Remove CSS imports from globals.css ---
|
|
639
|
+
for (const cssPath of globalsCssPaths) {
|
|
640
|
+
const fullPath = path.join(targetDir, cssPath);
|
|
641
|
+
if (fs.existsSync(fullPath)) {
|
|
642
|
+
try {
|
|
643
|
+
let content = fs.readFileSync(fullPath, "utf-8");
|
|
644
|
+
const originalContent = content;
|
|
645
|
+
// Remove lines containing the imports
|
|
646
|
+
content = content.split('\n')
|
|
647
|
+
.filter(line => !line.includes('brand-overrides.css') && !line.includes('sonance-theme.css'))
|
|
648
|
+
.join('\n');
|
|
649
|
+
// Clean up extra blank lines at the top
|
|
650
|
+
content = content.replace(/^\n+/, '');
|
|
651
|
+
if (content !== originalContent) {
|
|
652
|
+
fs.writeFileSync(fullPath, content, "utf-8");
|
|
653
|
+
removedItems.push(`Removed CSS imports from ${cssPath}`);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
catch (err) {
|
|
657
|
+
errors.push(`Could not modify ${cssPath}`);
|
|
658
|
+
}
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
// --- 2. Remove from layout.tsx ---
|
|
663
|
+
for (const layoutPath of layoutPaths) {
|
|
664
|
+
const fullPath = path.join(targetDir, layoutPath);
|
|
665
|
+
if (fs.existsSync(fullPath)) {
|
|
666
|
+
try {
|
|
667
|
+
let content = fs.readFileSync(fullPath, "utf-8");
|
|
668
|
+
const originalContent = content;
|
|
669
|
+
// Remove import line
|
|
670
|
+
content = content.split('\n')
|
|
671
|
+
.filter(line => !line.includes("SonanceDevTools") || !line.includes("import"))
|
|
672
|
+
.join('\n');
|
|
673
|
+
// Remove component usage line
|
|
674
|
+
content = content.split('\n')
|
|
675
|
+
.filter(line => !line.includes("<SonanceDevTools"))
|
|
676
|
+
.join('\n');
|
|
677
|
+
if (content !== originalContent) {
|
|
678
|
+
fs.writeFileSync(fullPath, content, "utf-8");
|
|
679
|
+
removedItems.push(`Removed DevTools from ${layoutPath}`);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
catch (err) {
|
|
683
|
+
errors.push(`Could not modify ${layoutPath}`);
|
|
684
|
+
}
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// --- 3. Delete installed directories/files ---
|
|
689
|
+
const itemsToDelete = [
|
|
690
|
+
"src/components/dev-tools",
|
|
691
|
+
"src/styles/brand-overrides.css",
|
|
692
|
+
"src/theme",
|
|
693
|
+
"src/app/api/sonance-theme",
|
|
694
|
+
"src/app/api/sonance-components",
|
|
695
|
+
"src/app/api/sonance-save-logo",
|
|
696
|
+
"src/app/api/sonance-assets",
|
|
697
|
+
"src/app/api/sonance-inject-id",
|
|
698
|
+
"src/app/api/sonance-analyze",
|
|
699
|
+
"src/lib/brand-system.ts"
|
|
700
|
+
];
|
|
701
|
+
for (const item of itemsToDelete) {
|
|
702
|
+
const fullPath = path.join(targetDir, item);
|
|
703
|
+
if (fs.existsSync(fullPath)) {
|
|
704
|
+
try {
|
|
705
|
+
const stats = fs.statSync(fullPath);
|
|
706
|
+
if (stats.isDirectory()) {
|
|
707
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
fs.unlinkSync(fullPath);
|
|
711
|
+
}
|
|
712
|
+
removedItems.push(`Deleted ${item}`);
|
|
713
|
+
}
|
|
714
|
+
catch (err) {
|
|
715
|
+
errors.push(`Could not delete ${item}`);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
// --- Output results ---
|
|
720
|
+
if (removedItems.length > 0) {
|
|
721
|
+
console.log(" ✅ Removed:");
|
|
722
|
+
removedItems.forEach(item => console.log(` ✓ ${item}`));
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
console.log(" ℹ️ No DevTools installation found to remove.");
|
|
726
|
+
}
|
|
727
|
+
if (errors.length > 0) {
|
|
728
|
+
console.log("");
|
|
729
|
+
console.log(" ⚠️ Some items could not be removed:");
|
|
730
|
+
errors.forEach(err => console.log(` - ${err}`));
|
|
731
|
+
}
|
|
732
|
+
console.log("");
|
|
733
|
+
console.log(" 🧹 Uninstall complete!");
|
|
734
|
+
console.log("");
|
|
735
|
+
}
|
|
594
736
|
// Check for install-devtools command
|
|
595
737
|
if (process.argv.includes("install-devtools") || process.argv.includes("--install-devtools")) {
|
|
596
738
|
runDevToolsInstaller();
|
|
597
739
|
process.exit(0);
|
|
598
740
|
}
|
|
741
|
+
// Check for uninstall-devtools command
|
|
742
|
+
if (process.argv.includes("uninstall-devtools") || process.argv.includes("--uninstall-devtools")) {
|
|
743
|
+
runDevToolsUninstaller();
|
|
744
|
+
process.exit(0);
|
|
745
|
+
}
|
|
599
746
|
// Resolve paths based on environment
|
|
600
747
|
function getAssetPath(assetType) {
|
|
601
748
|
if (IS_BUNDLED) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonance-brand-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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",
|