()
| 195 | } |
| 196 | |
| 197 | async function generateFiles() { |
| 198 | console.log(`Generating ${NUM_FILES.toLocaleString()} test files...`) |
| 199 | console.time('Generation time') |
| 200 | |
| 201 | // Clean and recreate output directory |
| 202 | try { |
| 203 | await fs.rm(OUTPUT_DIR, {recursive: true}) |
| 204 | } catch { |
| 205 | // Directory doesn't exist, that's fine |
| 206 | } |
| 207 | await fs.mkdir(OUTPUT_DIR, {recursive: true}) |
| 208 | |
| 209 | // Generate files in batches |
| 210 | const numSubdirs = Math.ceil(NUM_FILES / FILES_PER_DIR) |
| 211 | |
| 212 | for (let dirIndex = 0; dirIndex < numSubdirs; dirIndex++) { |
| 213 | const subdirName = `batch_${dirIndex.toString().padStart(4, '0')}` |
| 214 | const subdirPath = path.join(OUTPUT_DIR, subdirName) |
| 215 | await fs.mkdir(subdirPath, {recursive: true}) |
| 216 | |
| 217 | const filesInThisDir = Math.min( |
| 218 | FILES_PER_DIR, |
| 219 | NUM_FILES - dirIndex * FILES_PER_DIR |
| 220 | ) |
| 221 | |
| 222 | // Generate files in parallel batches of 100 to avoid overwhelming the system |
| 223 | const BATCH_SIZE = 100 |
| 224 | for (let batch = 0; batch < filesInThisDir; batch += BATCH_SIZE) { |
| 225 | const batchEnd = Math.min(batch + BATCH_SIZE, filesInThisDir) |
| 226 | const promises = [] |
| 227 | |
| 228 | for (let i = batch; i < batchEnd; i++) { |
| 229 | const fileIndex = dirIndex * FILES_PER_DIR + i |
| 230 | const fileName = `file_${fileIndex.toString().padStart(6, '0')}.tsx` |
| 231 | const filePath = path.join(subdirPath, fileName) |
| 232 | const content = generateFileContent(fileIndex) |
| 233 | promises.push(fs.writeFile(filePath, content, 'utf8')) |
| 234 | } |
| 235 | |
| 236 | await Promise.all(promises) |
| 237 | } |
| 238 | |
| 239 | if ((dirIndex + 1) % 10 === 0) { |
| 240 | const progress = ((dirIndex + 1) / numSubdirs) * 100 |
| 241 | console.log( |
| 242 | `Progress: ${progress.toFixed(1)}% (${((dirIndex + 1) * FILES_PER_DIR).toLocaleString()} files)` |
| 243 | ) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | console.timeEnd('Generation time') |
| 248 | console.log( |
| 249 | `✓ Generated ${NUM_FILES.toLocaleString()} files in ${OUTPUT_DIR}` |
| 250 | ) |
| 251 | |
| 252 | // Generate summary statistics |
| 253 | console.log('\nFile structure:') |
| 254 | console.log(` - ${numSubdirs} subdirectories`) |
no test coverage detected