@nbtca/prompt 1.0.4 → 1.0.6
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/CHANGELOG.md +48 -0
- package/README.md +45 -3
- package/dist/config/data.d.ts +1 -1
- package/dist/config/data.js +1 -1
- package/dist/core/logo.d.ts +3 -3
- package/dist/core/logo.js +40 -40
- package/dist/core/logo.js.map +1 -1
- package/dist/core/menu.d.ts +3 -3
- package/dist/core/menu.d.ts.map +1 -1
- package/dist/core/menu.js +112 -67
- package/dist/core/menu.js.map +1 -1
- package/dist/core/ui.d.ts +11 -11
- package/dist/core/ui.js +15 -15
- package/dist/core/ui.js.map +1 -1
- package/dist/features/calendar.d.ts.map +1 -1
- package/dist/features/calendar.js +21 -15
- package/dist/features/calendar.js.map +1 -1
- package/dist/features/docs.d.ts.map +1 -1
- package/dist/features/docs.js +104 -44
- package/dist/features/docs.js.map +1 -1
- package/dist/features/repair.d.ts.map +1 -1
- package/dist/features/repair.js +6 -10
- package/dist/features/repair.js.map +1 -1
- package/dist/features/website.d.ts +3 -3
- package/dist/features/website.d.ts.map +1 -1
- package/dist/features/website.js +11 -9
- package/dist/features/website.js.map +1 -1
- package/dist/i18n/index.d.ts +140 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +113 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/main.d.ts +2 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -10
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
- package/src/config/data.ts +1 -1
- package/src/core/logo.ts +40 -40
- package/src/core/menu.ts +119 -67
- package/src/core/ui.ts +15 -15
- package/src/features/calendar.ts +23 -15
- package/src/features/docs.ts +116 -45
- package/src/features/repair.ts +6 -10
- package/src/features/website.ts +11 -9
- package/src/i18n/index.ts +236 -0
- package/src/i18n/locales/en.json +107 -0
- package/src/i18n/locales/zh.json +107 -0
- package/src/main.ts +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## [1.0.5] - 2025-12-10
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Knowledge Base 403 Error**: Resolved GitHub API rate limiting issue that caused 403 errors when browsing documentation
|
|
7
|
+
- Added GitHub token authentication support via `GITHUB_TOKEN` or `GH_TOKEN` environment variables
|
|
8
|
+
- Improved error messages with rate limit information and reset time
|
|
9
|
+
- Increased rate limit from 60 to 5000 requests per hour when using a token
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **Pager-Style Document Viewer**: Documents now open in a pager (similar to vim/journalctl/less)
|
|
13
|
+
- Natural scrolling navigation with arrow keys, Space, j/k (vim-style), and q to quit
|
|
14
|
+
- Content doesn't flood the terminal anymore
|
|
15
|
+
- Better reading experience for long documents
|
|
16
|
+
- Automatic fallback to direct output if pager is unavailable
|
|
17
|
+
- **Re-read Document Option**: Added ability to re-read a document after viewing without going back to the list
|
|
18
|
+
- **Environment Variable Support**:
|
|
19
|
+
- `GITHUB_TOKEN` or `GH_TOKEN` for GitHub API authentication
|
|
20
|
+
- `PAGER` for custom pager selection (defaults to `less`)
|
|
21
|
+
|
|
22
|
+
### Improved
|
|
23
|
+
- Enhanced error handling with detailed rate limit diagnostics
|
|
24
|
+
- Better user feedback when rate limits are reached
|
|
25
|
+
- Clearer instructions for resolving authentication issues
|
|
26
|
+
|
|
27
|
+
### Technical Details
|
|
28
|
+
- Added `displayInPager()` function for spawning system pager processes
|
|
29
|
+
- Enhanced `fetchGitHubDirectory()` with conditional token authentication
|
|
30
|
+
- Updated documentation viewer workflow for better UX
|
|
31
|
+
|
|
32
|
+
## [1.0.4] - 2025-12-10
|
|
33
|
+
|
|
34
|
+
### Enhanced
|
|
35
|
+
- **Smooth Slogan Animation**: Implemented true color interpolation for buttery smooth gradient animation
|
|
36
|
+
- Increased frame rate from 24 to 60 FPS for ultra-smooth motion
|
|
37
|
+
- Changed easing from cubic to sine wave for more natural transitions
|
|
38
|
+
- Dynamically generate gradients per frame instead of using pre-defined set
|
|
39
|
+
- Eliminates staggered/jumping effect in the slogan text animation
|
|
40
|
+
|
|
41
|
+
### Technical Details
|
|
42
|
+
- Added `hexToRgb()`, `rgbToHex()`, and `interpolateColor()` functions for mathematical color blending
|
|
43
|
+
- Implemented `easeInOutSine()` easing function for smooth acceleration/deceleration
|
|
44
|
+
- Each frame now uses unique, mathematically interpolated colors
|
|
45
|
+
|
|
46
|
+
## [1.0.3] - 2025-11-27
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
- Version alignment and bug fixes
|
|
50
|
+
|
|
3
51
|
## [1.0.2] - 2025-11-27
|
|
4
52
|
|
|
5
53
|
### Added
|
package/README.md
CHANGED
|
@@ -13,9 +13,10 @@ NBTCA Prompt is a minimalist command-line interface tool designed for the Comput
|
|
|
13
13
|
|
|
14
14
|
- View upcoming association events (30-day calendar)
|
|
15
15
|
- Access repair service information
|
|
16
|
-
- Browse technical documentation from terminal
|
|
16
|
+
- Browse technical documentation from terminal with pager support (vim/journalctl style)
|
|
17
17
|
- Quick links to official website and GitHub
|
|
18
18
|
- Minimalist design with maximum terminal compatibility
|
|
19
|
+
- Smooth gradient animations for enhanced visual experience
|
|
19
20
|
|
|
20
21
|
## Installation
|
|
21
22
|
|
|
@@ -131,11 +132,25 @@ src/
|
|
|
131
132
|
|
|
132
133
|
The knowledge base viewer features:
|
|
133
134
|
|
|
134
|
-
- Direct GitHub repository access
|
|
135
|
+
- Direct GitHub repository access with authentication support
|
|
136
|
+
- Pager-style document reading (similar to vim/journalctl/less)
|
|
135
137
|
- VitePress syntax cleaning
|
|
136
|
-
- Terminal Markdown rendering
|
|
138
|
+
- Terminal Markdown rendering with color support
|
|
137
139
|
- Browser fallback option
|
|
138
140
|
- Directory tree navigation
|
|
141
|
+
- Improved error handling with rate limit detection
|
|
142
|
+
|
|
143
|
+
### GitHub Token Configuration (Optional)
|
|
144
|
+
|
|
145
|
+
To avoid GitHub API rate limits when browsing documentation, you can set a GitHub token:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
export GITHUB_TOKEN="your_github_token_here"
|
|
149
|
+
# or
|
|
150
|
+
export GH_TOKEN="your_github_token_here"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Without a token, you have 60 requests per hour. With a token, you get 5000 requests per hour.
|
|
139
154
|
|
|
140
155
|
### Supported Formats
|
|
141
156
|
|
|
@@ -163,6 +178,10 @@ ASCII-based UI elements ensure rendering on any terminal emulator.
|
|
|
163
178
|
|
|
164
179
|
## Common Issues
|
|
165
180
|
|
|
181
|
+
### Q: Getting 403 error when browsing documentation?
|
|
182
|
+
|
|
183
|
+
A: This is due to GitHub API rate limiting. Set a `GITHUB_TOKEN` environment variable to increase your rate limit from 60 to 5000 requests per hour. See the [GitHub Token Configuration](#github-token-configuration-optional) section above.
|
|
184
|
+
|
|
166
185
|
### Q: Auto-restart when using `pnpm run dev:watch`?
|
|
167
186
|
|
|
168
187
|
A: This is expected behavior. Use `pnpm run dev` for interactive testing.
|
|
@@ -171,6 +190,10 @@ A: This is expected behavior. Use `pnpm run dev` for interactive testing.
|
|
|
171
190
|
|
|
172
191
|
A: Select the Exit option from menu, or press Ctrl+C.
|
|
173
192
|
|
|
193
|
+
### Q: How to navigate documents in the pager?
|
|
194
|
+
|
|
195
|
+
A: Use arrow keys, Space (page down), 'j/k' (vim-style), or 'q' to quit the pager.
|
|
196
|
+
|
|
174
197
|
### Q: Changes not reflected?
|
|
175
198
|
|
|
176
199
|
A: If using `pnpm start`, rebuild with `pnpm run build` first.
|
|
@@ -206,6 +229,25 @@ MIT License - See LICENSE file for details
|
|
|
206
229
|
|
|
207
230
|
## Changelog
|
|
208
231
|
|
|
232
|
+
### v1.0.5 (2025-12-10)
|
|
233
|
+
|
|
234
|
+
- **Fixed**: Knowledge Base 403 error due to GitHub API rate limiting
|
|
235
|
+
- **Added**: GitHub token authentication support (GITHUB_TOKEN/GH_TOKEN)
|
|
236
|
+
- **Added**: Pager-style document viewer (vim/journalctl/less style)
|
|
237
|
+
- **Added**: "Re-read document" option after viewing
|
|
238
|
+
- **Improved**: Better error messages with rate limit information
|
|
239
|
+
- **Improved**: Document reading experience with scroll navigation
|
|
240
|
+
|
|
241
|
+
### v1.0.4 (2025-12-10)
|
|
242
|
+
|
|
243
|
+
- **Enhanced**: Smooth slogan animation with true color interpolation
|
|
244
|
+
- **Improved**: 60 FPS animation with sine easing for natural transitions
|
|
245
|
+
- **Technical**: Added hexToRgb, rgbToHex, and interpolateColor functions
|
|
246
|
+
|
|
247
|
+
### v1.0.3 (2025-11-27)
|
|
248
|
+
|
|
249
|
+
- Version alignment and bug fixes
|
|
250
|
+
|
|
209
251
|
### v1.0.1 (2025-11-27)
|
|
210
252
|
|
|
211
253
|
- Added terminal documentation viewer
|
package/dist/config/data.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const URLS: {
|
|
|
12
12
|
};
|
|
13
13
|
export declare const APP_INFO: {
|
|
14
14
|
readonly name: "Prompt";
|
|
15
|
-
readonly version: "1.0.
|
|
15
|
+
readonly version: "1.0.6";
|
|
16
16
|
readonly description: "浙大宁波理工学院计算机协会";
|
|
17
17
|
readonly fullDescription: "NBTCA Prompt - 极简命令行工具";
|
|
18
18
|
readonly author: "m1ngsama <contact@m1ng.space>";
|
package/dist/config/data.js
CHANGED
package/dist/core/logo.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Smart logo display module
|
|
3
|
+
* Attempts to display iTerm2 image format logo, falls back to ASCII art
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Attempt to read and display logo file
|
|
7
7
|
*/
|
|
8
8
|
export declare function printLogo(): Promise<void>;
|
|
9
9
|
//# sourceMappingURL=logo.d.ts.map
|
package/dist/core/logo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Smart logo display module
|
|
3
|
+
* Attempts to display iTerm2 image format logo, falls back to ASCII art
|
|
4
4
|
*/
|
|
5
5
|
import { readFileSync } from 'fs';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
@@ -9,19 +9,19 @@ import gradient from 'gradient-string';
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = dirname(__filename);
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Create blue-toned gradient effect
|
|
13
13
|
*/
|
|
14
14
|
function createBlueGradient(text) {
|
|
15
|
-
//
|
|
15
|
+
// Blue gradient: deep blue -> sky blue -> cyan
|
|
16
16
|
const blueGradient = gradient([
|
|
17
|
-
{ color: '#1e3a8a', pos: 0 }, //
|
|
18
|
-
{ color: '#0ea5e9', pos: 0.5 }, //
|
|
19
|
-
{ color: '#06b6d4', pos: 1 } //
|
|
17
|
+
{ color: '#1e3a8a', pos: 0 }, // Deep blue
|
|
18
|
+
{ color: '#0ea5e9', pos: 0.5 }, // Sky blue
|
|
19
|
+
{ color: '#06b6d4', pos: 1 } // Cyan
|
|
20
20
|
]);
|
|
21
21
|
return blueGradient(text);
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Convert hex color to RGB
|
|
25
25
|
*/
|
|
26
26
|
function hexToRgb(hex) {
|
|
27
27
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
@@ -30,7 +30,7 @@ function hexToRgb(hex) {
|
|
|
30
30
|
: [0, 0, 0];
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Convert RGB to hex color
|
|
34
34
|
*/
|
|
35
35
|
function rgbToHex(r, g, b) {
|
|
36
36
|
return '#' + [r, g, b].map(x => {
|
|
@@ -39,7 +39,7 @@ function rgbToHex(r, g, b) {
|
|
|
39
39
|
}).join('');
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Linear interpolation between two colors
|
|
43
43
|
*/
|
|
44
44
|
function interpolateColor(color1, color2, factor) {
|
|
45
45
|
const [r1, g1, b1] = hexToRgb(color1);
|
|
@@ -50,40 +50,40 @@ function interpolateColor(color1, color2, factor) {
|
|
|
50
50
|
return rgbToHex(r, g, b);
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Easing function - smooth in-out effect
|
|
54
54
|
*/
|
|
55
55
|
function easeInOutSine(t) {
|
|
56
56
|
return -(Math.cos(Math.PI * t) - 1) / 2;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Display gradient animation effect (optimized - truly smooth animation)
|
|
60
60
|
*/
|
|
61
61
|
async function animateGradient(text, duration = 1200) {
|
|
62
|
-
const frames = 60; // 60
|
|
62
|
+
const frames = 60; // 60 frames for truly smooth animation
|
|
63
63
|
const frameDelay = duration / frames;
|
|
64
|
-
//
|
|
64
|
+
// Define color sequence - forms complete blue spectrum cycle
|
|
65
65
|
const colorSequence = [
|
|
66
|
-
'#1e3a8a', //
|
|
67
|
-
'#2563eb', //
|
|
68
|
-
'#3b82f6', //
|
|
69
|
-
'#0ea5e9', //
|
|
70
|
-
'#06b6d4', //
|
|
71
|
-
'#14b8a6', //
|
|
72
|
-
'#06b6d4', //
|
|
73
|
-
'#0ea5e9', //
|
|
74
|
-
'#3b82f6', //
|
|
75
|
-
'#2563eb', //
|
|
76
|
-
'#1e3a8a', //
|
|
66
|
+
'#1e3a8a', // Deep blue
|
|
67
|
+
'#2563eb', // Blue
|
|
68
|
+
'#3b82f6', // Bright blue
|
|
69
|
+
'#0ea5e9', // Sky blue
|
|
70
|
+
'#06b6d4', // Cyan
|
|
71
|
+
'#14b8a6', // Teal
|
|
72
|
+
'#06b6d4', // Cyan
|
|
73
|
+
'#0ea5e9', // Sky blue
|
|
74
|
+
'#3b82f6', // Bright blue
|
|
75
|
+
'#2563eb', // Blue
|
|
76
|
+
'#1e3a8a', // Deep blue
|
|
77
77
|
];
|
|
78
78
|
for (let i = 0; i < frames; i++) {
|
|
79
|
-
//
|
|
79
|
+
// Use smooth sine easing
|
|
80
80
|
const progress = easeInOutSine(i / frames);
|
|
81
|
-
//
|
|
81
|
+
// Calculate position in color sequence
|
|
82
82
|
const position = progress * (colorSequence.length - 1);
|
|
83
83
|
const index1 = Math.floor(position);
|
|
84
84
|
const index2 = Math.min(index1 + 1, colorSequence.length - 1);
|
|
85
85
|
const localProgress = position - index1;
|
|
86
|
-
//
|
|
86
|
+
// Interpolate between adjacent colors, generating three smoothly transitioning colors
|
|
87
87
|
const color1 = interpolateColor(colorSequence[index1], colorSequence[index2], localProgress);
|
|
88
88
|
const nextIndex1 = Math.min(index2, colorSequence.length - 1);
|
|
89
89
|
const nextIndex2 = Math.min(nextIndex1 + 1, colorSequence.length - 1);
|
|
@@ -91,24 +91,24 @@ async function animateGradient(text, duration = 1200) {
|
|
|
91
91
|
const nextIndex3 = Math.min(nextIndex2, colorSequence.length - 1);
|
|
92
92
|
const nextIndex4 = Math.min(nextIndex3 + 1, colorSequence.length - 1);
|
|
93
93
|
const color3 = interpolateColor(colorSequence[nextIndex3], colorSequence[nextIndex4], localProgress);
|
|
94
|
-
//
|
|
94
|
+
// Create gradient for current frame
|
|
95
95
|
const frameGradient = gradient(color1, color2, color3);
|
|
96
|
-
//
|
|
96
|
+
// Clear current line and display new frame
|
|
97
97
|
process.stdout.write('\r' + frameGradient(text));
|
|
98
98
|
await new Promise(resolve => setTimeout(resolve, frameDelay));
|
|
99
99
|
}
|
|
100
|
-
//
|
|
100
|
+
// Finally display static blue gradient
|
|
101
101
|
process.stdout.write('\r' + createBlueGradient(text) + '\n');
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* Attempt to read and display logo file
|
|
105
105
|
*/
|
|
106
106
|
export async function printLogo() {
|
|
107
107
|
try {
|
|
108
|
-
//
|
|
108
|
+
// Try to read iTerm2 image format logo
|
|
109
109
|
const logoPath = join(__dirname, '../logo/logo.txt');
|
|
110
110
|
const logoContent = readFileSync(logoPath, 'utf-8');
|
|
111
|
-
//
|
|
111
|
+
// If successfully read and content is valid, display directly
|
|
112
112
|
if (logoContent && logoContent.length > 100) {
|
|
113
113
|
console.log(logoContent);
|
|
114
114
|
await printDescription();
|
|
@@ -116,13 +116,13 @@ export async function printLogo() {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
catch (error) {
|
|
119
|
-
// iTerm2 logo
|
|
119
|
+
// iTerm2 logo read failed, continue trying ASCII logo
|
|
120
120
|
}
|
|
121
|
-
//
|
|
121
|
+
// Fallback: display ASCII art logo
|
|
122
122
|
try {
|
|
123
123
|
const asciiLogoPath = join(__dirname, '../logo/ascii-logo.txt');
|
|
124
124
|
const asciiContent = readFileSync(asciiLogoPath, 'utf-8');
|
|
125
|
-
//
|
|
125
|
+
// Display ASCII logo with gradient colors
|
|
126
126
|
console.log();
|
|
127
127
|
const lines = asciiContent.split('\n').filter(line => line.trim());
|
|
128
128
|
lines.forEach(line => {
|
|
@@ -131,19 +131,19 @@ export async function printLogo() {
|
|
|
131
131
|
await printDescription();
|
|
132
132
|
}
|
|
133
133
|
catch (error) {
|
|
134
|
-
//
|
|
134
|
+
// If ASCII logo also fails, display simple text logo
|
|
135
135
|
console.log();
|
|
136
136
|
console.log(createBlueGradient(' NBTCA'));
|
|
137
137
|
await printDescription();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
|
-
*
|
|
141
|
+
* Display description text (with gradient animation)
|
|
142
142
|
*/
|
|
143
143
|
async function printDescription() {
|
|
144
144
|
const tagline = 'To be at the intersection of technology and liberal arts.';
|
|
145
145
|
console.log();
|
|
146
|
-
//
|
|
146
|
+
// Display gradient animation
|
|
147
147
|
await animateGradient(tagline, 1500);
|
|
148
148
|
console.log();
|
|
149
149
|
}
|
package/dist/core/logo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logo.js","sourceRoot":"","sources":["../../src/core/logo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;GAEG;AACH,SAAS,kBAAkB,CAAC,IAAY;IACtC
|
|
1
|
+
{"version":3,"file":"logo.js","sourceRoot":"","sources":["../../src/core/logo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;GAEG;AACH,SAAS,kBAAkB,CAAC,IAAY;IACtC,+CAA+C;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC;QAC5B,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,EAAK,YAAY;QAC7C,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,EAAG,WAAW;QAC5C,EAAE,KAAK,EAAE,SA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AC,CAAC,CAAC;QAEH,MAAM,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qDAAqD;QACrD,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;QAC3C,MAAM,gBAAgB,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,gBAAgB;IAC7B,MAAM,OAAO,GAAG,2DAA2D,CAAC;IAE5E,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,6BAA6B;IAC7B,MAAM,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAErC,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
package/dist/core/menu.d.ts
CHANGED
package/dist/core/menu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/core/menu.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/core/menu.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8DH;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CA2ClD"}
|
package/dist/core/menu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Minimalist menu system
|
|
3
|
+
* Six core feature menus
|
|
4
4
|
*/
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import chalk from 'chalk';
|
|
@@ -10,83 +10,93 @@ import { showDocsMenu } from '../features/docs.js';
|
|
|
10
10
|
import { openHomepage, openGithub } from '../features/website.js';
|
|
11
11
|
import { printDivider, printNewLine } from './ui.js';
|
|
12
12
|
import { APP_INFO, URLS } from '../config/data.js';
|
|
13
|
+
import { t, getCurrentLanguage, setLanguage, clearTranslationCache } from '../i18n/index.js';
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Get main menu options
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
17
|
+
function getMainMenuOptions() {
|
|
18
|
+
const trans = t();
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
name: '[*] ' + trans.menu.events.padEnd(16) + ' ' + chalk.gray(trans.menu.eventsDesc),
|
|
22
|
+
value: 'events',
|
|
23
|
+
short: trans.menu.events
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: '[*] ' + trans.menu.repair.padEnd(16) + ' ' + chalk.gray(trans.menu.repairDesc),
|
|
27
|
+
value: 'repair',
|
|
28
|
+
short: trans.menu.repair
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: '[*] ' + trans.menu.docs.padEnd(16) + ' ' + chalk.gray(trans.menu.docsDesc),
|
|
32
|
+
value: 'docs',
|
|
33
|
+
short: trans.menu.docs
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: '[*] ' + trans.menu.website.padEnd(16) + ' ' + chalk.gray(trans.menu.websiteDesc),
|
|
37
|
+
value: 'website',
|
|
38
|
+
short: trans.menu.website
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: '[*] ' + trans.menu.github.padEnd(16) + ' ' + chalk.gray(trans.menu.githubDesc),
|
|
42
|
+
value: 'github',
|
|
43
|
+
short: trans.menu.github
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: '[?] ' + trans.menu.about.padEnd(16) + ' ' + chalk.gray(trans.menu.aboutDesc),
|
|
47
|
+
value: 'about',
|
|
48
|
+
short: trans.menu.about
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: '[⚙] ' + trans.menu.language.padEnd(16) + ' ' + chalk.gray(trans.menu.languageDesc),
|
|
52
|
+
value: 'language',
|
|
53
|
+
short: trans.menu.language
|
|
54
|
+
},
|
|
55
|
+
new inquirer.Separator(' '),
|
|
56
|
+
{
|
|
57
|
+
name: chalk.dim('[x] ' + trans.common.exit),
|
|
58
|
+
value: 'exit',
|
|
59
|
+
short: trans.common.exit
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
}
|
|
54
63
|
/**
|
|
55
|
-
*
|
|
64
|
+
* Display main menu
|
|
56
65
|
*/
|
|
57
66
|
export async function showMainMenu() {
|
|
58
67
|
while (true) {
|
|
59
68
|
try {
|
|
69
|
+
const trans = t();
|
|
60
70
|
// Show keybinding hints
|
|
61
|
-
console.log(chalk.dim('
|
|
71
|
+
console.log(chalk.dim(' ' + trans.menu.navigationHint));
|
|
62
72
|
console.log();
|
|
63
73
|
const { action } = await inquirer.prompt([
|
|
64
74
|
{
|
|
65
75
|
type: 'list',
|
|
66
76
|
name: 'action',
|
|
67
|
-
message:
|
|
68
|
-
choices:
|
|
77
|
+
message: trans.menu.chooseAction,
|
|
78
|
+
choices: getMainMenuOptions(),
|
|
69
79
|
pageSize: 15,
|
|
70
80
|
loop: false
|
|
71
81
|
}
|
|
72
82
|
]);
|
|
73
|
-
//
|
|
83
|
+
// Handle user selection
|
|
74
84
|
if (action === 'exit') {
|
|
75
85
|
console.log();
|
|
76
|
-
console.log(chalk.dim(
|
|
86
|
+
console.log(chalk.dim(trans.common.goodbye));
|
|
77
87
|
process.exit(0);
|
|
78
88
|
}
|
|
79
89
|
await handleAction(action);
|
|
80
|
-
//
|
|
90
|
+
// Show divider after operation
|
|
81
91
|
printNewLine();
|
|
82
92
|
printDivider();
|
|
83
93
|
printNewLine();
|
|
84
94
|
}
|
|
85
95
|
catch (err) {
|
|
86
|
-
//
|
|
96
|
+
// Handle Ctrl+C exit
|
|
87
97
|
if (err.message?.includes('User force closed')) {
|
|
88
98
|
console.log();
|
|
89
|
-
console.log(chalk.dim(
|
|
99
|
+
console.log(chalk.dim(t().common.goodbye));
|
|
90
100
|
process.exit(0);
|
|
91
101
|
}
|
|
92
102
|
throw err;
|
|
@@ -94,7 +104,7 @@ export async function showMainMenu() {
|
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
/**
|
|
97
|
-
*
|
|
107
|
+
* Handle user action
|
|
98
108
|
*/
|
|
99
109
|
async function handleAction(action) {
|
|
100
110
|
switch (action) {
|
|
@@ -116,33 +126,68 @@ async function handleAction(action) {
|
|
|
116
126
|
case 'about':
|
|
117
127
|
showAbout();
|
|
118
128
|
break;
|
|
129
|
+
case 'language':
|
|
130
|
+
await showLanguageMenu();
|
|
131
|
+
break;
|
|
119
132
|
default:
|
|
120
|
-
console.log(chalk.gray('
|
|
133
|
+
console.log(chalk.gray('Unknown action'));
|
|
121
134
|
}
|
|
122
135
|
}
|
|
123
136
|
/**
|
|
124
|
-
*
|
|
137
|
+
* Display about information
|
|
125
138
|
*/
|
|
126
139
|
function showAbout() {
|
|
140
|
+
const trans = t();
|
|
141
|
+
console.log();
|
|
142
|
+
console.log(chalk.bold('>> ' + trans.about.title));
|
|
143
|
+
console.log();
|
|
144
|
+
console.log(chalk.dim(trans.about.project.padEnd(12)) + APP_INFO.name);
|
|
145
|
+
console.log(chalk.dim(trans.about.version.padEnd(12)) + `v${APP_INFO.version}`);
|
|
146
|
+
console.log(chalk.dim(trans.about.description.padEnd(12)) + APP_INFO.fullDescription);
|
|
127
147
|
console.log();
|
|
128
|
-
console.log(chalk.
|
|
148
|
+
console.log(chalk.dim(trans.about.github.padEnd(12)) + chalk.cyan(APP_INFO.repository));
|
|
149
|
+
console.log(chalk.dim(trans.about.website.padEnd(12)) + chalk.cyan(URLS.homepage));
|
|
150
|
+
console.log(chalk.dim(trans.about.email.padEnd(12)) + chalk.cyan(URLS.email));
|
|
129
151
|
console.log();
|
|
130
|
-
console.log(chalk.dim(
|
|
131
|
-
console.log(
|
|
132
|
-
console.log(
|
|
152
|
+
console.log(chalk.dim(trans.about.features));
|
|
153
|
+
console.log(' ' + trans.about.feature1);
|
|
154
|
+
console.log(' ' + trans.about.feature2);
|
|
155
|
+
console.log(' ' + trans.about.feature3);
|
|
156
|
+
console.log(' ' + trans.about.feature4);
|
|
133
157
|
console.log();
|
|
134
|
-
console.log(chalk.dim(
|
|
135
|
-
console.log(chalk.dim(
|
|
136
|
-
console.log(chalk.dim('Email ') + chalk.cyan(URLS.email));
|
|
158
|
+
console.log(chalk.dim(trans.about.license.padEnd(12)) + 'MIT License');
|
|
159
|
+
console.log(chalk.dim(trans.about.author.padEnd(12)) + 'm1ngsama');
|
|
137
160
|
console.log();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Display language selection menu
|
|
164
|
+
*/
|
|
165
|
+
async function showLanguageMenu() {
|
|
166
|
+
const trans = t();
|
|
167
|
+
const currentLang = getCurrentLanguage();
|
|
143
168
|
console.log();
|
|
144
|
-
console.log(chalk.
|
|
145
|
-
console.log(chalk.dim('Author ') + 'm1ngsama');
|
|
169
|
+
console.log(chalk.bold('>> ' + trans.language.title));
|
|
146
170
|
console.log();
|
|
171
|
+
console.log(chalk.dim(trans.language.currentLanguage + ': ') + chalk.cyan(trans.language[currentLang]));
|
|
172
|
+
console.log();
|
|
173
|
+
const { language } = await inquirer.prompt([
|
|
174
|
+
{
|
|
175
|
+
type: 'list',
|
|
176
|
+
name: 'language',
|
|
177
|
+
message: trans.language.selectLanguage,
|
|
178
|
+
choices: [
|
|
179
|
+
{ name: trans.language.zh, value: 'zh' },
|
|
180
|
+
{ name: trans.language.en, value: 'en' }
|
|
181
|
+
],
|
|
182
|
+
default: currentLang
|
|
183
|
+
}
|
|
184
|
+
]);
|
|
185
|
+
if (language !== currentLang) {
|
|
186
|
+
setLanguage(language);
|
|
187
|
+
clearTranslationCache();
|
|
188
|
+
console.log();
|
|
189
|
+
console.log(chalk.green('✓ ' + t().language.changed));
|
|
190
|
+
console.log();
|
|
191
|
+
}
|
|
147
192
|
}
|
|
148
193
|
//# sourceMappingURL=menu.js.map
|