@inquirer/password 4.0.22 → 5.0.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.
@@ -0,0 +1,10 @@
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/index.js ADDED
@@ -0,0 +1,55 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/password",
3
- "version": "4.0.22",
3
+ "version": "5.0.0",
4
4
  "description": "Inquirer password prompt",
5
5
  "keywords": [
6
6
  "answer",
@@ -52,51 +52,35 @@
52
52
  "type": "module",
53
53
  "exports": {
54
54
  "./package.json": "./package.json",
55
- ".": {
56
- "import": {
57
- "types": "./dist/esm/index.d.ts",
58
- "default": "./dist/esm/index.js"
59
- },
60
- "require": {
61
- "types": "./dist/commonjs/index.d.ts",
62
- "default": "./dist/commonjs/index.js"
63
- }
64
- }
55
+ ".": "./src/index.ts"
65
56
  },
66
- "main": "./dist/commonjs/index.js",
67
- "module": "./dist/esm/index.js",
68
- "types": "./dist/commonjs/index.d.ts",
69
57
  "files": [
70
58
  "dist"
71
59
  ],
72
60
  "scripts": {
73
- "attw": "attw --pack",
74
- "tsc": "tshy"
61
+ "tsc": "tsc"
75
62
  },
76
63
  "dependencies": {
77
- "@inquirer/ansi": "^1.0.2",
78
- "@inquirer/core": "^10.3.1",
79
- "@inquirer/type": "^3.0.10"
64
+ "@inquirer/ansi": "^2.0.0",
65
+ "@inquirer/core": "^11.0.0",
66
+ "@inquirer/type": "^4.0.0"
80
67
  },
81
68
  "devDependencies": {
82
- "@arethetypeswrong/cli": "^0.18.2",
83
- "@inquirer/testing": "^2.1.52",
69
+ "@inquirer/testing": "^3.0.0",
84
70
  "@repo/tsconfig": "0.0.0",
85
- "tshy": "^3.0.3"
71
+ "typescript": "^5.9.3"
86
72
  },
87
73
  "engines": {
88
- "node": ">=18"
74
+ "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
89
75
  },
90
76
  "publishConfig": {
91
- "access": "public"
92
- },
93
- "tshy": {
94
- "exclude": [
95
- "src/**/*.test.ts"
96
- ],
77
+ "access": "public",
97
78
  "exports": {
98
79
  "./package.json": "./package.json",
99
- ".": "./src/index.ts"
80
+ ".": {
81
+ "types": "./dist/index.d.ts",
82
+ "default": "./dist/index.js"
83
+ }
100
84
  }
101
85
  },
102
86
  "peerDependencies": {
@@ -107,5 +91,5 @@
107
91
  "optional": true
108
92
  }
109
93
  },
110
- "gitHead": "6881993e517e76fa891b72e1f5086fd11f7676ac"
94
+ "gitHead": "676685d33374a30340c1b9f0831c7eae2b2357dd"
111
95
  }