@inquirer/testing 3.0.0 → 3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/testing",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Inquirer testing utilities",
5
5
  "keywords": [
6
6
  "answer",
@@ -55,7 +55,10 @@
55
55
  "type": "module",
56
56
  "exports": {
57
57
  "./package.json": "./package.json",
58
- ".": "./src/index.ts"
58
+ ".": {
59
+ "types": "./dist/index.d.ts",
60
+ "default": "./dist/index.js"
61
+ }
59
62
  },
60
63
  "files": [
61
64
  "dist"
@@ -64,11 +67,10 @@
64
67
  "tsc": "tsc"
65
68
  },
66
69
  "dependencies": {
67
- "@inquirer/type": "^4.0.0",
70
+ "@inquirer/type": "^4.0.2",
68
71
  "mute-stream": "^3.0.0"
69
72
  },
70
73
  "devDependencies": {
71
- "@repo/tsconfig": "0.0.0",
72
74
  "@types/mute-stream": "^0.0.4",
73
75
  "@types/node": "^24.10.1",
74
76
  "typescript": "^5.9.3"
@@ -85,14 +87,9 @@
85
87
  }
86
88
  },
87
89
  "publishConfig": {
88
- "access": "public",
89
- "exports": {
90
- "./package.json": "./package.json",
91
- ".": {
92
- "types": "./dist/index.d.ts",
93
- "default": "./dist/index.js"
94
- }
95
- }
90
+ "access": "public"
96
91
  },
97
- "gitHead": "676685d33374a30340c1b9f0831c7eae2b2357dd"
92
+ "main": "./dist/index.js",
93
+ "types": "./dist/index.d.ts",
94
+ "gitHead": "9c724296daad3d740b09173f9aae035dc62cb106"
98
95
  }
@@ -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
- }>;
@@ -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
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -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/index.js DELETED
@@ -1,66 +0,0 @@
1
- import { Stream } from 'node:stream';
2
- import { stripVTControlCharacters } from 'node:util';
3
- import MuteStream from 'mute-stream';
4
- class BufferedStream extends Stream.Writable {
5
- #_fullOutput = '';
6
- #_chunks = [];
7
- #_rawChunks = [];
8
- _write(chunk, _encoding, callback) {
9
- const str = chunk.toString();
10
- this.#_fullOutput += str;
11
- // Keep track of every chunk send through.
12
- this.#_rawChunks.push(str);
13
- // Stripping the ANSI codes here because Inquirer will push commands ANSI (like cursor move.)
14
- // This is probably fine since we don't care about those for testing; but this could become
15
- // an issue if we ever want to test for those.
16
- if (stripVTControlCharacters(str).trim().length > 0) {
17
- this.#_chunks.push(str);
18
- }
19
- callback();
20
- }
21
- getLastChunk({ raw }) {
22
- const chunks = raw ? this.#_rawChunks : this.#_chunks;
23
- const lastChunk = chunks.at(-1);
24
- return lastChunk ?? '';
25
- }
26
- getFullOutput() {
27
- return this.#_fullOutput;
28
- }
29
- }
30
- export async function render(prompt, props, options) {
31
- const input = new MuteStream();
32
- input.unmute();
33
- const output = new BufferedStream();
34
- const answer = prompt(props, { input, output, ...options });
35
- // Wait for event listeners to be ready
36
- await Promise.resolve();
37
- await Promise.resolve();
38
- const events = {
39
- keypress(key) {
40
- if (typeof key === 'string') {
41
- input.emit('keypress', null, { name: key });
42
- }
43
- else {
44
- input.emit('keypress', null, key);
45
- }
46
- },
47
- type(text) {
48
- input.write(text);
49
- for (const char of text) {
50
- input.emit('keypress', null, { name: char });
51
- }
52
- },
53
- };
54
- return {
55
- answer,
56
- input,
57
- events,
58
- getScreen: ({ raw } = {}) => {
59
- const lastScreen = output.getLastChunk({ raw: Boolean(raw) });
60
- return raw ? lastScreen : stripVTControlCharacters(lastScreen).trim();
61
- },
62
- getFullOutput: () => {
63
- return output.getFullOutput();
64
- },
65
- };
66
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }