* Main function
()
| 290 | * Main function |
| 291 | */ |
| 292 | async function main() { |
| 293 | const actionText = shouldUpdate ? 'Updating' : 'Checking for' |
| 294 | console.log( |
| 295 | `${colors.bold}${colors.blue}${actionText} outdated packages in frameworks directory...${colors.reset}\n`, |
| 296 | ) |
| 297 | |
| 298 | const frameworksDir = join(__dirname, '..', 'frameworks') |
| 299 | const packageJsonFiles = findPackageJsonFiles(frameworksDir) |
| 300 | |
| 301 | console.log(`Found ${packageJsonFiles.length} package.json files\n`) |
| 302 | |
| 303 | let totalOutdated = 0 |
| 304 | let totalChecked = 0 |
| 305 | let totalUpdated = 0 |
| 306 | const results = [] |
| 307 | |
| 308 | for (let i = 0; i < packageJsonFiles.length; i++) { |
| 309 | const filePath = packageJsonFiles[i] |
| 310 | const displayPath = getDisplayPath(filePath, frameworksDir) |
| 311 | |
| 312 | // Show progress |
| 313 | process.stdout.write( |
| 314 | `\r${colors.blue}Processing ${i + 1}/${packageJsonFiles.length}: ${displayPath}...${colors.reset}`, |
| 315 | ) |
| 316 | |
| 317 | const result = await checkPackageJson(filePath) |
| 318 | results.push(result) |
| 319 | |
| 320 | if (result.error) { |
| 321 | console.log(`\n${colors.red}Error: ${result.error}${colors.reset}`) |
| 322 | continue |
| 323 | } |
| 324 | |
| 325 | totalChecked += result.totalDependencies |
| 326 | totalOutdated += result.outdatedPackages.length |
| 327 | |
| 328 | if (result.outdatedPackages.length > 0) { |
| 329 | console.log( |
| 330 | `\n${colors.red}${colors.bold}Found ${result.outdatedPackages.length} outdated packages in ${displayPath}:${colors.reset}`, |
| 331 | ) |
| 332 | for (const pkg of result.outdatedPackages) { |
| 333 | console.log( |
| 334 | ` ${colors.red}${pkg.name}${colors.reset}: ${pkg.current} → ${colors.green}${pkg.latest}${colors.reset}`, |
| 335 | ) |
| 336 | } |
| 337 | |
| 338 | if (shouldUpdate) { |
| 339 | const updated = updatePackageJson(filePath, result.outdatedPackages) |
| 340 | if (updated) { |
| 341 | totalUpdated++ |
| 342 | console.log( |
| 343 | ` ${colors.green}✓ Updated ${displayPath}${colors.reset}`, |
| 344 | ) |
| 345 | } else { |
| 346 | console.log( |
| 347 | ` ${colors.yellow}⚠ Failed to update ${displayPath}${colors.reset}`, |
| 348 | ) |
| 349 | } |
no test coverage detected