-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
29 lines (25 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { collectYearData } from './collector.js';
import { generateWrappedReport } from './wrapped.js';
const args = process.argv.slice(2);
const mode = args[0]?.toLowerCase();
const currentYear = new Date().getFullYear();
switch (mode) {
case 'generate':
console.log(`Generating wrapped report from existing database for ${currentYear}...`);
const report = await generateWrappedReport();
await Bun.write(`wrapped_${currentYear}.html`, report);
console.log('Report generated successfully!');
break;
case undefined:
case 'full':
console.log(`Collecting ${currentYear} data...`);
await collectYearData();
console.log('Generating wrapped report...');
const fullReport = await generateWrappedReport();
await Bun.write(`wrapped_${currentYear}.html`, fullReport);
console.log('Collection and report generation completed successfully!');
break;
default:
console.error('Invalid mode. Use "generate" for report generation only, or no parameter/full for complete collection and generation.');
process.exit(1);
}