@depup/inquirer 13.3.1-depup.0 → 13.3.2-depup.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 CHANGED
@@ -13,9 +13,9 @@ npm install @depup/inquirer
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [inquirer](https://www.npmjs.com/package/inquirer) @ 13.3.1 |
17
- | Processed | 2026-03-15 |
18
- | Smoke test | failed |
16
+ | Original | [inquirer](https://www.npmjs.com/package/inquirer) @ 13.3.2 |
17
+ | Processed | 2026-03-16 |
18
+ | Smoke test | passed |
19
19
  | Deps updated | 0 |
20
20
 
21
21
  ---
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Inquirer.js
3
+ * A collection of common interactive command line user interfaces.
4
+ */
5
+ import { Separator } from '@inquirer/prompts';
6
+ import type { Prettify } from '@inquirer/type';
7
+ import PromptsRunner from './ui/prompt.ts';
8
+ import type { PromptCollection, LegacyPromptConstructor, PromptFn } from './ui/prompt.ts';
9
+ import type { Answers, StreamOptions, QuestionMap, PromptSession, PromptModulePublicQuestion, PromptModuleSpecificQuestion, PromptModuleNamedQuestion, QuestionSequence, MergedAnswers, DictionaryAnswers } from './types.ts';
10
+ type PublicQuestions<A extends Answers, Prefilled extends Answers> = QuestionSequence<PromptModulePublicQuestion<MergedAnswers<A, Prefilled>, A>>;
11
+ type InternalQuestions<A extends Answers, Prefilled extends Answers, Prompts extends Record<string, Record<string, unknown>>> = QuestionSequence<PromptModuleNamedQuestion<MergedAnswers<A, Prefilled>, Prompts, A>>;
12
+ type QuestionsDictionary<A extends Answers, Prefilled extends Answers, Prompts extends Record<string, Record<string, unknown>>> = {
13
+ [name in keyof A]: PromptModuleSpecificQuestion<MergedAnswers<A, Prefilled>, Prompts>;
14
+ };
15
+ type PromptModuleApi<Prompts extends Record<string, Record<string, unknown>> = never> = {
16
+ <const A extends Answers, const Prefilled extends Answers = object>(questions: PublicQuestions<A, Prefilled> | InternalQuestions<A, Prefilled, Prompts>, answers?: Prefilled): PromptReturnType<MergedAnswers<A, Prefilled>>;
17
+ <const A extends Answers, const Prefilled extends Answers = object>(questions: QuestionsDictionary<A, Prefilled, Prompts>, answers?: Prefilled): PromptReturnType<DictionaryAnswers<A, Prefilled>>;
18
+ <A extends Answers>(questions: PromptSession<A>, answers?: Partial<A>): PromptReturnType<A>;
19
+ } & {
20
+ prompts: PromptCollection;
21
+ registerPrompt(name: string, prompt: LegacyPromptConstructor | PromptFn): PromptModuleApi<Prompts>;
22
+ restoreDefaultPrompts(): void;
23
+ };
24
+ export type { QuestionMap, Question, DistinctQuestion, Answers, PromptSession, } from './types.ts';
25
+ type PromptReturnType<T> = Promise<Prettify<T>> & {
26
+ ui: PromptsRunner<Prettify<T>>;
27
+ };
28
+ /**
29
+ * Create a new self-contained prompt module.
30
+ */
31
+ export declare function createPromptModule<Prompts extends Record<string, Record<string, unknown>> = never>(opt?: StreamOptions): PromptModuleApi<Prompts>;
32
+ declare function registerPrompt(name: string, newPrompt: LegacyPromptConstructor): void;
33
+ declare function restoreDefaultPrompts(): void;
34
+ declare const inquirer: {
35
+ prompt: PromptModuleApi<Omit<QuestionMap, "__dummy">>;
36
+ ui: {
37
+ Prompt: typeof PromptsRunner;
38
+ };
39
+ createPromptModule: typeof createPromptModule;
40
+ registerPrompt: typeof registerPrompt;
41
+ restoreDefaultPrompts: typeof restoreDefaultPrompts;
42
+ Separator: typeof Separator;
43
+ };
44
+ export default inquirer;
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Inquirer.js
3
+ * A collection of common interactive command line user interfaces.
4
+ */
5
+ import { input, select, number, confirm, rawlist, expand, checkbox, password, editor, search, Separator, } from '@inquirer/prompts';
6
+ import PromptsRunner from "./ui/prompt.js";
7
+ const builtInPrompts = {
8
+ input,
9
+ select,
10
+ number,
11
+ confirm,
12
+ rawlist,
13
+ expand,
14
+ checkbox,
15
+ password,
16
+ editor,
17
+ search,
18
+ };
19
+ /**
20
+ * Create a new self-contained prompt module.
21
+ */
22
+ export function createPromptModule(opt) {
23
+ function promptModule(questions, answers) {
24
+ const runner = new PromptsRunner(promptModule.prompts, opt);
25
+ const promptPromise = runner.run(questions, answers);
26
+ return Object.assign(promptPromise, { ui: runner });
27
+ }
28
+ promptModule.prompts = { ...builtInPrompts };
29
+ /**
30
+ * Register a prompt type
31
+ */
32
+ promptModule.registerPrompt = function (name, prompt) {
33
+ promptModule.prompts[name] = prompt;
34
+ return this;
35
+ };
36
+ /**
37
+ * Register the defaults provider prompts
38
+ */
39
+ promptModule.restoreDefaultPrompts = function () {
40
+ promptModule.prompts = { ...builtInPrompts };
41
+ };
42
+ return promptModule;
43
+ }
44
+ /**
45
+ * Public CLI helper interface
46
+ */
47
+ const prompt = createPromptModule();
48
+ // Expose helper functions on the top level for easiest usage by common users
49
+ function registerPrompt(name, newPrompt) {
50
+ prompt.registerPrompt(name, newPrompt);
51
+ }
52
+ function restoreDefaultPrompts() {
53
+ prompt.restoreDefaultPrompts();
54
+ }
55
+ const inquirer = {
56
+ prompt,
57
+ ui: {
58
+ Prompt: PromptsRunner,
59
+ },
60
+ createPromptModule,
61
+ registerPrompt,
62
+ restoreDefaultPrompts,
63
+ Separator,
64
+ };
65
+ export default inquirer;
@@ -0,0 +1,100 @@
1
+ import { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select } from '@inquirer/prompts';
2
+ import type { Context, DistributiveMerge, Prettify } from '@inquirer/type';
3
+ import { Observable } from 'rxjs';
4
+ export type Answers<Key extends string = string> = Record<Key, any>;
5
+ export type NoInfer<T> = [T][T extends any ? 0 : never];
6
+ type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
7
+ type EmptyRecord = Record<string, never>;
8
+ type DotPathRecord<Path extends string, Value> = Path extends `${infer Head}.${infer Rest}` ? Head extends '' ? EmptyRecord : {
9
+ [K in Head]: DotPathRecord<Rest, Value>;
10
+ } : Path extends '' ? EmptyRecord : {
11
+ [K in Path]: Value;
12
+ };
13
+ export type NormalizeAnswers<A extends Answers> = string extends keyof A ? A : Extract<keyof A, string> extends never ? EmptyRecord : Prettify<UnionToIntersection<{
14
+ [Key in Extract<keyof A, string>]: DotPathRecord<Key, [
15
+ A[Key]
16
+ ] extends [never] ? any : A[Key]>;
17
+ }[Extract<keyof A, string>]>>;
18
+ type Mutable<T> = {
19
+ -readonly [K in keyof T]: T[K];
20
+ };
21
+ type WidenAnswerLiterals<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T extends symbol ? symbol : T extends ReadonlyArray<infer U> ? ReadonlyArray<WidenAnswerLiterals<U>> : T extends Array<infer U> ? Array<WidenAnswerLiterals<U>> : T extends Record<string, unknown> ? {
22
+ [K in keyof Mutable<T>]: Mutable<T>[K] extends infer V ? V extends undefined ? never : WidenAnswerLiterals<V> : never;
23
+ } : T;
24
+ type MergeAnswerObjects<Base, Override> = Prettify<Omit<Base, keyof Override> & Override>;
25
+ export type AsyncGetterFunction<T, A extends Answers> = (this: {
26
+ async: () => (...args: [error: null | undefined, value: T] | [error: Error, value: undefined]) => void;
27
+ }, answers: NoInfer<Prettify<Partial<A>>>) => void | T | Promise<T>;
28
+ type MaybeAsyncValue<T, A extends Answers> = T | AsyncGetterFunction<T, A>;
29
+ /**
30
+ * Allows to inject a custom question type into inquirer module.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * declare module 'inquirer' {
35
+ * interface QuestionMap {
36
+ * custom: { message: string };
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * Globally defined question types are not correct.
42
+ */
43
+ export interface QuestionMap {
44
+ __dummy: {
45
+ message: string;
46
+ };
47
+ }
48
+ type KeyValueOrAsyncGetterFunction<T, k extends string, A extends Answers> = T extends Record<string, any> ? MaybeAsyncValue<T[k], A> : never;
49
+ export type Question<A extends Answers = Answers, Type extends string = string> = {
50
+ type: Type;
51
+ name: string;
52
+ message: MaybeAsyncValue<string, A>;
53
+ default?: any;
54
+ choices?: any;
55
+ validate?: (value: any, answers: NoInfer<Partial<A>>) => boolean | string | Promise<boolean | string>;
56
+ filter?: (answer: any, answers: NoInfer<Partial<A>>) => any;
57
+ askAnswered?: boolean;
58
+ when?: MaybeAsyncValue<boolean, A>;
59
+ };
60
+ type QuestionWithGetters<Type extends string, Q extends Record<string, any>, A extends Answers> = DistributiveMerge<Q, {
61
+ type: Type;
62
+ askAnswered?: boolean;
63
+ when?: MaybeAsyncValue<boolean, A>;
64
+ filter?(input: any, answers: NoInfer<A>): any;
65
+ message: KeyValueOrAsyncGetterFunction<Q, 'message', A>;
66
+ default?: KeyValueOrAsyncGetterFunction<Q, 'default', A>;
67
+ choices?: KeyValueOrAsyncGetterFunction<Q, 'choices', A>;
68
+ }>;
69
+ export type UnnamedDistinctQuestion<A extends Answers = object> = QuestionWithGetters<'checkbox', Parameters<typeof checkbox>[0] & {
70
+ default: unknown[];
71
+ }, A> | QuestionWithGetters<'confirm', Parameters<typeof confirm>[0], A> | QuestionWithGetters<'editor', Parameters<typeof editor>[0], A> | QuestionWithGetters<'expand', Parameters<typeof expand>[0], A> | QuestionWithGetters<'input', Parameters<typeof input>[0], A> | QuestionWithGetters<'number', Parameters<typeof number>[0], A> | QuestionWithGetters<'password', Parameters<typeof password>[0], A> | QuestionWithGetters<'rawlist', Parameters<typeof rawlist>[0], A> | QuestionWithGetters<'search', Parameters<typeof search>[0], A> | QuestionWithGetters<'select', Parameters<typeof select>[0], A>;
72
+ export type CustomQuestion<A extends Answers, Q extends Record<string, Record<string, any>>> = {
73
+ [key in Extract<keyof Q, string>]: Readonly<QuestionWithGetters<key, Q[key], A>>;
74
+ }[Extract<keyof Q, string>];
75
+ export type PromptModuleSpecificQuestion<A extends Answers, Prompts extends Record<string, Record<string, any>> = never> = UnnamedDistinctQuestion<A> | CustomQuestion<A, Prompts>;
76
+ export type PromptModuleNamedQuestion<A extends Answers, Prompts extends Record<string, Record<string, any>> = never, Flat extends Answers = A> = Prettify<PromptModuleSpecificQuestion<A, Prompts> & {
77
+ name: Extract<keyof Flat, string>;
78
+ }>;
79
+ export type DistinctQuestion<A extends Answers = Answers> = PromptModuleNamedQuestion<A>;
80
+ export type PromptSession<A extends Answers = Answers, Q extends Question<A> = Question<A>> = readonly Q[] | Record<string, Omit<Q, 'name'>> | Observable<Q> | Q;
81
+ export type QuestionSequence<Q> = Q | readonly Q[] | Observable<Q>;
82
+ export type MergedAnswers<A extends Answers, Prefilled extends Answers> = MergeAnswerObjects<NormalizeAnswers<A>, WidenAnswerLiterals<Prefilled>>;
83
+ export type QuestionDictionary<A extends Answers, Q> = {
84
+ [name in keyof A]: Q;
85
+ };
86
+ export type DictionaryAnswers<A extends Answers, Prefilled extends Answers> = MergeAnswerObjects<NormalizeAnswers<Answers<Extract<keyof A, string>>>, WidenAnswerLiterals<Prefilled>>;
87
+ export type PromptModulePublicQuestion<A extends Answers, Flat extends Answers = A> = {
88
+ type: 'input' | 'confirm' | 'editor' | 'password' | 'number' | 'rawlist' | 'expand' | 'checkbox' | 'search' | 'select';
89
+ name: Extract<keyof Flat, string>;
90
+ message: MaybeAsyncValue<string, A>;
91
+ default?: unknown;
92
+ choices?: unknown;
93
+ filter?: (input: any, answers: NoInfer<Partial<A>>) => any;
94
+ askAnswered?: boolean;
95
+ when?: MaybeAsyncValue<boolean, A>;
96
+ } & Record<string, unknown>;
97
+ export type StreamOptions = Prettify<Context & {
98
+ skipTTYChecks?: boolean;
99
+ }>;
100
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ import { Observable } from 'rxjs';
2
+ import type { InquirerReadline } from '@inquirer/type';
3
+ import type { Answers, PromptSession, StreamOptions } from '../types.ts';
4
+ export declare const _: {
5
+ set: (obj: Record<string, unknown>, path: string | undefined, value: unknown) => void;
6
+ get: (obj: object, path?: string | number | symbol, defaultValue?: unknown) => any;
7
+ };
8
+ export interface PromptBase {
9
+ /**
10
+ * Runs the prompt.
11
+ *
12
+ * @returns
13
+ * The result of the prompt.
14
+ */
15
+ run(): Promise<any>;
16
+ }
17
+ /**
18
+ * Provides the functionality to initialize new prompts.
19
+ */
20
+ export interface LegacyPromptConstructor {
21
+ /**
22
+ * Initializes a new instance of a prompt.
23
+ *
24
+ * @param question
25
+ * The question to prompt.
26
+ *
27
+ * @param readLine
28
+ * An object for reading from the command-line.
29
+ *
30
+ * @param answers
31
+ * The answers provided by the user.
32
+ */
33
+ new (question: any, readLine: InquirerReadline, answers: Record<string, any>): PromptBase;
34
+ }
35
+ export type PromptFn<Value = any, Config = any> = (config: Config, context: StreamOptions & {
36
+ signal: AbortSignal;
37
+ }) => Promise<Value>;
38
+ /**
39
+ * Provides a set of prompt-constructors.
40
+ */
41
+ export type PromptCollection = Record<string, PromptFn | LegacyPromptConstructor>;
42
+ /**
43
+ * Base interface class other can inherits from
44
+ */
45
+ export default class PromptsRunner<A extends Answers> {
46
+ private prompts;
47
+ answers: Partial<A>;
48
+ process: Observable<any>;
49
+ private abortController;
50
+ private opt;
51
+ constructor(prompts: PromptCollection, opt?: StreamOptions);
52
+ run(questions: PromptSession<A>, answers?: Partial<A>): Promise<A>;
53
+ private prepareQuestion;
54
+ private fetchAnswer;
55
+ /**
56
+ * Close the interface and cleanup listeners
57
+ */
58
+ close: () => void;
59
+ private shouldRun;
60
+ }
@@ -0,0 +1,271 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment */
2
+ import readline from 'node:readline';
3
+ import { defer, EMPTY, from, of, concatMap, filter, reduce, isObservable, lastValueFrom, } from 'rxjs';
4
+ import runAsync from 'run-async';
5
+ import MuteStream from 'mute-stream';
6
+ import { AbortPromptError } from '@inquirer/core';
7
+ import { cursorShow } from '@inquirer/ansi';
8
+ export const _ = {
9
+ set: (obj, path = '', value) => {
10
+ let pointer = obj;
11
+ path.split('.').forEach((key, index, arr) => {
12
+ if (key === '__proto__' || key === 'constructor')
13
+ return;
14
+ if (index === arr.length - 1) {
15
+ pointer[key] = value;
16
+ }
17
+ else if (!(key in pointer) || typeof pointer[key] !== 'object') {
18
+ pointer[key] = {};
19
+ }
20
+ pointer = pointer[key];
21
+ });
22
+ },
23
+ get: (obj, path = '', defaultValue) => {
24
+ const travel = (regexp) => String.prototype.split
25
+ .call(path, regexp)
26
+ .filter(Boolean)
27
+ .reduce(
28
+ // @ts-expect-error implicit any on res[key]
29
+ (res, key) => (res == null ? res : res[key]), obj);
30
+ const result = travel(/[,[\]]+?/) || travel(/[,.[\]]+?/);
31
+ return result === undefined || result === obj ? defaultValue : result;
32
+ },
33
+ };
34
+ /**
35
+ * Resolve a question property value if it is passed as a function.
36
+ * This method will overwrite the property on the question object with the received value.
37
+ */
38
+ async function fetchAsyncQuestionProperty(question, prop, answers) {
39
+ const propGetter = question[prop];
40
+ if (typeof propGetter === 'function') {
41
+ return runAsync(propGetter)(answers);
42
+ }
43
+ return propGetter;
44
+ }
45
+ class TTYError extends Error {
46
+ name = 'TTYError';
47
+ isTtyError = true;
48
+ }
49
+ function setupReadlineOptions(opt) {
50
+ // Inquirer 8.x:
51
+ // opt.skipTTYChecks = opt.skipTTYChecks === undefined ? opt.input !== undefined : opt.skipTTYChecks;
52
+ opt.skipTTYChecks = opt.skipTTYChecks === undefined ? true : opt.skipTTYChecks;
53
+ // Default `input` to stdin
54
+ const input = opt.input || process.stdin;
55
+ // Check if prompt is being called in TTY environment
56
+ // If it isn't return a failed promise
57
+ // @ts-expect-error: ignore isTTY type error
58
+ if (!opt.skipTTYChecks && !input.isTTY) {
59
+ throw new TTYError('Prompts can not be meaningfully rendered in non-TTY environments');
60
+ }
61
+ // Add mute capabilities to the output
62
+ const ms = new MuteStream();
63
+ ms.pipe(opt.output || process.stdout);
64
+ const output = ms;
65
+ return {
66
+ terminal: true,
67
+ ...opt,
68
+ input,
69
+ output,
70
+ };
71
+ }
72
+ function isQuestionArray(questions) {
73
+ return Array.isArray(questions);
74
+ }
75
+ function isQuestionMap(questions) {
76
+ return Object.values(questions).every((maybeQuestion) => typeof maybeQuestion === 'object' &&
77
+ !Array.isArray(maybeQuestion) &&
78
+ maybeQuestion != null);
79
+ }
80
+ function isPromptConstructor(prompt) {
81
+ return Boolean(prompt.prototype &&
82
+ 'run' in prompt.prototype &&
83
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
84
+ typeof prompt.prototype.run === 'function');
85
+ }
86
+ /**
87
+ * Base interface class other can inherits from
88
+ */
89
+ export default class PromptsRunner {
90
+ prompts;
91
+ answers = {};
92
+ process = EMPTY;
93
+ abortController = new AbortController();
94
+ opt;
95
+ constructor(prompts, opt = {}) {
96
+ this.opt = opt;
97
+ this.prompts = prompts;
98
+ }
99
+ async run(questions, answers) {
100
+ this.abortController = new AbortController();
101
+ // Keep global reference to the answers
102
+ this.answers = typeof answers === 'object' ? { ...answers } : {};
103
+ let obs;
104
+ if (isQuestionArray(questions)) {
105
+ obs = from(questions);
106
+ }
107
+ else if (isObservable(questions)) {
108
+ obs = questions;
109
+ }
110
+ else if (isQuestionMap(questions)) {
111
+ // Case: Called with a set of { name: question }
112
+ obs = from(Object.entries(questions).map(([name, question]) => {
113
+ return Object.assign({}, question, { name });
114
+ }));
115
+ }
116
+ else {
117
+ // Case: Called with a single question config
118
+ obs = from([questions]);
119
+ }
120
+ this.process = obs.pipe(concatMap((question) => of(question).pipe(concatMap((question) => from(this.shouldRun(question).then((shouldRun) => {
121
+ if (shouldRun) {
122
+ return question;
123
+ }
124
+ return;
125
+ })).pipe(filter((val) => val != null))), concatMap((question) => defer(() => from(this.fetchAnswer(question)))))));
126
+ return lastValueFrom(this.process.pipe(reduce((answersObj, answer) => {
127
+ _.set(answersObj, answer.name, answer.answer);
128
+ return answersObj;
129
+ }, this.answers)))
130
+ .then(() => this.answers)
131
+ .finally(() => this.close());
132
+ }
133
+ prepareQuestion = async (question) => {
134
+ const [message, defaultValue, resolvedChoices] = await Promise.all([
135
+ fetchAsyncQuestionProperty(question, 'message', this.answers),
136
+ fetchAsyncQuestionProperty(question, 'default', this.answers),
137
+ fetchAsyncQuestionProperty(question, 'choices', this.answers),
138
+ ]);
139
+ let choices;
140
+ if (Array.isArray(resolvedChoices)) {
141
+ choices = resolvedChoices.map((choice) => {
142
+ const choiceObj = typeof choice !== 'object' || choice == null
143
+ ? { name: choice, value: choice }
144
+ : {
145
+ ...choice,
146
+ value: 'value' in choice
147
+ ? choice.value
148
+ : 'name' in choice
149
+ ? choice.name
150
+ : undefined,
151
+ };
152
+ if ('value' in choiceObj && Array.isArray(defaultValue)) {
153
+ // Add checked to question for backward compatibility. default was supported as alternative of per choice checked.
154
+ return {
155
+ checked: defaultValue.includes(choiceObj.value),
156
+ ...choiceObj,
157
+ };
158
+ }
159
+ return choiceObj;
160
+ });
161
+ }
162
+ // Wrap the validate function to pass answers as second parameter for backward compatibility
163
+ const wrappedQuestion = Object.assign({}, question, {
164
+ message,
165
+ default: defaultValue,
166
+ choices,
167
+ type: question.type in this.prompts ? question.type : 'input',
168
+ });
169
+ if (question.validate) {
170
+ const originalValidate = question.validate;
171
+ wrappedQuestion.validate = (value) => {
172
+ return originalValidate(value, this.answers);
173
+ };
174
+ }
175
+ return wrappedQuestion;
176
+ };
177
+ fetchAnswer = async (rawQuestion) => {
178
+ const question = await this.prepareQuestion(rawQuestion);
179
+ const prompt = this.prompts[question.type];
180
+ if (prompt == null) {
181
+ throw new Error(`Prompt for type ${question.type} not found`);
182
+ }
183
+ let cleanupSignal;
184
+ const promptFn = isPromptConstructor(prompt)
185
+ ? (q, opt) => new Promise((resolve, reject) => {
186
+ const { signal } = opt;
187
+ if (signal.aborted) {
188
+ reject(new AbortPromptError({ cause: signal.reason }));
189
+ return;
190
+ }
191
+ const rl = readline.createInterface(setupReadlineOptions(opt));
192
+ /**
193
+ * Handle the ^C exit
194
+ */
195
+ const onForceClose = () => {
196
+ this.close();
197
+ process.kill(process.pid, 'SIGINT');
198
+ console.log('');
199
+ };
200
+ const onClose = () => {
201
+ process.removeListener('exit', onForceClose);
202
+ rl.removeListener('SIGINT', onForceClose);
203
+ rl.setPrompt('');
204
+ rl.output.unmute();
205
+ rl.output.write(cursorShow);
206
+ rl.output.end();
207
+ rl.close();
208
+ };
209
+ // Make sure new prompt start on a newline when closing
210
+ process.on('exit', onForceClose);
211
+ rl.on('SIGINT', onForceClose);
212
+ const activePrompt = new prompt(q, rl, this.answers);
213
+ const cleanup = () => {
214
+ onClose();
215
+ cleanupSignal?.();
216
+ };
217
+ const abort = () => {
218
+ reject(new AbortPromptError({ cause: signal.reason }));
219
+ cleanup();
220
+ };
221
+ signal.addEventListener('abort', abort);
222
+ cleanupSignal = () => {
223
+ signal.removeEventListener('abort', abort);
224
+ cleanupSignal = undefined;
225
+ };
226
+ activePrompt.run().then(resolve, reject).finally(cleanup);
227
+ })
228
+ : prompt;
229
+ let cleanupModuleSignal;
230
+ const { signal: moduleSignal } = this.opt;
231
+ if (moduleSignal?.aborted) {
232
+ this.abortController.abort(moduleSignal.reason);
233
+ }
234
+ else if (moduleSignal) {
235
+ const abort = () => this.abortController.abort(moduleSignal.reason);
236
+ moduleSignal.addEventListener('abort', abort);
237
+ cleanupModuleSignal = () => {
238
+ moduleSignal.removeEventListener('abort', abort);
239
+ };
240
+ }
241
+ const { filter = (value) => value } = question;
242
+ const { signal } = this.abortController;
243
+ return promptFn(question, { ...this.opt, signal })
244
+ .then((answer) => ({
245
+ name: question.name,
246
+ answer: filter(answer, this.answers),
247
+ }))
248
+ .finally(() => {
249
+ cleanupSignal?.();
250
+ cleanupModuleSignal?.();
251
+ });
252
+ };
253
+ /**
254
+ * Close the interface and cleanup listeners
255
+ */
256
+ close = () => {
257
+ this.abortController.abort();
258
+ };
259
+ shouldRun = async (question) => {
260
+ if (question.askAnswered !== true &&
261
+ _.get(this.answers, question.name) !== undefined) {
262
+ return false;
263
+ }
264
+ const { when } = question;
265
+ if (typeof when === 'function') {
266
+ const shouldRun = await runAsync(when)(this.answers);
267
+ return Boolean(shouldRun);
268
+ }
269
+ return when !== false;
270
+ };
271
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/inquirer",
3
- "version": "13.3.1-depup.0",
3
+ "version": "13.3.2-depup.0",
4
4
  "description": "[DepUp] A collection of common interactive command line user interfaces.",
5
5
  "keywords": [
6
6
  "depup",
@@ -67,10 +67,10 @@
67
67
  "tsc": "tsc"
68
68
  },
69
69
  "dependencies": {
70
- "@inquirer/ansi": "^2.0.3",
71
- "@inquirer/core": "^11.1.6",
72
- "@inquirer/prompts": "^8.3.1",
73
- "@inquirer/type": "^4.0.3",
70
+ "@inquirer/ansi": "^2.0.4",
71
+ "@inquirer/core": "^11.1.7",
72
+ "@inquirer/prompts": "^8.3.2",
73
+ "@inquirer/type": "^4.0.4",
74
74
  "mute-stream": "^3.0.0",
75
75
  "run-async": "^4.0.6",
76
76
  "rxjs": "^7.8.2"
@@ -92,13 +92,13 @@
92
92
  },
93
93
  "main": "./dist/index.js",
94
94
  "types": "./dist/index.d.ts",
95
- "gitHead": "1ce03199b82b4a5fb6f7c97ce374c6da5087444f",
95
+ "gitHead": "b218fcc4afe888a58957aa78c9a032f9bd2d60cb",
96
96
  "depup": {
97
97
  "changes": {},
98
98
  "depsUpdated": 0,
99
99
  "originalPackage": "inquirer",
100
- "originalVersion": "13.3.1",
101
- "processedAt": "2026-03-15T20:15:54.914Z",
102
- "smokeTest": "failed"
100
+ "originalVersion": "13.3.2",
101
+ "processedAt": "2026-03-16T00:39:29.540Z",
102
+ "smokeTest": "passed"
103
103
  }
104
104
  }