/ src / cli / enrich.js
enrich.js
 1  #!/usr/bin/env node
 2  
 3  /**
 4   * CLI for Enrichment Stage
 5   * Usage: npm run enrich [-- --limit N]
 6   */
 7  
 8  import '../utils/load-env.js';
 9  import { runEnrichmentStage, getEnrichmentStats } from '../stages/enrich.js';
10  import { parseFlags } from '../utils/flag-parser.js';
11  
12  const command = process.argv[2];
13  
14  // Handle stats command
15  if (command === 'stats') {
16    const stats = getEnrichmentStats();
17    console.log('\nšŸ“Š Enrichment Statistics');
18    console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
19    console.log(`Total enriched:    ${stats.total_enriched}`);
20    console.log(`With forms:        ${stats.with_forms}`);
21    console.log(`With emails:       ${stats.with_emails}`);
22    console.log(`With phones:       ${stats.with_phones}`);
23    console.log('');
24    process.exit(0);
25  }
26  
27  // Run enrichment stage
28  const flags = parseFlags(process.argv.slice(2));
29  runEnrichmentStage({
30    limit: flags.limit,
31    concurrency: flags.concurrency,
32  })
33    .then(() => {
34      console.log('\nāœ… Enrichment stage complete\n');
35      process.exit(0);
36    })
37    .catch(error => {
38      console.error('\nāŒ Enrichment stage failed:', error.message);
39      console.error(error.stack);
40      process.exit(1);
41    });