| 12 | }; |
| 13 | |
| 14 | const readComponents = (relativePath) => { |
| 15 | let reactFiles = []; |
| 16 | |
| 17 | const folderPath = !relativePath.startsWith(baseDir) |
| 18 | ? path.join(baseDir, relativePath) |
| 19 | : relativePath; |
| 20 | |
| 21 | try { |
| 22 | const files = fs.readdirSync(folderPath); |
| 23 | |
| 24 | files.forEach((file) => { |
| 25 | const filePath = path.join(folderPath, file); |
| 26 | const stat = fs.statSync(filePath); |
| 27 | |
| 28 | if (stat.isDirectory()) { |
| 29 | reactFiles = reactFiles.concat(readComponents(filePath)); |
| 30 | } else if (path.extname(file) === ".tsx") { |
| 31 | reactFiles.push(path.basename(file).replace(".tsx", "")); |
| 32 | } |
| 33 | }); |
| 34 | } catch (error) { |
| 35 | console.error("Error while searching for .tsx files:", error); |
| 36 | } |
| 37 | |
| 38 | return reactFiles; |
| 39 | }; |
| 40 | |
| 41 | const sharedUI = readComponents("ui"); |
| 42 | const features = readComponents("features"); |