Socket
Socket
Sign inDemoInstall

inquirer

Package Overview
Dependencies
Maintainers
0
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquirer - npm Package Compare versions

Comparing version 9.2.23 to 9.3.0

16

lib/objects/choices.js
import assert from 'node:assert';
import filter from 'lodash/filter.js';
import map from 'lodash/map.js';

@@ -81,7 +79,15 @@ import Separator from './separator.js';

* Match the valid choices against a where clause
* @param {Object} whereClause Lodash `where` clause
* @param {Function|Object} whereClause filter function or key-value object to match against
* @return {Array} Matching choices or empty array
*/
where(whereClause) {
return filter(this.realChoices, whereClause);
let filterFn;
if (typeof whereClause === 'function') {
filterFn = whereClause;
} else {
const [key, value] = Object.entries(whereClause)[0];
filterFn = (choice) => choice[key] === value;
}
return this.realChoices.filter(filterFn);
}

@@ -95,3 +101,3 @@

pluck(propertyName) {
return map(this.realChoices, propertyName);
return this.realChoices.map((choice) => choice[propertyName]);
}

@@ -98,0 +104,0 @@

@@ -1,2 +0,2 @@

import chalk from 'chalk';
import pc from 'picocolors';
import figures from '@inquirer/figures';

@@ -14,3 +14,3 @@

this.type = 'separator';
this.line = chalk.dim(line || Array.from({ length: 15 }).join(figures.line));
this.line = pc.dim(line || Array.from({ length: 15 }).join(figures.line));
}

@@ -17,0 +17,0 @@

@@ -1,3 +0,1 @@

import defaults from 'lodash/defaults.js';
import clone from 'lodash/clone.js';
/**

@@ -7,10 +5,5 @@ * Base prompt implementation

*/
const _ = {
defaults,
clone,
};
import chalk from 'chalk';
import pc from 'picocolors';
import runAsync from 'run-async';
import { filter, flatMap, share, take, takeUntil } from 'rxjs';
import { filter, mergeMap, share, take, takeUntil } from 'rxjs';
import Choices from '../objects/choices.js';

@@ -28,3 +21,3 @@ import ScreenManager from '../utils/screen-manager.js';

// Set defaults prompt options
this.opt = _.defaults(_.clone(question), {
this.opt = {
validate: () => true,

@@ -36,5 +29,6 @@ validatingText: '',

suffix: '',
prefix: chalk.green('?'),
prefix: pc.green('?'),
transformer: (val) => val,
});
...question,
};

@@ -103,3 +97,3 @@ // Make sure name is present

const validation = submit.pipe(
flatMap((value) => {
mergeMap((value) => {
this.startSpinner(value, this.opt.filteringText);

@@ -162,5 +156,5 @@ return asyncFilter(value, this.answers).then(

(this.opt.prefix ? this.opt.prefix + ' ' : '') +
chalk.bold(this.opt.message) +
pc.bold(this.opt.message) +
this.opt.suffix +
chalk.reset(' ');
pc.reset(' ');

@@ -176,4 +170,4 @@ // Append the default if available, and if question isn't touched/answered

this.opt.type === 'password'
? chalk.italic.dim('[hidden] ')
: chalk.dim('(' + this.opt.default + ') ');
? pc.italic(pc.dim('[hidden] '))
: pc.dim('(' + this.opt.default + ') ');
}

@@ -180,0 +174,0 @@

@@ -5,4 +5,4 @@ /**

import chalk from 'chalk';
import cliCursor from 'cli-cursor';
import ansiEscapes from 'ansi-escapes';
import pc from 'picocolors';
import figures from '@inquirer/figures';

@@ -73,3 +73,2 @@ import { map, takeUntil } from 'rxjs';

// Init the prompt
cliCursor.hide();
this.render();

@@ -94,9 +93,9 @@ this.firstRender = false;

'(Press ' +
chalk.cyan.bold('<space>') +
pc.cyan(pc.bold('<space>')) +
' to select, ' +
chalk.cyan.bold('<a>') +
pc.cyan(pc.bold('<a>')) +
' to toggle all, ' +
chalk.cyan.bold('<i>') +
pc.cyan(pc.bold('<i>')) +
' to invert selection, and ' +
chalk.cyan.bold('<enter>') +
pc.cyan(pc.bold('<enter>')) +
' to proceed)';

@@ -107,3 +106,3 @@ }

if (this.status === 'answered') {
message += chalk.cyan(this.selection.join(', '));
message += pc.cyan(this.selection.join(', '));
} else {

@@ -140,5 +139,7 @@ const choicesStr = renderChoices(this.opt.choices, this.pointer);

if (error) {
bottomContent = chalk.red('>> ') + error;
bottomContent = pc.red('>> ') + error;
}
message += ansiEscapes.cursorHide;
this.screen.render(message, bottomContent);

@@ -158,3 +159,2 @@ }

this.screen.done();
cliCursor.show();
this.done(state.value);

@@ -258,3 +258,3 @@ }

output +=
i - separatorOffset === pointer ? chalk.cyan(figures.pointer + line) : ' ' + line;
i - separatorOffset === pointer ? pc.cyan(figures.pointer + line) : ' ' + line;
}

@@ -275,3 +275,3 @@

function getCheckbox(checked) {
return checked ? chalk.green(figures.radioOn) : figures.radioOff;
return checked ? pc.green(figures.radioOn) : figures.radioOff;
}

@@ -5,3 +5,3 @@ /**

import chalk from 'chalk';
import pc from 'picocolors';
import { take, takeUntil } from 'rxjs';

@@ -64,3 +64,3 @@ import observe from '../utils/events.js';

if (typeof answer === 'boolean') {
message += chalk.cyan(answer ? 'Yes' : 'No');
message += pc.cyan(answer ? 'Yes' : 'No');
} else if (answer) {

@@ -67,0 +67,0 @@ message += answer;

@@ -5,3 +5,3 @@ /**

import chalk from 'chalk';
import pc from 'picocolors';
import { editAsync } from 'external-editor';

@@ -60,7 +60,7 @@ import { Subject } from 'rxjs';

this.status === 'answered'
? chalk.dim('Received')
: chalk.dim('Press <enter> to launch your preferred editor.');
? pc.dim('Received')
: pc.dim('Press <enter> to launch your preferred editor.');
if (error) {
bottomContent = chalk.red('>> ') + error;
bottomContent = pc.red('>> ') + error;
}

@@ -67,0 +67,0 @@

@@ -5,3 +5,3 @@ /**

import chalk from 'chalk';
import pc from 'picocolors';
import { map, takeUntil } from 'rxjs';

@@ -80,3 +80,3 @@ import Separator from '../objects/separator.js';

if (this.status === 'answered') {
message += chalk.cyan(this.answer);
message += pc.cyan(this.answer);
} else if (this.status === 'expanded') {

@@ -91,7 +91,7 @@ const choicesStr = renderChoices(this.opt.choices, this.selectedKey);

if (error) {
bottomContent = chalk.red('>> ') + error;
bottomContent = pc.red('>> ') + error;
}
if (hint) {
bottomContent = chalk.cyan('>> ') + hint;
bottomContent = pc.cyan('>> ') + hint;
}

@@ -131,3 +131,3 @@

if (this.selectedKey === choice.key) {
choiceStr = chalk.cyan(choiceStr);
choiceStr = pc.cyan(choiceStr);
}

@@ -265,3 +265,3 @@

if (pointer === choice.key) {
choiceStr = chalk.cyan(choiceStr);
choiceStr = pc.cyan(choiceStr);
}

@@ -268,0 +268,0 @@

@@ -5,3 +5,3 @@ /**

import chalk from 'chalk';
import pc from 'picocolors';
import { map, takeUntil } from 'rxjs';

@@ -56,7 +56,7 @@ import observe from '../utils/events.js';

} else {
message += isFinal ? chalk.cyan(appendContent) : appendContent;
message += isFinal ? pc.cyan(appendContent) : appendContent;
}
if (error) {
bottomContent = chalk.red('>> ') + error;
bottomContent = pc.red('>> ') + error;
}

@@ -63,0 +63,0 @@

@@ -5,5 +5,5 @@ /**

import chalk from 'chalk';
import ansiEscapes from 'ansi-escapes';
import pc from 'picocolors';
import figures from '@inquirer/figures';
import cliCursor from 'cli-cursor';
import runAsync from 'run-async';

@@ -70,3 +70,2 @@ import { flatMap, map, take, takeUntil } from 'rxjs';

// Init the prompt
cliCursor.hide();
this.render();

@@ -87,3 +86,3 @@

if (this.firstRender) {
message += chalk.dim('(Use arrow keys)');
message += pc.dim('(Use arrow keys)');
}

@@ -93,3 +92,3 @@

if (this.status === 'answered') {
message += chalk.cyan(this.opt.choices.getChoice(this.selected).short);
message += pc.cyan(this.opt.choices.getChoice(this.selected).short);
} else {

@@ -125,2 +124,3 @@ const choicesStr = listRender(this.opt.choices, this.selected);

message += ansiEscapes.cursorHide;
this.firstRender = false;

@@ -142,3 +142,2 @@

this.screen.done();
cliCursor.show();
this.done(value);

@@ -202,3 +201,3 @@ }

if (isSelected) {
line = chalk.cyan(line);
line = pc.cyan(line);
}

@@ -205,0 +204,0 @@

@@ -5,3 +5,3 @@ /**

import chalk from 'chalk';
import pc from 'picocolors';
import { map, takeUntil } from 'rxjs';

@@ -65,3 +65,3 @@ import observe from '../utils/events.js';

if (error) {
bottomContent = '\n' + chalk.red('>> ') + error;
bottomContent = '\n' + pc.red('>> ') + error;
}

@@ -75,8 +75,8 @@

return this.opt.mask
? chalk.cyan(mask(value, this.opt.mask))
: chalk.italic.dim('[hidden]');
? pc.cyan(mask(value, this.opt.mask))
: pc.italic(pc.dim('[hidden]'));
}
return this.opt.mask
? mask(value, this.opt.mask)
: chalk.italic.dim('[input is hidden] ');
: pc.italic(pc.dim('[input is hidden] '));
}

@@ -83,0 +83,0 @@

@@ -5,3 +5,3 @@ /**

import chalk from 'chalk';
import pc from 'picocolors';
import { map, takeUntil } from 'rxjs';

@@ -97,3 +97,3 @@ import Separator from '../objects/separator.js';

if (this.status === 'answered') {
message += chalk.cyan(this.opt.choices.getChoice(this.selected).short);
message += pc.cyan(this.opt.choices.getChoice(this.selected).short);
} else {

@@ -108,3 +108,3 @@ const choicesStr = renderChoices(this.opt.choices, this.selected);

if (error) {
bottomContent = '\n' + chalk.red('>> ') + error;
bottomContent = '\n' + pc.red('>> ') + error;
}

@@ -217,3 +217,3 @@

if (index === pointer) {
display = chalk.cyan(display);
display = pc.cyan(display);
}

@@ -220,0 +220,0 @@

@@ -5,3 +5,3 @@ /**

import through from '@ljharb/through';
import { Writable } from 'node:stream';
import * as rlUtils from '../utils/readline.js';

@@ -14,3 +14,9 @@ import Base from './baseUI.js';

this.log = through(this.writeLog.bind(this));
this.log = new Writable({
write: (chunk, encoding, cb) => {
this.writeLog(chunk);
cb();
},
});
this.bottomBar = opt.bottomBar || '';

@@ -17,0 +23,0 @@ this.render();

@@ -1,11 +0,19 @@

import isPlainObject from 'lodash/isPlainObject.js';
import get from 'lodash/get.js';
import set from 'lodash/set.js';
import get from 'lodash.get';
import set from 'lodash.set';
const _ = {
isPlainObject,
set,
get,
};
import { defer, empty, from, of, concatMap, filter, publish, reduce } from 'rxjs';
import {
defer,
EMPTY,
from,
of,
concatMap,
filter,
publish,
reduce,
isObservable,
} from 'rxjs';
import runAsync from 'run-async';

@@ -26,19 +34,29 @@ import * as utils from '../utils/utils.js';

// Keep global reference to the answers
this.answers = _.isPlainObject(answers) ? { ...answers } : {};
this.answers = typeof answers === 'object' ? { ...answers } : {};
// Make sure questions is an array.
if (_.isPlainObject(questions)) {
// It's either an object of questions or a single question
questions = Object.values(questions).every(
(v) => _.isPlainObject(v) && v.name === undefined,
let obs;
if (Array.isArray(questions)) {
obs = from(questions);
} else if (isObservable(questions)) {
obs = questions;
} else if (
Object.values(questions).every(
(maybeQuestion) =>
typeof maybeQuestion === 'object' &&
!Array.isArray(maybeQuestion) &&
maybeQuestion != null,
)
? Object.entries(questions).map(([name, question]) => ({ name, ...question }))
: [questions];
) {
// Case: Called with a set of { name: question }
obs = from(
Object.entries(questions).map(([name, question]) => ({
name,
...question,
})),
);
} else {
// Case: Called with a single question config
obs = from([questions]);
}
// Create an observable, unless we received one as parameter.
// Note: As this is a public interface, we cannot do an instanceof check as we won't
// be using the exact same object in memory.
const obs = Array.isArray(questions) ? from(questions) : questions;
this.process = obs.pipe(

@@ -120,7 +138,7 @@ concatMap(this.processQuestion.bind(this)),

) {
return empty();
return EMPTY;
}
if (question.when === false) {
return empty();
return EMPTY;
}

@@ -127,0 +145,0 @@

@@ -1,2 +0,2 @@

import chalk from 'chalk';
import pc from 'picocolors';

@@ -41,5 +41,3 @@ /**

return (
visibleLines.join('\n') +
'\n' +
chalk.dim('(Move up and down to reveal more choices)')
visibleLines.join('\n') + '\n' + pc.dim('(Move up and down to reveal more choices)')
);

@@ -46,0 +44,0 @@ }

@@ -0,1 +1,2 @@

import ansiEscapes from 'ansi-escapes';
import cliWidth from 'cli-width';

@@ -134,3 +135,3 @@ import wrapAnsi from 'wrap-ansi';

this.rl.output.unmute();
this.rl.output.write('\n');
this.rl.output.write(`\n${ansiEscapes.cursorShow}`);
}

@@ -137,0 +138,0 @@

{
"name": "inquirer",
"type": "module",
"version": "9.2.23",
"version": "9.3.0",
"description": "A collection of common interactive command line user interfaces.",

@@ -63,11 +63,10 @@ "author": "Simon Boudrias <admin@simonboudrias.com>",

"@inquirer/figures": "^1.0.3",
"@ljharb/through": "^2.3.13",
"ansi-escapes": "^4.3.2",
"chalk": "^5.3.0",
"cli-cursor": "^3.1.0",
"cli-width": "^4.1.0",
"external-editor": "^3.1.0",
"lodash": "^4.17.21",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"mute-stream": "1.0.0",
"ora": "^5.4.1",
"picocolors": "^1.0.1",
"run-async": "^3.0.0",

@@ -81,3 +80,3 @@ "rxjs": "^7.8.1",

"sideEffects": false,
"gitHead": "209b4ce30fe71f8e2f0e066a1a98e385eecb15f4"
"gitHead": "d5f62c6ee3e671f7d1b776b85d43781869d70918"
}
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