mepcli 0.6.1 → 1.0.0-beta.2
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/LICENSE +21 -21
- package/README.md +512 -326
- package/dist/ansi.d.ts +8 -0
- package/dist/ansi.js +8 -0
- package/dist/base.d.ts +21 -0
- package/dist/base.js +57 -0
- package/dist/core.d.ts +48 -1
- package/dist/core.js +156 -0
- package/dist/data/licenses.d.ts +2 -0
- package/dist/data/licenses.js +109 -0
- package/dist/highlight.js +58 -26
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/input.js +0 -3
- package/dist/prompts/box.d.ts +21 -0
- package/dist/prompts/box.js +192 -0
- package/dist/prompts/breadcrumb.d.ts +22 -0
- package/dist/prompts/breadcrumb.js +302 -0
- package/dist/prompts/byte.d.ts +13 -0
- package/dist/prompts/byte.js +159 -0
- package/dist/prompts/calculator.d.ts +16 -0
- package/dist/prompts/calculator.js +213 -0
- package/dist/prompts/calendar.js +0 -5
- package/dist/prompts/code.d.ts +2 -0
- package/dist/prompts/code.js +104 -70
- package/dist/prompts/connection-string.d.ts +18 -0
- package/dist/prompts/connection-string.js +97 -0
- package/dist/prompts/curl.d.ts +39 -0
- package/dist/prompts/curl.js +285 -0
- package/dist/prompts/data-inspector.d.ts +22 -0
- package/dist/prompts/data-inspector.js +256 -0
- package/dist/prompts/dependency.d.ts +16 -0
- package/dist/prompts/dependency.js +265 -0
- package/dist/prompts/dial.d.ts +10 -0
- package/dist/prompts/dial.js +110 -0
- package/dist/prompts/diff.d.ts +10 -0
- package/dist/prompts/diff.js +101 -0
- package/dist/prompts/draw.d.ts +20 -0
- package/dist/prompts/draw.js +188 -0
- package/dist/prompts/editor.js +0 -4
- package/dist/prompts/emoji.d.ts +18 -0
- package/dist/prompts/emoji.js +228 -0
- package/dist/prompts/exec.d.ts +13 -0
- package/dist/prompts/exec.js +83 -0
- package/dist/prompts/fuzzy.d.ts +12 -0
- package/dist/prompts/fuzzy.js +136 -0
- package/dist/prompts/gauge.d.ts +21 -0
- package/dist/prompts/gauge.js +130 -0
- package/dist/prompts/heatmap.d.ts +13 -0
- package/dist/prompts/heatmap.js +141 -0
- package/dist/prompts/ip.d.ts +11 -0
- package/dist/prompts/ip.js +118 -0
- package/dist/prompts/kanban.d.ts +17 -0
- package/dist/prompts/kanban.js +228 -0
- package/dist/prompts/keypress.js +0 -2
- package/dist/prompts/license.d.ts +9 -0
- package/dist/prompts/license.js +105 -0
- package/dist/prompts/map.d.ts +15 -0
- package/dist/prompts/map.js +199 -0
- package/dist/prompts/match.d.ts +19 -0
- package/dist/prompts/match.js +275 -0
- package/dist/prompts/miller.d.ts +15 -0
- package/dist/prompts/miller.js +221 -0
- package/dist/prompts/multi-column-select.d.ts +10 -0
- package/dist/prompts/multi-column-select.js +166 -0
- package/dist/prompts/number.js +0 -2
- package/dist/prompts/otp.d.ts +10 -0
- package/dist/prompts/otp.js +91 -0
- package/dist/prompts/pattern.d.ts +22 -0
- package/dist/prompts/pattern.js +249 -0
- package/dist/prompts/quiz-select.d.ts +10 -0
- package/dist/prompts/quiz-select.js +104 -0
- package/dist/prompts/quiz-text.d.ts +11 -0
- package/dist/prompts/quiz-text.js +82 -0
- package/dist/prompts/regex.d.ts +13 -0
- package/dist/prompts/regex.js +131 -0
- package/dist/prompts/region.d.ts +11 -0
- package/dist/prompts/region.js +164 -0
- package/dist/prompts/schedule.d.ts +18 -0
- package/dist/prompts/schedule.js +221 -0
- package/dist/prompts/scroll.d.ts +13 -0
- package/dist/prompts/scroll.js +152 -0
- package/dist/prompts/seat.d.ts +17 -0
- package/dist/prompts/seat.js +165 -0
- package/dist/prompts/select-range.d.ts +8 -0
- package/dist/prompts/select-range.js +136 -0
- package/dist/prompts/select.d.ts +9 -9
- package/dist/prompts/semver.d.ts +6 -0
- package/dist/prompts/semver.js +32 -0
- package/dist/prompts/shortcut.d.ts +9 -0
- package/dist/prompts/shortcut.js +135 -0
- package/dist/prompts/slot.d.ts +16 -0
- package/dist/prompts/slot.js +107 -0
- package/dist/prompts/snippet.js +0 -3
- package/dist/prompts/sort-grid.d.ts +16 -0
- package/dist/prompts/sort-grid.js +146 -0
- package/dist/prompts/sort.js +0 -1
- package/dist/prompts/spreadsheet.d.ts +21 -0
- package/dist/prompts/spreadsheet.js +239 -0
- package/dist/prompts/text.d.ts +9 -7
- package/dist/prompts/text.js +52 -0
- package/dist/prompts/time.d.ts +12 -0
- package/dist/prompts/time.js +202 -0
- package/dist/prompts/tree-select.d.ts +0 -1
- package/dist/prompts/tree-select.js +1 -5
- package/dist/symbols.d.ts +12 -0
- package/dist/symbols.js +14 -2
- package/dist/theme.js +10 -1
- package/dist/types.d.ts +264 -1
- package/dist/utils.d.ts +53 -0
- package/dist/utils.js +252 -0
- package/package.json +51 -47
- package/example.ts +0 -390
package/package.json
CHANGED
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mepcli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Zero-dependency, interactive CLI prompt for Node.js",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/CodeTease/mep.git"
|
|
8
|
-
},
|
|
9
|
-
"main": "dist/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
|
-
"files": [
|
|
12
|
-
"dist",
|
|
13
|
-
"README.md",
|
|
14
|
-
"LICENSE"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"lint": "eslint ."
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"interactive",
|
|
30
|
-
"zero-dependency",
|
|
31
|
-
"codetease"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"jest": "^30",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "mepcli",
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
|
+
"description": "Zero-dependency, interactive CLI prompt for Node.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/CodeTease/mep.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"demo": "ts-node example.ts",
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"lint:fix": "eslint . --fix"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"cli",
|
|
26
|
+
"prompt",
|
|
27
|
+
"inquirer",
|
|
28
|
+
"enquirer",
|
|
29
|
+
"interactive",
|
|
30
|
+
"zero-dependency",
|
|
31
|
+
"codetease",
|
|
32
|
+
"command-line",
|
|
33
|
+
"typescript",
|
|
34
|
+
"color",
|
|
35
|
+
"ansi"
|
|
36
|
+
],
|
|
37
|
+
"author": "CodeTease",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^9",
|
|
41
|
+
"@types/jest": "^30",
|
|
42
|
+
"@types/node": "^22",
|
|
43
|
+
"eslint": "^9",
|
|
44
|
+
"globals": "^17",
|
|
45
|
+
"jest": "^30",
|
|
46
|
+
"ts-jest": "^29",
|
|
47
|
+
"ts-node": "^10",
|
|
48
|
+
"typescript": "^5",
|
|
49
|
+
"typescript-eslint": "^8"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/example.ts
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
import { MepCLI } from './src'; // Or 'mepcli' if installed via NPM
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Runs a comprehensive demo showcasing all MepCLI prompt types and utilities.
|
|
5
|
-
* This demonstrates all core functionalities including Text, Password, Select,
|
|
6
|
-
* Checkbox, Number, Toggle, Confirm, List, Slider, Date, File, MultiSelect,
|
|
7
|
-
* Autocomplete, Sort, Table, and the Spin utility.
|
|
8
|
-
*/
|
|
9
|
-
async function runComprehensiveDemo() {
|
|
10
|
-
console.clear();
|
|
11
|
-
console.log("--- MepCLI Comprehensive Demo (All Prompts + Spin Utility) ---\n");
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
// --- 1. Text Prompt (Input with Validation and initial value) ---
|
|
15
|
-
const projectName = await MepCLI.text({
|
|
16
|
-
message: "Enter the name for your new project:",
|
|
17
|
-
placeholder: "e.g., minimalist-cli-app",
|
|
18
|
-
initial: "MepProject",
|
|
19
|
-
validate: (value) => {
|
|
20
|
-
if (value.length < 3) return "Project name must be at least 3 characters long.";
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
console.log(`\n Text Result: Project name set to '${projectName}'`);
|
|
25
|
-
|
|
26
|
-
// --- 2. Password Prompt (Hidden input) ---
|
|
27
|
-
const apiKey = await MepCLI.password({
|
|
28
|
-
message: "Enter the project's external API key:",
|
|
29
|
-
placeholder: "Input will be hidden..."
|
|
30
|
-
});
|
|
31
|
-
console.log(`\n Password Result: API key entered (length: ${apiKey.length})`);
|
|
32
|
-
|
|
33
|
-
// --- 2.5. Secret Prompt (Completely hidden input) ---
|
|
34
|
-
const secretToken = await MepCLI.secret({
|
|
35
|
-
message: "Enter secret token (no feedback):",
|
|
36
|
-
validate: (v) => v.length > 0 || "Token required"
|
|
37
|
-
});
|
|
38
|
-
console.log(`\n Secret Result: Token entered (length: ${secretToken.length})`);
|
|
39
|
-
|
|
40
|
-
// --- 3. Select Prompt (Single choice, supports filtering/searching by typing) ---
|
|
41
|
-
const theme = await MepCLI.select({
|
|
42
|
-
message: "Choose your preferred editor color theme:",
|
|
43
|
-
choices: [
|
|
44
|
-
{ title: "Dark Mode (Default)", value: "dark" },
|
|
45
|
-
{ title: "Light Mode (Classic)", value: "light" },
|
|
46
|
-
{ title: "High Contrast (Accessibility)", value: "contrast" },
|
|
47
|
-
// Demonstrates a separator option
|
|
48
|
-
{ separator: true, text: "--- Pro Themes ---" },
|
|
49
|
-
{ title: "Monokai Pro", value: "monokai" },
|
|
50
|
-
]
|
|
51
|
-
});
|
|
52
|
-
console.log(`\n Select Result: Chosen theme is: ${theme}`);
|
|
53
|
-
|
|
54
|
-
// --- 4. Checkbox Prompt (Multi-choice with Min/Max limits) ---
|
|
55
|
-
const buildTools = await MepCLI.checkbox({
|
|
56
|
-
message: "Select your required bundlers/build tools (Min 1, Max 2):",
|
|
57
|
-
min: 1,
|
|
58
|
-
max: 2,
|
|
59
|
-
choices: [
|
|
60
|
-
{ title: "Webpack", value: "webpack" },
|
|
61
|
-
{ title: "Vite", value: "vite", selected: true }, // Default selected state
|
|
62
|
-
{ title: "Rollup", value: "rollup" },
|
|
63
|
-
{ title: "esbuild", value: "esbuild" }
|
|
64
|
-
]
|
|
65
|
-
});
|
|
66
|
-
console.log(`\n Checkbox Result: Selected build tools: [${buildTools.join(', ')}]`);
|
|
67
|
-
|
|
68
|
-
// --- 5. Number Prompt (Numeric input, supports Min/Max and Up/Down arrow for Step) ---
|
|
69
|
-
const port = await MepCLI.number({
|
|
70
|
-
message: "Which port should the server run on?",
|
|
71
|
-
initial: 3000,
|
|
72
|
-
min: 1024,
|
|
73
|
-
max: 65535,
|
|
74
|
-
step: 100 // Increments/decrements by 100 with arrows
|
|
75
|
-
});
|
|
76
|
-
console.log(`\n Number Result: Server port: ${port}`);
|
|
77
|
-
|
|
78
|
-
// --- 6. Toggle Prompt (Boolean input, supports custom labels) ---
|
|
79
|
-
const isSecure = await MepCLI.toggle({
|
|
80
|
-
message: "Enable HTTPS/SSL for production?",
|
|
81
|
-
initial: false,
|
|
82
|
-
activeText: "SECURE", // Custom 'on' label
|
|
83
|
-
inactiveText: "INSECURE" // Custom 'off' label
|
|
84
|
-
});
|
|
85
|
-
console.log(`\n Toggle Result: HTTPS enabled: ${isSecure}`);
|
|
86
|
-
|
|
87
|
-
// --- 7. List / Tags Input ---
|
|
88
|
-
const keywords = await MepCLI.list({
|
|
89
|
-
message: "Enter keywords for package.json (Enter to add, Backspace to remove):",
|
|
90
|
-
initial: ["cli", "mep"],
|
|
91
|
-
validate: (tags) => tags.length > 0 || "Please add at least one keyword."
|
|
92
|
-
});
|
|
93
|
-
console.log(`\n List Result: Keywords: [${keywords.join(', ')}]`);
|
|
94
|
-
|
|
95
|
-
// --- 8. Slider / Scale ---
|
|
96
|
-
const brightness = await MepCLI.slider({
|
|
97
|
-
message: "Set initial brightness:",
|
|
98
|
-
min: 0,
|
|
99
|
-
max: 100,
|
|
100
|
-
initial: 80,
|
|
101
|
-
step: 5,
|
|
102
|
-
unit: "%"
|
|
103
|
-
});
|
|
104
|
-
console.log(`\n Slider Result: Brightness: ${brightness}%`);
|
|
105
|
-
|
|
106
|
-
// --- 8.1. Range Prompt (Dual Slider) ---
|
|
107
|
-
const priceRange = await MepCLI.range({
|
|
108
|
-
message: "Filter by price range:",
|
|
109
|
-
min: 0,
|
|
110
|
-
max: 1000,
|
|
111
|
-
initial: [200, 800],
|
|
112
|
-
step: 50,
|
|
113
|
-
unit: "$"
|
|
114
|
-
});
|
|
115
|
-
console.log(`\n Range Result: $${priceRange[0]} - $${priceRange[1]}`);
|
|
116
|
-
|
|
117
|
-
// --- 9. Rating Prompt ---
|
|
118
|
-
const userRating = await MepCLI.rating({
|
|
119
|
-
message: "How would you rate this CLI tool?",
|
|
120
|
-
min: 1,
|
|
121
|
-
max: 5,
|
|
122
|
-
initial: 5
|
|
123
|
-
});
|
|
124
|
-
console.log(`\n Rating Result: You rated it: ${userRating}/5`);
|
|
125
|
-
|
|
126
|
-
// --- 10. Date / Time Picker ---
|
|
127
|
-
// We capture 'now' once to ensure initial >= min
|
|
128
|
-
const now = new Date();
|
|
129
|
-
const releaseDate = await MepCLI.date({
|
|
130
|
-
message: "Schedule release date:",
|
|
131
|
-
initial: now,
|
|
132
|
-
min: now // Cannot be in the past
|
|
133
|
-
});
|
|
134
|
-
console.log(`\n Date Result: Release set for: ${releaseDate.toLocaleString()}`);
|
|
135
|
-
|
|
136
|
-
// --- 11. File Path Selector ---
|
|
137
|
-
const configPath = await MepCLI.file({
|
|
138
|
-
message: "Select configuration file (Tab to autocomplete):",
|
|
139
|
-
basePath: process.cwd()
|
|
140
|
-
});
|
|
141
|
-
console.log(`\n File Result: Path: ${configPath}`);
|
|
142
|
-
|
|
143
|
-
// --- 12. Multi-Select Autocomplete ---
|
|
144
|
-
const linters = await MepCLI.multiSelect({
|
|
145
|
-
message: "Select linters to install (Type to search, Space to select):",
|
|
146
|
-
choices: [
|
|
147
|
-
{ title: "ESLint", value: "eslint", selected: true },
|
|
148
|
-
{ title: "Prettier", value: "prettier" },
|
|
149
|
-
{ title: "Stylelint", value: "stylelint" },
|
|
150
|
-
{ title: "TSLint (Deprecated)", value: "tslint" },
|
|
151
|
-
{ title: "JSHint", value: "jshint" },
|
|
152
|
-
{ title: "StandardJS", value: "standard" }
|
|
153
|
-
],
|
|
154
|
-
min: 1
|
|
155
|
-
});
|
|
156
|
-
console.log(`\n MultiSelect Result: Linters: [${linters.join(', ')}]`);
|
|
157
|
-
|
|
158
|
-
// --- 13. Autocomplete Prompt ---
|
|
159
|
-
const city = await MepCLI.autocomplete({
|
|
160
|
-
message: "Search for a city (simulated async):",
|
|
161
|
-
suggest: async (query) => {
|
|
162
|
-
const cities = [
|
|
163
|
-
{ title: "New York", value: "NY" },
|
|
164
|
-
{ title: "London", value: "LDN" },
|
|
165
|
-
{ title: "Paris", value: "PAR" },
|
|
166
|
-
{ title: "Tokyo", value: "TKY" },
|
|
167
|
-
{ title: "Berlin", value: "BER" },
|
|
168
|
-
{ title: "San Francisco", value: "SF" },
|
|
169
|
-
{ title: "Toronto", value: "TOR" }
|
|
170
|
-
];
|
|
171
|
-
// Simulate delay
|
|
172
|
-
await new Promise(r => setTimeout(r, 400));
|
|
173
|
-
return cities.filter(c => c.title.toLowerCase().includes(query.toLowerCase()));
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
console.log(`\n Autocomplete Result: City code: ${city}`);
|
|
177
|
-
|
|
178
|
-
// --- 14. Sort Prompt ---
|
|
179
|
-
const priorities = await MepCLI.sort({
|
|
180
|
-
message: "Rank your top priorities (Space to grab/drop, Arrows to move):",
|
|
181
|
-
items: ["Performance", "Security", "Features", "Usability", "Cost"]
|
|
182
|
-
});
|
|
183
|
-
console.log(`\n Sort Result: Priorities: [${priorities.join(', ')}]`);
|
|
184
|
-
|
|
185
|
-
// --- 14.1 Transfer Prompt (PickList) ---
|
|
186
|
-
const teamA = await MepCLI.transfer({
|
|
187
|
-
message: "Assign members to Team A (Space to move):",
|
|
188
|
-
source: ["Alice", "Bob", "Charlie", "David", "Eve"],
|
|
189
|
-
target: ["Frank"] // Pre-assigned
|
|
190
|
-
});
|
|
191
|
-
console.log(`\n Transfer Result: Team A: [${teamA[1].join(', ')}] (Remaining: [${teamA[0].join(', ')}])`);
|
|
192
|
-
|
|
193
|
-
// --- 15. Table Prompt ---
|
|
194
|
-
const userId = await MepCLI.table({
|
|
195
|
-
message: "Select a user from the database:",
|
|
196
|
-
columns: ["ID", "Name", "Role", "Status"],
|
|
197
|
-
data: [
|
|
198
|
-
{ value: 1, row: ["001", "Alice", "Admin", "Active"] },
|
|
199
|
-
{ value: 2, row: ["002", "Bob", "Dev", "Offline"] },
|
|
200
|
-
{ value: 3, row: ["003", "Charlie", "User", "Active"] },
|
|
201
|
-
{ value: 4, row: ["004", "David", "Manager", "Active"] },
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
console.log(`\n Table Result: Selected User ID: ${userId}`);
|
|
205
|
-
|
|
206
|
-
// --- 16. Confirm Prompt (Simple Yes/No) ---
|
|
207
|
-
const proceed = await MepCLI.confirm({
|
|
208
|
-
message: "Ready to deploy the project now?",
|
|
209
|
-
initial: true
|
|
210
|
-
});
|
|
211
|
-
console.log(`\n Confirm Result: Deployment decision: ${proceed ? 'Proceed' : 'Cancel'}`);
|
|
212
|
-
|
|
213
|
-
// --- 17. Editor Prompt ---
|
|
214
|
-
const bio = await MepCLI.editor({
|
|
215
|
-
message: "Write your biography (opens default editor):",
|
|
216
|
-
initial: "Hi, I am a developer...",
|
|
217
|
-
extension: ".md",
|
|
218
|
-
waitUserInput: true
|
|
219
|
-
});
|
|
220
|
-
console.log(`\n Editor Result: Biography length: ${bio.length} chars`);
|
|
221
|
-
|
|
222
|
-
// --- 18. Keypress Prompt ---
|
|
223
|
-
console.log("\n--- Press any key to continue to the Tree Prompt Demo... ---");
|
|
224
|
-
const key = await MepCLI.keypress({
|
|
225
|
-
message: "Press any key to proceed (or 'q' to quit):",
|
|
226
|
-
keys: ['q', 'enter', 'space', 'escape'] // Optional whitelist, or leave undefined for any
|
|
227
|
-
});
|
|
228
|
-
console.log(`\n Keypress Result: You pressed '${key}'`);
|
|
229
|
-
if (key === 'q') return;
|
|
230
|
-
|
|
231
|
-
// --- 19. Tree Prompt ---
|
|
232
|
-
const selectedFile = await MepCLI.tree({
|
|
233
|
-
message: "Select a file from the project structure (Space to toggle, Enter to select):",
|
|
234
|
-
data: [
|
|
235
|
-
{
|
|
236
|
-
title: "src",
|
|
237
|
-
value: "src",
|
|
238
|
-
children: [
|
|
239
|
-
{ title: "index.ts", value: "src/index.ts" },
|
|
240
|
-
{ title: "utils.ts", value: "src/utils.ts" },
|
|
241
|
-
{
|
|
242
|
-
title: "prompts",
|
|
243
|
-
value: "src/prompts",
|
|
244
|
-
expanded: true,
|
|
245
|
-
children: [
|
|
246
|
-
{ title: "text.ts", value: "src/prompts/text.ts" },
|
|
247
|
-
{ title: "select.ts", value: "src/prompts/select.ts" }
|
|
248
|
-
]
|
|
249
|
-
}
|
|
250
|
-
]
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
title: "package.json",
|
|
254
|
-
value: "package.json"
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
title: "README.md",
|
|
258
|
-
value: "README.md"
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
});
|
|
262
|
-
console.log(`\n Tree Result: Selected path: ${selectedFile}`);
|
|
263
|
-
|
|
264
|
-
// --- 20. Form Prompt ---
|
|
265
|
-
const userDetails = await MepCLI.form({
|
|
266
|
-
message: "Enter User Details (Up/Down/Tab to navigate):",
|
|
267
|
-
fields: [
|
|
268
|
-
{ name: "firstname", message: "First Name", initial: "John" },
|
|
269
|
-
{ name: "lastname", message: "Last Name", validate: (v) => v.length > 0 ? true : "Required" },
|
|
270
|
-
{ name: "email", message: "Email", validate: (v) => v.includes("@") || "Invalid email" },
|
|
271
|
-
{ name: "role", message: "Job Role", initial: "Developer" }
|
|
272
|
-
]
|
|
273
|
-
});
|
|
274
|
-
console.log(`\n Form Result: User: ${JSON.stringify(userDetails)}`);
|
|
275
|
-
|
|
276
|
-
// --- 21. Snippet Prompt ---
|
|
277
|
-
const commitMsg = await MepCLI.snippet({
|
|
278
|
-
message: "Compose Commit Message (Tab/Shift+Tab to navigate variables):",
|
|
279
|
-
template: "feat(${scope}): ${message} (Refs: #${issue})",
|
|
280
|
-
values: {
|
|
281
|
-
scope: "cli",
|
|
282
|
-
issue: "123"
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
console.log(`\n Snippet Result: "${commitMsg}"`);
|
|
286
|
-
|
|
287
|
-
// --- 22. Spam Prompt ---
|
|
288
|
-
const spamConfirmed = await MepCLI.spam({
|
|
289
|
-
message: "Hold on! Confirm deployment by mashing the Space key!",
|
|
290
|
-
threshold: 10,
|
|
291
|
-
decay: false, // We're not devil
|
|
292
|
-
spamKey: ' ' // Space key
|
|
293
|
-
});
|
|
294
|
-
console.log(`\n Spam Result: Deployment confirmed: ${spamConfirmed}`);
|
|
295
|
-
|
|
296
|
-
// --- 23. Wait Prompt ---
|
|
297
|
-
await MepCLI.wait({
|
|
298
|
-
message: "Please wait while we finalize the setup...",
|
|
299
|
-
seconds: 3, // Just 3 seconds for demo
|
|
300
|
-
autoSubmit: true // Automatically proceeds after time is up
|
|
301
|
-
});
|
|
302
|
-
console.log("\n Wait Result: Wait complete.");
|
|
303
|
-
|
|
304
|
-
// --- 24. Code Prompt ---
|
|
305
|
-
const config = await MepCLI.code({
|
|
306
|
-
message: "Configure Server (JSON) - Tab to nav:",
|
|
307
|
-
language: "json",
|
|
308
|
-
highlight: true, // Experimental syntax highlighting
|
|
309
|
-
template: `
|
|
310
|
-
{
|
|
311
|
-
"host": "\${host}",
|
|
312
|
-
"port": \${port},
|
|
313
|
-
"debug": \${debug}
|
|
314
|
-
}
|
|
315
|
-
`
|
|
316
|
-
});
|
|
317
|
-
console.log(`\n Code Result: Config: ${config.replace(/\n/g, ' ')}`);
|
|
318
|
-
|
|
319
|
-
// --- 25. Tree Select Prompt ---
|
|
320
|
-
const selectedTreeItems = await MepCLI.treeSelect({
|
|
321
|
-
message: "Select files to backup (Multi-select Tree):",
|
|
322
|
-
data: [
|
|
323
|
-
{
|
|
324
|
-
title: "src",
|
|
325
|
-
value: "src",
|
|
326
|
-
children: [
|
|
327
|
-
{ title: "index.ts", value: "src/index.ts" },
|
|
328
|
-
{ title: "utils.ts", value: "src/utils.ts" }
|
|
329
|
-
]
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
title: "tests",
|
|
333
|
-
value: "tests",
|
|
334
|
-
expanded: true,
|
|
335
|
-
children: [
|
|
336
|
-
{ title: "e2e", value: "tests/e2e", selected: true },
|
|
337
|
-
{ title: "unit", value: "tests/unit" }
|
|
338
|
-
]
|
|
339
|
-
}
|
|
340
|
-
]
|
|
341
|
-
});
|
|
342
|
-
console.log(`\n TreeSelect Result: Selected: [${selectedTreeItems.join(', ')}]`);
|
|
343
|
-
|
|
344
|
-
// --- 26. Cron Prompt ---
|
|
345
|
-
const schedule = await MepCLI.cron({
|
|
346
|
-
message: "Set backup schedule (Cron):",
|
|
347
|
-
initial: "0 4 * * *" // Daily at 4:00 AM
|
|
348
|
-
});
|
|
349
|
-
console.log(`\n Cron Result: "${schedule}"`);
|
|
350
|
-
|
|
351
|
-
// --- 27. Color Prompt ---
|
|
352
|
-
const themeColor = await MepCLI.color({
|
|
353
|
-
message: "Pick your brand color (RGB):",
|
|
354
|
-
initial: "#6366f1"
|
|
355
|
-
});
|
|
356
|
-
console.log(`\n Color Result: "${themeColor}"`);
|
|
357
|
-
|
|
358
|
-
// --- 28. Grid Prompt ---
|
|
359
|
-
const permissions = await MepCLI.grid({
|
|
360
|
-
message: "Configure Access Permissions:",
|
|
361
|
-
rows: ["Admin", "User", "Guest"],
|
|
362
|
-
columns: ["Read", "Write", "Execute"]
|
|
363
|
-
});
|
|
364
|
-
console.log(`\n Grid Result: (Boolean Matrix)`, permissions);
|
|
365
|
-
|
|
366
|
-
// --- 29. Calendar Prompt ---
|
|
367
|
-
const bookingRange = await MepCLI.calendar({
|
|
368
|
-
message: "Select booking period:",
|
|
369
|
-
mode: "range"
|
|
370
|
-
});
|
|
371
|
-
console.log(`\n Calendar Result:`, bookingRange);
|
|
372
|
-
|
|
373
|
-
// --- 30. Spin Utility (Loading/Async Task Indicator) ---
|
|
374
|
-
const s = MepCLI.spinner("Finalizing configuration and deploying...").start();
|
|
375
|
-
await new Promise(resolve => setTimeout(resolve, 1500)); // Simulates a 1.5 second async task
|
|
376
|
-
s.success();
|
|
377
|
-
|
|
378
|
-
console.log("\n--- Deployment successful! All MepCLI features demonstrated! ---");
|
|
379
|
-
|
|
380
|
-
} catch (e) {
|
|
381
|
-
// Global handler for Ctrl+C closure
|
|
382
|
-
if (e instanceof Error && e.message === 'User force closed') {
|
|
383
|
-
console.log("\nOperation cancelled by user (Ctrl+C).");
|
|
384
|
-
} else {
|
|
385
|
-
console.error("\nAn error occurred during prompt execution:", e);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
runComprehensiveDemo();
|