@aopslabs/aops 0.2.0 → 0.3.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.
@@ -1,70 +0,0 @@
1
- import inquirer from 'inquirer';
2
- const DONE_PREFIX = '\u2714 ';
3
- const PROMPT_THEME = { prefix: { idle: '?', done: DONE_PREFIX } };
4
- const normalizePromptMessage = (message) => message.trimStart();
5
- export async function promptInput(opts) {
6
- const { value } = await inquirer.prompt([
7
- {
8
- type: 'input',
9
- name: 'value',
10
- message: normalizePromptMessage(opts.message),
11
- default: opts.default,
12
- validate: opts.validate,
13
- theme: PROMPT_THEME,
14
- },
15
- ]);
16
- return String(value ?? '');
17
- }
18
- export async function promptPassword(opts) {
19
- const { value } = await inquirer.prompt([
20
- {
21
- type: 'password',
22
- name: 'value',
23
- message: normalizePromptMessage(opts.message),
24
- default: opts.default,
25
- mask: '*',
26
- validate: opts.validate,
27
- theme: PROMPT_THEME,
28
- },
29
- ]);
30
- return String(value ?? '');
31
- }
32
- export async function promptConfirm(opts) {
33
- const { confirm } = await inquirer.prompt([
34
- {
35
- type: 'confirm',
36
- name: 'confirm',
37
- message: normalizePromptMessage(opts.message),
38
- default: opts.default ?? true,
39
- theme: PROMPT_THEME,
40
- },
41
- ]);
42
- return Boolean(confirm);
43
- }
44
- export async function promptSelect(opts) {
45
- const resolvedType = opts.type === 'list' || !opts.type ? 'select' : opts.type;
46
- const { value } = await inquirer.prompt([
47
- {
48
- type: resolvedType,
49
- name: 'value',
50
- message: normalizePromptMessage(opts.message),
51
- choices: opts.choices,
52
- default: opts.default,
53
- pageSize: opts.pageSize,
54
- theme: PROMPT_THEME,
55
- },
56
- ]);
57
- return String(value);
58
- }
59
- export async function promptMultiSelect(opts) {
60
- const { values } = await inquirer.prompt([
61
- {
62
- type: 'checkbox',
63
- name: 'values',
64
- message: normalizePromptMessage(opts.message),
65
- choices: opts.choices,
66
- theme: PROMPT_THEME,
67
- },
68
- ]);
69
- return Array.isArray(values) ? values.map((v) => String(v)) : [];
70
- }