mepcli 0.2.7 → 0.4.0
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 +25 -3
- package/dist/ansi.d.ts +3 -0
- package/dist/ansi.js +4 -0
- package/dist/base.d.ts +11 -0
- package/dist/base.js +38 -157
- package/dist/core.d.ts +2 -1
- package/dist/core.js +8 -3
- package/dist/input.d.ts +1 -0
- package/dist/input.js +62 -8
- package/dist/prompts/checkbox.d.ts +2 -1
- package/dist/prompts/checkbox.js +19 -4
- package/dist/prompts/confirm.d.ts +2 -1
- package/dist/prompts/confirm.js +6 -0
- package/dist/prompts/date.d.ts +3 -1
- package/dist/prompts/date.js +64 -32
- package/dist/prompts/file.js +3 -2
- package/dist/prompts/list.js +2 -1
- package/dist/prompts/multi-select.d.ts +2 -1
- package/dist/prompts/multi-select.js +20 -4
- package/dist/prompts/number.d.ts +2 -1
- package/dist/prompts/number.js +24 -1
- package/dist/prompts/rating.d.ts +8 -0
- package/dist/prompts/rating.js +78 -0
- package/dist/prompts/select.d.ts +2 -1
- package/dist/prompts/select.js +18 -2
- package/dist/prompts/slider.d.ts +2 -1
- package/dist/prompts/slider.js +16 -1
- package/dist/prompts/text.js +2 -32
- package/dist/prompts/toggle.d.ts +2 -1
- package/dist/prompts/toggle.js +6 -0
- package/dist/symbols.d.ts +21 -0
- package/dist/symbols.js +29 -0
- package/dist/types.d.ts +14 -0
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +38 -7
- package/example.ts +14 -5
- package/package.json +4 -4
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -14,17 +14,48 @@ function detectCapabilities() {
|
|
|
14
14
|
const isCI = !!env.CI;
|
|
15
15
|
// Check for True Color support
|
|
16
16
|
const hasTrueColor = env.COLORTERM === 'truecolor';
|
|
17
|
-
// Check
|
|
18
|
-
|
|
17
|
+
// Check if it is a TTY
|
|
18
|
+
const isTTY = process.stdout.isTTY;
|
|
19
19
|
const isWindows = process.platform === 'win32';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(
|
|
20
|
+
// Logic detect Unicode xịn hơn
|
|
21
|
+
const isUnicodeSupported = () => {
|
|
22
|
+
// 1. Windows: Check specific environmental variables
|
|
23
|
+
if (isWindows) {
|
|
24
|
+
// Windows Terminal
|
|
25
|
+
if (env.WT_SESSION)
|
|
26
|
+
return true;
|
|
27
|
+
// VSCode terminal
|
|
28
|
+
if (env.TERM_PROGRAM === 'vscode')
|
|
29
|
+
return true;
|
|
30
|
+
// Modern terminals setting TERM (e.g. Alacritty, Git Bash, Cygwin)
|
|
31
|
+
if (env.TERM === 'xterm-256color' || env.TERM === 'alacritty')
|
|
32
|
+
return true;
|
|
33
|
+
// ConEmu / Cmder
|
|
34
|
+
if (env.ConEmuTask)
|
|
35
|
+
return true;
|
|
36
|
+
// CI on Windows typically supports Unicode.
|
|
37
|
+
if (isCI)
|
|
38
|
+
return true;
|
|
39
|
+
// Default cmd.exe / old powershell => False (ASCII)
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
// 2. Non-Windows (Linux/macOS)
|
|
43
|
+
if (env.TERM_PROGRAM === 'Apple_Terminal')
|
|
44
|
+
return true;
|
|
45
|
+
// Check if the LANG or LC_ALL variable contains UTF-8.
|
|
46
|
+
const lang = env.LANG || '';
|
|
47
|
+
const lcAll = env.LC_ALL || '';
|
|
48
|
+
return (lang && lang.toUpperCase().endsWith('UTF-8')) ||
|
|
49
|
+
(lcAll && lcAll.toUpperCase().endsWith('UTF-8'));
|
|
50
|
+
};
|
|
24
51
|
return {
|
|
25
52
|
isCI,
|
|
26
53
|
hasTrueColor,
|
|
27
|
-
|
|
54
|
+
// Enable Unicode only if it's TTY and environment supports it.
|
|
55
|
+
hasUnicode: isTTY && isUnicodeSupported(),
|
|
56
|
+
// Check if mouse should be enabled (TTY and not CI, or explicit override)
|
|
57
|
+
// SGR is widely supported in modern terminals
|
|
58
|
+
hasMouse: isTTY && !isCI
|
|
28
59
|
};
|
|
29
60
|
}
|
|
30
61
|
/**
|
package/example.ts
CHANGED
|
@@ -96,7 +96,16 @@ async function runComprehensiveDemo() {
|
|
|
96
96
|
});
|
|
97
97
|
console.log(`\n✅ Slider Result: Brightness: ${brightness}%`);
|
|
98
98
|
|
|
99
|
-
// --- 9.
|
|
99
|
+
// --- 9. Rating Prompt (New) ---
|
|
100
|
+
const userRating = await MepCLI.rating({
|
|
101
|
+
message: "How would you rate this CLI tool?",
|
|
102
|
+
min: 1,
|
|
103
|
+
max: 5,
|
|
104
|
+
initial: 5
|
|
105
|
+
});
|
|
106
|
+
console.log(`\n✅ Rating Result: You rated it: ${userRating}/5`);
|
|
107
|
+
|
|
108
|
+
// --- 10. Date / Time Picker (New) ---
|
|
100
109
|
// We capture 'now' once to ensure initial >= min
|
|
101
110
|
const now = new Date();
|
|
102
111
|
const releaseDate = await MepCLI.date({
|
|
@@ -106,14 +115,14 @@ async function runComprehensiveDemo() {
|
|
|
106
115
|
});
|
|
107
116
|
console.log(`\n✅ Date Result: Release set for: ${releaseDate.toLocaleString()}`);
|
|
108
117
|
|
|
109
|
-
// ---
|
|
118
|
+
// --- 11. File Path Selector (New) ---
|
|
110
119
|
const configPath = await MepCLI.file({
|
|
111
120
|
message: "Select configuration file (Tab to autocomplete):",
|
|
112
121
|
basePath: process.cwd()
|
|
113
122
|
});
|
|
114
123
|
console.log(`\n✅ File Result: Path: ${configPath}`);
|
|
115
124
|
|
|
116
|
-
// ---
|
|
125
|
+
// --- 12. Multi-Select Autocomplete (New) ---
|
|
117
126
|
const linters = await MepCLI.multiSelect({
|
|
118
127
|
message: "Select linters to install (Type to search, Space to select):",
|
|
119
128
|
choices: [
|
|
@@ -128,14 +137,14 @@ async function runComprehensiveDemo() {
|
|
|
128
137
|
});
|
|
129
138
|
console.log(`\n✅ MultiSelect Result: Linters: [${linters.join(', ')}]`);
|
|
130
139
|
|
|
131
|
-
// ---
|
|
140
|
+
// --- 13. Confirm Prompt (Simple Yes/No) ---
|
|
132
141
|
const proceed = await MepCLI.confirm({
|
|
133
142
|
message: "Ready to deploy the project now?",
|
|
134
143
|
initial: true
|
|
135
144
|
});
|
|
136
145
|
console.log(`\n✅ Confirm Result: Deployment decision: ${proceed ? 'Proceed' : 'Cancel'}`);
|
|
137
146
|
|
|
138
|
-
// ---
|
|
147
|
+
// --- 14. Spin Utility (Loading/Async Task Indicator) ---
|
|
139
148
|
await MepCLI.spin(
|
|
140
149
|
"Finalizing configuration and deploying...",
|
|
141
150
|
new Promise(resolve => setTimeout(resolve, 1500)) // Simulates a 1.5 second async task
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mepcli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Zero-dependency, minimalist interactive CLI prompt for Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"author": "CodeTease",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"ts-node": "^10
|
|
35
|
-
"typescript": "^5
|
|
33
|
+
"@types/node": "^22",
|
|
34
|
+
"ts-node": "^10",
|
|
35
|
+
"typescript": "^5"
|
|
36
36
|
}
|
|
37
37
|
}
|