@schandlergarcia/sf-web-components 1.2.8 ā 1.2.10
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 +2 -1
- package/scripts/postinstall.mjs +62 -49
- package/src/lib/index.ts +1 -0
- package/src/lib/utils.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schandlergarcia/sf-web-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
4
4
|
"description": "Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"scripts",
|
|
30
30
|
"src/templates",
|
|
31
31
|
"src/components",
|
|
32
|
+
"src/lib",
|
|
32
33
|
"README.md",
|
|
33
34
|
".a4drules"
|
|
34
35
|
],
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -30,40 +30,63 @@ const PACKAGE_NAME = '@schandlergarcia/sf-web-components';
|
|
|
30
30
|
let filesUpdated = 0;
|
|
31
31
|
let componentsCopied = 0;
|
|
32
32
|
|
|
33
|
-
// Copy
|
|
33
|
+
// Copy entire library directory
|
|
34
34
|
const packageRoot = path.join(cwd, 'node_modules', PACKAGE_NAME);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
35
|
+
const sourceLibraryDir = path.join(packageRoot, 'src/components/library');
|
|
36
|
+
const targetLibraryDir = path.join(cwd, 'src/components/library');
|
|
37
37
|
|
|
38
|
-
console.log('š¦ Copying
|
|
38
|
+
console.log('š¦ Copying component library...\n');
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!fs.existsSync(targetComponentsDir)) {
|
|
43
|
-
fs.mkdirSync(targetComponentsDir, { recursive: true });
|
|
44
|
-
}
|
|
40
|
+
function copyDirectoryRecursive(source, target) {
|
|
41
|
+
if (!fs.existsSync(source)) return 0;
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
let count = 0;
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
if (!fs.existsSync(target)) {
|
|
46
|
+
fs.mkdirSync(target, { recursive: true });
|
|
47
|
+
}
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
const items = fs.readdirSync(source);
|
|
50
|
+
|
|
51
|
+
for (const item of items) {
|
|
52
|
+
const sourcePath = path.join(source, item);
|
|
53
|
+
const targetPath = path.join(target, item);
|
|
54
|
+
const stat = fs.statSync(sourcePath);
|
|
55
|
+
|
|
56
|
+
if (stat.isDirectory()) {
|
|
57
|
+
count += copyDirectoryRecursive(sourcePath, targetPath);
|
|
58
|
+
} else if (item.match(/\.(jsx|tsx|js|ts|css)$/)) {
|
|
59
|
+
try {
|
|
60
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
61
|
+
count++;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(` ā Failed to copy ${item}: ${error.message}`);
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
67
|
+
|
|
68
|
+
return count;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (fs.existsSync(sourceLibraryDir)) {
|
|
72
|
+
componentsCopied = copyDirectoryRecursive(sourceLibraryDir, targetLibraryDir);
|
|
73
|
+
console.log(` ā Copied ${componentsCopied} component files\n`);
|
|
60
74
|
}
|
|
61
75
|
|
|
62
|
-
//
|
|
76
|
+
// Also copy lib directory (utils, etc.)
|
|
77
|
+
const sourceLibDir = path.join(packageRoot, 'src/lib');
|
|
78
|
+
const targetLibDir = path.join(cwd, 'src/lib');
|
|
79
|
+
|
|
80
|
+
if (fs.existsSync(sourceLibDir)) {
|
|
81
|
+
const libFilesCopied = copyDirectoryRecursive(sourceLibDir, targetLibDir);
|
|
82
|
+
console.log(` ā Copied ${libFilesCopied} lib files\n`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Update imports in existing files to use local library
|
|
63
86
|
const files = glob.sync('src/**/*.{ts,tsx,js,jsx}', {
|
|
64
87
|
cwd,
|
|
65
88
|
absolute: true,
|
|
66
|
-
ignore: ['**/node_modules/**', '**/dist/**', '**/components/
|
|
89
|
+
ignore: ['**/node_modules/**', '**/dist/**', '**/components/library/**']
|
|
67
90
|
});
|
|
68
91
|
|
|
69
92
|
console.log(`\nš Updating imports in ${files.length} files...\n`);
|
|
@@ -73,38 +96,28 @@ for (const file of files) {
|
|
|
73
96
|
let content = fs.readFileSync(file, 'utf-8');
|
|
74
97
|
let modified = false;
|
|
75
98
|
|
|
76
|
-
// Replace package imports with local imports
|
|
77
|
-
// Match: import { UIButton,
|
|
78
|
-
// Replace
|
|
99
|
+
// Replace package imports with local library imports
|
|
100
|
+
// Match: import { UIButton, Card, MetricCard } from '@schandlergarcia/sf-web-components';
|
|
101
|
+
// Replace: import { UIButton, Card, MetricCard } from '@/components/library';
|
|
79
102
|
const packageImportRegex = new RegExp(
|
|
80
|
-
`
|
|
103
|
+
`from\\s+['"]${PACKAGE_NAME}['"]`,
|
|
81
104
|
'g'
|
|
82
105
|
);
|
|
83
106
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const otherComponents = importedNames.filter(name => !name.startsWith('UI'));
|
|
99
|
-
const packageImport = otherComponents.length > 0
|
|
100
|
-
? `import { ${otherComponents.join(', ')} } from '${PACKAGE_NAME}';`
|
|
101
|
-
: '';
|
|
102
|
-
|
|
103
|
-
const replacement = [individualImports, packageImport].filter(Boolean).join('\n');
|
|
104
|
-
content = content.replace(match[0], replacement);
|
|
105
|
-
modified = true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
107
|
+
if (packageImportRegex.test(content)) {
|
|
108
|
+
content = content.replace(packageImportRegex, `from '@/components/library'`);
|
|
109
|
+
modified = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Also replace specific subpath imports
|
|
113
|
+
const subpathRegex = new RegExp(
|
|
114
|
+
`from\\s+['"]${PACKAGE_NAME}/lib['"]`,
|
|
115
|
+
'g'
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
if (subpathRegex.test(content)) {
|
|
119
|
+
content = content.replace(subpathRegex, `from '@/components/library/lib'`);
|
|
120
|
+
modified = true;
|
|
108
121
|
}
|
|
109
122
|
|
|
110
123
|
if (modified) {
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils';
|