1- import * as prompt from "inquirer " ;
1+ import * as prompt from "prompts " ;
22import * as helpers from "./helpers" ;
33import * as readline from "readline" ;
44import { ReadStream } from "tty" ;
5- import { IAllowEmpty , IPrompterOptions } from "./declarations" ;
5+ import {
6+ IAllowEmpty ,
7+ IPrompterAnswers ,
8+ IPrompterOptions ,
9+ IPrompterQuestion ,
10+ } from "./declarations" ;
611import { injector } from "./yok" ;
712const MuteStream = require ( "mute-stream" ) ;
813import * as _ from "lodash" ;
914
1015export class Prompter implements IPrompter {
11- private descriptionSeparator = "|" ;
1216 private ctrlcReader : readline . ReadLine ;
1317 private muteStreamInstance : any = null ;
1418
@@ -18,12 +22,7 @@ export class Prompter implements IPrompter {
1822 }
1923 }
2024
21- public async get ( questions : prompt . Question [ ] ) : Promise < any > {
22- _ . each ( questions , ( q ) => {
23- q . filter = ( selection : string ) => {
24- return selection . split ( this . descriptionSeparator ) [ 0 ] . trim ( ) ;
25- } ;
26- } ) ;
25+ public async get ( questions : IPrompterQuestion [ ] ) : Promise < any > {
2726 try {
2827 this . muteStdout ( ) ;
2928
@@ -55,7 +54,7 @@ export class Prompter implements IPrompter {
5554 message : string ,
5655 options ?: IAllowEmpty
5756 ) : Promise < string > {
58- const schema : prompt . Question = {
57+ const schema : IPrompterQuestion = {
5958 message,
6059 type : "password" ,
6160 name : "password" ,
@@ -73,9 +72,9 @@ export class Prompter implements IPrompter {
7372 message : string ,
7473 options ?: IPrompterOptions
7574 ) : Promise < string > {
76- const schema : prompt . Question = {
75+ const schema : IPrompterQuestion = {
7776 message,
78- type : "input " ,
77+ type : "text " ,
7978 name : "inputString" ,
8079 validate : ( value : any ) => {
8180 const doesNotAllowEmpty =
@@ -95,9 +94,9 @@ export class Prompter implements IPrompter {
9594 promptMessage : string ,
9695 choices : string [ ]
9796 ) : Promise < string > {
98- const schema : prompt . Answers = {
97+ const schema : IPrompterAnswers = {
9998 message : promptMessage ,
100- type : "list " ,
99+ type : "select " ,
101100 name : "userAnswer" ,
102101 choices,
103102 } ;
@@ -110,21 +109,17 @@ export class Prompter implements IPrompter {
110109 promptMessage : string ,
111110 choices : { key : string ; description : string } [ ]
112111 ) : Promise < string > {
113- const longestKeyLength = choices . concat ( ) . sort ( function ( a , b ) {
114- return b . key . length - a . key . length ;
115- } ) [ 0 ] . key . length ;
116112 const inquirerChoices = choices . map ( ( choice ) => {
117113 return {
118- name : `${ _ . padEnd ( choice . key , longestKeyLength ) } ${
119- choice . description ? this . descriptionSeparator : ""
120- } ${ choice . description } `,
121- short : choice . key ,
114+ title : choice . key ,
115+ value : choice . key ,
116+ description : choice . description ,
122117 } ;
123118 } ) ;
124119
125120 const schema : any = {
126121 message : promptMessage ,
127- type : "list " ,
122+ type : "select " ,
128123 name : "userAnswer" ,
129124 choices : inquirerChoices ,
130125 } ;
0 commit comments