@schandlergarcia/sf-web-components 1.9.32 → 1.9.34

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.9.32",
3
+ "version": "1.9.34",
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",
@@ -35,6 +35,7 @@
35
35
  "build": "vite build && cp -r src/styles dist/",
36
36
  "build:types": "tsc --emitDeclarationOnly",
37
37
  "prepublishOnly": "npm run build",
38
+ "postinstall": "node scripts/postinstall.mjs",
38
39
  "reset:command-center": "bash scripts/reset-command-center.sh",
39
40
  "validate:dashboard": "bash scripts/validate-dashboard.sh",
40
41
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install script for @schandlergarcia/sf-web-components
5
+ *
6
+ * Automatically copies sample data to the consuming project's src/data directory
7
+ */
8
+
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+
16
+ // Get the package root (one level up from scripts/)
17
+ const PACKAGE_ROOT = path.resolve(__dirname, '..');
18
+
19
+ // Get the project root (where the consuming project installed this package)
20
+ // Go up from node_modules/@schandlergarcia/sf-web-components
21
+ const PROJECT_ROOT = path.resolve(PACKAGE_ROOT, '../../..');
22
+
23
+ console.log('\n📦 @schandlergarcia/sf-web-components post-install');
24
+
25
+ // Check if we're in a node_modules context (not during package development)
26
+ if (!PACKAGE_ROOT.includes('node_modules')) {
27
+ console.log(' ℹ️ Running in development mode, skipping data copy');
28
+ process.exit(0);
29
+ }
30
+
31
+ // Find src/data directory in the consuming project
32
+ const possiblePaths = [
33
+ path.join(PROJECT_ROOT, 'src/data'),
34
+ path.join(PROJECT_ROOT, 'force-app/main/default/webapplications/src/data'),
35
+ ];
36
+
37
+ // Try to find an existing src directory
38
+ let targetDir = null;
39
+ for (const p of possiblePaths) {
40
+ const srcDir = path.dirname(p); // Get src directory
41
+ if (fs.existsSync(srcDir)) {
42
+ targetDir = p;
43
+ break;
44
+ }
45
+ }
46
+
47
+ // If no src directory found, look for any webapp with src/
48
+ const webappPattern = /force-app\/main\/default\/webapplications\/[^/]+$/;
49
+ if (!targetDir) {
50
+ try {
51
+ const webappRoot = path.join(PROJECT_ROOT, 'force-app/main/default/webapplications');
52
+ if (fs.existsSync(webappRoot)) {
53
+ const webapps = fs.readdirSync(webappRoot, { withFileTypes: true });
54
+ for (const webapp of webapps) {
55
+ if (webapp.isDirectory()) {
56
+ const srcDir = path.join(webappRoot, webapp.name, 'src');
57
+ if (fs.existsSync(srcDir)) {
58
+ targetDir = path.join(srcDir, 'data');
59
+ break;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ } catch (err) {
65
+ // Ignore errors
66
+ }
67
+ }
68
+
69
+ if (!targetDir) {
70
+ console.log(' ⚠️ Could not find src/ directory in project');
71
+ console.log(' ℹ️ To manually copy sample data, run:');
72
+ console.log('');
73
+ console.log(' mkdir -p src/data');
74
+ console.log(' cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/');
75
+ console.log('');
76
+ process.exit(0);
77
+ }
78
+
79
+ // Create target directory if it doesn't exist
80
+ try {
81
+ if (!fs.existsSync(targetDir)) {
82
+ fs.mkdirSync(targetDir, { recursive: true });
83
+ }
84
+ } catch (err) {
85
+ console.error(' ❌ Failed to create data directory:', err.message);
86
+ process.exit(0); // Don't fail the install
87
+ }
88
+
89
+ // Copy sample data file
90
+ const sourceFile = path.join(PACKAGE_ROOT, 'data/engine-sample-data.js');
91
+ const targetFile = path.join(targetDir, 'engine-sample-data.js');
92
+
93
+ try {
94
+ // Only copy if target doesn't exist (don't overwrite user's modifications)
95
+ if (!fs.existsSync(targetFile)) {
96
+ fs.copyFileSync(sourceFile, targetFile);
97
+ console.log(' ✅ Sample data copied to:', path.relative(PROJECT_ROOT, targetFile));
98
+ console.log('');
99
+ console.log(' Import in your components:');
100
+ console.log('');
101
+ console.log(" import { MAP_MARKERS, METRICS } from '@/data/engine-sample-data';");
102
+ console.log('');
103
+ } else {
104
+ console.log(' ℹ️ Sample data already exists (not overwriting)');
105
+ console.log(' 📁', path.relative(PROJECT_ROOT, targetFile));
106
+ console.log('');
107
+ }
108
+ } catch (err) {
109
+ console.error(' ⚠️ Could not copy sample data:', err.message);
110
+ console.log(' ℹ️ To manually copy, run:');
111
+ console.log('');
112
+ console.log(' cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/');
113
+ console.log('');
114
+ }
115
+
116
+ process.exit(0);