DefinitelyTyped/types/console-ui/index.d.ts
Manuel Thalmann 59e7099918 Refactor the type-declaration of inquirer (#36708)
* Refactor incorrect tests

* Add export-statements to the exported components

* Add a base-class for prompt-modules

* Externalize the Prompts-type

* Externalize the Separator-class

* Move the ChoiceOption-type to a new namespace "poll"

* Rename the ChoiceOption-type to ChoiceOptions

* Add a choice base-type

* Move ChoiceType to the poll-namespace

* Rename the ChoiceType-type

* Reorder the types

* Convert types to interfaces

* Rename the qeustion-type to "DistinctQuestion"

* Add types for representing optional object-keys

* Add a type for dynamic question-properties

* Fix some question-options

* Ad the `filter`-methjod to the QuestionCommon-interface

* Move uestionCommon to the poll-namespace

* Rename QuestionCommon to Question

* Refactor the question-types

* Refactor the Questions-type

* Rename Questions to QuestionCollection

* Rearrange the namespaces

* Add a type-option to the Question-interface

* Add a ScreenManager-class

* Rework visibility of ScreenManager-members

* Add a Prompt-class

* Force all generic answers to extend Answers

* Add an interface for basic prompts

* Add a PromptConstrructor type

* Add types for the paginator

* Rework the event-submission of prompts

* Fix the type of the run-callback

* Add a generic parameter for the type of answer

* Add types for the Checkbox-prompt

* Make the type of the checkbox-prompt generic

* Add a module for the checkbox-prompt

* Fix js-doc

* Add missing import

* Fix typo

* Add types for the confirm-prompt

* Remove the generic answer-type

* Rework the checkbox-prompt

* Add an editor-prompt

* Add the Choice-class

* Move the choice-class to another directory

* Add a separator-interface

* Fix the separator-class

* Add a choices-class

* Add the separator-type

* Move the objects to the correct location

* Move all external modules to the proper place

* Fix the PromptModule interface

* Convert all internal components to internal modules

* Rework the prompt-type

* Make the choices public

* Fix the editor-prompt

* Move all external modules into the index-file

* Move all remaining modules into the index-file

* Fix incorrect choices-module

* Export the DynamicQuestionProperty

* Add a question-map

* Fix the choicebase-type

* Fix asynchronously fetched question-options

* Improve the handling of choices

* Add an expand-prompt

* Intuitively rework the prompts

* Rework the expand-prompt

* Add the input-prompt

* Add trhe list-prompt

* Refactor all prompts

* Fix incorrect module-export

* Fix the prompt-constructor

* Fix the handling of the question-options

* Add the number-prompt

* Add the password-prompt

* Add the rawlist-prompt

* Add ui-classes

* Add all remaining types

* Fix the generic types

* Remove unnecessary types

* Rework the type-declarations according to tslint

* Complete the docs

* Order the imports

* Add a new author-tag

* Increase the major-version

* Import all unused files

* Fix the AsyncDynamicQuestionProperty

* Improve the docs

* Remove the poll-namespace

* Fix the inquirer-types according to tslint

* Fix dependent type-declarations

* Remove the index-signature from the choice-class

* Fix the constructor of the prompt-ui

* Add tests

* Simplify the PromptCollection-type

* Rearrange the file-header

* Add an interface for the bottom-bar options

* Make the log-stream public

* Complete the docs of the choice-class

* Add a validator-type

* Add a choice-collection type

* Add a Transformer-type

* Fix the PromptModule-type

* Add all inquirer code-examples

* Fix incorrect code

* Rework the way to import the example-files

* Fix dependent types
2019-07-31 10:17:47 -07:00

94 lines
3.1 KiB
TypeScript

// Type definitions for console-ui 2.2
// Project: https://github.com/ember-cli/console-ui#readme
// Definitions by: Dan Freeman <https://github.com/dfreeman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.3
import { Readable, Writable } from 'stream';
import { QuestionCollection } from 'inquirer';
type WriteLevel = 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR';
export = UI;
/**
* The UI provides the CLI with a unified mechanism for providing output and
* requesting input from the user. This becomes useful when wanting to adjust
* logLevels, or mock input/output for tests.
*/
declare class UI {
constructor(options?: {
inputStream?: Readable;
outputStream?: Writable;
errorStream?: Writable;
writeLevel?: WriteLevel;
ci?: boolean;
});
/**
* Unified mechanism to write a string to the console.
* Optionally include a writeLevel, this is used to decide if the specific
* logging mechanism should or should not be printed.
*/
write(message: string, level?: WriteLevel): void;
/**
* Unified mechanism to write a string and new line to the console.
* Optionally include a writeLevel, this is used to decide if the specific
* logging mechanism should or should not be printed.
*/
writeLine(message: string, level?: WriteLevel): void;
/**
* Helper method to write a string with the DEBUG writeLevel and gray chalk
*/
writeDebugLine(message: string): void;
/**
* Helper method to write a string with the INFO writeLevel and cyan chalk
*/
writeInfoLine(message: string): void;
/**
* Helper method to write a string with the WARNING writeLevel and yellow chalk.
* Optionally include a test. If falsy, the warning will be printed. By default, warnings
* will be prepended with WARNING text when printed.
*/
writeWarnLine(message: string, test?: boolean, prepend?: boolean): void;
/**
* Helper method to write a string with the WARNING writeLevel and yellow chalk.
* Optionally include a test. If falsy, the deprecation will be printed. By default deprecations
* will be prepended with DEPRECATION text when printed.
*/
writeDeprecateLine(message: string, test?: boolean, prepend?: boolean): void;
/**
* Unified mechanism to an Error to the console.
* This will occure at a writeLevel of ERROR
*/
writeError(error: object): void;
/**
* Sets the write level for the UI. Valid write levels are 'DEBUG', 'INFO',
* 'WARNING', and 'ERROR'.
*/
setWriteLevel(level: WriteLevel): void;
/**
* Begins a progress spinner with a message (only if the INFO write level is visible).
*/
startProgress(message: string): void;
/**
* Ends the current progress spinner.
*/
stopProgress(): void;
/**
* Launch the prompt interface (inquiry session) with (Array of Questions || Question)
* See [Inquirer.js#question](https://github.com/SBoudrias/Inquirer.js#question) for Question properties
*/
prompt<T>(questions: QuestionCollection<T>, callback?: (answers: T) => void): Promise<T>;
}