Skip to content

Commit

Permalink
Update some dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed May 21, 2021
1 parent 33407e3 commit de13f14
Show file tree
Hide file tree
Showing 79 changed files with 3,031 additions and 3,033 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ A collection of common interactive command line user interfaces.
1. [Reactive Interface](#reactive)
3. [Support](#support)
4. [Known issues](#issues)
4. [News](#news)
5. [Contributing](#contributing)
6. [License](#license)
7. [Plugins](#plugins)
5. [News](#news)
6. [Contributing](#contributing)
7. [License](#license)
8. [Plugins](#plugins)

## Goal and Philosophy

Expand Down Expand Up @@ -61,11 +61,11 @@ inquirer
.prompt([
/* Pass your questions in here */
])
.then(answers => {
.then((answers) => {
// Use user feedback for... whatever!!
})
.catch(error => {
if(error.isTtyError) {
.catch((error) => {
if (error.isTtyError) {
// Prompt couldn't be rendered in the current environment
} else {
// Something else went wrong
Expand Down Expand Up @@ -297,8 +297,8 @@ The `postfix` property is useful if you want to provide an extension.
<a name="layouts"></a>

### Use in Non-Interactive Environments
`prompt()` requires that it is run in an interactive environment. (I.e. [One where `process.stdin.isTTY` is `true`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_a_note_on_process_i_o)). If `prompt()` is invoked outside of such an environment, then `prompt()` will return a rejected promise with an error. For convenience, the error will have a `isTtyError` property to programmatically indicate the cause.

`prompt()` requires that it is run in an interactive environment. (I.e. [One where `process.stdin.isTTY` is `true`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_a_note_on_process_i_o)). If `prompt()` is invoked outside of such an environment, then `prompt()` will return a rejected promise with an error. For convenience, the error will have a `isTtyError` property to programmatically indicate the cause.

## User Interfaces and layouts

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"private": true,
"devDependencies": {
"@babel/core": "^7.13.1",
"@babel/preset-env": "^7.13.5",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"babel-jest": "^26.6.3",
"codecov": "^3.8.1",
"eslint": "^7.20.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-xo": "^0.35.0",
"eslint-plugin-prettier": "^3.3.1",
"codecov": "^3.8.2",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-xo": "^0.36.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^4.3.8",
"jest": "^26.6.3",
"lerna": "^3.20.2",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1"
"lerna": "^4.0.0",
"lint-staged": "^11.0.0",
"prettier": "^2.3.0"
},
"workspaces": [
"packages/*"
Expand Down
12 changes: 4 additions & 8 deletions packages/checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = createPrompt(
showHelpTip: false,
choices: choices.map((choice, i) => {
if (i === cursorPosition) {
return Object.assign({}, choice, { checked: !choice.checked });
return { ...choice, checked: !choice.checked };
}

return choice;
Expand All @@ -34,15 +34,11 @@ module.exports = createPrompt(
} else if (key.name === 'a') {
const selectAll = Boolean(choices.find((choice) => !choice.checked));
setState({
choices: choices.map((choice) =>
Object.assign({}, choice, { checked: selectAll })
),
choices: choices.map((choice) => ({ ...choice, checked: selectAll })),
});
} else if (key.name === 'i') {
setState({
choices: choices.map((choice) =>
Object.assign({}, choice, { checked: !choice.checked })
),
choices: choices.map((choice) => ({ ...choice, checked: !choice.checked })),
});
} else if (isNumberKey(key)) {
// Adjust index to start at 1
Expand All @@ -57,7 +53,7 @@ module.exports = createPrompt(
cursorPosition: position,
choices: choices.map((choice, i) => {
if (i === position) {
return Object.assign({}, choice, { checked: !choice.checked });
return { ...choice, checked: !choice.checked };
}

return choice;
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"dependencies": {
"@inquirer/core": "^0.0.14-alpha.0",
"chalk": "^4.1.0",
"chalk": "^4.1.1",
"figures": "^3.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/confirm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@inquirer/core": "^0.0.14-alpha.0",
"@inquirer/input": "^0.0.14-alpha.0",
"chalk": "^4.1.0"
"chalk": "^4.1.1"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { getPromptConfig } = require('./lib/options');

let sessionRl;
let hooks = [];
let hooksCleanup = [];
const hooksCleanup = [];
let index = 0;
let handleChange = () => {};

Expand Down
30 changes: 13 additions & 17 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class StateManager {
const { validate: configValidate = () => true } = this.config;

const { mapStateToValue = defaultMapStateToValue } = this.config;
let value = mapStateToValue(state);
const value = mapStateToValue(state);

const showLoader = setTimeout(this.startLoading, 500);
this.rl.pause();
Expand Down Expand Up @@ -164,12 +164,12 @@ class StateManager {
}

setState(partialState) {
this.currentState = Object.assign({}, this.currentState, partialState);
this.currentState = { ...this.currentState, ...partialState };
this.onChange(this.getState());
}

getState() {
return Object.assign({}, defaultState, this.initialState, this.currentState);
return { ...defaultState, ...this.initialState, ...this.currentState };
}

getPrefix() {
Expand All @@ -191,20 +191,16 @@ class StateManager {
error = `${chalk.red('>>')} ${state.error}`;
}

const renderState = Object.assign(
{
prefix: this.getPrefix(),
},
state,
{
// Only pass message down if it's a string. Otherwise we're still in init state
message: _.isFunction(message) ? 'Loading...' : message,
value: transformer(value, { isFinal: status === 'done' }),
validate: undefined,
filter: undefined,
transformer: undefined,
}
);
const renderState = {
prefix: this.getPrefix(),
...state,
// Only pass message down if it's a string. Otherwise we're still in init state
message: _.isFunction(message) ? 'Loading...' : message,
value: transformer(value, { isFinal: status === 'done' }),
validate: undefined,
filter: undefined,
transformer: undefined,
};
this.screen.render(this.render(renderState, this.config), error);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/lib/Paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Paginator {
// TODO: I've remove the dependency on readline here. But we should refactor the
// paginator to also rely on hook.
const width = cliWidth({ defaultWidth: 80, output: process.stdout });
let lines = breakLines(output, width).split('\n');
const lines = breakLines(output, width).split('\n');

// Make sure there's enough lines to paginate
if (lines.length <= pageSize) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/lib/options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports.getPromptConfig = async (options) => {
let message = options.message;
let { message } = options;
if (typeof options.message === 'function') {
message = message();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"license": "MIT",
"dependencies": {
"ansi-escapes": "^4.2.1",
"chalk": "^4.1.0",
"cli-spinners": "^2.5.0",
"chalk": "^4.1.1",
"cli-spinners": "^2.6.0",
"cli-width": "^3.0.0",
"lodash": "^4.17.21",
"mute-stream": "^0.0.8",
Expand Down
6 changes: 2 additions & 4 deletions packages/editor/demo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const editor = require('.');

(async () => {
let answer;

answer = await editor({
const answer = await editor({
message: 'Please write a short bio of at least 3 lines.',
validate: function (text) {
validate(text) {
if (text.split('\n').length < 3) {
return 'Must be at least 3 lines.';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"dependencies": {
"@inquirer/core": "^0.0.14-alpha.0",
"chalk": "^4.1.0",
"chalk": "^4.1.1",
"external-editor": "^3.0.3"
},
"publishConfig": {
Expand Down
12 changes: 6 additions & 6 deletions packages/expand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ const answer = await expand({
{
key: 'y',
name: 'Overwrite',
value: 'overwrite'
value: 'overwrite',
},
{
key: 'a',
name: 'Overwrite this one and all next',
value: 'overwrite_all'
value: 'overwrite_all',
},
{
key: 'd',
name: 'Show diff',
value: 'diff'
value: 'diff',
},
{
key: 'x',
name: 'Abort',
value: 'abort'
}
]
value: 'abort',
},
],
});
```

Expand Down
2 changes: 1 addition & 1 deletion packages/expand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"dependencies": {
"@inquirer/core": "^0.0.14-alpha.0",
"chalk": "^4.1.0",
"chalk": "^4.1.1",
"figures": "^3.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"dependencies": {
"@inquirer/core": "^0.0.14-alpha.0",
"chalk": "^4.1.0"
"chalk": "^4.1.1"
},
"publishConfig": {
"access": "public"
Expand Down
14 changes: 7 additions & 7 deletions packages/inquirer/examples/bottom-bar.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
var BottomBar = require('../lib/ui/bottom-bar');
var cmdify = require('cmdify');
const BottomBar = require('../lib/ui/bottom-bar');
const cmdify = require('cmdify');

var loader = ['/ Installing', '| Installing', '\\ Installing', '- Installing'];
var i = 4;
var ui = new BottomBar({ bottomBar: loader[i % 4] });
const loader = ['/ Installing', '| Installing', '\\ Installing', '- Installing'];
let i = 4;
const ui = new BottomBar({ bottomBar: loader[i % 4] });

setInterval(() => {
ui.updateBottomBar(loader[i++ % 4]);
}, 300);

var spawn = require('child_process').spawn;
const { spawn } = require('child_process');

var cmd = spawn(cmdify('npm'), ['-g', 'install', 'inquirer'], { stdio: 'pipe' });
const cmd = spawn(cmdify('npm'), ['-g', 'install', 'inquirer'], { stdio: 'pipe' });
cmd.stdout.pipe(ui.log);
cmd.on('close', () => {
ui.updateBottomBar('Installation done!\n');
Expand Down
4 changes: 2 additions & 2 deletions packages/inquirer/examples/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

'use strict';
var inquirer = require('..');
const inquirer = require('..');

inquirer
.prompt([
Expand Down Expand Up @@ -55,7 +55,7 @@ inquirer
name: 'Extra cheese',
},
],
validate: function (answer) {
validate(answer) {
if (answer.length < 1) {
return 'You must choose at least one topping.';
}
Expand Down
6 changes: 3 additions & 3 deletions packages/inquirer/examples/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
*/

'use strict';
var inquirer = require('..');
const inquirer = require('..');

var questions = [
const questions = [
{
type: 'editor',
name: 'bio',
message: 'Please write a short bio of at least 3 lines.',
validate: function (text) {
validate(text) {
if (text.split('\n').length < 3) {
return 'Must be at least 3 lines.';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/examples/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

'use strict';
var inquirer = require('..');
const inquirer = require('..');

inquirer
.prompt([
Expand Down
10 changes: 5 additions & 5 deletions packages/inquirer/examples/hierarchical.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/

'use strict';
var inquirer = require('..');
const inquirer = require('..');

var directionsPrompt = {
const directionsPrompt = {
type: 'list',
name: 'direction',
message: 'Which direction would you like to go?',
Expand Down Expand Up @@ -34,7 +34,7 @@ function exitHouse() {

function encounter1() {
inquirer.prompt(directionsPrompt).then((answers) => {
var direction = answers.direction;
const { direction } = answers;
if (direction === 'Forward') {
console.log('You attempt to fight the wolf');
console.log(
Expand All @@ -54,9 +54,9 @@ function encounter1() {

function encounter2a() {
inquirer.prompt(directionsPrompt).then((answers) => {
var direction = answers.direction;
const { direction } = answers;
if (direction === 'Forward') {
var output = 'You find a painted wooden sign that says:';
let output = 'You find a painted wooden sign that says:';
output += ' \n';
output += ' ____ _____ ____ _____ \n';
output += '(_ _)( _ )( _ \\( _ ) \n';
Expand Down

0 comments on commit de13f14

Please sign in to comment.