Skip to content

Commit

Permalink
replace inquirer with prompts (#10083)
Browse files Browse the repository at this point in the history
- remove `react-dev-utils/inquirer` public import
  • Loading branch information
EvanBacon committed Nov 17, 2020
1 parent 8f03b91 commit 8bf050a
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 278 deletions.
26 changes: 12 additions & 14 deletions packages/create-react-app/createReactApp.js
Expand Up @@ -37,7 +37,7 @@ const envinfo = require('envinfo');
const execSync = require('child_process').execSync;
const fs = require('fs-extra');
const hyperquest = require('hyperquest');
const inquirer = require('inquirer');
const prompts = require('prompts');
const os = require('os');
const path = require('path');
const semver = require('semver');
Expand Down Expand Up @@ -604,20 +604,18 @@ function getInstallPackage(version, originalDirectory) {

for (const script of scriptsToWarn) {
if (packageToInstall.startsWith(script.name)) {
return inquirer
.prompt({
type: 'confirm',
name: 'useScript',
message: script.message,
default: false,
})
.then(answer => {
if (!answer.useScript) {
process.exit(0);
}
return prompts({
type: 'confirm',
name: 'useScript',
message: script.message,
initial: false,
}).then(answer => {
if (!answer.useScript) {
process.exit(0);
}

return packageToInstall;
});
return packageToInstall;
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/create-react-app/package.json
Expand Up @@ -35,7 +35,7 @@
"envinfo": "7.7.3",
"fs-extra": "9.0.1",
"hyperquest": "2.1.3",
"inquirer": "7.3.3",
"prompts": "2.4.0",
"semver": "7.3.2",
"tar-pack": "3.4.1",
"tmp": "0.2.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-dev-utils/WebpackDevServerUtils.js
Expand Up @@ -13,7 +13,7 @@ const url = require('url');
const chalk = require('chalk');
const detect = require('detect-port-alt');
const isRoot = require('is-root');
const inquirer = require('inquirer');
const prompts = require('prompts');
const clearConsole = require('./clearConsole');
const formatWebpackMessages = require('./formatWebpackMessages');
const getProcessForPort = require('./getProcessForPort');
Expand Down Expand Up @@ -467,9 +467,9 @@ function choosePort(host, defaultPort) {
message +
`${existingProcess ? ` Probably:\n ${existingProcess}` : ''}`
) + '\n\nWould you like to run the app on another port instead?',
default: true,
initial: true,
};
inquirer.prompt(question).then(answer => {
prompts(question).then(answer => {
if (answer.shouldChangePort) {
resolve(port);
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-dev-utils/browsersHelper.js
Expand Up @@ -9,7 +9,7 @@
const browserslist = require('browserslist');
const chalk = require('chalk');
const os = require('os');
const inquirer = require('inquirer');
const prompts = require('prompts');
const pkgUp = require('pkg-up');
const fs = require('fs');

Expand All @@ -35,10 +35,10 @@ function shouldSetBrowsers(isInteractive) {
`\n\nWould you like to add the defaults to your ${chalk.bold(
'package.json'
)}?`,
default: true,
initial: true,
};

return inquirer.prompt(question).then(answer => answer.shouldSetBrowsers);
return prompts(question).then(answer => answer.shouldSetBrowsers);
}

function checkBrowsers(dir, isInteractive, retry = true) {
Expand Down
12 changes: 0 additions & 12 deletions packages/react-dev-utils/inquirer.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/react-dev-utils/package.json
Expand Up @@ -34,7 +34,6 @@
"ignoredFiles.js",
"immer.js",
"InlineChunkHtmlPlugin.js",
"inquirer.js",
"InterpolateHtmlPlugin.js",
"launchEditor.js",
"launchEditorEndpoint.js",
Expand Down Expand Up @@ -67,7 +66,7 @@
"globby": "11.0.1",
"gzip-size": "5.1.1",
"immer": "7.0.9",
"inquirer": "7.3.3",
"prompts": "2.4.0",
"is-root": "2.1.0",
"loader-utils": "2.0.0",
"open": "^7.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/react-scripts/package.json
Expand Up @@ -70,6 +70,7 @@
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "5.0.2",
"prompts": "2.4.0",
"react-app-polyfill": "^2.0.0",
"react-dev-utils": "^11.0.0",
"react-refresh": "^0.8.3",
Expand Down

0 comments on commit 8bf050a

Please sign in to comment.