@schandlergarcia/sf-web-components 1.9.20 ā 1.9.22
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 +78 -0
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -268,10 +268,88 @@ if (fs.existsSync(packageJsonPath)) {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
// Copy .a4drules from package to project root (so AI assistants can discover them)
|
|
272
|
+
const packageA4dRules = path.join(packageRoot, '.a4drules');
|
|
273
|
+
const projectRootA4dRules = path.join(cwd, '../../../../../.a4drules'); // Go up from webapp to project root
|
|
274
|
+
|
|
275
|
+
if (fs.existsSync(packageA4dRules)) {
|
|
276
|
+
console.log('\nš Copying AI assistant rules to project root...\n');
|
|
277
|
+
|
|
278
|
+
// Resolve to absolute path
|
|
279
|
+
const projectRootPath = path.resolve(cwd, '../../../../../');
|
|
280
|
+
const targetA4dRules = path.join(projectRootPath, '.a4drules');
|
|
281
|
+
|
|
282
|
+
// Create .a4drules if it doesn't exist
|
|
283
|
+
if (!fs.existsSync(targetA4dRules)) {
|
|
284
|
+
fs.mkdirSync(targetA4dRules, { recursive: true });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Copy skills directory
|
|
288
|
+
const skillsSource = path.join(packageA4dRules, 'skills');
|
|
289
|
+
const skillsTarget = path.join(targetA4dRules, 'skills');
|
|
290
|
+
if (fs.existsSync(skillsSource)) {
|
|
291
|
+
const skillsCopied = copyDirectoryRecursive(skillsSource, skillsTarget);
|
|
292
|
+
console.log(` ā Copied ${skillsCopied} skill files`);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Copy features directory
|
|
296
|
+
const featuresSource = path.join(packageA4dRules, 'features');
|
|
297
|
+
const featuresTarget = path.join(targetA4dRules, 'features');
|
|
298
|
+
if (fs.existsSync(featuresSource)) {
|
|
299
|
+
const featuresCopied = copyDirectoryRecursive(featuresSource, featuresTarget);
|
|
300
|
+
console.log(` ā Copied ${featuresCopied} feature rule files`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Migrate any dashboards from old location (src/components/pages/) to new location (src/pages/)
|
|
305
|
+
const oldPagesDir = path.join(cwd, 'src/components/pages');
|
|
306
|
+
const newPagesDir = path.join(cwd, 'src/pages');
|
|
307
|
+
let migratedFiles = 0;
|
|
308
|
+
|
|
309
|
+
if (fs.existsSync(oldPagesDir)) {
|
|
310
|
+
console.log('\nš Migrating dashboards from old location...\n');
|
|
311
|
+
|
|
312
|
+
const oldFiles = fs.readdirSync(oldPagesDir).filter(f =>
|
|
313
|
+
(f.endsWith('.jsx') || f.endsWith('.tsx')) &&
|
|
314
|
+
f.includes('Dashboard') &&
|
|
315
|
+
f !== 'BlankDashboard.jsx' &&
|
|
316
|
+
f !== 'BlankDashboard.tsx'
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
for (const file of oldFiles) {
|
|
320
|
+
const oldPath = path.join(oldPagesDir, file);
|
|
321
|
+
const newFile = file.replace('.jsx', '.tsx'); // Also convert .jsx to .tsx
|
|
322
|
+
const newPath = path.join(newPagesDir, newFile);
|
|
323
|
+
|
|
324
|
+
try {
|
|
325
|
+
fs.renameSync(oldPath, newPath);
|
|
326
|
+
console.log(` ā Migrated ${file} ā src/pages/${newFile}`);
|
|
327
|
+
migratedFiles++;
|
|
328
|
+
} catch (error) {
|
|
329
|
+
console.error(` ā Failed to migrate ${file}: ${error.message}`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Try to remove old directory if empty
|
|
334
|
+
try {
|
|
335
|
+
const remaining = fs.readdirSync(oldPagesDir);
|
|
336
|
+
if (remaining.length === 0) {
|
|
337
|
+
fs.rmdirSync(oldPagesDir);
|
|
338
|
+
console.log(' ā Removed empty src/components/pages directory');
|
|
339
|
+
}
|
|
340
|
+
} catch {
|
|
341
|
+
// Ignore errors
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
271
345
|
console.log('\nš Summary:');
|
|
272
346
|
console.log(` - Copied ${componentsCopied} UI components`);
|
|
273
347
|
console.log(` - Updated ${filesUpdated} files`);
|
|
274
348
|
console.log(` - Installed ${templatesInstalled} page templates`);
|
|
275
349
|
console.log(` - Installed CommandCenter.tsx for dashboard management`);
|
|
276
350
|
console.log(` - Added "npm run reset:command-center" script`);
|
|
351
|
+
console.log(` - Installed AI assistant rules for command center building`);
|
|
352
|
+
if (migratedFiles > 0) {
|
|
353
|
+
console.log(` - Migrated ${migratedFiles} dashboard files to correct location`);
|
|
354
|
+
}
|
|
277
355
|
console.log('\nā
Setup complete! UI components are now local for optimal Tailwind scanning\n');
|