|
| 1 | + |
| 2 | +const fs = require('fs'); |
| 3 | +const path = require('path'); |
| 4 | + |
| 5 | +const dir = path.join(process.cwd(), 'packages/components/src/ui'); |
| 6 | + |
| 7 | +try { |
| 8 | + const files = fs.readdirSync(dir); |
| 9 | + |
| 10 | + files.forEach(file => { |
| 11 | + if (!file.endsWith('.tsx')) return; |
| 12 | + |
| 13 | + const filePath = path.join(dir, file); |
| 14 | + let content = fs.readFileSync(filePath, 'utf8'); |
| 15 | + |
| 16 | + // Check if file contains the incorrect import |
| 17 | + if (content.includes('registry/')) { |
| 18 | + console.log(`Fixing imports in ${file}...`); |
| 19 | + |
| 20 | + // Replace @/registry/default/ui/ with ./ |
| 21 | + content = content.replace(/@\/registry\/default\/ui\//g, './'); |
| 22 | + |
| 23 | + // Replace @/registry/new-york/ui/ with ./ |
| 24 | + content = content.replace(/@\/registry\/new-york\/ui\//g, './'); |
| 25 | + |
| 26 | + // Replace @/registry/default/hooks/ with ../hooks/ |
| 27 | + content = content.replace(/@\/registry\/default\/hooks\//g, '../hooks/'); |
| 28 | + |
| 29 | + // Replace @/registry/default/lib/ with ../lib/ |
| 30 | + content = content.replace(/@\/registry\/default\/lib\//g, '../lib/'); |
| 31 | + |
| 32 | + fs.writeFileSync(filePath, content, 'utf8'); |
| 33 | + } |
| 34 | + }); |
| 35 | + |
| 36 | + console.log('Finished fixing imports.'); |
| 37 | +} catch (err) { |
| 38 | + console.error('Error processing files:', err); |
| 39 | + process.exit(1); |
| 40 | +} |
0 commit comments