@schandlergarcia/sf-web-components 1.1.0 → 1.1.1
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/postinstall.mjs +18 -0
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -39,6 +39,13 @@ const files = glob.sync('src/**/*.{ts,tsx,js,jsx}', {
|
|
|
39
39
|
|
|
40
40
|
console.log(`Found ${files.length} source files to check\n`);
|
|
41
41
|
|
|
42
|
+
// Shadcn component replacements - map shadcn names to library names
|
|
43
|
+
const componentReplacements = {
|
|
44
|
+
'Button': 'UIButton',
|
|
45
|
+
'Input': 'UIInput',
|
|
46
|
+
// Keep other components as-is if they're not in the library
|
|
47
|
+
};
|
|
48
|
+
|
|
42
49
|
// Update imports in each file
|
|
43
50
|
for (const file of files) {
|
|
44
51
|
try {
|
|
@@ -70,6 +77,17 @@ for (const file of files) {
|
|
|
70
77
|
updates.push('utils import');
|
|
71
78
|
}
|
|
72
79
|
|
|
80
|
+
// Replace shadcn component names with library equivalents
|
|
81
|
+
for (const [shadcnName, libraryName] of Object.entries(componentReplacements)) {
|
|
82
|
+
// Match import statements like: import { Button } from '...'
|
|
83
|
+
const importRegex = new RegExp(`\\b${shadcnName}\\b(?=\\s*[,}])`, 'g');
|
|
84
|
+
if (importRegex.test(content)) {
|
|
85
|
+
content = content.replace(importRegex, libraryName);
|
|
86
|
+
modified = true;
|
|
87
|
+
updates.push(`renamed ${shadcnName} to ${libraryName}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
if (modified) {
|
|
74
92
|
fs.writeFileSync(file, content, 'utf-8');
|
|
75
93
|
filesUpdated++;
|