@nbtca/prompt 1.0.8 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -289
- package/dist/config/data.d.ts +1 -1
- package/dist/config/data.js +1 -1
- package/dist/config/data.js.map +1 -1
- package/dist/core/logo.d.ts.map +1 -1
- package/dist/core/logo.js +13 -2
- package/dist/core/logo.js.map +1 -1
- package/dist/core/menu.d.ts +5 -0
- package/dist/core/menu.d.ts.map +1 -1
- package/dist/core/menu.js +12 -5
- package/dist/core/menu.js.map +1 -1
- package/dist/core/ui.d.ts.map +1 -1
- package/dist/core/ui.js +5 -3
- package/dist/core/ui.js.map +1 -1
- package/dist/features/calendar.d.ts +13 -14
- package/dist/features/calendar.d.ts.map +1 -1
- package/dist/features/calendar.js +57 -59
- package/dist/features/calendar.js.map +1 -1
- package/dist/features/docs.d.ts.map +1 -1
- package/dist/features/docs.js +50 -47
- package/dist/features/docs.js.map +1 -1
- package/dist/features/repair.d.ts +4 -0
- package/dist/features/repair.d.ts.map +1 -1
- package/dist/features/repair.js +1 -1
- package/dist/features/repair.js.map +1 -1
- package/dist/features/website.d.ts +10 -0
- package/dist/features/website.d.ts.map +1 -1
- package/dist/features/website.js +14 -2
- package/dist/features/website.js.map +1 -1
- package/dist/i18n/index.d.ts +9 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/locales/en.json +10 -1
- package/dist/i18n/locales/zh.json +10 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +7 -3
- package/dist/main.js.map +1 -1
- package/package.json +8 -2
- package/.github/workflows/ci.yml +0 -40
- package/.github/workflows/publish.yml +0 -59
- package/CHANGELOG.md +0 -125
- package/DEVELOPMENT.md +0 -258
- package/TERMINAL_UX.md +0 -184
- package/assets/Prompt_demo.gif +0 -0
- package/src/config/data.js +0 -484
- package/src/config/data.ts +0 -28
- package/src/config/theme.js +0 -138
- package/src/config/theme.ts +0 -26
- package/src/core/logo.ts +0 -189
- package/src/core/menu.ts +0 -213
- package/src/core/ui.ts +0 -89
- package/src/core/vim-keys.ts +0 -70
- package/src/features/calendar.ts +0 -161
- package/src/features/docs.ts +0 -588
- package/src/features/repair.ts +0 -36
- package/src/features/website.ts +0 -45
- package/src/i18n/index.ts +0 -236
- package/src/i18n/locales/en.json +0 -107
- package/src/i18n/locales/zh.json +0 -107
- package/src/index.ts +0 -9
- package/src/logo/ascii-logo.txt +0 -6
- package/src/logo/logo.txt +0 -2
- package/src/logo/printLogo.js +0 -26
- package/src/main.ts +0 -45
- package/src/types.ts +0 -51
- package/tsconfig.json +0 -53
package/src/features/calendar.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ICS日历功能模块
|
|
3
|
-
* 从远程获取并显示近期活动
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import axios from 'axios';
|
|
7
|
-
import ICAL from 'ical.js';
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
import { error, info, printDivider } from '../core/ui.js';
|
|
10
|
-
import { t } from '../i18n/index.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 活动接口
|
|
14
|
-
*/
|
|
15
|
-
export interface Event {
|
|
16
|
-
date: string;
|
|
17
|
-
time: string;
|
|
18
|
-
title: string;
|
|
19
|
-
location: string;
|
|
20
|
-
startDate: Date;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 从远程获取ICS文件并解析活动
|
|
25
|
-
*/
|
|
26
|
-
export async function fetchEvents(): Promise<Event[]> {
|
|
27
|
-
try {
|
|
28
|
-
const response = await axios.get('https://ical.nbtca.space', {
|
|
29
|
-
timeout: 5000,
|
|
30
|
-
headers: {
|
|
31
|
-
'User-Agent': 'NBTCA-CLI/2.3.1'
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const jcalData = ICAL.parse(response.data);
|
|
36
|
-
const comp = new ICAL.Component(jcalData);
|
|
37
|
-
const vevents = comp.getAllSubcomponents('vevent');
|
|
38
|
-
|
|
39
|
-
const events: Event[] = [];
|
|
40
|
-
const now = new Date();
|
|
41
|
-
const thirtyDaysLater = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000);
|
|
42
|
-
|
|
43
|
-
for (const vevent of vevents) {
|
|
44
|
-
const event = new ICAL.Event(vevent);
|
|
45
|
-
const startDate = event.startDate.toJSDate();
|
|
46
|
-
|
|
47
|
-
// Only show events within next 30 days
|
|
48
|
-
if (startDate >= now && startDate <= thirtyDaysLater) {
|
|
49
|
-
const trans = t();
|
|
50
|
-
const untitledEvent = trans.calendar.eventName === 'Event Name' ? 'Untitled Event' : '未命名活动';
|
|
51
|
-
const tbdLocation = trans.calendar.location === 'Location' ? 'TBD' : '待定';
|
|
52
|
-
|
|
53
|
-
events.push({
|
|
54
|
-
date: formatDate(startDate),
|
|
55
|
-
time: formatTime(startDate),
|
|
56
|
-
title: event.summary || untitledEvent,
|
|
57
|
-
location: event.location || tbdLocation,
|
|
58
|
-
startDate: startDate
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 按日期排序
|
|
64
|
-
events.sort((a, b) => a.startDate.getTime() - b.startDate.getTime());
|
|
65
|
-
|
|
66
|
-
return events;
|
|
67
|
-
} catch (err) {
|
|
68
|
-
throw new Error(t().calendar.error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 以表格形式显示活动
|
|
74
|
-
*/
|
|
75
|
-
export function displayEvents(events: Event[]): void {
|
|
76
|
-
const trans = t();
|
|
77
|
-
|
|
78
|
-
if (events.length === 0) {
|
|
79
|
-
info(trans.calendar.noEvents);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
console.log();
|
|
84
|
-
console.log(chalk.cyan.bold(' ' + trans.calendar.title) + chalk.gray(` ${trans.calendar.subtitle}`));
|
|
85
|
-
console.log();
|
|
86
|
-
|
|
87
|
-
// Table header
|
|
88
|
-
const dateWidth = 14;
|
|
89
|
-
const titleWidth = 25;
|
|
90
|
-
const locationWidth = 15;
|
|
91
|
-
|
|
92
|
-
console.log(
|
|
93
|
-
' ' +
|
|
94
|
-
chalk.bold(trans.calendar.dateTime.padEnd(dateWidth)) +
|
|
95
|
-
chalk.bold(trans.calendar.eventName.padEnd(titleWidth)) +
|
|
96
|
-
chalk.bold(trans.calendar.location)
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
printDivider();
|
|
100
|
-
|
|
101
|
-
// Event list
|
|
102
|
-
events.forEach(event => {
|
|
103
|
-
const dateTime = `${event.date} ${event.time}`.padEnd(dateWidth);
|
|
104
|
-
const title = truncate(event.title, titleWidth - 2).padEnd(titleWidth);
|
|
105
|
-
const location = truncate(event.location, locationWidth);
|
|
106
|
-
|
|
107
|
-
console.log(
|
|
108
|
-
' ' +
|
|
109
|
-
chalk.cyan(dateTime) +
|
|
110
|
-
chalk.white(title) +
|
|
111
|
-
chalk.gray(location)
|
|
112
|
-
);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
console.log();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 格式化日期
|
|
120
|
-
*/
|
|
121
|
-
function formatDate(date: Date): string {
|
|
122
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
123
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
124
|
-
return `${month}-${day}`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 格式化时间
|
|
129
|
-
*/
|
|
130
|
-
function formatTime(date: Date): string {
|
|
131
|
-
const hours = String(date.getHours()).padStart(2, '0');
|
|
132
|
-
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
133
|
-
return `${hours}:${minutes}`;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 截断字符串
|
|
138
|
-
*/
|
|
139
|
-
function truncate(str: string, maxLength: number): string {
|
|
140
|
-
if (str.length <= maxLength) {
|
|
141
|
-
return str;
|
|
142
|
-
}
|
|
143
|
-
return str.substring(0, maxLength - 3) + '...';
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* 主函数:获取并显示活动
|
|
148
|
-
*/
|
|
149
|
-
export async function showCalendar(): Promise<void> {
|
|
150
|
-
const trans = t();
|
|
151
|
-
try {
|
|
152
|
-
info(trans.calendar.loading);
|
|
153
|
-
const events = await fetchEvents();
|
|
154
|
-
console.log('\r' + ' '.repeat(50) + '\r'); // Clear loading message
|
|
155
|
-
displayEvents(events);
|
|
156
|
-
} catch (err) {
|
|
157
|
-
error(trans.calendar.error);
|
|
158
|
-
console.log(chalk.gray(' ' + trans.calendar.errorHint));
|
|
159
|
-
console.log();
|
|
160
|
-
}
|
|
161
|
-
}
|