@inquirer/i18n 1.0.1 → 1.0.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/dist/create.d.ts +32 -0
- package/dist/create.js +123 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +78 -0
- package/dist/locales/en.d.ts +1 -0
- package/dist/locales/en.js +1 -0
- package/dist/locales/es.d.ts +209 -0
- package/dist/locales/es.js +32 -0
- package/dist/locales/fr.d.ts +209 -0
- package/dist/locales/fr.js +32 -0
- package/dist/locales/pt.d.ts +209 -0
- package/dist/locales/pt.js +32 -0
- package/dist/locales/zh.d.ts +209 -0
- package/dist/locales/zh.js +32 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.js +1 -0
- package/package.json +4 -4
package/dist/create.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { checkbox as checkboxPrompt, confirm as confirmPrompt, editor as editorPrompt, expand as expandPrompt, input as inputPrompt, number as numberPrompt, password as passwordPrompt, rawlist as rawlistPrompt, search as searchPrompt, select as selectPrompt } from '@inquirer/prompts';
|
|
2
|
+
import type { Locale } from './types.js';
|
|
3
|
+
export type { Locale } from './types.js';
|
|
4
|
+
type ConfirmConfig = Parameters<typeof confirmPrompt>[0];
|
|
5
|
+
type SelectConfig<Value> = Parameters<typeof selectPrompt<Value>>[0];
|
|
6
|
+
type CheckboxConfig<Value> = Parameters<typeof checkboxPrompt<Value>>[0];
|
|
7
|
+
type SearchConfig<Value> = Parameters<typeof searchPrompt<Value>>[0];
|
|
8
|
+
type ExpandConfig<Value> = Parameters<typeof expandPrompt<Value>>[0];
|
|
9
|
+
type RawlistConfig<Value> = Parameters<typeof rawlistPrompt<Value>>[0];
|
|
10
|
+
type EditorConfig = Parameters<typeof editorPrompt>[0];
|
|
11
|
+
type InputConfig = Parameters<typeof inputPrompt>[0];
|
|
12
|
+
type NumberConfig<Required extends boolean = boolean> = Parameters<typeof numberPrompt<Required>>[0];
|
|
13
|
+
type PasswordConfig = Parameters<typeof passwordPrompt>[0];
|
|
14
|
+
type Context = Parameters<typeof confirmPrompt>[1];
|
|
15
|
+
/**
|
|
16
|
+
* Factory function that creates localized prompt wrappers for a given locale.
|
|
17
|
+
*
|
|
18
|
+
* @param locale - The locale object containing all localized strings
|
|
19
|
+
* @returns An object containing all prompt functions with localization applied
|
|
20
|
+
*/
|
|
21
|
+
export declare function createLocalizedPrompts(locale: Locale): {
|
|
22
|
+
confirm(this: void, config: ConfirmConfig, context?: Context): Promise<boolean>;
|
|
23
|
+
select<Value>(this: void, config: SelectConfig<Value>, context?: Context): Promise<Value>;
|
|
24
|
+
checkbox<Value>(this: void, config: CheckboxConfig<Value>, context?: Context): Promise<Value[]>;
|
|
25
|
+
search<Value>(this: void, config: SearchConfig<Value>, context?: Context): Promise<Value>;
|
|
26
|
+
expand<Value>(this: void, config: ExpandConfig<Value>, context?: Context): Promise<Value>;
|
|
27
|
+
rawlist<Value>(this: void, config: RawlistConfig<Value>, context?: Context): Promise<Value>;
|
|
28
|
+
editor(this: void, config: EditorConfig, context?: Context): Promise<string>;
|
|
29
|
+
input(this: void, config: InputConfig, context?: Context): Promise<string>;
|
|
30
|
+
number<Required extends boolean = boolean>(this: void, config: NumberConfig<Required>, context?: Context): Promise<Required extends true ? number : number | undefined>;
|
|
31
|
+
password(this: void, config: PasswordConfig, context?: Context): Promise<string>;
|
|
32
|
+
};
|
package/dist/create.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { checkbox as checkboxPrompt, confirm as confirmPrompt, editor as editorPrompt, expand as expandPrompt, input as inputPrompt, number as numberPrompt, password as passwordPrompt, rawlist as rawlistPrompt, search as searchPrompt, select as selectPrompt, } from '@inquirer/prompts';
|
|
2
|
+
import { makeTheme } from '@inquirer/core';
|
|
3
|
+
import { styleText } from 'node:util';
|
|
4
|
+
/**
|
|
5
|
+
* Factory function that creates localized prompt wrappers for a given locale.
|
|
6
|
+
*
|
|
7
|
+
* @param locale - The locale object containing all localized strings
|
|
8
|
+
* @returns An object containing all prompt functions with localization applied
|
|
9
|
+
*/
|
|
10
|
+
export function createLocalizedPrompts(locale) {
|
|
11
|
+
return {
|
|
12
|
+
confirm(config, context) {
|
|
13
|
+
const theme = makeTheme(config.theme, {
|
|
14
|
+
style: {
|
|
15
|
+
defaultAnswer: (text) => {
|
|
16
|
+
if (text === 'Y/n')
|
|
17
|
+
return styleText('dim', `(${locale.confirm.hintYes})`);
|
|
18
|
+
if (text === 'y/N')
|
|
19
|
+
return styleText('dim', `(${locale.confirm.hintNo})`);
|
|
20
|
+
return styleText('dim', `(${text})`);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return confirmPrompt({
|
|
25
|
+
...config,
|
|
26
|
+
theme,
|
|
27
|
+
transformer: config.transformer ??
|
|
28
|
+
((answer) => answer ? locale.confirm.yesLabel : locale.confirm.noLabel),
|
|
29
|
+
}, context);
|
|
30
|
+
},
|
|
31
|
+
select(config, context) {
|
|
32
|
+
const theme = makeTheme(config.theme, {
|
|
33
|
+
style: {
|
|
34
|
+
keysHelpTip: (keys) => {
|
|
35
|
+
const localizedKeys = keys.map(([key, label]) => {
|
|
36
|
+
if (label === 'navigate')
|
|
37
|
+
return [key, locale.select.helpNavigate];
|
|
38
|
+
if (label === 'select')
|
|
39
|
+
return [key, locale.select.helpSelect];
|
|
40
|
+
return [key, label];
|
|
41
|
+
});
|
|
42
|
+
return localizedKeys
|
|
43
|
+
.map(([k, l]) => `${styleText('bold', k)} ${styleText('dim', l)}`)
|
|
44
|
+
.join(styleText('dim', ' • '));
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
return selectPrompt({ ...config, theme }, context);
|
|
49
|
+
},
|
|
50
|
+
checkbox(config, context) {
|
|
51
|
+
const theme = makeTheme(config.theme, {
|
|
52
|
+
style: {
|
|
53
|
+
keysHelpTip: (keys) => {
|
|
54
|
+
const localizedKeys = keys.map(([key, label]) => {
|
|
55
|
+
if (label === 'navigate')
|
|
56
|
+
return [key, locale.checkbox.helpNavigate];
|
|
57
|
+
if (label === 'select')
|
|
58
|
+
return [key, locale.checkbox.helpSelect];
|
|
59
|
+
if (label === 'submit')
|
|
60
|
+
return [key, locale.checkbox.helpSubmit];
|
|
61
|
+
if (label === 'all')
|
|
62
|
+
return [key, locale.checkbox.helpAll];
|
|
63
|
+
if (label === 'invert')
|
|
64
|
+
return [key, locale.checkbox.helpInvert];
|
|
65
|
+
return [key, label];
|
|
66
|
+
});
|
|
67
|
+
return localizedKeys
|
|
68
|
+
.map(([k, l]) => `${styleText('bold', k)} ${styleText('dim', l)}`)
|
|
69
|
+
.join(styleText('dim', ' • '));
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return checkboxPrompt({ ...config, theme }, context);
|
|
74
|
+
},
|
|
75
|
+
search(config, context) {
|
|
76
|
+
const theme = makeTheme(config.theme, {
|
|
77
|
+
style: {
|
|
78
|
+
keysHelpTip: (keys) => {
|
|
79
|
+
const localizedKeys = keys.map(([key, label]) => {
|
|
80
|
+
if (label === 'navigate')
|
|
81
|
+
return [key, locale.search.helpNavigate];
|
|
82
|
+
if (label === 'select')
|
|
83
|
+
return [key, locale.search.helpSelect];
|
|
84
|
+
return [key, label];
|
|
85
|
+
});
|
|
86
|
+
return localizedKeys
|
|
87
|
+
.map(([k, l]) => `${styleText('bold', k)} ${styleText('dim', l)}`)
|
|
88
|
+
.join(styleText('dim', ' • '));
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
return searchPrompt({ ...config, theme }, context);
|
|
93
|
+
},
|
|
94
|
+
expand(config, context) {
|
|
95
|
+
return expandPrompt(config, context);
|
|
96
|
+
},
|
|
97
|
+
rawlist(config, context) {
|
|
98
|
+
return rawlistPrompt(config, context);
|
|
99
|
+
},
|
|
100
|
+
editor(config, context) {
|
|
101
|
+
const theme = makeTheme(config.theme, {
|
|
102
|
+
style: {
|
|
103
|
+
waitingMessage: locale.editor.waitingMessage,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
return editorPrompt({ ...config, theme }, context);
|
|
107
|
+
},
|
|
108
|
+
input(config, context) {
|
|
109
|
+
return inputPrompt(config, context);
|
|
110
|
+
},
|
|
111
|
+
number(config, context) {
|
|
112
|
+
return numberPrompt(config, context);
|
|
113
|
+
},
|
|
114
|
+
password(config, context) {
|
|
115
|
+
const theme = makeTheme(config.theme, {
|
|
116
|
+
style: {
|
|
117
|
+
maskedText: locale.password.maskedText,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
return passwordPrompt({ ...config, theme }, context);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as en from './locales/en.js';
|
|
2
|
+
import { createLocalizedPrompts } from './create.js';
|
|
3
|
+
export * from './create.js';
|
|
4
|
+
type LocaleModule = ReturnType<typeof createLocalizedPrompts>;
|
|
5
|
+
/**
|
|
6
|
+
* Register a custom locale so it is automatically picked up by the
|
|
7
|
+
* auto-detection logic in the root `@inquirer/i18n` import.
|
|
8
|
+
*
|
|
9
|
+
* Call this before any prompt is invoked. Use `createLocalizedPrompts`
|
|
10
|
+
* to build the locale object.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { registerLocale, createLocalizedPrompts } from '@inquirer/i18n';
|
|
15
|
+
*
|
|
16
|
+
* registerLocale('de', createLocalizedPrompts({ confirm: { ... }, ... }));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerLocale(code: string, locale: LocaleModule): void;
|
|
20
|
+
export declare const confirm: typeof en.confirm;
|
|
21
|
+
export declare const select: typeof en.select;
|
|
22
|
+
export declare const checkbox: typeof en.checkbox;
|
|
23
|
+
export declare const search: typeof en.search;
|
|
24
|
+
export declare const expand: typeof en.expand;
|
|
25
|
+
export declare const editor: typeof en.editor;
|
|
26
|
+
export declare const input: typeof en.input;
|
|
27
|
+
export declare const number: typeof en.number;
|
|
28
|
+
export declare const password: typeof en.password;
|
|
29
|
+
export declare const rawlist: typeof en.rawlist;
|
|
30
|
+
export { Separator } from '@inquirer/prompts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as en from './locales/en.js';
|
|
2
|
+
import * as es from './locales/es.js';
|
|
3
|
+
import * as fr from './locales/fr.js';
|
|
4
|
+
import * as pt from './locales/pt.js';
|
|
5
|
+
import * as zh from './locales/zh.js';
|
|
6
|
+
export * from './create.js';
|
|
7
|
+
const localeMap = { en, es, fr, pt, zh };
|
|
8
|
+
/**
|
|
9
|
+
* Register a custom locale so it is automatically picked up by the
|
|
10
|
+
* auto-detection logic in the root `@inquirer/i18n` import.
|
|
11
|
+
*
|
|
12
|
+
* Call this before any prompt is invoked. Use `createLocalizedPrompts`
|
|
13
|
+
* to build the locale object.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { registerLocale, createLocalizedPrompts } from '@inquirer/i18n';
|
|
18
|
+
*
|
|
19
|
+
* registerLocale('de', createLocalizedPrompts({ confirm: { ... }, ... }));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function registerLocale(code, locale) {
|
|
23
|
+
localeMap[code] = locale;
|
|
24
|
+
// Invalidate the memo so the next prompt call re-runs detection.
|
|
25
|
+
cachedLocale = undefined;
|
|
26
|
+
}
|
|
27
|
+
function normalize(value) {
|
|
28
|
+
const [withoutEncoding = ''] = value.split('.');
|
|
29
|
+
const [lang = ''] = withoutEncoding.split(/[_-]/);
|
|
30
|
+
return lang.toLowerCase();
|
|
31
|
+
}
|
|
32
|
+
function detectLocale() {
|
|
33
|
+
// 1. LANGUAGE (GNU/Linux colon-separated preference list)
|
|
34
|
+
for (const seg of (process.env['LANGUAGE'] ?? '').split(':')) {
|
|
35
|
+
const lang = normalize(seg);
|
|
36
|
+
if (lang && lang in localeMap)
|
|
37
|
+
return lang;
|
|
38
|
+
}
|
|
39
|
+
// 2–4. LC_ALL, LC_MESSAGES, LANG
|
|
40
|
+
for (const key of ['LC_ALL', 'LC_MESSAGES', 'LANG']) {
|
|
41
|
+
const lang = normalize(process.env[key] ?? '');
|
|
42
|
+
if (lang && lang in localeMap)
|
|
43
|
+
return lang;
|
|
44
|
+
}
|
|
45
|
+
// 5. Intl API (cross-platform / primary Windows path)
|
|
46
|
+
try {
|
|
47
|
+
const lang = normalize(Intl.DateTimeFormat().resolvedOptions().locale);
|
|
48
|
+
if (lang && lang in localeMap)
|
|
49
|
+
return lang;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// ignore
|
|
53
|
+
}
|
|
54
|
+
return 'en';
|
|
55
|
+
}
|
|
56
|
+
// Memoized on a fingerprint of the four env vars we consult.
|
|
57
|
+
// Cleared by `registerLocale()` so newly registered locales are picked up.
|
|
58
|
+
let cachedLocale;
|
|
59
|
+
let cachedEnvKey;
|
|
60
|
+
function getLocale() {
|
|
61
|
+
const envKey = `${process.env['LANGUAGE'] ?? ''}|${process.env['LC_ALL'] ?? ''}|${process.env['LC_MESSAGES'] ?? ''}|${process.env['LANG'] ?? ''}`;
|
|
62
|
+
if (cachedLocale && envKey === cachedEnvKey)
|
|
63
|
+
return cachedLocale;
|
|
64
|
+
cachedEnvKey = envKey;
|
|
65
|
+
cachedLocale = localeMap[detectLocale()] ?? en;
|
|
66
|
+
return cachedLocale;
|
|
67
|
+
}
|
|
68
|
+
export const confirm = (config, context) => getLocale().confirm(config, context);
|
|
69
|
+
export const select = (config, context) => getLocale().select(config, context);
|
|
70
|
+
export const checkbox = (config, context) => getLocale().checkbox(config, context);
|
|
71
|
+
export const search = (config, context) => getLocale().search(config, context);
|
|
72
|
+
export const expand = (config, context) => getLocale().expand(config, context);
|
|
73
|
+
export const editor = (config, context) => getLocale().editor(config, context);
|
|
74
|
+
export const input = (config, context) => getLocale().input(config, context);
|
|
75
|
+
export const number = (config, context) => getLocale().number(config, context);
|
|
76
|
+
export const password = (config, context) => getLocale().password(config, context);
|
|
77
|
+
export const rawlist = (config, context) => getLocale().rawlist(config, context);
|
|
78
|
+
export { Separator } from '@inquirer/prompts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@inquirer/prompts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@inquirer/prompts';
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export declare const confirm: (this: void, config: {
|
|
2
|
+
message: string;
|
|
3
|
+
default?: boolean;
|
|
4
|
+
transformer?: (value: boolean) => string;
|
|
5
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme>;
|
|
6
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<boolean>, select: <Value>(this: void, config: {
|
|
7
|
+
message: string;
|
|
8
|
+
choices: readonly (import("@inquirer/prompts").Separator | Value | {
|
|
9
|
+
value: Value;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
short?: string;
|
|
13
|
+
disabled?: boolean | string;
|
|
14
|
+
type?: never;
|
|
15
|
+
})[];
|
|
16
|
+
pageSize?: number | undefined;
|
|
17
|
+
loop?: boolean | undefined;
|
|
18
|
+
default?: NoInfer<Value> | undefined;
|
|
19
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
20
|
+
icon: {
|
|
21
|
+
cursor: string;
|
|
22
|
+
};
|
|
23
|
+
style: {
|
|
24
|
+
disabled: (text: string) => string;
|
|
25
|
+
description: (text: string) => string;
|
|
26
|
+
keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
|
|
27
|
+
};
|
|
28
|
+
i18n: {
|
|
29
|
+
disabledError: string;
|
|
30
|
+
};
|
|
31
|
+
indexMode: "hidden" | "number";
|
|
32
|
+
keybindings: ReadonlyArray<import("@inquirer/core").Keybinding>;
|
|
33
|
+
}>> | undefined;
|
|
34
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, checkbox: <Value>(this: void, config: {
|
|
35
|
+
message: string;
|
|
36
|
+
prefix?: string | undefined;
|
|
37
|
+
pageSize?: number | undefined;
|
|
38
|
+
choices: readonly (string | import("@inquirer/prompts").Separator)[] | readonly (import("@inquirer/prompts").Separator | {
|
|
39
|
+
value: Value;
|
|
40
|
+
name?: string;
|
|
41
|
+
checkedName?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
short?: string;
|
|
44
|
+
disabled?: boolean | string;
|
|
45
|
+
checked?: boolean;
|
|
46
|
+
type?: never;
|
|
47
|
+
})[];
|
|
48
|
+
loop?: boolean | undefined;
|
|
49
|
+
required?: boolean | undefined;
|
|
50
|
+
validate?: ((choices: readonly {
|
|
51
|
+
value: Value;
|
|
52
|
+
name: string;
|
|
53
|
+
checkedName: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
short: string;
|
|
56
|
+
disabled: boolean | string;
|
|
57
|
+
checked: boolean;
|
|
58
|
+
}[]) => boolean | string | Promise<string | boolean>) | undefined;
|
|
59
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
60
|
+
icon: {
|
|
61
|
+
checked: string;
|
|
62
|
+
unchecked: string;
|
|
63
|
+
cursor: string;
|
|
64
|
+
disabledChecked: string;
|
|
65
|
+
disabledUnchecked: string;
|
|
66
|
+
};
|
|
67
|
+
style: {
|
|
68
|
+
disabled: (text: string) => string;
|
|
69
|
+
renderSelectedChoices: <T>(selectedChoices: ReadonlyArray<{
|
|
70
|
+
value: T;
|
|
71
|
+
name: string;
|
|
72
|
+
checkedName: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
short: string;
|
|
75
|
+
disabled: boolean | string;
|
|
76
|
+
checked: boolean;
|
|
77
|
+
}>, allChoices: ReadonlyArray<{
|
|
78
|
+
value: T;
|
|
79
|
+
name: string;
|
|
80
|
+
checkedName: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
short: string;
|
|
83
|
+
disabled: boolean | string;
|
|
84
|
+
checked: boolean;
|
|
85
|
+
} | import("@inquirer/prompts").Separator>) => string;
|
|
86
|
+
description: (text: string) => string;
|
|
87
|
+
keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
|
|
88
|
+
};
|
|
89
|
+
i18n: {
|
|
90
|
+
disabledError: string;
|
|
91
|
+
};
|
|
92
|
+
keybindings: ReadonlyArray<import("@inquirer/core").Keybinding>;
|
|
93
|
+
}>> | undefined;
|
|
94
|
+
shortcuts?: {
|
|
95
|
+
all?: string | null;
|
|
96
|
+
invert?: string | null;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<Value[]>, search: <Value>(this: void, config: {
|
|
99
|
+
message: string;
|
|
100
|
+
source: (term: string | undefined, opt: {
|
|
101
|
+
signal: AbortSignal;
|
|
102
|
+
}) => readonly (string | import("@inquirer/prompts").Separator)[] | Promise<readonly (string | import("@inquirer/prompts").Separator)[]> | readonly (import("@inquirer/prompts").Separator | {
|
|
103
|
+
value: Value;
|
|
104
|
+
name?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
short?: string;
|
|
107
|
+
disabled?: boolean | string;
|
|
108
|
+
type?: never;
|
|
109
|
+
})[] | Promise<readonly (import("@inquirer/prompts").Separator | {
|
|
110
|
+
value: Value;
|
|
111
|
+
name?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
short?: string;
|
|
114
|
+
disabled?: boolean | string;
|
|
115
|
+
type?: never;
|
|
116
|
+
})[]>;
|
|
117
|
+
validate?: ((value: Value) => boolean | string | Promise<string | boolean>) | undefined;
|
|
118
|
+
pageSize?: number | undefined;
|
|
119
|
+
default?: NoInfer<Value> | undefined;
|
|
120
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
121
|
+
icon: {
|
|
122
|
+
cursor: string;
|
|
123
|
+
};
|
|
124
|
+
style: {
|
|
125
|
+
disabled: (text: string) => string;
|
|
126
|
+
searchTerm: (text: string) => string;
|
|
127
|
+
description: (text: string) => string;
|
|
128
|
+
keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
|
|
129
|
+
};
|
|
130
|
+
}>> | undefined;
|
|
131
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, expand: <Value>(this: void, config: {
|
|
132
|
+
message: string;
|
|
133
|
+
choices: readonly {
|
|
134
|
+
key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
135
|
+
name: string;
|
|
136
|
+
}[] | readonly (import("@inquirer/prompts").Separator | ({
|
|
137
|
+
key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
138
|
+
value: Value;
|
|
139
|
+
} | {
|
|
140
|
+
key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
141
|
+
name: string;
|
|
142
|
+
value: Value;
|
|
143
|
+
}))[];
|
|
144
|
+
default?: (("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z") | "h") | undefined;
|
|
145
|
+
expanded?: boolean | undefined;
|
|
146
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme> | undefined;
|
|
147
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, rawlist: <Value>(this: void, config: {
|
|
148
|
+
message: string;
|
|
149
|
+
choices: readonly (import("@inquirer/prompts").Separator | Value | {
|
|
150
|
+
value: Value;
|
|
151
|
+
name?: string;
|
|
152
|
+
short?: string;
|
|
153
|
+
key?: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
})[];
|
|
156
|
+
loop?: boolean | undefined;
|
|
157
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
158
|
+
style: {
|
|
159
|
+
description: (text: string) => string;
|
|
160
|
+
};
|
|
161
|
+
}>> | undefined;
|
|
162
|
+
default?: NoInfer<Value> | undefined;
|
|
163
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, editor: (this: void, config: {
|
|
164
|
+
message: string;
|
|
165
|
+
default?: string;
|
|
166
|
+
postfix?: string;
|
|
167
|
+
waitForUserInput?: boolean;
|
|
168
|
+
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
|
169
|
+
file?: import("@inquirer/external-editor").IFileOptions;
|
|
170
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
171
|
+
validationFailureMode: "keep" | "clear";
|
|
172
|
+
style: {
|
|
173
|
+
waitingMessage: (enterKey: string) => string;
|
|
174
|
+
};
|
|
175
|
+
}>>;
|
|
176
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<string>, input: (this: void, config: {
|
|
177
|
+
message: string;
|
|
178
|
+
default?: string;
|
|
179
|
+
prefill?: "tab" | "editable";
|
|
180
|
+
required?: boolean;
|
|
181
|
+
transformer?: (value: string, { isFinal }: {
|
|
182
|
+
isFinal: boolean;
|
|
183
|
+
}) => string;
|
|
184
|
+
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
|
185
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
186
|
+
validationFailureMode: "keep" | "clear";
|
|
187
|
+
}>>;
|
|
188
|
+
pattern?: RegExp;
|
|
189
|
+
patternError?: string;
|
|
190
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<string>, number: <Required extends boolean = boolean>(this: void, config: {
|
|
191
|
+
message: string;
|
|
192
|
+
default?: number | undefined;
|
|
193
|
+
min?: number | undefined;
|
|
194
|
+
max?: number | undefined;
|
|
195
|
+
step?: number | "any" | undefined;
|
|
196
|
+
required?: Required | undefined;
|
|
197
|
+
validate?: ((value: Required extends true ? number : number | undefined) => boolean | string | Promise<string | boolean>) | undefined;
|
|
198
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme> | undefined;
|
|
199
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<Required extends true ? number : number | undefined>, password: (this: void, config: {
|
|
200
|
+
message: string;
|
|
201
|
+
mask?: boolean | string;
|
|
202
|
+
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
|
203
|
+
theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
|
|
204
|
+
style: {
|
|
205
|
+
maskedText: string;
|
|
206
|
+
};
|
|
207
|
+
}>>;
|
|
208
|
+
}, context?: import("@inquirer/type").Context | undefined) => Promise<string>;
|
|
209
|
+
export { Separator } from '@inquirer/prompts';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createLocalizedPrompts } from "../create.js";
|
|
2
|
+
const esLocale = {
|
|
3
|
+
confirm: {
|
|
4
|
+
yesLabel: 'Sí',
|
|
5
|
+
noLabel: 'No',
|
|
6
|
+
hintYes: 'S/n',
|
|
7
|
+
hintNo: 's/N',
|
|
8
|
+
},
|
|
9
|
+
select: {
|
|
10
|
+
helpNavigate: 'navegar',
|
|
11
|
+
helpSelect: 'seleccionar',
|
|
12
|
+
},
|
|
13
|
+
checkbox: {
|
|
14
|
+
helpNavigate: 'navegar',
|
|
15
|
+
helpSelect: 'seleccionar',
|
|
16
|
+
helpSubmit: 'enviar',
|
|
17
|
+
helpAll: 'todos',
|
|
18
|
+
helpInvert: 'invertir',
|
|
19
|
+
},
|
|
20
|
+
search: {
|
|
21
|
+
helpNavigate: 'navegar',
|
|
22
|
+
helpSelect: 'seleccionar',
|
|
23
|
+
},
|
|
24
|
+
editor: {
|
|
25
|
+
waitingMessage: (enterKey) => `Presione ${enterKey} para lanzar su editor preferido.`,
|
|
26
|
+
},
|
|
27
|
+
password: {
|
|
28
|
+
maskedText: '[entrada oculta]',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export const { confirm, select, checkbox, search, expand, rawlist, editor, input, number, password, } = createLocalizedPrompts(esLocale);
|
|
32
|
+
export { Separator } from '@inquirer/prompts';
|