@inquirer/password 5.0.0 → 5.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/package.json +13 -16
- package/dist/commonjs/index.d.ts +0 -10
- package/dist/commonjs/index.js +0 -57
- package/dist/commonjs/package.json +0 -3
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/index.js +0 -55
- package/dist/esm/package.json +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/password",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Inquirer password prompt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -52,7 +52,10 @@
|
|
|
52
52
|
"type": "module",
|
|
53
53
|
"exports": {
|
|
54
54
|
"./package.json": "./package.json",
|
|
55
|
-
".":
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/index.d.ts",
|
|
57
|
+
"default": "./dist/index.js"
|
|
58
|
+
}
|
|
56
59
|
},
|
|
57
60
|
"files": [
|
|
58
61
|
"dist"
|
|
@@ -61,27 +64,19 @@
|
|
|
61
64
|
"tsc": "tsc"
|
|
62
65
|
},
|
|
63
66
|
"dependencies": {
|
|
64
|
-
"@inquirer/ansi": "^2.0.
|
|
65
|
-
"@inquirer/core": "^11.0.
|
|
66
|
-
"@inquirer/type": "^4.0.
|
|
67
|
+
"@inquirer/ansi": "^2.0.2",
|
|
68
|
+
"@inquirer/core": "^11.0.2",
|
|
69
|
+
"@inquirer/type": "^4.0.2"
|
|
67
70
|
},
|
|
68
71
|
"devDependencies": {
|
|
69
|
-
"@inquirer/testing": "^3.0.
|
|
70
|
-
"@repo/tsconfig": "0.0.0",
|
|
72
|
+
"@inquirer/testing": "^3.0.2",
|
|
71
73
|
"typescript": "^5.9.3"
|
|
72
74
|
},
|
|
73
75
|
"engines": {
|
|
74
76
|
"node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
|
|
75
77
|
},
|
|
76
78
|
"publishConfig": {
|
|
77
|
-
"access": "public"
|
|
78
|
-
"exports": {
|
|
79
|
-
"./package.json": "./package.json",
|
|
80
|
-
".": {
|
|
81
|
-
"types": "./dist/index.d.ts",
|
|
82
|
-
"default": "./dist/index.js"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
79
|
+
"access": "public"
|
|
85
80
|
},
|
|
86
81
|
"peerDependencies": {
|
|
87
82
|
"@types/node": ">=18"
|
|
@@ -91,5 +86,7 @@
|
|
|
91
86
|
"optional": true
|
|
92
87
|
}
|
|
93
88
|
},
|
|
94
|
-
"
|
|
89
|
+
"main": "./dist/index.js",
|
|
90
|
+
"types": "./dist/index.d.ts",
|
|
91
|
+
"gitHead": "9c724296daad3d740b09173f9aae035dc62cb106"
|
|
95
92
|
}
|
package/dist/commonjs/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Theme } from '@inquirer/core';
|
|
2
|
-
import type { PartialDeep } from '@inquirer/type';
|
|
3
|
-
type PasswordConfig = {
|
|
4
|
-
message: string;
|
|
5
|
-
mask?: boolean | string;
|
|
6
|
-
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
|
7
|
-
theme?: PartialDeep<Theme>;
|
|
8
|
-
};
|
|
9
|
-
declare const _default: import("@inquirer/type").Prompt<string, PasswordConfig>;
|
|
10
|
-
export default _default;
|
package/dist/commonjs/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@inquirer/core");
|
|
4
|
-
const ansi_1 = require("@inquirer/ansi");
|
|
5
|
-
exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
6
|
-
const { validate = () => true } = config;
|
|
7
|
-
const theme = (0, core_1.makeTheme)(config.theme);
|
|
8
|
-
const [status, setStatus] = (0, core_1.useState)('idle');
|
|
9
|
-
const [errorMsg, setError] = (0, core_1.useState)();
|
|
10
|
-
const [value, setValue] = (0, core_1.useState)('');
|
|
11
|
-
const prefix = (0, core_1.usePrefix)({ status, theme });
|
|
12
|
-
(0, core_1.useKeypress)(async (key, rl) => {
|
|
13
|
-
// Ignore keypress while our prompt is doing other processing.
|
|
14
|
-
if (status !== 'idle') {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if ((0, core_1.isEnterKey)(key)) {
|
|
18
|
-
const answer = value;
|
|
19
|
-
setStatus('loading');
|
|
20
|
-
const isValid = await validate(answer);
|
|
21
|
-
if (isValid === true) {
|
|
22
|
-
setValue(answer);
|
|
23
|
-
setStatus('done');
|
|
24
|
-
done(answer);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// Reset the readline line value to the previous value. On line event, the value
|
|
28
|
-
// get cleared, forcing the user to re-enter the value instead of fixing it.
|
|
29
|
-
rl.write(value);
|
|
30
|
-
setError(isValid || 'You must provide a valid value');
|
|
31
|
-
setStatus('idle');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
setValue(rl.line);
|
|
36
|
-
setError(undefined);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const message = theme.style.message(config.message, status);
|
|
40
|
-
let formattedValue = '';
|
|
41
|
-
let helpTip;
|
|
42
|
-
if (config.mask) {
|
|
43
|
-
const maskChar = typeof config.mask === 'string' ? config.mask : '*';
|
|
44
|
-
formattedValue = maskChar.repeat(value.length);
|
|
45
|
-
}
|
|
46
|
-
else if (status !== 'done') {
|
|
47
|
-
helpTip = `${theme.style.help('[input is masked]')}${ansi_1.cursorHide}`;
|
|
48
|
-
}
|
|
49
|
-
if (status === 'done') {
|
|
50
|
-
formattedValue = theme.style.answer(formattedValue);
|
|
51
|
-
}
|
|
52
|
-
let error = '';
|
|
53
|
-
if (errorMsg) {
|
|
54
|
-
error = theme.style.error(errorMsg);
|
|
55
|
-
}
|
|
56
|
-
return [[prefix, message, config.mask ? formattedValue : helpTip].join(' '), error];
|
|
57
|
-
});
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Theme } from '@inquirer/core';
|
|
2
|
-
import type { PartialDeep } from '@inquirer/type';
|
|
3
|
-
type PasswordConfig = {
|
|
4
|
-
message: string;
|
|
5
|
-
mask?: boolean | string;
|
|
6
|
-
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
|
7
|
-
theme?: PartialDeep<Theme>;
|
|
8
|
-
};
|
|
9
|
-
declare const _default: import("@inquirer/type").Prompt<string, PasswordConfig>;
|
|
10
|
-
export default _default;
|
package/dist/esm/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createPrompt, useState, useKeypress, usePrefix, isEnterKey, makeTheme, } from '@inquirer/core';
|
|
2
|
-
import { cursorHide } from '@inquirer/ansi';
|
|
3
|
-
export default createPrompt((config, done) => {
|
|
4
|
-
const { validate = () => true } = config;
|
|
5
|
-
const theme = makeTheme(config.theme);
|
|
6
|
-
const [status, setStatus] = useState('idle');
|
|
7
|
-
const [errorMsg, setError] = useState();
|
|
8
|
-
const [value, setValue] = useState('');
|
|
9
|
-
const prefix = usePrefix({ status, theme });
|
|
10
|
-
useKeypress(async (key, rl) => {
|
|
11
|
-
// Ignore keypress while our prompt is doing other processing.
|
|
12
|
-
if (status !== 'idle') {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (isEnterKey(key)) {
|
|
16
|
-
const answer = value;
|
|
17
|
-
setStatus('loading');
|
|
18
|
-
const isValid = await validate(answer);
|
|
19
|
-
if (isValid === true) {
|
|
20
|
-
setValue(answer);
|
|
21
|
-
setStatus('done');
|
|
22
|
-
done(answer);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// Reset the readline line value to the previous value. On line event, the value
|
|
26
|
-
// get cleared, forcing the user to re-enter the value instead of fixing it.
|
|
27
|
-
rl.write(value);
|
|
28
|
-
setError(isValid || 'You must provide a valid value');
|
|
29
|
-
setStatus('idle');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
setValue(rl.line);
|
|
34
|
-
setError(undefined);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const message = theme.style.message(config.message, status);
|
|
38
|
-
let formattedValue = '';
|
|
39
|
-
let helpTip;
|
|
40
|
-
if (config.mask) {
|
|
41
|
-
const maskChar = typeof config.mask === 'string' ? config.mask : '*';
|
|
42
|
-
formattedValue = maskChar.repeat(value.length);
|
|
43
|
-
}
|
|
44
|
-
else if (status !== 'done') {
|
|
45
|
-
helpTip = `${theme.style.help('[input is masked]')}${cursorHide}`;
|
|
46
|
-
}
|
|
47
|
-
if (status === 'done') {
|
|
48
|
-
formattedValue = theme.style.answer(formattedValue);
|
|
49
|
-
}
|
|
50
|
-
let error = '';
|
|
51
|
-
if (errorMsg) {
|
|
52
|
-
error = theme.style.error(errorMsg);
|
|
53
|
-
}
|
|
54
|
-
return [[prefix, message, config.mask ? formattedValue : helpTip].join(' '), error];
|
|
55
|
-
});
|
package/dist/esm/package.json
DELETED