20 lines
1.3 KiB
TypeScript
20 lines
1.3 KiB
TypeScript
// `storebound events`: the events `storebound watch` recorded in ~/.storebound/events.jsonl (and events.jsonl.1), read-only.
|
|
// storebound events [--since 24h] [--app <name>] [--kind rejected,live] [--json]
|
|
// Kinds: rejected, approved, live, rollout_halted, crash_threshold, review_low, review_needs_reply. Newest last.
|
|
import type { Args } from './lib/args';
|
|
import { done, printJson } from './lib/log';
|
|
import { textTable } from './lib/table';
|
|
import { durationMs, EVENT_KINDS, eventsFile, filterEvents, readEvents } from './lib/watch';
|
|
|
|
export function run(args: Args): Promise<void> {
|
|
const kinds = args.list('kind');
|
|
for (const k of kinds) if (!(EVENT_KINDS as readonly string[]).includes(k)) throw new Error(`--kind: ${k} is not an event kind (${EVENT_KINDS.join(', ')})`);
|
|
const since = args.get('since');
|
|
const evs = filterEvents(readEvents(), { ...(since ? { sinceMs: durationMs(since) } : {}), ...(args.get('app') ? { app: args.get('app')! } : {}), kind: kinds });
|
|
if (args.has('json')) printJson(evs);
|
|
else {
|
|
console.log(textTable(['at', 'app', 'store', 'kind', 'version', 'detail'], evs.map(e => [e.at.slice(0, 16).replace('T', ' '), e.app, e.store, e.kind, e.version ?? '', e.detail.slice(0, 90)])));
|
|
done('events', `${evs.length} event(s) in ${eventsFile()}${since ? ` since ${since}` : ''}`);
|
|
}
|
|
return Promise.resolve();
|
|
}
|