()
| 153 | } |
| 154 | |
| 155 | function main() { |
| 156 | // Parse --period flag |
| 157 | let period = 'all'; |
| 158 | const args = process.argv.slice(2); |
| 159 | for (let i = 0; i < args.length; i++) { |
| 160 | if (args[i] === '--period' && i + 1 < args.length) { |
| 161 | period = args[i + 1]; |
| 162 | i++; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // Read file |
| 167 | if (!fs.existsSync(ANALYTICS_FILE)) { |
| 168 | console.log('No analytics data found.'); |
| 169 | process.exit(0); |
| 170 | } |
| 171 | |
| 172 | const content = fs.readFileSync(ANALYTICS_FILE, 'utf-8').trim(); |
| 173 | if (!content) { |
| 174 | console.log('No analytics data found.'); |
| 175 | process.exit(0); |
| 176 | } |
| 177 | |
| 178 | const events = parseJSONL(content); |
| 179 | if (events.length === 0) { |
| 180 | console.log('No analytics data found.'); |
| 181 | process.exit(0); |
| 182 | } |
| 183 | |
| 184 | const filtered = filterByPeriod(events, period); |
| 185 | console.log(formatReport(filtered, period)); |
| 186 | } |
| 187 | |
| 188 | if (import.meta.main) { |
| 189 | main(); |
no test coverage detected