const fs = require('fs'); const path = require('path'); function walk(dir) { let results = []; const list = fs.readdirSync(dir); list.forEach(function(file) { file = path.join(dir, file); const stat = fs.statSync(file); if (stat && stat.isDirectory()) { results = results.concat(walk(file)); } else { if (file.endsWith('.tsx') || file.endsWith('.ts')) { results.push(file); } } }); return results; } const files = walk(path.join(__dirname, 'src/renderer')); const d3roGlobals = ['d3roPalette', 'd3roTypo', 'd3roRadius', 'd3roShadow', 'd3roFontSans', 'd3roFontMono']; files.forEach(file => { const content = fs.readFileSync(file, 'utf8'); d3roGlobals.forEach(token => { if (content.includes(token)) { const isImported = content.includes(token + ' ') || content.includes(token + ',') || content.includes(token + '}') || content.includes(token + '\n'); const hasImportLine = /import\s+\{[^}]*\}\s+from\s+['"]@d3ro\/ui\/theme['"]/.test(content); if (!hasImportLine || !content.match(new RegExp(`import\\s+\\{[^}]*\\b${token}\\b[^}]*\\}\\s+from\\s+['"]@d3ro\\/ui\\/theme['"]`))) { console.log(`WARNING: ${path.relative(__dirname, file)} uses ${token} but might be missing import!`); } } }); }); console.log('Finished import check.');