import { BaseCommand } from '@adonisjs/core/ace' import type { CommandOptions } from '@adonisjs/core/types/ace' export default class ScrapeParts extends BaseCommand { static commandName = 'scrape:parts' static description = 'Refresh the new-parts cache by scraping pc-builder.io category pages' static options: CommandOptions = { startApp: true, } async run() { const { scrapeAllCategories } = await import('#services/part_scraper_service') this.logger.info('Scraping pc-builder.io categories...') const summary = await scrapeAllCategories() let total = 0 for (const [type, count] of Object.entries(summary)) { this.logger.info(` ${type}: ${count} parts`) total += count } this.logger.success( `Done. Upserted ${total} parts across ${Object.keys(summary).length} categories.` ) } }