Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@poppinss/prompts

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/prompts - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

12

build/src/Base.d.ts

@@ -9,8 +9,8 @@ /// <reference types="node" />

on(event: 'prompt:answer', callback: (message: any) => any): this;
ask(title: string, options?: TextPromptOptions): Promise<string>;
secure(title: string, options?: TextPromptOptions): Promise<string>;
confirm(title: string, options?: BooleanPromptOptions): Promise<boolean>;
toggle(title: string, choices: [string, string], options?: TogglePromptOptions): Promise<boolean>;
choice(title: string, choices: (string | PromptChoice)[], options?: ChoicePromptOptions): Promise<string>;
multiple(title: string, choices: (string | PromptChoice)[], options?: MultiplePromptOptions): Promise<string[]>;
ask<Result extends any = string>(title: string, options?: TextPromptOptions): Promise<Result>;
secure<Result extends any = string>(title: string, options?: TextPromptOptions): Promise<Result>;
confirm<Result extends any = boolean>(title: string, options?: BooleanPromptOptions): Promise<Result>;
toggle<Result extends any = boolean>(title: string, choices: [string, string], options?: TogglePromptOptions): Promise<Result>;
choice<Result extends any = string>(title: string, choices: (string | PromptChoice)[], options?: ChoicePromptOptions): Promise<Result>;
multiple<Result extends any = string[]>(title: string, choices: (string | PromptChoice)[], options?: MultiplePromptOptions): Promise<Result>;
}

@@ -16,4 +16,6 @@ "use strict";

type: 'input',
name: options.name,
message: title,
initial: options.default,
result: options.result,
format: options.format,

@@ -28,3 +30,5 @@ validate: options.validate,

message: title,
name: options.name,
initial: options.default,
result: options.result,
format: options.format,

@@ -39,3 +43,5 @@ validate: options.validate,

message: title,
name: options.name,
initial: options.default,
result: options.result,
format: options.format,

@@ -50,5 +56,7 @@ validate: options.validate,

message: title,
name: options.name,
enabled: choices[0],
disabled: choices[1],
initial: options.default,
result: options.result,
format: options.format,

@@ -63,2 +71,3 @@ validate: options.validate,

message: title,
name: options.name,
choices: choices.map((choice) => {

@@ -71,2 +80,3 @@ if (typeof (choice) === 'string') {

initial: options.default,
result: options.result,
format: options.format,

@@ -81,2 +91,3 @@ validate: options.validate,

message: title,
name: options.name,
choices: choices.map((choice) => {

@@ -89,2 +100,3 @@ if (typeof (choice) === 'string') {

initial: options.default,
result: options.result,
format: options.format,

@@ -91,0 +103,0 @@ validate: options.validate,

@@ -9,5 +9,7 @@ export declare type PromptState<T extends any> = {

export declare type PromptFormatFunction<T extends any> = (value: T) => T | Promise<T>;
export declare type PromptResultFunction<T extends any> = (value: T) => any | Promise<any>;
export declare type TextPromptOptions = {
default?: string;
name?: string;
result?: PromptResultFunction<string>;
format?: PromptFormatFunction<string>;

@@ -19,2 +21,3 @@ validate?: PromptValidationFunction<PromptState<string>>;

name?: string;
result?: PromptResultFunction<string>;
format?: PromptFormatFunction<string>;

@@ -28,2 +31,3 @@ validate?: PromptValidationFunction<PromptState<string> & {

name?: string;
result?: PromptResultFunction<string[]>;
format?: PromptFormatFunction<string[]>;

@@ -37,2 +41,3 @@ validate?: PromptValidationFunction<PromptState<string[]> & {

name?: string;
result?: PromptResultFunction<boolean>;
format?: PromptFormatFunction<boolean>;

@@ -44,3 +49,4 @@ validate?: PromptValidationFunction<PromptState<boolean>>;

name?: string;
format?: PromptFormatFunction<string>;
result?: PromptResultFunction<boolean>;
format?: PromptFormatFunction<boolean>;
validate?: PromptValidationFunction<PromptState<boolean>>;

@@ -53,2 +59,3 @@ };

initial?: string | boolean | string[];
result?: PromptResultFunction<any>;
format?: PromptFormatFunction<any>;

@@ -69,8 +76,8 @@ validate?: PromptValidationFunction<any>;

export interface PromptContract {
ask(title: string, options?: TextPromptOptions): Promise<string>;
secure(title: string, options?: TextPromptOptions): Promise<string>;
confirm(title: string, options?: BooleanPromptOptions): Promise<boolean>;
toggle(title: string, choices: [string, string], options?: TogglePromptOptions): Promise<boolean>;
choice(title: string, choices: (string | PromptChoice)[], options?: ChoicePromptOptions): Promise<string>;
multiple(title: string, choices: (string | PromptChoice)[], options?: MultiplePromptOptions): Promise<string[]>;
ask<Result extends any = string>(title: string, options?: TextPromptOptions): Promise<Result>;
secure<Result extends any = string>(title: string, options?: TextPromptOptions): Promise<Result>;
confirm<Result extends any = boolean>(title: string, options?: BooleanPromptOptions): Promise<Result>;
toggle<Result extends any = boolean>(title: string, choices: [string, string], options?: TogglePromptOptions): Promise<Result>;
choice<Result extends any = string>(title: string, choices: (string | PromptChoice)[], options?: ChoicePromptOptions): Promise<Result>;
multiple<Result extends any = string[]>(title: string, choices: (string | PromptChoice)[], options?: MultiplePromptOptions): Promise<Result>;
on(event: 'prompt', callback: (options: PromptEventOptions) => any): this;

@@ -77,0 +84,0 @@ on(event: 'prompt:error', callback: (message: string) => any): this;

@@ -43,22 +43,23 @@ "use strict";

}
if (typeof (this.validate) !== 'function') {
return resolve(answer);
let passes = true;
if (typeof (this.validate) === 'function') {
const state = {
value: answer,
type: this.type,
name: this.name,
message: this.message,
choices: this.choices,
initial: this.initial,
format: this.format,
submitted: true,
cancelled: false,
};
if (state.choices) {
state.size = state.choices.size;
state.multiple = state.type === 'multiselect';
}
passes = await this.validate(answer, state);
}
const state = {
value: answer,
type: this.type,
name: this.name,
message: this.message,
choices: this.choices,
initial: this.initial,
format: this.format,
submitted: true,
cancelled: false,
};
if (state.choices) {
state.size = state.choices.size;
state.multiple = state.type === 'multiselect';
}
const passes = await this.validate(answer, state);
if (passes === true) {
answer = typeof (this.result) === 'function' ? await this.result(answer) : answer;
self.emit('prompt:answer', answer);

@@ -65,0 +66,0 @@ resolve(answer);

{
"name": "@poppinss/prompts",
"version": "1.0.0",
"version": "1.0.1",
"description": "Module on top of enquirer with API to fake prompts during testing",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -6,3 +6,3 @@ # Prompts

[![appveyor-image]][appveyor-url] [![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]

@@ -191,5 +191,2 @@ <!-- START doctoc generated TOC please keep comment here to allow auto update -->

[appveyor-image]: https://img.shields.io/appveyor/ci/thetutlage/prompts/master.svg?style=for-the-badge&logo=appveyor
[appveyor-url]: https://ci.appveyor.com/project/thetutlage/prompts "appveyor"
[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/prompts/master.svg?style=for-the-badge&logo=circleci

@@ -196,0 +193,0 @@ [circleci-url]: https://circleci.com/gh/poppinss/prompts "circleci"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc