mepcli 1.3.2 → 2.0.0-beta.1
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 +11 -2
- package/dist/{ansi.js → src/ansi.js} +17 -9
- package/dist/src/ansi.js.map +1 -0
- package/dist/{base.js → src/base.js} +82 -70
- package/dist/src/base.js.map +1 -0
- package/dist/{core.js → src/core.js} +266 -320
- package/dist/src/core.js.map +1 -0
- package/dist/src/data/countries.js +569 -0
- package/dist/src/data/countries.js.map +1 -0
- package/dist/src/data/licenses.js +480 -0
- package/dist/src/data/licenses.js.map +1 -0
- package/dist/{highlight.js → src/highlight.js} +77 -69
- package/dist/src/highlight.js.map +1 -0
- package/dist/src/index.js +66 -0
- package/dist/src/index.js.map +1 -0
- package/dist/{input.js → src/input.js} +47 -41
- package/dist/src/input.js.map +1 -0
- package/dist/src/pipeline.js +273 -0
- package/dist/src/pipeline.js.map +1 -0
- package/dist/{prompts → src/prompts}/autocomplete.js +58 -57
- package/dist/src/prompts/autocomplete.js.map +1 -0
- package/dist/{prompts → src/prompts}/box.js +86 -53
- package/dist/src/prompts/box.js.map +1 -0
- package/dist/{prompts → src/prompts}/breadcrumb-search.js +110 -98
- package/dist/src/prompts/breadcrumb-search.js.map +1 -0
- package/dist/{prompts → src/prompts}/breadcrumb.js +126 -121
- package/dist/src/prompts/breadcrumb.js.map +1 -0
- package/dist/{prompts → src/prompts}/byte.js +69 -52
- package/dist/src/prompts/byte.js.map +1 -0
- package/dist/{prompts → src/prompts}/calculator.js +79 -56
- package/dist/src/prompts/calculator.js.map +1 -0
- package/dist/{prompts → src/prompts}/calendar.js +167 -127
- package/dist/src/prompts/calendar.js.map +1 -0
- package/dist/{prompts → src/prompts}/checkbox.js +53 -49
- package/dist/src/prompts/checkbox.js.map +1 -0
- package/dist/{prompts → src/prompts}/code.js +88 -76
- package/dist/src/prompts/code.js.map +1 -0
- package/dist/{prompts → src/prompts}/color.js +68 -50
- package/dist/src/prompts/color.js.map +1 -0
- package/dist/{prompts → src/prompts}/confirm.js +22 -15
- package/dist/src/prompts/confirm.js.map +1 -0
- package/dist/{prompts → src/prompts}/connection-string.js +59 -36
- package/dist/src/prompts/connection-string.js.map +1 -0
- package/dist/{prompts → src/prompts}/cron.js +90 -59
- package/dist/src/prompts/cron.js.map +1 -0
- package/dist/src/prompts/curl-utils.js +71 -0
- package/dist/src/prompts/curl-utils.js.map +1 -0
- package/dist/{prompts → src/prompts}/curl.js +153 -132
- package/dist/src/prompts/curl.js.map +1 -0
- package/dist/{prompts → src/prompts}/data-inspector.js +96 -91
- package/dist/src/prompts/data-inspector.js.map +1 -0
- package/dist/{prompts → src/prompts}/date.js +64 -57
- package/dist/src/prompts/date.js.map +1 -0
- package/dist/{prompts → src/prompts}/dependency.js +84 -80
- package/dist/src/prompts/dependency.js.map +1 -0
- package/dist/{prompts → src/prompts}/dial.js +49 -35
- package/dist/src/prompts/dial.js.map +1 -0
- package/dist/src/prompts/diff.js +118 -0
- package/dist/src/prompts/diff.js.map +1 -0
- package/dist/{prompts → src/prompts}/draw.js +83 -80
- package/dist/src/prompts/draw.js.map +1 -0
- package/dist/src/prompts/editor.js +234 -0
- package/dist/src/prompts/editor.js.map +1 -0
- package/dist/{prompts → src/prompts}/emoji.js +80 -82
- package/dist/src/prompts/emoji.js.map +1 -0
- package/dist/{prompts → src/prompts}/exec.js +60 -46
- package/dist/src/prompts/exec.js.map +1 -0
- package/dist/src/prompts/file.js +217 -0
- package/dist/src/prompts/file.js.map +1 -0
- package/dist/{prompts → src/prompts}/form.js +63 -54
- package/dist/src/prompts/form.js.map +1 -0
- package/dist/{prompts → src/prompts}/fuzzy-multi-column.js +65 -53
- package/dist/src/prompts/fuzzy-multi-column.js.map +1 -0
- package/dist/{prompts → src/prompts}/fuzzy.js +66 -55
- package/dist/src/prompts/fuzzy.js.map +1 -0
- package/dist/src/prompts/gauge.js +137 -0
- package/dist/src/prompts/gauge.js.map +1 -0
- package/dist/{prompts → src/prompts}/grid.js +70 -57
- package/dist/src/prompts/grid.js.map +1 -0
- package/dist/{prompts → src/prompts}/heatmap.js +70 -64
- package/dist/src/prompts/heatmap.js.map +1 -0
- package/dist/{prompts → src/prompts}/ip.js +56 -36
- package/dist/src/prompts/ip.js.map +1 -0
- package/dist/{prompts → src/prompts}/kanban.js +63 -58
- package/dist/src/prompts/kanban.js.map +1 -0
- package/dist/src/prompts/keypress.js +54 -0
- package/dist/src/prompts/keypress.js.map +1 -0
- package/dist/src/prompts/license.js +144 -0
- package/dist/src/prompts/license.js.map +1 -0
- package/dist/{prompts → src/prompts}/list.js +46 -31
- package/dist/src/prompts/list.js.map +1 -0
- package/dist/{prompts → src/prompts}/map.js +93 -77
- package/dist/src/prompts/map.js.map +1 -0
- package/dist/{prompts → src/prompts}/match.js +91 -95
- package/dist/src/prompts/match.js.map +1 -0
- package/dist/{prompts → src/prompts}/miller.js +74 -67
- package/dist/src/prompts/miller.js.map +1 -0
- package/dist/{prompts → src/prompts}/multi-column-select.js +54 -44
- package/dist/src/prompts/multi-column-select.js.map +1 -0
- package/dist/{prompts → src/prompts}/multi-range.js +70 -52
- package/dist/src/prompts/multi-range.js.map +1 -0
- package/dist/{prompts → src/prompts}/multi-select.js +67 -58
- package/dist/src/prompts/multi-select.js.map +1 -0
- package/dist/{prompts → src/prompts}/number.js +51 -39
- package/dist/src/prompts/number.js.map +1 -0
- package/dist/{prompts → src/prompts}/otp.js +43 -27
- package/dist/src/prompts/otp.js.map +1 -0
- package/dist/{prompts → src/prompts}/pattern.js +74 -71
- package/dist/src/prompts/pattern.js.map +1 -0
- package/dist/{prompts → src/prompts}/phone.js +107 -118
- package/dist/src/prompts/phone.js.map +1 -0
- package/dist/src/prompts/quiz-select.js +114 -0
- package/dist/src/prompts/quiz-select.js.map +1 -0
- package/dist/src/prompts/quiz-text.js +98 -0
- package/dist/src/prompts/quiz-text.js.map +1 -0
- package/dist/{prompts → src/prompts}/range.js +85 -61
- package/dist/src/prompts/range.js.map +1 -0
- package/dist/{prompts → src/prompts}/rating.js +29 -24
- package/dist/src/prompts/rating.js.map +1 -0
- package/dist/{prompts → src/prompts}/regex.js +50 -36
- package/dist/src/prompts/regex.js.map +1 -0
- package/dist/{prompts → src/prompts}/region.js +62 -56
- package/dist/src/prompts/region.js.map +1 -0
- package/dist/{prompts → src/prompts}/schedule.js +82 -75
- package/dist/src/prompts/schedule.js.map +1 -0
- package/dist/{prompts → src/prompts}/scroll.js +61 -58
- package/dist/src/prompts/scroll.js.map +1 -0
- package/dist/src/prompts/seat.js +164 -0
- package/dist/src/prompts/seat.js.map +1 -0
- package/dist/{prompts → src/prompts}/select-range.js +58 -46
- package/dist/src/prompts/select-range.js.map +1 -0
- package/dist/{prompts → src/prompts}/select.js +65 -66
- package/dist/src/prompts/select.js.map +1 -0
- package/dist/{prompts → src/prompts}/semver.js +24 -13
- package/dist/src/prompts/semver.js.map +1 -0
- package/dist/src/prompts/shortcut.js +133 -0
- package/dist/src/prompts/shortcut.js.map +1 -0
- package/dist/{prompts → src/prompts}/slider.js +28 -23
- package/dist/src/prompts/slider.js.map +1 -0
- package/dist/src/prompts/slot.js +117 -0
- package/dist/src/prompts/slot.js.map +1 -0
- package/dist/{prompts → src/prompts}/snippet.js +82 -61
- package/dist/src/prompts/snippet.js.map +1 -0
- package/dist/{prompts → src/prompts}/sort-grid.js +64 -59
- package/dist/src/prompts/sort-grid.js.map +1 -0
- package/dist/{prompts → src/prompts}/sort.js +59 -49
- package/dist/src/prompts/sort.js.map +1 -0
- package/dist/src/prompts/spam.js +80 -0
- package/dist/src/prompts/spam.js.map +1 -0
- package/dist/{prompts → src/prompts}/spreadsheet.js +71 -70
- package/dist/src/prompts/spreadsheet.js.map +1 -0
- package/dist/{prompts → src/prompts}/table.js +52 -38
- package/dist/src/prompts/table.js.map +1 -0
- package/dist/{prompts → src/prompts}/text.js +74 -70
- package/dist/src/prompts/text.js.map +1 -0
- package/dist/{prompts → src/prompts}/time.js +105 -96
- package/dist/src/prompts/time.js.map +1 -0
- package/dist/src/prompts/toggle.js +53 -0
- package/dist/src/prompts/toggle.js.map +1 -0
- package/dist/{prompts → src/prompts}/transfer.js +71 -67
- package/dist/src/prompts/transfer.js.map +1 -0
- package/dist/{prompts → src/prompts}/tree-select.js +83 -86
- package/dist/src/prompts/tree-select.js.map +1 -0
- package/dist/{prompts → src/prompts}/tree.js +69 -67
- package/dist/src/prompts/tree.js.map +1 -0
- package/dist/src/prompts/wait.js +79 -0
- package/dist/src/prompts/wait.js.map +1 -0
- package/dist/src/spinner.js +105 -0
- package/dist/src/spinner.js.map +1 -0
- package/dist/{symbols.js → src/symbols.js} +32 -7
- package/dist/src/symbols.js.map +1 -0
- package/dist/{tasks.js → src/tasks.js} +104 -79
- package/dist/src/tasks.js.map +1 -0
- package/dist/src/theme.js +29 -0
- package/dist/src/theme.js.map +1 -0
- package/dist/src/types.js +8 -0
- package/dist/src/types.js.map +1 -0
- package/dist/{utils.js → src/utils.js} +196 -152
- package/dist/src/utils.js.map +1 -0
- package/package.json +16 -13
- package/dist/ansi.d.ts +0 -36
- package/dist/base.d.ts +0 -60
- package/dist/core.d.ts +0 -1072
- package/dist/data/countries.d.ts +0 -2
- package/dist/data/countries.js +0 -105
- package/dist/data/licenses.d.ts +0 -2
- package/dist/data/licenses.js +0 -109
- package/dist/highlight.d.ts +0 -7
- package/dist/index.d.ts +0 -48
- package/dist/index.js +0 -64
- package/dist/input.d.ts +0 -14
- package/dist/pipeline.d.ts +0 -39
- package/dist/pipeline.js +0 -54
- package/dist/prompts/autocomplete.d.ts +0 -22
- package/dist/prompts/box.d.ts +0 -21
- package/dist/prompts/breadcrumb-search.d.ts +0 -14
- package/dist/prompts/breadcrumb.d.ts +0 -32
- package/dist/prompts/byte.d.ts +0 -13
- package/dist/prompts/calculator.d.ts +0 -17
- package/dist/prompts/calendar.d.ts +0 -33
- package/dist/prompts/checkbox.d.ts +0 -13
- package/dist/prompts/code.d.ts +0 -19
- package/dist/prompts/color.d.ts +0 -14
- package/dist/prompts/confirm.d.ts +0 -8
- package/dist/prompts/connection-string.d.ts +0 -18
- package/dist/prompts/cron.d.ts +0 -13
- package/dist/prompts/curl-utils.d.ts +0 -25
- package/dist/prompts/curl-utils.js +0 -41
- package/dist/prompts/curl.d.ts +0 -41
- package/dist/prompts/data-inspector.d.ts +0 -22
- package/dist/prompts/date.d.ts +0 -12
- package/dist/prompts/dependency.d.ts +0 -16
- package/dist/prompts/dial.d.ts +0 -10
- package/dist/prompts/diff.d.ts +0 -10
- package/dist/prompts/diff.js +0 -101
- package/dist/prompts/draw.d.ts +0 -20
- package/dist/prompts/editor.d.ts +0 -14
- package/dist/prompts/editor.js +0 -203
- package/dist/prompts/emoji.d.ts +0 -18
- package/dist/prompts/exec.d.ts +0 -17
- package/dist/prompts/file.d.ts +0 -21
- package/dist/prompts/file.js +0 -210
- package/dist/prompts/form.d.ts +0 -18
- package/dist/prompts/fuzzy-multi-column.d.ts +0 -12
- package/dist/prompts/fuzzy.d.ts +0 -12
- package/dist/prompts/gauge.d.ts +0 -21
- package/dist/prompts/gauge.js +0 -130
- package/dist/prompts/grid.d.ts +0 -14
- package/dist/prompts/heatmap.d.ts +0 -13
- package/dist/prompts/ip.d.ts +0 -11
- package/dist/prompts/kanban.d.ts +0 -17
- package/dist/prompts/keypress.d.ts +0 -7
- package/dist/prompts/keypress.js +0 -55
- package/dist/prompts/license.d.ts +0 -9
- package/dist/prompts/license.js +0 -105
- package/dist/prompts/list.d.ts +0 -9
- package/dist/prompts/map.d.ts +0 -17
- package/dist/prompts/match.d.ts +0 -19
- package/dist/prompts/miller.d.ts +0 -15
- package/dist/prompts/multi-column-select.d.ts +0 -10
- package/dist/prompts/multi-range.d.ts +0 -9
- package/dist/prompts/multi-select.d.ts +0 -15
- package/dist/prompts/number.d.ts +0 -11
- package/dist/prompts/otp.d.ts +0 -10
- package/dist/prompts/pattern.d.ts +0 -22
- package/dist/prompts/phone.d.ts +0 -41
- package/dist/prompts/quiz-select.d.ts +0 -10
- package/dist/prompts/quiz-select.js +0 -104
- package/dist/prompts/quiz-text.d.ts +0 -11
- package/dist/prompts/quiz-text.js +0 -82
- package/dist/prompts/range.d.ts +0 -9
- package/dist/prompts/rating.d.ts +0 -8
- package/dist/prompts/regex.d.ts +0 -13
- package/dist/prompts/region.d.ts +0 -11
- package/dist/prompts/schedule.d.ts +0 -20
- package/dist/prompts/scroll.d.ts +0 -13
- package/dist/prompts/seat.d.ts +0 -17
- package/dist/prompts/seat.js +0 -165
- package/dist/prompts/select-range.d.ts +0 -8
- package/dist/prompts/select.d.ts +0 -15
- package/dist/prompts/semver.d.ts +0 -6
- package/dist/prompts/shortcut.d.ts +0 -9
- package/dist/prompts/shortcut.js +0 -135
- package/dist/prompts/slider.d.ts +0 -8
- package/dist/prompts/slot.d.ts +0 -16
- package/dist/prompts/slot.js +0 -107
- package/dist/prompts/snippet.d.ts +0 -19
- package/dist/prompts/sort-grid.d.ts +0 -16
- package/dist/prompts/sort.d.ts +0 -14
- package/dist/prompts/spam.d.ts +0 -17
- package/dist/prompts/spam.js +0 -62
- package/dist/prompts/spreadsheet.d.ts +0 -21
- package/dist/prompts/table.d.ts +0 -14
- package/dist/prompts/text.d.ts +0 -17
- package/dist/prompts/time.d.ts +0 -12
- package/dist/prompts/toggle.d.ts +0 -8
- package/dist/prompts/toggle.js +0 -47
- package/dist/prompts/transfer.d.ts +0 -18
- package/dist/prompts/tree-select.d.ts +0 -31
- package/dist/prompts/tree.d.ts +0 -20
- package/dist/prompts/wait.d.ts +0 -18
- package/dist/prompts/wait.js +0 -62
- package/dist/spinner.d.ts +0 -33
- package/dist/spinner.js +0 -89
- package/dist/symbols.d.ts +0 -33
- package/dist/tasks.d.ts +0 -57
- package/dist/theme.d.ts +0 -2
- package/dist/theme.js +0 -20
- package/dist/types.d.ts +0 -503
- package/dist/types.js +0 -5
- package/dist/utils.d.ts +0 -81
package/dist/prompts/file.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FilePrompt = void 0;
|
|
37
|
-
const ansi_1 = require("../ansi");
|
|
38
|
-
const base_1 = require("../base");
|
|
39
|
-
const theme_1 = require("../theme");
|
|
40
|
-
const symbols_1 = require("../symbols");
|
|
41
|
-
const fs = __importStar(require("fs"));
|
|
42
|
-
const path = __importStar(require("path"));
|
|
43
|
-
/**
|
|
44
|
-
* Implementation of FilePrompt with autocomplete.
|
|
45
|
-
*/
|
|
46
|
-
class FilePrompt extends base_1.Prompt {
|
|
47
|
-
constructor(options) {
|
|
48
|
-
super(options);
|
|
49
|
-
this.input = '';
|
|
50
|
-
this.cursor = 0;
|
|
51
|
-
this.suggestions = [];
|
|
52
|
-
this.selectedSuggestion = -1;
|
|
53
|
-
this.errorMsg = '';
|
|
54
|
-
this.lastLinesUp = 0;
|
|
55
|
-
this.input = options.basePath || '';
|
|
56
|
-
this.cursor = this.input.length;
|
|
57
|
-
this.updateSuggestions();
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Updates the suggestions list based on the current input path.
|
|
61
|
-
*/
|
|
62
|
-
updateSuggestions() {
|
|
63
|
-
try {
|
|
64
|
-
// Determine the directory to scan and the partial file name
|
|
65
|
-
const isDirQuery = this.input.endsWith('/') || this.input.endsWith('\\');
|
|
66
|
-
const dir = isDirQuery ? this.input : (path.dirname(this.input) || '.');
|
|
67
|
-
const partial = isDirQuery ? '' : path.basename(this.input);
|
|
68
|
-
if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
|
|
69
|
-
const files = fs.readdirSync(dir);
|
|
70
|
-
this.suggestions = files
|
|
71
|
-
.filter(f => f.toLowerCase().startsWith(partial.toLowerCase()))
|
|
72
|
-
.filter(f => {
|
|
73
|
-
const fullPath = path.join(dir, f);
|
|
74
|
-
try {
|
|
75
|
-
const stats = fs.statSync(fullPath);
|
|
76
|
-
const isDir = stats.isDirectory();
|
|
77
|
-
if (this.options.onlyDirectories && !isDir)
|
|
78
|
-
return false;
|
|
79
|
-
if (this.options.extensions && !isDir) {
|
|
80
|
-
return this.options.extensions.some(ext => f.endsWith(ext));
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
catch (_e) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
.map(f => {
|
|
89
|
-
const fullPath = path.join(dir, f);
|
|
90
|
-
try {
|
|
91
|
-
// Append separator if the file is a directory
|
|
92
|
-
if (fs.statSync(fullPath).isDirectory())
|
|
93
|
-
return f + path.sep;
|
|
94
|
-
}
|
|
95
|
-
catch (_e) { /* ignore */ }
|
|
96
|
-
return f;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
this.suggestions = [];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
catch (_e) {
|
|
104
|
-
this.suggestions = [];
|
|
105
|
-
}
|
|
106
|
-
this.selectedSuggestion = -1;
|
|
107
|
-
}
|
|
108
|
-
render(firstRender) {
|
|
109
|
-
// Restore cursor position to the bottom before renderFrame clears the area
|
|
110
|
-
if (!firstRender && this.lastLinesUp > 0) {
|
|
111
|
-
this.print(`\x1b[${this.lastLinesUp}B`);
|
|
112
|
-
this.lastLinesUp = 0;
|
|
113
|
-
}
|
|
114
|
-
const icon = this.errorMsg ? `${theme_1.theme.error}${symbols_1.symbols.cross}` : `${theme_1.theme.success}?`;
|
|
115
|
-
let output = `${icon} ${ansi_1.ANSI.BOLD}${theme_1.theme.title}${this.options.message}${ansi_1.ANSI.RESET} ${this.input}`;
|
|
116
|
-
if (this.suggestions.length > 0) {
|
|
117
|
-
output += '\n';
|
|
118
|
-
const maxShow = 5;
|
|
119
|
-
const displayed = this.suggestions.slice(0, maxShow);
|
|
120
|
-
displayed.forEach((s, i) => {
|
|
121
|
-
if (i > 0)
|
|
122
|
-
output += '\n';
|
|
123
|
-
if (i === this.selectedSuggestion) {
|
|
124
|
-
output += `${theme_1.theme.main}${symbols_1.symbols.pointer} ${s}${ansi_1.ANSI.RESET}`;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
output += ` ${s}`;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
if (this.suggestions.length > maxShow) {
|
|
131
|
-
output += `\n ${theme_1.theme.muted}...and ${this.suggestions.length - maxShow} more${ansi_1.ANSI.RESET}`;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
this.renderFrame(output);
|
|
135
|
-
// Move cursor back up to the input line
|
|
136
|
-
const totalLines = this.lastRenderHeight;
|
|
137
|
-
if (totalLines > 1) {
|
|
138
|
-
this.lastLinesUp = totalLines - 1;
|
|
139
|
-
this.print(`\x1b[${this.lastLinesUp}A`);
|
|
140
|
-
}
|
|
141
|
-
// Calculate horizontal cursor position on the input line
|
|
142
|
-
const prefix = `${icon} ${theme_1.theme.title}${this.options.message} `;
|
|
143
|
-
const prefixLen = this.stripAnsi(prefix).length;
|
|
144
|
-
const targetCol = prefixLen + this.input.length;
|
|
145
|
-
this.print(ansi_1.ANSI.CURSOR_LEFT);
|
|
146
|
-
if (targetCol > 0)
|
|
147
|
-
this.print(`\x1b[${targetCol}C`);
|
|
148
|
-
this.print(ansi_1.ANSI.SHOW_CURSOR);
|
|
149
|
-
}
|
|
150
|
-
cleanup() {
|
|
151
|
-
if (this.lastLinesUp > 0) {
|
|
152
|
-
this.print(`\x1b[${this.lastLinesUp}B`);
|
|
153
|
-
this.lastLinesUp = 0;
|
|
154
|
-
}
|
|
155
|
-
super.cleanup();
|
|
156
|
-
}
|
|
157
|
-
handleInput(char) {
|
|
158
|
-
if (char === '\t') {
|
|
159
|
-
if (this.suggestions.length > 0) {
|
|
160
|
-
// Use the selected suggestion or the first one available
|
|
161
|
-
const idx = this.selectedSuggestion === -1 ? 0 : this.selectedSuggestion;
|
|
162
|
-
const suggestion = this.suggestions[idx];
|
|
163
|
-
const isDir = this.input.endsWith('/') || this.input.endsWith('\\');
|
|
164
|
-
const dir = isDir ? this.input : path.dirname(this.input);
|
|
165
|
-
// Construct the new path accurately
|
|
166
|
-
const baseDir = (dir === '.' && !this.input.startsWith('.')) ? '' : dir;
|
|
167
|
-
this.input = path.join(baseDir, suggestion);
|
|
168
|
-
this.cursor = this.input.length;
|
|
169
|
-
// Immediately refresh suggestions for the new path
|
|
170
|
-
this.updateSuggestions();
|
|
171
|
-
this.render(false);
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (char === '\r' || char === '\n') {
|
|
176
|
-
this.submit(this.input);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (this.isDown(char)) {
|
|
180
|
-
if (this.suggestions.length > 0) {
|
|
181
|
-
const count = Math.min(this.suggestions.length, 5);
|
|
182
|
-
this.selectedSuggestion = (this.selectedSuggestion + 1) % count;
|
|
183
|
-
this.render(false);
|
|
184
|
-
}
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (this.isUp(char)) {
|
|
188
|
-
if (this.suggestions.length > 0) {
|
|
189
|
-
const count = Math.min(this.suggestions.length, 5);
|
|
190
|
-
this.selectedSuggestion = (this.selectedSuggestion - 1 + count) % count;
|
|
191
|
-
this.render(false);
|
|
192
|
-
}
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (char === '\u0008' || char === '\x7f') {
|
|
196
|
-
if (this.input.length > 0) {
|
|
197
|
-
this.input = this.input.slice(0, -1);
|
|
198
|
-
this.updateSuggestions();
|
|
199
|
-
this.render(false);
|
|
200
|
-
}
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (!/^[\x00-\x1F]/.test(char) && !char.startsWith('\x1b')) {
|
|
204
|
-
this.input += char;
|
|
205
|
-
this.updateSuggestions();
|
|
206
|
-
this.render(false);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
exports.FilePrompt = FilePrompt;
|
package/dist/prompts/form.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { FormOptions, MouseEvent } from '../types';
|
|
3
|
-
export declare class FormPrompt extends Prompt<Record<string, string>, FormOptions> {
|
|
4
|
-
private values;
|
|
5
|
-
private activeIndex;
|
|
6
|
-
private fieldErrors;
|
|
7
|
-
private globalError;
|
|
8
|
-
private cursor;
|
|
9
|
-
private lastLinesUp;
|
|
10
|
-
constructor(options: FormOptions);
|
|
11
|
-
protected render(firstRender: boolean): void;
|
|
12
|
-
protected handleInput(char: string, key: Buffer): void;
|
|
13
|
-
protected handleMouse(event: MouseEvent): void;
|
|
14
|
-
private moveFocus;
|
|
15
|
-
private validateCurrentField;
|
|
16
|
-
protected cleanup(): void;
|
|
17
|
-
private submitForm;
|
|
18
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MultiColumnSelectPrompt } from './multi-column-select';
|
|
2
|
-
import { MultiColumnSelectOptions } from '../types';
|
|
3
|
-
export declare class FuzzyMultiColumnPrompt<V> extends MultiColumnSelectPrompt<V> {
|
|
4
|
-
private filteredResults;
|
|
5
|
-
private debounceTimer;
|
|
6
|
-
constructor(options: MultiColumnSelectOptions<V>);
|
|
7
|
-
protected getFilteredChoices(): any[];
|
|
8
|
-
protected handleInput(char: string): void;
|
|
9
|
-
private performSearch;
|
|
10
|
-
private highlight;
|
|
11
|
-
protected render(_firstRender: boolean): void;
|
|
12
|
-
}
|
package/dist/prompts/fuzzy.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SelectPrompt } from './select';
|
|
2
|
-
import { FuzzySelectOptions } from '../types';
|
|
3
|
-
export declare class FuzzySelectPrompt<V> extends SelectPrompt<V, FuzzySelectOptions<V>> {
|
|
4
|
-
private filteredResults;
|
|
5
|
-
private debounceTimer;
|
|
6
|
-
constructor(options: FuzzySelectOptions<V>);
|
|
7
|
-
protected getFilteredChoices(): any[];
|
|
8
|
-
protected handleInput(char: string): void;
|
|
9
|
-
private performSearch;
|
|
10
|
-
private highlight;
|
|
11
|
-
protected render(_firstRender: boolean): void;
|
|
12
|
-
}
|
package/dist/prompts/gauge.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { GaugeOptions } from '../types';
|
|
3
|
-
export declare class GaugePrompt extends Prompt<string, GaugeOptions> {
|
|
4
|
-
private cursor;
|
|
5
|
-
private direction;
|
|
6
|
-
private running;
|
|
7
|
-
private timer?;
|
|
8
|
-
private readonly width;
|
|
9
|
-
private readonly safeZoneHalf;
|
|
10
|
-
private readonly warnZoneHalf;
|
|
11
|
-
private result;
|
|
12
|
-
private resultColor;
|
|
13
|
-
constructor(options: GaugeOptions);
|
|
14
|
-
run(): Promise<string>;
|
|
15
|
-
private startLoop;
|
|
16
|
-
private tick;
|
|
17
|
-
private stop;
|
|
18
|
-
protected handleInput(char: string, _key: Buffer): void;
|
|
19
|
-
protected render(_firstRender: boolean): void;
|
|
20
|
-
protected cleanup(): void;
|
|
21
|
-
}
|
package/dist/prompts/gauge.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GaugePrompt = void 0;
|
|
4
|
-
const ansi_1 = require("../ansi");
|
|
5
|
-
const base_1 = require("../base");
|
|
6
|
-
const theme_1 = require("../theme");
|
|
7
|
-
class GaugePrompt extends base_1.Prompt {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
super(options);
|
|
10
|
-
this.cursor = 0; // 0 to 100
|
|
11
|
-
this.direction = 1;
|
|
12
|
-
this.running = true;
|
|
13
|
-
this.result = null;
|
|
14
|
-
this.resultColor = '';
|
|
15
|
-
this.width = options.width || 40;
|
|
16
|
-
// Calculate safe zone logic (0-100 scale)
|
|
17
|
-
// Default safe width: 20% ( +/- 10%)
|
|
18
|
-
const safeParam = options.safeZone ?? 0.2;
|
|
19
|
-
// Convert to percentage (0-100)
|
|
20
|
-
let safeWidthPct;
|
|
21
|
-
if (safeParam <= 1) {
|
|
22
|
-
safeWidthPct = safeParam * 100;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
safeWidthPct = (safeParam / this.width) * 100;
|
|
26
|
-
}
|
|
27
|
-
this.safeZoneHalf = safeWidthPct / 2;
|
|
28
|
-
// Arbitrary "Good" zone is 3x the safe zone (or until limits)
|
|
29
|
-
this.warnZoneHalf = Math.max(this.safeZoneHalf * 3, 30);
|
|
30
|
-
}
|
|
31
|
-
run() {
|
|
32
|
-
// Start the loop when run is called (after initial render)
|
|
33
|
-
const p = super.run();
|
|
34
|
-
this.startLoop();
|
|
35
|
-
return p;
|
|
36
|
-
}
|
|
37
|
-
startLoop() {
|
|
38
|
-
if (!this.running)
|
|
39
|
-
return;
|
|
40
|
-
this.timer = setTimeout(() => {
|
|
41
|
-
this.tick();
|
|
42
|
-
this.startLoop();
|
|
43
|
-
}, 30); // ~33 FPS
|
|
44
|
-
}
|
|
45
|
-
tick() {
|
|
46
|
-
this.cursor += this.direction * 2; // Speed multiplier
|
|
47
|
-
if (this.cursor >= 100) {
|
|
48
|
-
this.cursor = 100;
|
|
49
|
-
this.direction = -1;
|
|
50
|
-
}
|
|
51
|
-
else if (this.cursor <= 0) {
|
|
52
|
-
this.cursor = 0;
|
|
53
|
-
this.direction = 1;
|
|
54
|
-
}
|
|
55
|
-
this.render(false);
|
|
56
|
-
}
|
|
57
|
-
stop() {
|
|
58
|
-
this.running = false;
|
|
59
|
-
if (this.timer)
|
|
60
|
-
clearTimeout(this.timer);
|
|
61
|
-
// Calculate score
|
|
62
|
-
const center = 50;
|
|
63
|
-
const distance = Math.abs(this.cursor - center);
|
|
64
|
-
if (distance <= this.safeZoneHalf) {
|
|
65
|
-
this.result = 'PERFECT!';
|
|
66
|
-
this.resultColor = theme_1.theme.success;
|
|
67
|
-
}
|
|
68
|
-
else if (distance <= this.warnZoneHalf) {
|
|
69
|
-
this.result = 'GOOD';
|
|
70
|
-
this.resultColor = ansi_1.ANSI.FG_YELLOW;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.result = 'MISS';
|
|
74
|
-
this.resultColor = theme_1.theme.error;
|
|
75
|
-
}
|
|
76
|
-
this.render(false);
|
|
77
|
-
// Wait a moment to show result, then submit
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
this.submit(this.result); // Force non-null
|
|
80
|
-
}, 800);
|
|
81
|
-
}
|
|
82
|
-
handleInput(char, _key) {
|
|
83
|
-
if (!this.running)
|
|
84
|
-
return;
|
|
85
|
-
if (char === ' ') {
|
|
86
|
-
this.stop();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
render(_firstRender) {
|
|
90
|
-
let output = '';
|
|
91
|
-
// Header
|
|
92
|
-
output += `${theme_1.theme.success}?${ansi_1.ANSI.RESET} ${ansi_1.ANSI.BOLD}${theme_1.theme.title}${this.options.message}${ansi_1.ANSI.RESET}\n`;
|
|
93
|
-
// Draw Gauge Bar
|
|
94
|
-
let barStr = '';
|
|
95
|
-
const center = 50;
|
|
96
|
-
for (let i = 0; i < this.width; i++) {
|
|
97
|
-
const pct = (i / this.width) * 100;
|
|
98
|
-
const dist = Math.abs(pct - center);
|
|
99
|
-
let charColor = theme_1.theme.error; // Default Miss (Red)
|
|
100
|
-
if (dist <= this.safeZoneHalf) {
|
|
101
|
-
charColor = theme_1.theme.success; // Perfect (Green)
|
|
102
|
-
}
|
|
103
|
-
else if (dist <= this.warnZoneHalf) {
|
|
104
|
-
charColor = ansi_1.ANSI.FG_YELLOW; // Good (Yellow)
|
|
105
|
-
}
|
|
106
|
-
// Using block characters for the bar
|
|
107
|
-
barStr += `${charColor}━${ansi_1.ANSI.RESET}`;
|
|
108
|
-
}
|
|
109
|
-
output += ` ${barStr}\n`;
|
|
110
|
-
// Draw Cursor
|
|
111
|
-
// Position relative to width
|
|
112
|
-
const pos = Math.floor((this.cursor / 100) * (this.width - 1));
|
|
113
|
-
const padding = ' '.repeat(pos);
|
|
114
|
-
output += ` ${padding}${theme_1.theme.main}▲${ansi_1.ANSI.RESET}\n`;
|
|
115
|
-
// Instructions or Result
|
|
116
|
-
if (this.running) {
|
|
117
|
-
output += `${theme_1.theme.muted}(Press Space to Stop)${ansi_1.ANSI.RESET}`;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
output += `${ansi_1.ANSI.BOLD}${this.resultColor}${this.result}${ansi_1.ANSI.RESET}`;
|
|
121
|
-
}
|
|
122
|
-
this.renderFrame(output);
|
|
123
|
-
}
|
|
124
|
-
cleanup() {
|
|
125
|
-
if (this.timer)
|
|
126
|
-
clearTimeout(this.timer);
|
|
127
|
-
super.cleanup();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.GaugePrompt = GaugePrompt;
|
package/dist/prompts/grid.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { GridOptions, MouseEvent } from '../types';
|
|
3
|
-
export declare class GridPrompt extends Prompt<boolean[][], GridOptions> {
|
|
4
|
-
private cursorRow;
|
|
5
|
-
private cursorCol;
|
|
6
|
-
private selected;
|
|
7
|
-
private columnWidths;
|
|
8
|
-
private rowLabelWidth;
|
|
9
|
-
constructor(options: GridOptions);
|
|
10
|
-
private calculateLayout;
|
|
11
|
-
protected render(_firstRender: boolean): void;
|
|
12
|
-
protected handleInput(char: string, _key: Buffer): void;
|
|
13
|
-
protected handleMouse(event: MouseEvent): void;
|
|
14
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { HeatmapOptions, MouseEvent } from '../types';
|
|
3
|
-
export declare class HeatmapPrompt extends Prompt<number[][], HeatmapOptions> {
|
|
4
|
-
private grid;
|
|
5
|
-
private cursorRow;
|
|
6
|
-
private cursorCol;
|
|
7
|
-
private validValues;
|
|
8
|
-
constructor(options: HeatmapOptions);
|
|
9
|
-
protected render(_firstRender: boolean): void;
|
|
10
|
-
private getLegend;
|
|
11
|
-
protected handleMouse(event: MouseEvent): void;
|
|
12
|
-
protected handleInput(char: string, _key: Buffer): void;
|
|
13
|
-
}
|
package/dist/prompts/ip.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { IPOptions, MouseEvent } from '../types';
|
|
3
|
-
export declare class IPPrompt extends Prompt<string, IPOptions> {
|
|
4
|
-
private octets;
|
|
5
|
-
private activeOctet;
|
|
6
|
-
private errorMsg;
|
|
7
|
-
constructor(options: IPOptions);
|
|
8
|
-
protected render(_firstRender: boolean): void;
|
|
9
|
-
protected handleInput(char: string): void;
|
|
10
|
-
protected handleMouse(event: MouseEvent): void;
|
|
11
|
-
}
|
package/dist/prompts/kanban.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { KanbanOptions, KanbanItem, MouseEvent } from '../types';
|
|
3
|
-
export declare class KanbanPrompt<V extends KanbanItem> extends Prompt<Record<string, V[]>, KanbanOptions<V>> {
|
|
4
|
-
private columns;
|
|
5
|
-
private activeCol;
|
|
6
|
-
private activeRow;
|
|
7
|
-
private grabbed;
|
|
8
|
-
private scrollStates;
|
|
9
|
-
constructor(options: KanbanOptions<V>);
|
|
10
|
-
protected render(_firstRender: boolean): void;
|
|
11
|
-
private padCenter;
|
|
12
|
-
protected handleMouse(event: MouseEvent): void;
|
|
13
|
-
protected handleInput(char: string, _key: Buffer): void;
|
|
14
|
-
private moveItemHorizontal;
|
|
15
|
-
private clampRow;
|
|
16
|
-
private ensureVisible;
|
|
17
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { KeypressOptions } from '../types';
|
|
3
|
-
export declare class KeypressPrompt extends Prompt<string, KeypressOptions> {
|
|
4
|
-
constructor(options: KeypressOptions);
|
|
5
|
-
protected render(_firstRender: boolean): void;
|
|
6
|
-
protected handleInput(char: string, _key: Buffer): void;
|
|
7
|
-
}
|
package/dist/prompts/keypress.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KeypressPrompt = void 0;
|
|
4
|
-
const ansi_1 = require("../ansi");
|
|
5
|
-
const base_1 = require("../base");
|
|
6
|
-
const theme_1 = require("../theme");
|
|
7
|
-
class KeypressPrompt extends base_1.Prompt {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
super(options);
|
|
10
|
-
}
|
|
11
|
-
render(_firstRender) {
|
|
12
|
-
let output = `${theme_1.theme.title}${this.options.message}${ansi_1.ANSI.RESET}`;
|
|
13
|
-
if (this.options.keys) {
|
|
14
|
-
const hint = this.options.keys.map(k => {
|
|
15
|
-
if (k === '\r' || k === '\n' || k === 'enter')
|
|
16
|
-
return 'enter';
|
|
17
|
-
if (k === ' ' || k === 'space')
|
|
18
|
-
return 'space';
|
|
19
|
-
return k;
|
|
20
|
-
}).join('/');
|
|
21
|
-
output += ` ${theme_1.theme.muted}(${hint})${ansi_1.ANSI.RESET}`;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
output += ` ${theme_1.theme.muted}(Press any key)${ansi_1.ANSI.RESET}`;
|
|
25
|
-
}
|
|
26
|
-
this.renderFrame(output);
|
|
27
|
-
}
|
|
28
|
-
handleInput(char, _key) {
|
|
29
|
-
let keyName = char;
|
|
30
|
-
if (char === '\r' || char === '\n')
|
|
31
|
-
keyName = 'enter';
|
|
32
|
-
else if (char === ' ')
|
|
33
|
-
keyName = 'space';
|
|
34
|
-
else if (char === '\u001b')
|
|
35
|
-
keyName = 'escape';
|
|
36
|
-
else if (char === '\t')
|
|
37
|
-
keyName = 'tab';
|
|
38
|
-
// Handle backspace
|
|
39
|
-
else if (char === '\x7f' || char === '\b')
|
|
40
|
-
keyName = 'backspace';
|
|
41
|
-
// Check against whitelist
|
|
42
|
-
if (this.options.keys) {
|
|
43
|
-
const allowed = this.options.keys.map(k => k.toLowerCase());
|
|
44
|
-
// Check normalized name or exact char
|
|
45
|
-
if (!allowed.includes(keyName) && !allowed.includes(char)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (this.options.showInvisible) {
|
|
50
|
-
this.print(` ${theme_1.theme.success}${keyName}${ansi_1.ANSI.RESET}`);
|
|
51
|
-
}
|
|
52
|
-
this.submit(keyName);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.KeypressPrompt = KeypressPrompt;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SelectPrompt } from './select';
|
|
2
|
-
import { LicenseOptions } from '../types';
|
|
3
|
-
export declare class LicensePrompt extends SelectPrompt<string> {
|
|
4
|
-
private licenses;
|
|
5
|
-
constructor(options: LicenseOptions);
|
|
6
|
-
protected render(_firstRender: boolean): void;
|
|
7
|
-
private renderList;
|
|
8
|
-
private renderDetails;
|
|
9
|
-
}
|
package/dist/prompts/license.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LicensePrompt = void 0;
|
|
4
|
-
const ansi_1 = require("../ansi");
|
|
5
|
-
const select_1 = require("./select");
|
|
6
|
-
const theme_1 = require("../theme");
|
|
7
|
-
const symbols_1 = require("../symbols");
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
|
-
const licenses_1 = require("../data/licenses");
|
|
10
|
-
class LicensePrompt extends select_1.SelectPrompt {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
// Map licenses to choices expected by SelectPrompt
|
|
13
|
-
const choices = licenses_1.POPULAR_LICENSES.map(l => ({
|
|
14
|
-
title: l.id,
|
|
15
|
-
value: l.id,
|
|
16
|
-
description: l.name
|
|
17
|
-
}));
|
|
18
|
-
super({
|
|
19
|
-
...options,
|
|
20
|
-
choices
|
|
21
|
-
});
|
|
22
|
-
this.licenses = licenses_1.POPULAR_LICENSES;
|
|
23
|
-
// Set initial selection if provided
|
|
24
|
-
if (options.defaultLicense) {
|
|
25
|
-
const idx = this.licenses.findIndex(l => l.id === options.defaultLicense);
|
|
26
|
-
if (idx !== -1) {
|
|
27
|
-
this.selectedIndex = idx;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
render(_firstRender) {
|
|
32
|
-
const width = this.stdout.columns || 80;
|
|
33
|
-
const gap = 2;
|
|
34
|
-
const ratio = 0.3;
|
|
35
|
-
// Calculate dimensions
|
|
36
|
-
// Left column: 30% or min 20 chars
|
|
37
|
-
// Right column: rest
|
|
38
|
-
const leftWidth = Math.floor((width - gap) * ratio);
|
|
39
|
-
const rightWidth = width - leftWidth - gap;
|
|
40
|
-
const leftContent = this.renderList();
|
|
41
|
-
const rightContent = this.renderDetails(rightWidth);
|
|
42
|
-
const content = utils_1.Layout.split(leftContent, rightContent, width, { ratio, gap });
|
|
43
|
-
// Header
|
|
44
|
-
const header = `${theme_1.theme.success}? ${ansi_1.ANSI.BOLD}${theme_1.theme.title}${this.options.message}${ansi_1.ANSI.RESET} ${theme_1.theme.muted}(Use arrows to navigate, Enter to select)${ansi_1.ANSI.RESET}`;
|
|
45
|
-
// Combine
|
|
46
|
-
this.renderFrame(`${header}\n${content}`);
|
|
47
|
-
}
|
|
48
|
-
renderList() {
|
|
49
|
-
const selectedIndex = this.selectedIndex;
|
|
50
|
-
const scrollTop = this.scrollTop;
|
|
51
|
-
const pageSize = this.pageSize;
|
|
52
|
-
const choices = this.options.choices; // from super
|
|
53
|
-
let output = '';
|
|
54
|
-
const visibleChoices = choices.slice(scrollTop, scrollTop + pageSize);
|
|
55
|
-
visibleChoices.forEach((choice, index) => {
|
|
56
|
-
const actualIndex = scrollTop + index;
|
|
57
|
-
const isSelected = actualIndex === selectedIndex;
|
|
58
|
-
const cursor = isSelected ? `${theme_1.theme.main}${symbols_1.symbols.pointer}` : ' ';
|
|
59
|
-
// Handle Separator type safety
|
|
60
|
-
if ('separator' in choice) {
|
|
61
|
-
output += `${theme_1.theme.muted}${choice.text || '---'}${ansi_1.ANSI.RESET}\n`;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const title = isSelected ? `${theme_1.theme.main}${choice.title}${ansi_1.ANSI.RESET}` : choice.title;
|
|
65
|
-
output += `${cursor} ${title}\n`;
|
|
66
|
-
});
|
|
67
|
-
// Fill remaining lines to maintain height
|
|
68
|
-
const filledLines = visibleChoices.length;
|
|
69
|
-
if (filledLines < pageSize) {
|
|
70
|
-
output += '\n'.repeat(pageSize - filledLines);
|
|
71
|
-
}
|
|
72
|
-
return output;
|
|
73
|
-
}
|
|
74
|
-
renderDetails(maxWidth) {
|
|
75
|
-
const selectedIndex = this.selectedIndex;
|
|
76
|
-
const license = this.licenses[selectedIndex];
|
|
77
|
-
if (!license)
|
|
78
|
-
return '';
|
|
79
|
-
let output = '';
|
|
80
|
-
output += `${ansi_1.ANSI.BOLD}${license.name}${ansi_1.ANSI.RESET}\n`;
|
|
81
|
-
const wrappedDesc = utils_1.Layout.wrap(license.description, maxWidth);
|
|
82
|
-
const coloredDesc = wrappedDesc.split('\n').map(line => `${theme_1.theme.muted}${line}${ansi_1.ANSI.RESET}`).join('\n');
|
|
83
|
-
output += `${coloredDesc}\n\n`;
|
|
84
|
-
// Permissions
|
|
85
|
-
if (license.permissions.length > 0) {
|
|
86
|
-
output += `${ansi_1.ANSI.FG_GREEN}Permissions:${ansi_1.ANSI.RESET}\n`;
|
|
87
|
-
license.permissions.forEach(p => output += ` ${theme_1.theme.success}${symbols_1.symbols.checked} ${p}${ansi_1.ANSI.RESET}\n`);
|
|
88
|
-
output += '\n';
|
|
89
|
-
}
|
|
90
|
-
// Conditions
|
|
91
|
-
if (license.conditions.length > 0) {
|
|
92
|
-
output += `${ansi_1.ANSI.FG_BLUE}Conditions:${ansi_1.ANSI.RESET}\n`;
|
|
93
|
-
// symbols.info doesn't exist, use 'i' or similar
|
|
94
|
-
license.conditions.forEach(c => output += ` ${ansi_1.ANSI.FG_BLUE}ℹ ${c}${ansi_1.ANSI.RESET}\n`);
|
|
95
|
-
output += '\n';
|
|
96
|
-
}
|
|
97
|
-
// Limitations
|
|
98
|
-
if (license.limitations.length > 0) {
|
|
99
|
-
output += `${ansi_1.ANSI.FG_RED}Limitations:${ansi_1.ANSI.RESET}\n`;
|
|
100
|
-
license.limitations.forEach(l => output += ` ${theme_1.theme.error}${symbols_1.symbols.cross} ${l}${ansi_1.ANSI.RESET}\n`);
|
|
101
|
-
}
|
|
102
|
-
return output;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.LicensePrompt = LicensePrompt;
|
package/dist/prompts/list.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { ListOptions } from '../types';
|
|
3
|
-
export declare class ListPrompt extends Prompt<string[], ListOptions> {
|
|
4
|
-
private currentInput;
|
|
5
|
-
private errorMsg;
|
|
6
|
-
constructor(options: ListOptions);
|
|
7
|
-
protected render(_firstRender: boolean): void;
|
|
8
|
-
protected handleInput(char: string): void;
|
|
9
|
-
}
|
package/dist/prompts/map.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Prompt } from '../base';
|
|
2
|
-
import { MapOptions, MouseEvent } from '../types';
|
|
3
|
-
export declare class MapPrompt extends Prompt<Record<string, string>, MapOptions> {
|
|
4
|
-
private items;
|
|
5
|
-
private rowIndex;
|
|
6
|
-
private colIndex;
|
|
7
|
-
private scrollTop;
|
|
8
|
-
private readonly pageSize;
|
|
9
|
-
private errorMsg;
|
|
10
|
-
private ghost;
|
|
11
|
-
constructor(options: MapOptions);
|
|
12
|
-
protected render(_firstRender: boolean): void;
|
|
13
|
-
private pad;
|
|
14
|
-
private updateGhost;
|
|
15
|
-
protected handleInput(char: string): void;
|
|
16
|
-
protected handleMouse(event: MouseEvent): void;
|
|
17
|
-
}
|