@reliverse/rempts 1.7.33 → 1.7.35

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 CHANGED
@@ -99,17 +99,19 @@ import {
99
99
 
100
100
  To help you migrate from the different CLI frameworks, `@reliverse/rempts` has some aliases for the most popular prompts.
101
101
 
102
- | Prompt | Aliases |
103
- |-----------------------|-----------------|
104
- | `useSpinner` | `spinner` |
105
- | `selectPrompt` | `select` |
106
- | `multiselectPrompt` | `multiselect` |
107
- | `inputPrompt` | `text`, `input` |
108
- | `@reliverse/relinka` | `log` |
109
-
110
- ### Notices
111
-
112
- - `setup`/`cleanup` are now `onCmdInit`/`onCmdExit` (old names still work for now).
102
+ | Prompt | Aliases |
103
+ |-----------------------|------------------|
104
+ | `createCli` | `runMain` |
105
+ | `onCmdInit` | `setup` |
106
+ | `onCmdExit` | `cleanup` |
107
+ | `useSpinner` | `spinner` |
108
+ | `selectPrompt` | `select` |
109
+ | `multiselectPrompt` | `multiselect` |
110
+ | `inputPrompt` | `text`, `input` |
111
+ | `confirmPrompt` | `confirm` |
112
+ | `introPrompt` | `intro`, `start` |
113
+ | `outroPrompt` | `outro`, `end` |
114
+ | `log` | `relinka` |
113
115
 
114
116
  ### Prompts Usage Example
115
117
 
@@ -1 +1,2 @@
1
- export declare const confirm: any;
1
+ import type { ConfirmPromptOptions } from "../../types.js";
2
+ export declare const confirm: (options: ConfirmPromptOptions) => Promise<boolean>;
@@ -63,11 +63,15 @@ function renderPrompt(params) {
63
63
  export async function confirmPrompt(options) {
64
64
  const {
65
65
  title = "",
66
+ message,
67
+ // Alias for title
66
68
  defaultValue,
69
+ initialValue,
70
+ // Alias for defaultValue
71
+ content,
67
72
  titleColor = "cyan",
68
73
  titleTypography = "none",
69
74
  titleVariant,
70
- content,
71
75
  contentColor = "dim",
72
76
  contentTypography = "italic",
73
77
  contentVariant,
@@ -80,11 +84,13 @@ export async function confirmPrompt(options) {
80
84
  endTitleColor = "dim",
81
85
  border = true
82
86
  } = options;
87
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Confirm";
88
+ const finalDefaultValue = defaultValue ?? initialValue;
83
89
  const rl = readline.createInterface({ input, output });
84
90
  let errorMessage = "";
85
- const effectiveDefault = defaultValue ?? true;
91
+ const effectiveDefault = finalDefaultValue ?? true;
86
92
  const defaultHint = effectiveDefault ? "[Y/n]" : "[y/N]";
87
- const adjustedTitle = displayInstructions ? title : `${re.blue(defaultHint)} ${title}`;
93
+ const adjustedTitle = displayInstructions ? finalTitle : `${re.blue(defaultHint)} ${finalTitle}`;
88
94
  const instructions = `Use <y/n> to confirm or deny, <Enter> for default (${effectiveDefault ? "Y" : "N"}), <Ctrl+C> to exit`;
89
95
  let lastUILineCount = 0;
90
96
  function endPrompt(isCtrlC = false) {
@@ -100,7 +100,7 @@ function renderPromptUI(params) {
100
100
  symbolColor
101
101
  });
102
102
  void streamText({
103
- text: title,
103
+ text: title || "",
104
104
  delay: streamDelay,
105
105
  color: titleColor,
106
106
  newline: false
@@ -200,10 +200,14 @@ async function validateInput(input, validate) {
200
200
  export async function inputPrompt(options) {
201
201
  const {
202
202
  title,
203
+ message,
204
+ // Alias for title
203
205
  hint,
204
206
  hintPlaceholderColor = "blue",
205
207
  validate,
206
208
  defaultValue = "",
209
+ initialValue,
210
+ // Alias for defaultValue
207
211
  titleColor = "cyan",
208
212
  titleTypography = "none",
209
213
  titleVariant = "none",
@@ -225,6 +229,8 @@ export async function inputPrompt(options) {
225
229
  shouldStream = false,
226
230
  streamDelay = 20
227
231
  } = options;
232
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Input";
233
+ const finalDefaultValue = defaultValue ?? initialValue;
228
234
  const terminal = readline.createInterface({
229
235
  input: process.stdin,
230
236
  output: process.stdout
@@ -257,7 +263,7 @@ export async function inputPrompt(options) {
257
263
  async function handleHardcodedInput() {
258
264
  msgUndoAll();
259
265
  await renderPromptUI({
260
- title,
266
+ title: finalTitle,
261
267
  hint,
262
268
  hintPlaceholderColor,
263
269
  content,
@@ -279,7 +285,7 @@ export async function inputPrompt(options) {
279
285
  shouldStream,
280
286
  streamDelay
281
287
  });
282
- const finalAnswer = currentInput || defaultValue;
288
+ const finalAnswer = currentInput || finalDefaultValue;
283
289
  const validated = await validateInput(finalAnswer, validate);
284
290
  if (!validated.isValid) {
285
291
  terminal.close();
@@ -303,7 +309,7 @@ export async function inputPrompt(options) {
303
309
  deleteLastLine();
304
310
  }
305
311
  await renderPromptUI({
306
- title,
312
+ title: finalTitle,
307
313
  hint,
308
314
  hintPlaceholderColor,
309
315
  content,
@@ -338,20 +344,20 @@ export async function inputPrompt(options) {
338
344
  if (showPlaceholder && currentInput !== "") {
339
345
  showPlaceholder = false;
340
346
  }
341
- const finalAnswer = currentInput || defaultValue;
347
+ const finalAnswer = currentInput || finalDefaultValue;
342
348
  const validated = await validateInput(finalAnswer, validate);
343
349
  if (validated.isValid) {
344
- if (!currentInput && defaultValue) {
350
+ if (!currentInput && finalDefaultValue) {
345
351
  if (mode === "password") {
346
352
  deleteLastLine();
347
353
  deleteLastLine();
348
354
  msg({
349
355
  type: "M_MIDDLE",
350
- title: ` ${getMaskChar(mask).repeat(defaultValue.length)}`
356
+ title: ` ${getMaskChar(mask).repeat(finalDefaultValue.length)}`
351
357
  });
352
358
  } else {
353
359
  deleteLastLine();
354
- msg({ type: "M_MIDDLE", title: ` ${re.reset(defaultValue)}` });
360
+ msg({ type: "M_MIDDLE", title: ` ${re.reset(finalDefaultValue)}` });
355
361
  }
356
362
  }
357
363
  if (errorMessage) {
@@ -1 +1,2 @@
1
- export declare const multiselect: any;
1
+ import type { MultiselectPromptParams } from "../../types.js";
2
+ export declare const multiselect: <T extends string>(params: MultiselectPromptParams<T>) => Promise<T[]>;
@@ -93,9 +93,11 @@ function renderPromptUI(params) {
93
93
  export async function multiselectPrompt(params) {
94
94
  const {
95
95
  title = "",
96
+ message,
96
97
  content = "",
97
98
  options,
98
99
  defaultValue = [],
100
+ initialValue,
99
101
  borderColor = "dim",
100
102
  titleColor = "cyan",
101
103
  titleTypography = "none",
@@ -112,8 +114,10 @@ export async function multiselectPrompt(params) {
112
114
  maxSelect,
113
115
  selectAll = false
114
116
  } = params;
115
- let pointer = defaultValue.length > 0 ? options.findIndex(
116
- (opt) => opt && isSelectOption(opt) && defaultValue.includes(opt.value) && !opt.disabled
117
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Select options";
118
+ const finalDefaultValue = defaultValue ?? initialValue;
119
+ let pointer = finalDefaultValue.length > 0 ? options.findIndex(
120
+ (opt) => opt && isSelectOption(opt) && finalDefaultValue.includes(opt.value) && !opt.disabled
117
121
  ) : 0;
118
122
  if (pointer === -1) {
119
123
  pointer = options.findIndex(
@@ -126,7 +130,7 @@ export async function multiselectPrompt(params) {
126
130
  const selectedOptions = new Set(
127
131
  selectAll ? options.map(
128
132
  (opt, index) => opt && isSelectOption(opt) && !opt.disabled ? index : -1
129
- ).filter((i) => i !== -1) : defaultValue.map(
133
+ ).filter((i) => i !== -1) : finalDefaultValue.map(
130
134
  (val) => options.findIndex((o) => o && isSelectOption(o) && o.value === val)
131
135
  ).filter(
132
136
  (i) => i >= 0 && options[i] && isSelectOption(options[i]) && !options[i].disabled
@@ -183,7 +187,7 @@ export async function multiselectPrompt(params) {
183
187
  }
184
188
  }
185
189
  lastUILineCount = renderPromptUI({
186
- title,
190
+ title: finalTitle,
187
191
  content,
188
192
  options,
189
193
  pointer,
@@ -205,7 +209,7 @@ export async function multiselectPrompt(params) {
205
209
  });
206
210
  }
207
211
  lastUILineCount = renderPromptUI({
208
- title,
212
+ title: finalTitle,
209
213
  content,
210
214
  options,
211
215
  pointer,
@@ -0,0 +1,2 @@
1
+ import type { SelectPromptParams } from "../../types.js";
2
+ export declare const select: <T extends string>(params: SelectPromptParams<T>) => Promise<T>;
@@ -1,34 +1,5 @@
1
- import type { BorderColorName, ColorName, SelectOption, TypographyName, VariantName } from "../../types.js";
2
- import { symbols } from "../msg-fmt/messages.js";
3
- interface SeparatorOption {
4
- separator: true;
5
- width?: number;
6
- symbol?: keyof typeof symbols;
7
- }
8
- interface SelectPromptParams<T extends string> {
9
- title?: string;
10
- message?: string;
11
- content?: string;
12
- options: (SelectOption<T> | SeparatorOption)[];
13
- defaultValue?: T;
14
- required?: boolean;
15
- borderColor?: BorderColorName;
16
- titleColor?: ColorName;
17
- titleTypography?: TypographyName;
18
- titleVariant?: VariantName;
19
- contentColor?: ColorName;
20
- contentTypography?: TypographyName;
21
- border?: boolean;
22
- endTitle?: string;
23
- endTitleColor?: ColorName;
24
- debug?: boolean;
25
- terminalWidth?: number;
26
- displayInstructions?: boolean;
27
- shouldStream?: boolean;
28
- streamDelay?: number;
29
- }
1
+ import type { SelectPromptParams } from "../../types.js";
30
2
  /**
31
3
  * Displays a selectable prompt in the terminal and returns the chosen value.
32
4
  */
33
5
  export declare function selectPrompt<T extends string>(params: SelectPromptParams<T>): Promise<T>;
34
- export {};
@@ -111,10 +111,11 @@ async function renderPromptUI(params) {
111
111
  export async function selectPrompt(params) {
112
112
  const {
113
113
  title = "",
114
- message = "",
114
+ message,
115
115
  content = "",
116
116
  options,
117
117
  defaultValue,
118
+ initialValue,
118
119
  required = false,
119
120
  borderColor = "dim",
120
121
  titleColor = "cyan",
@@ -131,9 +132,10 @@ export async function selectPrompt(params) {
131
132
  shouldStream = false,
132
133
  streamDelay = 20
133
134
  } = params;
134
- const finalTitle = message || title;
135
- let selectedIndex = defaultValue ? options.findIndex(
136
- (option) => isSelectOption(option) && option.value === defaultValue && !option.disabled
135
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Select option";
136
+ const finalDefaultValue = defaultValue ?? initialValue;
137
+ let selectedIndex = finalDefaultValue ? options.findIndex(
138
+ (option) => isSelectOption(option) && option.value === finalDefaultValue && !option.disabled
137
139
  ) : -1;
138
140
  if (selectedIndex === -1) {
139
141
  selectedIndex = options.findIndex(
package/bin/mod.d.ts CHANGED
@@ -17,7 +17,7 @@ export type { EmptyArgs, BaseArgProps, BaseArgDefinition, PositionalArgDefinitio
17
17
  export { loadCommand } from "./libs/launcher/run-command.js";
18
18
  export { addCompletions } from "./libs/launcher/trpc-orpc-support/completions.js";
19
19
  export { CliValidationError, FailedToExitError, } from "./libs/launcher/trpc-orpc-support/errors.js";
20
- export { TrpcCommand, parseRouter, createRpcCli, z, } from "./libs/launcher/trpc-orpc-support/index.js";
20
+ export { TrpcCommand, parseRouter, createRpcCli, z, trpcServer, zod, } from "./libs/launcher/trpc-orpc-support/index.js";
21
21
  export { flattenedProperties, incompatiblePropertyPairs, getDescription, getSchemaTypes, getEnumChoices, } from "./libs/launcher/trpc-orpc-support/json-schema.js";
22
22
  export type { CommandJSON } from "./libs/launcher/trpc-orpc-support/json.js";
23
23
  export { commandToJSON } from "./libs/launcher/trpc-orpc-support/json.js";
@@ -46,7 +46,7 @@ export { endPrompt, outro } from "./libs/outro/outro-alias.js";
46
46
  export { outroPrompt } from "./libs/outro/outro-mod.js";
47
47
  export type { ResultsType } from "./libs/results/results.js";
48
48
  export { resultPrompt } from "./libs/results/results.js";
49
- export { select } from "./libs/select/aliases-alias.js";
49
+ export { select } from "./libs/select/select-alias.js";
50
50
  export { numMultiSelectPrompt } from "./libs/select/nummultiselect-prompt.js";
51
51
  export { numSelectPrompt } from "./libs/select/numselect-prompt.js";
52
52
  export { selectPrompt } from "./libs/select/select-prompt.js";
package/bin/mod.js CHANGED
@@ -41,7 +41,9 @@ export {
41
41
  TrpcCommand,
42
42
  parseRouter,
43
43
  createRpcCli,
44
- z
44
+ z,
45
+ trpcServer,
46
+ zod
45
47
  } from "./libs/launcher/trpc-orpc-support/index.js";
46
48
  export {
47
49
  flattenedProperties,
@@ -115,7 +117,7 @@ export { numberPrompt } from "./libs/number/number-mod.js";
115
117
  export { endPrompt, outro } from "./libs/outro/outro-alias.js";
116
118
  export { outroPrompt } from "./libs/outro/outro-mod.js";
117
119
  export { resultPrompt } from "./libs/results/results.js";
118
- export { select } from "./libs/select/aliases-alias.js";
120
+ export { select } from "./libs/select/select-alias.js";
119
121
  export { numMultiSelectPrompt } from "./libs/select/nummultiselect-prompt.js";
120
122
  export { numSelectPrompt } from "./libs/select/numselect-prompt.js";
121
123
  export { selectPrompt } from "./libs/select/select-prompt.js";
package/bin/types.d.ts CHANGED
@@ -115,8 +115,10 @@ export interface ProgressBar {
115
115
  */
116
116
  export type PromptType = "input" | "inputmasked" | "select" | "multiselect" | "nummultiselect" | "numselect" | "toggle" | "confirm" | "spinner" | "progressbar" | "results" | "nextsteps" | "animatedtext" | "date" | "end";
117
117
  export interface ConfirmPromptOptions {
118
- title: string;
118
+ title?: string;
119
+ message?: string;
119
120
  defaultValue?: boolean;
121
+ initialValue?: boolean;
120
122
  content?: string;
121
123
  titleColor?: ColorName;
122
124
  titleTypography?: TypographyName;
@@ -192,6 +194,7 @@ export type InputPromptOptions = {
192
194
  contentVariant?: VariantName;
193
195
  customSymbol?: string;
194
196
  defaultValue?: string;
197
+ initialValue?: string;
195
198
  endTitle?: string;
196
199
  endTitleColor?: ColorName;
197
200
  hardcoded?: {
@@ -201,6 +204,7 @@ export type InputPromptOptions = {
201
204
  };
202
205
  hint?: string;
203
206
  hintPlaceholderColor?: ColorName;
207
+ message?: string;
204
208
  mode?: "plain" | "password";
205
209
  mask?: string;
206
210
  placeholder?: string;
@@ -209,7 +213,7 @@ export type InputPromptOptions = {
209
213
  streamDelay?: number;
210
214
  symbol?: SymbolName;
211
215
  symbolColor?: ColorName;
212
- title: string;
216
+ title?: string;
213
217
  titleColor?: ColorName;
214
218
  titleTypography?: TypographyName;
215
219
  titleVariant?: VariantName;
@@ -231,7 +235,7 @@ export interface RenderParams {
231
235
  placeholder?: string;
232
236
  symbol?: SymbolName;
233
237
  symbolColor?: ColorName;
234
- title: string;
238
+ title?: string;
235
239
  titleColor?: ColorName;
236
240
  titleTypography?: TypographyName;
237
241
  titleVariant?: VariantName;
@@ -281,10 +285,12 @@ export interface FmtMsgOptions {
281
285
  noNewLine?: boolean;
282
286
  }
283
287
  export interface TogglePromptParams<T extends string> {
284
- title: string;
288
+ title?: string;
289
+ message?: string;
285
290
  content?: string;
286
291
  options?: [T, T];
287
292
  defaultValue?: T;
293
+ initialValue?: T;
288
294
  borderColor?: BorderColorName;
289
295
  titleColor?: ColorName;
290
296
  titleTypography?: TypographyName;
@@ -302,11 +308,36 @@ export interface SeparatorOption {
302
308
  width?: number;
303
309
  symbol?: SymbolName;
304
310
  }
311
+ export interface SelectPromptParams<T extends string> {
312
+ title?: string;
313
+ message?: string;
314
+ content?: string;
315
+ options: (SelectOption<T> | SeparatorOption)[];
316
+ defaultValue?: T;
317
+ initialValue?: T;
318
+ required?: boolean;
319
+ borderColor?: BorderColorName;
320
+ titleColor?: ColorName;
321
+ titleTypography?: TypographyName;
322
+ titleVariant?: VariantName;
323
+ contentColor?: ColorName;
324
+ contentTypography?: TypographyName;
325
+ border?: boolean;
326
+ endTitle?: string;
327
+ endTitleColor?: ColorName;
328
+ debug?: boolean;
329
+ terminalWidth?: number;
330
+ displayInstructions?: boolean;
331
+ shouldStream?: boolean;
332
+ streamDelay?: number;
333
+ }
305
334
  export interface MultiselectPromptParams<T extends string> {
306
- title: string;
335
+ title?: string;
336
+ message?: string;
307
337
  content?: string;
308
338
  options: (SelectOption<T> | SeparatorOption)[];
309
339
  defaultValue?: T[];
340
+ initialValue?: T[];
310
341
  borderColor?: BorderColorName;
311
342
  titleColor?: ColorName;
312
343
  titleTypography?: TypographyName;
package/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  "license": "MIT",
45
45
  "name": "@reliverse/rempts",
46
46
  "type": "module",
47
- "version": "1.7.33",
47
+ "version": "1.7.35",
48
48
  "author": "reliverse",
49
49
  "bugs": {
50
50
  "email": "blefnk@gmail.com",
@@ -1 +0,0 @@
1
- export declare const select: any;