Skip to content

Commit 7d857c8

Browse files
committed
polish: logo version line, clean empty-state flows in calendar
- printLogo(): add dim "@nbtca/prompt v{version}" under tagline so npx users immediately see which package and version they are running - showEventsPreview(): early return on empty state — avoid rendering the empty table (redundant with the spinner message that already says it) - showCalendar(): move empty check before table render — heatmap still shown (past activity is useful even with no upcoming events), table and selector only rendered when there are events - showPastEvents(): same early-return pattern for empty state - Remove unused `info` import from calendar.ts
1 parent 4a20e04 commit 7d857c8

2 files changed

Lines changed: 25 additions & 16 deletions

File tree

src/core/logo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import { readFileSync } from 'fs';
88
import { fileURLToPath } from 'url';
99
import { dirname, join } from 'path';
10+
import chalk from 'chalk';
1011
import gradient from 'gradient-string';
1112
import { useUnicodeIcons } from './icons.js';
13+
import { APP_INFO } from '../config/data.js';
1214

1315
const __dirname = dirname(fileURLToPath(import.meta.url));
1416

@@ -49,5 +51,6 @@ export function printLogo(): void {
4951
console.log(paint(art ?? 'NBTCA', color));
5052
console.log();
5153
console.log(color ? brand(TAGLINE) : TAGLINE);
54+
console.log(chalk.dim(`@nbtca/prompt v${APP_INFO.version}`));
5255
console.log();
5356
}

src/features/calendar.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { loadCalendar, FeedFetchError, FeedParseError } from '@nbtca/nbtcal';
22
import type { Calendar, CalendarEvent, HeatmapBucket } from '@nbtca/nbtcal';
33
import chalk from 'chalk';
44
import { select, isCancel } from '@clack/prompts';
5-
import { info, createSpinner } from '../core/ui.js';
5+
import { createSpinner } from '../core/ui.js';
66
import { c } from '../core/theme.js';
77
import { pickIcon } from '../core/icons.js';
88
import { padEndV, truncate } from '../core/text.js';
@@ -160,14 +160,15 @@ export async function showEventsPreview(): Promise<void> {
160160

161161
if (events.length === 0) {
162162
s.stop(trans.calendar.noEvents);
163-
} else {
164-
s.stop(`${events.length} ${trans.calendar.eventsFound}`);
163+
console.log();
164+
return;
165165
}
166166

167+
s.stop(`${events.length} ${trans.calendar.eventsFound}`);
167168
console.log();
168169
console.log(renderEventsTable(events.slice(0, 5), { color: !!process.stdout.isTTY }));
169170
console.log();
170-
if (events.length > 0) renderSubscribeHint();
171+
renderSubscribeHint();
171172
console.log();
172173
} catch {
173174
s.error(trans.calendar.error);
@@ -198,17 +199,18 @@ export async function showPastEvents(): Promise<void> {
198199
try {
199200
const cal = await loadCalendarOrThrow();
200201
const events = cal.past({ days: 30 }).reverse().map(toDisplayEvent);
201-
s.stop(`${events.length} ${trans.calendar.eventsFound}`);
202-
203-
console.log();
204-
console.log(renderEventsTable(events, { color: true }));
205-
console.log();
206202

207203
if (events.length === 0) {
208-
info(trans.calendar.noPastEvents);
204+
s.stop(trans.calendar.noPastEvents);
205+
console.log();
209206
return;
210207
}
211208

209+
s.stop(`${events.length} ${trans.calendar.eventsFound}`);
210+
console.log();
211+
console.log(renderEventsTable(events, { color: true }));
212+
console.log();
213+
212214
const options = [
213215
...events.map((e, i) => ({
214216
value: String(i),
@@ -237,14 +239,23 @@ export async function showCalendar(): Promise<void> {
237239
try {
238240
const cal = await loadCalendarOrThrow();
239241
const events = cal.upcoming({ days: 30 }).map(toDisplayEvent);
240-
s.stop(`${events.length} ${trans.calendar.eventsFound}`);
241242

242243
const now = new Date();
243244
const heatmapBuckets = cal.heatmap({
244245
start: new Date(now.getTime() - 365 * 24 * 60 * 60 * 1000),
245246
end: now,
246247
bucket: 'day',
247248
});
249+
250+
if (events.length === 0) {
251+
s.stop(trans.calendar.noEvents);
252+
console.log();
253+
console.log(renderHeatmap(heatmapBuckets, now, { color: true }));
254+
console.log();
255+
return;
256+
}
257+
258+
s.stop(`${events.length} ${trans.calendar.eventsFound}`);
248259
console.log();
249260
console.log(renderHeatmap(heatmapBuckets, now, { color: true }));
250261
console.log();
@@ -253,11 +264,6 @@ export async function showCalendar(): Promise<void> {
253264
renderSubscribeHint();
254265
console.log();
255266

256-
if (events.length === 0) {
257-
info(trans.calendar.noEvents);
258-
return;
259-
}
260-
261267
const options = [
262268
...events.map((e, i) => ({
263269
value: String(i),

0 commit comments

Comments
 (0)