Skip to content

Commit cc92333

Browse files
author
DimitarTachev
committed
chore: update inquirer to the latest version
1 parent 6167820 commit cc92333

File tree

10 files changed

+1791
-884
lines changed

10 files changed

+1791
-884
lines changed

lib/common/commands/proxy/proxy-set.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ProxyCommandBase } from "./proxy-base";
44
import { HttpProtocolToPort } from "../../constants";
55
import { parse } from "url";
66
import { platform, EOL } from "os";
7+
import * as prompt from "inquirer";
78
const { getCredentialsFromAuth } = require("proxy-lib/lib/utils");
89

910
const proxySetCommandName = "proxy|set";
@@ -121,7 +122,7 @@ export class ProxySetCommand extends ProxyCommandBase {
121122

122123
private async getPortFromUserInput(): Promise<number> {
123124
const schemaName = "port";
124-
const schema: IPromptSchema = {
125+
const schema: prompt.Question = {
125126
message: "Port",
126127
type: "input",
127128
name: schemaName,

lib/common/declarations.d.ts

-8
Original file line numberDiff line numberDiff line change
@@ -721,14 +721,6 @@ interface IPrompterOptions extends IAllowEmpty {
721721
defaultAction?: () => string
722722
}
723723

724-
interface IPrompter extends IDisposable {
725-
get(schemas: IPromptSchema[]): Promise<any>;
726-
getPassword(prompt: string, options?: IAllowEmpty): Promise<string>;
727-
getString(prompt: string, options?: IPrompterOptions): Promise<string>;
728-
promptForChoice(promptMessage: string, choices: any[]): Promise<string>;
729-
confirm(prompt: string, defaultAction?: () => boolean): Promise<boolean>;
730-
}
731-
732724
interface IAnalyticsSettingsService {
733725
canDoRequest(): Promise<boolean>;
734726
getUserId(): Promise<string>;

lib/common/definitions/prompt.d.ts

-295
This file was deleted.

lib/common/prompter.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@ export class Prompter implements IPrompter {
1414
}
1515
}
1616

17-
public async get(schemas: IPromptSchema[]): Promise<any> {
17+
public async get(questions: prompt.Question[]): Promise<any> {
1818
let promptResult: any;
1919

2020
try {
2121
promptResult = await new Promise<any>((resolve, reject) => {
2222
this.muteStdout();
2323

2424
if (!helpers.isInteractive()) {
25-
if (_.some(schemas, s => !s.default)) {
25+
if (_.some(questions, s => !s.default)) {
2626
reject(new Error("Console is not interactive and no default action specified."));
2727
} else {
2828
const result: any = {};
2929

30-
_.each(schemas, s => {
30+
_.each(questions, s => {
3131
// Curly brackets needed because s.default() may return false and break the loop
3232
result[s.name] = s.default();
3333
});
3434

3535
resolve(result);
3636
}
3737
} else {
38-
prompt.prompt(schemas, (result: any) => {
39-
if (result) {
38+
prompt.prompt(questions).then((result: any) => {
4039
resolve(result);
41-
} else {
42-
reject(new Error(`Unable to get result from prompt: ${result}`));
43-
}
40+
}, (error) => {
41+
reject(new Error(`Unable to get result from prompt: ${error}`));
4442
});
4543
}
4644
});
@@ -52,7 +50,7 @@ export class Prompter implements IPrompter {
5250
}
5351

5452
public async getPassword(prompt: string, options?: IAllowEmpty): Promise<string> {
55-
const schema: IPromptSchema = {
53+
const schema: prompt.Question = {
5654
message: prompt,
5755
type: "password",
5856
name: "password",
@@ -67,7 +65,7 @@ export class Prompter implements IPrompter {
6765
}
6866

6967
public async getString(prompt: string, options?: IPrompterOptions): Promise<string> {
70-
const schema: IPromptSchema = {
68+
const schema: prompt.Question = {
7169
message: prompt,
7270
type: "input",
7371
name: "inputString",
@@ -83,7 +81,7 @@ export class Prompter implements IPrompter {
8381
}
8482

8583
public async promptForChoice(promptMessage: string, choices: any[]): Promise<string> {
86-
const schema: IPromptSchema = {
84+
const schema: prompt.Question = {
8785
message: promptMessage,
8886
type: "list",
8987
name: "userAnswer",

0 commit comments

Comments
 (0)