@inquirer/testing 2.1.53 → 3.0.1
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,10 +1,7 @@
|
|
|
1
1
|
import MuteStream from 'mute-stream';
|
|
2
2
|
import type { Prompt, Context } from '@inquirer/type';
|
|
3
3
|
export declare function render<const Props, const Value>(prompt: Prompt<Value, Props>, props: Props, options?: Context): Promise<{
|
|
4
|
-
answer: Promise<Value
|
|
5
|
-
/** @deprecated pass an AbortSignal in the context options instead. See {@link https://github.com/SBoudrias/Inquirer.js#canceling-prompt} */
|
|
6
|
-
cancel: () => void;
|
|
7
|
-
};
|
|
4
|
+
answer: Promise<Value>;
|
|
8
5
|
input: MuteStream;
|
|
9
6
|
events: {
|
|
10
7
|
keypress: (key: string | {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/testing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Inquirer testing utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -56,48 +56,27 @@
|
|
|
56
56
|
"exports": {
|
|
57
57
|
"./package.json": "./package.json",
|
|
58
58
|
".": {
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
"default": "./dist/esm/index.js"
|
|
62
|
-
},
|
|
63
|
-
"require": {
|
|
64
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
65
|
-
"default": "./dist/commonjs/index.js"
|
|
66
|
-
}
|
|
59
|
+
"types": "./dist/index.d.ts",
|
|
60
|
+
"default": "./dist/index.js"
|
|
67
61
|
}
|
|
68
62
|
},
|
|
69
|
-
"main": "./dist/commonjs/index.js",
|
|
70
|
-
"module": "./dist/esm/index.js",
|
|
71
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
72
63
|
"files": [
|
|
73
64
|
"dist"
|
|
74
65
|
],
|
|
75
66
|
"scripts": {
|
|
76
|
-
"
|
|
77
|
-
"tsc": "tshy"
|
|
67
|
+
"tsc": "tsc"
|
|
78
68
|
},
|
|
79
69
|
"dependencies": {
|
|
80
|
-
"@inquirer/type": "^
|
|
81
|
-
"mute-stream": "^
|
|
70
|
+
"@inquirer/type": "^4.0.1",
|
|
71
|
+
"mute-stream": "^3.0.0"
|
|
82
72
|
},
|
|
83
73
|
"devDependencies": {
|
|
84
|
-
"@arethetypeswrong/cli": "^0.18.2",
|
|
85
|
-
"@repo/tsconfig": "0.0.0",
|
|
86
74
|
"@types/mute-stream": "^0.0.4",
|
|
87
|
-
"@types/node": "^24.10.
|
|
88
|
-
"
|
|
75
|
+
"@types/node": "^24.10.1",
|
|
76
|
+
"typescript": "^5.9.3"
|
|
89
77
|
},
|
|
90
78
|
"engines": {
|
|
91
|
-
"node": ">=
|
|
92
|
-
},
|
|
93
|
-
"tshy": {
|
|
94
|
-
"exclude": [
|
|
95
|
-
"src/**/*.test.ts"
|
|
96
|
-
],
|
|
97
|
-
"exports": {
|
|
98
|
-
"./package.json": "./package.json",
|
|
99
|
-
".": "./src/index.ts"
|
|
100
|
-
}
|
|
79
|
+
"node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
|
|
101
80
|
},
|
|
102
81
|
"peerDependencies": {
|
|
103
82
|
"@types/node": ">=18"
|
|
@@ -110,5 +89,5 @@
|
|
|
110
89
|
"publishConfig": {
|
|
111
90
|
"access": "public"
|
|
112
91
|
},
|
|
113
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "cce79ce3b9bbdfb4dbb798078cf3b94b9adc7d1b"
|
|
114
93
|
}
|
package/dist/commonjs/index.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.render = render;
|
|
7
|
-
const node_stream_1 = require("node:stream");
|
|
8
|
-
const node_util_1 = require("node:util");
|
|
9
|
-
const mute_stream_1 = __importDefault(require("mute-stream"));
|
|
10
|
-
class BufferedStream extends node_stream_1.Stream.Writable {
|
|
11
|
-
#_fullOutput = '';
|
|
12
|
-
#_chunks = [];
|
|
13
|
-
#_rawChunks = [];
|
|
14
|
-
_write(chunk, _encoding, callback) {
|
|
15
|
-
const str = chunk.toString();
|
|
16
|
-
this.#_fullOutput += str;
|
|
17
|
-
// Keep track of every chunk send through.
|
|
18
|
-
this.#_rawChunks.push(str);
|
|
19
|
-
// Stripping the ANSI codes here because Inquirer will push commands ANSI (like cursor move.)
|
|
20
|
-
// This is probably fine since we don't care about those for testing; but this could become
|
|
21
|
-
// an issue if we ever want to test for those.
|
|
22
|
-
if ((0, node_util_1.stripVTControlCharacters)(str).trim().length > 0) {
|
|
23
|
-
this.#_chunks.push(str);
|
|
24
|
-
}
|
|
25
|
-
callback();
|
|
26
|
-
}
|
|
27
|
-
getLastChunk({ raw }) {
|
|
28
|
-
const chunks = raw ? this.#_rawChunks : this.#_chunks;
|
|
29
|
-
const lastChunk = chunks.at(-1);
|
|
30
|
-
return lastChunk ?? '';
|
|
31
|
-
}
|
|
32
|
-
getFullOutput() {
|
|
33
|
-
return this.#_fullOutput;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async function render(prompt, props, options) {
|
|
37
|
-
const input = new mute_stream_1.default();
|
|
38
|
-
input.unmute();
|
|
39
|
-
const output = new BufferedStream();
|
|
40
|
-
const answer = prompt(props, { input, output, ...options });
|
|
41
|
-
// Wait for event listeners to be ready
|
|
42
|
-
await Promise.resolve();
|
|
43
|
-
await Promise.resolve();
|
|
44
|
-
const events = {
|
|
45
|
-
keypress(key) {
|
|
46
|
-
if (typeof key === 'string') {
|
|
47
|
-
input.emit('keypress', null, { name: key });
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
input.emit('keypress', null, key);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
type(text) {
|
|
54
|
-
input.write(text);
|
|
55
|
-
for (const char of text) {
|
|
56
|
-
input.emit('keypress', null, { name: char });
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
answer,
|
|
62
|
-
input,
|
|
63
|
-
events,
|
|
64
|
-
getScreen: ({ raw } = {}) => {
|
|
65
|
-
const lastScreen = output.getLastChunk({ raw: Boolean(raw) });
|
|
66
|
-
return raw ? lastScreen : (0, node_util_1.stripVTControlCharacters)(lastScreen).trim();
|
|
67
|
-
},
|
|
68
|
-
getFullOutput: () => {
|
|
69
|
-
return output.getFullOutput();
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import MuteStream from 'mute-stream';
|
|
2
|
-
import type { Prompt, Context } from '@inquirer/type';
|
|
3
|
-
export declare function render<const Props, const Value>(prompt: Prompt<Value, Props>, props: Props, options?: Context): Promise<{
|
|
4
|
-
answer: Promise<Value> & {
|
|
5
|
-
/** @deprecated pass an AbortSignal in the context options instead. See {@link https://github.com/SBoudrias/Inquirer.js#canceling-prompt} */
|
|
6
|
-
cancel: () => void;
|
|
7
|
-
};
|
|
8
|
-
input: MuteStream;
|
|
9
|
-
events: {
|
|
10
|
-
keypress: (key: string | {
|
|
11
|
-
name?: string;
|
|
12
|
-
ctrl?: boolean;
|
|
13
|
-
meta?: boolean;
|
|
14
|
-
shift?: boolean;
|
|
15
|
-
}) => void;
|
|
16
|
-
type: (text: string) => void;
|
|
17
|
-
};
|
|
18
|
-
getScreen: ({ raw }?: {
|
|
19
|
-
raw?: boolean;
|
|
20
|
-
}) => string;
|
|
21
|
-
getFullOutput: () => string;
|
|
22
|
-
}>;
|
package/dist/esm/package.json
DELETED
|
File without changes
|