@schandlergarcia/sf-web-components 1.2.7 → 1.2.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schandlergarcia/sf-web-components",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
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",
@@ -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 UI components
33
+ // Copy entire library directory
34
34
  const packageRoot = path.join(cwd, 'node_modules', PACKAGE_NAME);
35
- const sourceComponentsDir = path.join(packageRoot, 'src/components/library/ui');
36
- const targetComponentsDir = path.join(cwd, 'src/components/ui');
35
+ const sourceLibraryDir = path.join(packageRoot, 'src/components/library');
36
+ const targetLibraryDir = path.join(cwd, 'src/components/library');
37
37
 
38
- console.log('šŸ“¦ Copying UI components...\n');
38
+ console.log('šŸ“¦ Copying component library...\n');
39
39
 
40
- if (fs.existsSync(sourceComponentsDir)) {
41
- // Create target directory if it doesn't exist
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
- const componentFiles = fs.readdirSync(sourceComponentsDir).filter(f => f.match(/\.(jsx|tsx)$/));
43
+ let count = 0;
47
44
 
48
- for (const componentFile of componentFiles) {
49
- const sourcePath = path.join(sourceComponentsDir, componentFile);
50
- const targetPath = path.join(targetComponentsDir, componentFile);
45
+ if (!fs.existsSync(target)) {
46
+ fs.mkdirSync(target, { recursive: true });
47
+ }
51
48
 
52
- try {
53
- fs.copyFileSync(sourcePath, targetPath);
54
- console.log(` āœ“ Copied ${componentFile}`);
55
- componentsCopied++;
56
- } catch (error) {
57
- console.error(` āœ— Failed to copy ${componentFile}: ${error.message}`);
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
- // Update imports in existing files to use local components
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/ui/**']
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, UIInput } from '@schandlergarcia/sf-web-components';
78
- // Replace with individual default imports: import UIButton from '@/components/ui/UIButton';
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
- `import\\s*\\{([^}]+)\\}\\s*from\\s*['"]${PACKAGE_NAME}['"];?`,
103
+ `from\\s+['"]${PACKAGE_NAME}['"]`,
81
104
  'g'
82
105
  );
83
106
 
84
- const matches = [...content.matchAll(packageImportRegex)];
85
-
86
- if (matches.length > 0) {
87
- for (const match of matches) {
88
- const importedNames = match[1].split(',').map(s => s.trim()).filter(Boolean);
89
- const uiComponents = importedNames.filter(name => name.startsWith('UI'));
90
-
91
- if (uiComponents.length > 0) {
92
- // Build individual imports for UI components
93
- const individualImports = uiComponents.map(name =>
94
- `import ${name} from '@/components/ui/${name}';`
95
- ).join('\n');
96
-
97
- // Keep non-UI imports from package
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) {
@@ -1,5 +1,6 @@
1
1
  import { useState } from "react";
2
- import { UIInput, UIButton } from '@schandlergarcia/sf-web-components';
2
+ import UIInput from '@/components/ui/UIInput';
3
+ import UIButton from '@/components/ui/UIButton';
3
4
  import { Search } from "lucide-react";
4
5
 
5
6
  export default function HomePage() {
@@ -1,5 +1,5 @@
1
1
  import { useNavigate } from "react-router";
2
- import { UIButton } from '@schandlergarcia/sf-web-components';
2
+ import UIButton from '@/components/ui/UIButton';
3
3
 
4
4
  export default function NotFound() {
5
5
  const navigate = useNavigate();