@inquirer/input 3.0.1 → 4.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.
- package/README.md +1 -1
- package/dist/{cjs → commonjs}/index.js +3 -12
- package/dist/commonjs/package.json +3 -0
- package/dist/esm/package.json +3 -0
- package/package.json +48 -35
- package/dist/esm/types/index.d.mts +0 -14
- /package/dist/{cjs/types → commonjs}/index.d.ts +0 -0
- /package/dist/{types → esm}/index.d.ts +0 -0
- /package/dist/esm/{index.mjs → index.js} +0 -0
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ const answer = await input({ message: 'Enter your name' });
|
|
|
63
63
|
| Property | Type | Required | Description |
|
|
64
64
|
| ----------- | ----------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
65
65
|
| message | `string` | yes | The question to ask |
|
|
66
|
-
| default | `string` | no | Default value if no answer is provided (clear
|
|
66
|
+
| default | `string` | no | Default value if no answer is provided (press `backspace` to clear the default; press `tab` to inline the value for edits) |
|
|
67
67
|
| required | `boolean` | no | Defaults to `false`. If set to true, `undefined` (empty) will not be accepted for this. |
|
|
68
68
|
| transformer | `(string, { isFinal: boolean }) => string` | no | Transform/Format the raw value entered by the user. Once the prompt is completed, `isFinal` will be `true`. This function is purely visual, modify the answer in your code if needed. |
|
|
69
69
|
| validate | `string => boolean \| string \| Promise<boolean \| string>` | no | On submit, validate the filtered answered content. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const core_1 = require("@inquirer/core");
|
|
13
4
|
exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
@@ -18,7 +9,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
18
9
|
const [errorMsg, setError] = (0, core_1.useState)();
|
|
19
10
|
const [value, setValue] = (0, core_1.useState)('');
|
|
20
11
|
const prefix = (0, core_1.usePrefix)({ status, theme });
|
|
21
|
-
(0, core_1.useKeypress)((key, rl) =>
|
|
12
|
+
(0, core_1.useKeypress)(async (key, rl) => {
|
|
22
13
|
// Ignore keypress while our prompt is doing other processing.
|
|
23
14
|
if (status !== 'idle') {
|
|
24
15
|
return;
|
|
@@ -26,7 +17,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
26
17
|
if ((0, core_1.isEnterKey)(key)) {
|
|
27
18
|
const answer = value || defaultValue;
|
|
28
19
|
setStatus('loading');
|
|
29
|
-
const isValid = required && !answer ? 'You must provide a value' :
|
|
20
|
+
const isValid = required && !answer ? 'You must provide a value' : await validate(answer);
|
|
30
21
|
if (isValid === true) {
|
|
31
22
|
setValue(answer);
|
|
32
23
|
setStatus('done');
|
|
@@ -53,7 +44,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
53
44
|
setValue(rl.line);
|
|
54
45
|
setError(undefined);
|
|
55
46
|
}
|
|
56
|
-
})
|
|
47
|
+
});
|
|
57
48
|
const message = theme.style.message(config.message, status);
|
|
58
49
|
let formattedValue = value;
|
|
59
50
|
if (typeof config.transformer === 'function') {
|
package/package.json
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/input",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Inquirer input text prompt",
|
|
5
|
-
"main": "./dist/cjs/index.js",
|
|
6
|
-
"typings": "./dist/cjs/types/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist/**/*"
|
|
9
|
-
],
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
|
13
|
-
},
|
|
14
5
|
"keywords": [
|
|
15
6
|
"answer",
|
|
16
7
|
"answers",
|
|
@@ -50,40 +41,62 @@
|
|
|
50
41
|
"yo",
|
|
51
42
|
"zsh"
|
|
52
43
|
],
|
|
53
|
-
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
|
54
|
-
"license": "MIT",
|
|
55
44
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/input/README.md",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
|
59
48
|
},
|
|
60
|
-
"
|
|
61
|
-
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"type": "module",
|
|
53
|
+
"exports": {
|
|
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
|
+
}
|
|
62
65
|
},
|
|
66
|
+
"main": "./dist/commonjs/index.js",
|
|
67
|
+
"module": "./dist/esm/index.js",
|
|
68
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
69
|
+
"files": [
|
|
70
|
+
"dist"
|
|
71
|
+
],
|
|
63
72
|
"scripts": {
|
|
64
|
-
"
|
|
65
|
-
"tsc
|
|
66
|
-
"tsc:cjs": "rm -rf dist/cjs && tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs",
|
|
67
|
-
"attw": "attw --pack"
|
|
73
|
+
"attw": "attw --pack",
|
|
74
|
+
"tsc": "tshy"
|
|
68
75
|
},
|
|
69
|
-
"
|
|
70
|
-
"
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@inquirer/core": "^10.0.0",
|
|
78
|
+
"@inquirer/type": "^3.0.0"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@arethetypeswrong/cli": "^0.16.4",
|
|
82
|
+
"@inquirer/testing": "^2.1.35",
|
|
83
|
+
"@repo/tsconfig": "workspace:*",
|
|
84
|
+
"tshy": "^3.0.2"
|
|
71
85
|
},
|
|
72
86
|
"engines": {
|
|
73
87
|
"node": ">=18"
|
|
74
88
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
"publishConfig": {
|
|
90
|
+
"access": "public"
|
|
91
|
+
},
|
|
92
|
+
"tshy": {
|
|
93
|
+
"exclude": [
|
|
94
|
+
"src/**/*.test.ts"
|
|
95
|
+
],
|
|
96
|
+
"exports": {
|
|
97
|
+
"./package.json": "./package.json",
|
|
98
|
+
".": "./src/index.ts"
|
|
85
99
|
}
|
|
86
100
|
},
|
|
87
|
-
"
|
|
88
|
-
"gitHead": "9e29035c2efc78f44aed3c7732aee46ab1d64ca2"
|
|
101
|
+
"gitHead": "483189975eb5ea7d214c265a5ce108544c2bf1a5"
|
|
89
102
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type Theme } from '@inquirer/core';
|
|
2
|
-
import type { PartialDeep } from '@inquirer/type';
|
|
3
|
-
type InputConfig = {
|
|
4
|
-
message: string;
|
|
5
|
-
default?: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
transformer?: (value: string, { isFinal }: {
|
|
8
|
-
isFinal: boolean;
|
|
9
|
-
}) => string;
|
|
10
|
-
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
|
11
|
-
theme?: PartialDeep<Theme>;
|
|
12
|
-
};
|
|
13
|
-
declare const _default: import("@inquirer/type").Prompt<string, InputConfig>;
|
|
14
|
-
export default _default;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|