mepcli 0.5.0 → 0.6.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.
Files changed (76) hide show
  1. package/README.md +182 -6
  2. package/dist/ansi.d.ts +1 -0
  3. package/dist/ansi.js +1 -0
  4. package/dist/base.d.ts +1 -1
  5. package/dist/base.js +1 -10
  6. package/dist/core.d.ts +26 -1
  7. package/dist/core.js +72 -0
  8. package/dist/highlight.d.ts +1 -0
  9. package/dist/highlight.js +40 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/input.js +26 -14
  13. package/dist/prompts/autocomplete.d.ts +1 -1
  14. package/dist/prompts/autocomplete.js +2 -7
  15. package/dist/prompts/calendar.d.ts +20 -0
  16. package/dist/prompts/calendar.js +329 -0
  17. package/dist/prompts/checkbox.d.ts +1 -1
  18. package/dist/prompts/checkbox.js +38 -8
  19. package/dist/prompts/code.d.ts +17 -0
  20. package/dist/prompts/code.js +210 -0
  21. package/dist/prompts/color.d.ts +14 -0
  22. package/dist/prompts/color.js +147 -0
  23. package/dist/prompts/confirm.d.ts +1 -1
  24. package/dist/prompts/confirm.js +1 -1
  25. package/dist/prompts/cron.d.ts +13 -0
  26. package/dist/prompts/cron.js +176 -0
  27. package/dist/prompts/date.d.ts +1 -1
  28. package/dist/prompts/date.js +15 -5
  29. package/dist/prompts/editor.d.ts +14 -0
  30. package/dist/prompts/editor.js +207 -0
  31. package/dist/prompts/file.d.ts +7 -0
  32. package/dist/prompts/file.js +56 -60
  33. package/dist/prompts/form.d.ts +17 -0
  34. package/dist/prompts/form.js +225 -0
  35. package/dist/prompts/grid.d.ts +14 -0
  36. package/dist/prompts/grid.js +178 -0
  37. package/dist/prompts/keypress.d.ts +7 -0
  38. package/dist/prompts/keypress.js +57 -0
  39. package/dist/prompts/list.d.ts +1 -1
  40. package/dist/prompts/list.js +42 -22
  41. package/dist/prompts/multi-select.d.ts +1 -1
  42. package/dist/prompts/multi-select.js +39 -4
  43. package/dist/prompts/number.d.ts +1 -1
  44. package/dist/prompts/number.js +2 -2
  45. package/dist/prompts/range.d.ts +9 -0
  46. package/dist/prompts/range.js +140 -0
  47. package/dist/prompts/rating.d.ts +1 -1
  48. package/dist/prompts/rating.js +1 -1
  49. package/dist/prompts/select.d.ts +1 -1
  50. package/dist/prompts/select.js +1 -1
  51. package/dist/prompts/slider.d.ts +1 -1
  52. package/dist/prompts/slider.js +1 -1
  53. package/dist/prompts/snippet.d.ts +18 -0
  54. package/dist/prompts/snippet.js +203 -0
  55. package/dist/prompts/sort.d.ts +1 -1
  56. package/dist/prompts/sort.js +1 -4
  57. package/dist/prompts/spam.d.ts +17 -0
  58. package/dist/prompts/spam.js +62 -0
  59. package/dist/prompts/table.d.ts +1 -1
  60. package/dist/prompts/table.js +1 -1
  61. package/dist/prompts/text.d.ts +1 -0
  62. package/dist/prompts/text.js +14 -32
  63. package/dist/prompts/toggle.d.ts +1 -1
  64. package/dist/prompts/toggle.js +1 -1
  65. package/dist/prompts/transfer.d.ts +18 -0
  66. package/dist/prompts/transfer.js +203 -0
  67. package/dist/prompts/tree-select.d.ts +32 -0
  68. package/dist/prompts/tree-select.js +277 -0
  69. package/dist/prompts/tree.d.ts +20 -0
  70. package/dist/prompts/tree.js +231 -0
  71. package/dist/prompts/wait.d.ts +18 -0
  72. package/dist/prompts/wait.js +62 -0
  73. package/dist/types.d.ts +105 -0
  74. package/dist/utils.js +6 -2
  75. package/example.ts +213 -27
  76. package/package.json +14 -4
package/example.ts CHANGED
@@ -8,7 +8,7 @@ import { MepCLI } from './src'; // Or 'mepcli' if installed via NPM
8
8
  */
9
9
  async function runComprehensiveDemo() {
10
10
  console.clear();
11
- console.log("--- MepCLI Comprehensive Demo (All 15 Prompts + Spin Utility) ---\n");
11
+ console.log("--- MepCLI Comprehensive Demo (All Prompts + Spin Utility) ---\n");
12
12
 
13
13
  try {
14
14
  // --- 1. Text Prompt (Input with Validation and initial value) ---
@@ -21,14 +21,21 @@ async function runComprehensiveDemo() {
21
21
  return true;
22
22
  }
23
23
  });
24
- console.log(`\n Text Result: Project name set to '${projectName}'`);
24
+ console.log(`\n Text Result: Project name set to '${projectName}'`);
25
25
 
26
26
  // --- 2. Password Prompt (Hidden input) ---
27
27
  const apiKey = await MepCLI.password({
28
28
  message: "Enter the project's external API key:",
29
29
  placeholder: "Input will be hidden..."
30
30
  });
31
- console.log(`\n Password Result: API key entered (length: ${apiKey.length})`);
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})`);
32
39
 
33
40
  // --- 3. Select Prompt (Single choice, supports filtering/searching by typing) ---
34
41
  const theme = await MepCLI.select({
@@ -42,7 +49,7 @@ async function runComprehensiveDemo() {
42
49
  { title: "Monokai Pro", value: "monokai" },
43
50
  ]
44
51
  });
45
- console.log(`\n Select Result: Chosen theme is: ${theme}`);
52
+ console.log(`\n Select Result: Chosen theme is: ${theme}`);
46
53
 
47
54
  // --- 4. Checkbox Prompt (Multi-choice with Min/Max limits) ---
48
55
  const buildTools = await MepCLI.checkbox({
@@ -56,7 +63,7 @@ async function runComprehensiveDemo() {
56
63
  { title: "esbuild", value: "esbuild" }
57
64
  ]
58
65
  });
59
- console.log(`\n Checkbox Result: Selected build tools: [${buildTools.join(', ')}]`);
66
+ console.log(`\n Checkbox Result: Selected build tools: [${buildTools.join(', ')}]`);
60
67
 
61
68
  // --- 5. Number Prompt (Numeric input, supports Min/Max and Up/Down arrow for Step) ---
62
69
  const port = await MepCLI.number({
@@ -66,7 +73,7 @@ async function runComprehensiveDemo() {
66
73
  max: 65535,
67
74
  step: 100 // Increments/decrements by 100 with arrows
68
75
  });
69
- console.log(`\n Number Result: Server port: ${port}`);
76
+ console.log(`\n Number Result: Server port: ${port}`);
70
77
 
71
78
  // --- 6. Toggle Prompt (Boolean input, supports custom labels) ---
72
79
  const isSecure = await MepCLI.toggle({
@@ -75,17 +82,17 @@ async function runComprehensiveDemo() {
75
82
  activeText: "SECURE", // Custom 'on' label
76
83
  inactiveText: "INSECURE" // Custom 'off' label
77
84
  });
78
- console.log(`\n Toggle Result: HTTPS enabled: ${isSecure}`);
85
+ console.log(`\n Toggle Result: HTTPS enabled: ${isSecure}`);
79
86
 
80
- // --- 7. List / Tags Input (New) ---
87
+ // --- 7. List / Tags Input ---
81
88
  const keywords = await MepCLI.list({
82
89
  message: "Enter keywords for package.json (Enter to add, Backspace to remove):",
83
90
  initial: ["cli", "mep"],
84
91
  validate: (tags) => tags.length > 0 || "Please add at least one keyword."
85
92
  });
86
- console.log(`\n List Result: Keywords: [${keywords.join(', ')}]`);
93
+ console.log(`\n List Result: Keywords: [${keywords.join(', ')}]`);
87
94
 
88
- // --- 8. Slider / Scale (New) ---
95
+ // --- 8. Slider / Scale ---
89
96
  const brightness = await MepCLI.slider({
90
97
  message: "Set initial brightness:",
91
98
  min: 0,
@@ -94,18 +101,29 @@ async function runComprehensiveDemo() {
94
101
  step: 5,
95
102
  unit: "%"
96
103
  });
97
- console.log(`\n Slider Result: Brightness: ${brightness}%`);
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]}`);
98
116
 
99
- // --- 9. Rating Prompt (New) ---
117
+ // --- 9. Rating Prompt ---
100
118
  const userRating = await MepCLI.rating({
101
119
  message: "How would you rate this CLI tool?",
102
120
  min: 1,
103
121
  max: 5,
104
122
  initial: 5
105
123
  });
106
- console.log(`\n Rating Result: You rated it: ${userRating}/5`);
124
+ console.log(`\n Rating Result: You rated it: ${userRating}/5`);
107
125
 
108
- // --- 10. Date / Time Picker (New) ---
126
+ // --- 10. Date / Time Picker ---
109
127
  // We capture 'now' once to ensure initial >= min
110
128
  const now = new Date();
111
129
  const releaseDate = await MepCLI.date({
@@ -113,16 +131,16 @@ async function runComprehensiveDemo() {
113
131
  initial: now,
114
132
  min: now // Cannot be in the past
115
133
  });
116
- console.log(`\n Date Result: Release set for: ${releaseDate.toLocaleString()}`);
134
+ console.log(`\n Date Result: Release set for: ${releaseDate.toLocaleString()}`);
117
135
 
118
- // --- 11. File Path Selector (New) ---
136
+ // --- 11. File Path Selector ---
119
137
  const configPath = await MepCLI.file({
120
138
  message: "Select configuration file (Tab to autocomplete):",
121
139
  basePath: process.cwd()
122
140
  });
123
- console.log(`\n File Result: Path: ${configPath}`);
141
+ console.log(`\n File Result: Path: ${configPath}`);
124
142
 
125
- // --- 12. Multi-Select Autocomplete (New) ---
143
+ // --- 12. Multi-Select Autocomplete ---
126
144
  const linters = await MepCLI.multiSelect({
127
145
  message: "Select linters to install (Type to search, Space to select):",
128
146
  choices: [
@@ -135,9 +153,9 @@ async function runComprehensiveDemo() {
135
153
  ],
136
154
  min: 1
137
155
  });
138
- console.log(`\n MultiSelect Result: Linters: [${linters.join(', ')}]`);
156
+ console.log(`\n MultiSelect Result: Linters: [${linters.join(', ')}]`);
139
157
 
140
- // --- 13. Autocomplete Prompt (New) ---
158
+ // --- 13. Autocomplete Prompt ---
141
159
  const city = await MepCLI.autocomplete({
142
160
  message: "Search for a city (simulated async):",
143
161
  suggest: async (query) => {
@@ -155,16 +173,24 @@ async function runComprehensiveDemo() {
155
173
  return cities.filter(c => c.title.toLowerCase().includes(query.toLowerCase()));
156
174
  }
157
175
  });
158
- console.log(`\n Autocomplete Result: City code: ${city}`);
176
+ console.log(`\n Autocomplete Result: City code: ${city}`);
159
177
 
160
- // --- 14. Sort Prompt (New) ---
178
+ // --- 14. Sort Prompt ---
161
179
  const priorities = await MepCLI.sort({
162
180
  message: "Rank your top priorities (Space to grab/drop, Arrows to move):",
163
181
  items: ["Performance", "Security", "Features", "Usability", "Cost"]
164
182
  });
165
- console.log(`\n Sort Result: Priorities: [${priorities.join(', ')}]`);
183
+ console.log(`\n Sort Result: Priorities: [${priorities.join(', ')}]`);
166
184
 
167
- // --- 15. Table Prompt (New) ---
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 ---
168
194
  const userId = await MepCLI.table({
169
195
  message: "Select a user from the database:",
170
196
  columns: ["ID", "Name", "Role", "Status"],
@@ -175,16 +201,176 @@ async function runComprehensiveDemo() {
175
201
  { value: 4, row: ["004", "David", "Manager", "Active"] },
176
202
  ]
177
203
  });
178
- console.log(`\n Table Result: Selected User ID: ${userId}`);
204
+ console.log(`\n Table Result: Selected User ID: ${userId}`);
179
205
 
180
206
  // --- 16. Confirm Prompt (Simple Yes/No) ---
181
207
  const proceed = await MepCLI.confirm({
182
208
  message: "Ready to deploy the project now?",
183
209
  initial: true
184
210
  });
185
- console.log(`\n Confirm Result: Deployment decision: ${proceed ? 'Proceed' : 'Cancel'}`);
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);
186
372
 
187
- // --- 17. Spin Utility (Loading/Async Task Indicator) ---
373
+ // --- 30. Spin Utility (Loading/Async Task Indicator) ---
188
374
  const s = MepCLI.spinner("Finalizing configuration and deploying...").start();
189
375
  await new Promise(resolve => setTimeout(resolve, 1500)); // Simulates a 1.5 second async task
190
376
  s.success();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mepcli",
3
- "version": "0.5.0",
4
- "description": "Zero-dependency, minimalist interactive CLI prompt for Node.js",
3
+ "version": "0.6.0",
4
+ "description": "Zero-dependency, interactive CLI prompt for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/CodeTease/mep.git"
@@ -17,7 +17,10 @@
17
17
  "scripts": {
18
18
  "build": "tsc",
19
19
  "prepublishOnly": "npm run build",
20
- "test": "ts-node example.ts"
20
+ "test": "jest",
21
+ "demo": "ts-node example.ts",
22
+ "lint": "eslint .",
23
+ "lint:fix": "eslint . --fix"
21
24
  },
22
25
  "keywords": [
23
26
  "cli",
@@ -30,8 +33,15 @@
30
33
  "author": "CodeTease",
31
34
  "license": "MIT",
32
35
  "devDependencies": {
36
+ "@eslint/js": "^9",
37
+ "@types/jest": "^30",
33
38
  "@types/node": "^22",
39
+ "eslint": "^9",
40
+ "globals": "^17",
41
+ "jest": "^30",
42
+ "ts-jest": "^29",
34
43
  "ts-node": "^10",
35
- "typescript": "^5"
44
+ "typescript": "^5",
45
+ "typescript-eslint": "^8"
36
46
  }
37
47
  }