From c91dc05f6a55954e14562fe4e4542c0d76527ed5 Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Fri, 22 Jan 2021 17:40:26 +0000 Subject: [PATCH] refactor(v2): Switch from inquirer to prompts Signed-off-by: Reece Dunham --- package.json | 1 - packages/docusaurus/package.json | 2 +- packages/docusaurus/src/choosePort.ts | 10 +++++----- yarn.lock | 17 +---------------- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 7f5db36a9b6a..9b37c8d098f4 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "@crowdin/cli": "^3.5.2", "@types/express": "^4.17.2", "@types/fs-extra": "^9.0.4", - "@types/inquirer": "^6.5.0", "@types/jest": "^25.2.1", "@types/loader-utils": "^1.1.3", "@types/lodash.camelcase": "^4.3.6", diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json index 4076c607703a..42c728f02902 100644 --- a/packages/docusaurus/package.json +++ b/packages/docusaurus/package.json @@ -77,7 +77,6 @@ "html-tags": "^3.1.0", "html-webpack-plugin": "^4.5.0", "import-fresh": "^3.3.0", - "inquirer": "^7.2.0", "is-root": "^2.1.0", "joi": "^17.2.1", "leven": "^3.1.0", @@ -93,6 +92,7 @@ "pnp-webpack-plugin": "^1.6.4", "postcss-loader": "^4.1.0", "postcss-preset-env": "^6.7.0", + "prompts": "^2.4.0", "react-dev-utils": "^10.2.1", "react-helmet": "^6.1.0", "react-loadable": "^5.5.0", diff --git a/packages/docusaurus/src/choosePort.ts b/packages/docusaurus/src/choosePort.ts index 62f973ec98bb..b1eee4e9b6cd 100644 --- a/packages/docusaurus/src/choosePort.ts +++ b/packages/docusaurus/src/choosePort.ts @@ -14,7 +14,7 @@ import {execSync} from 'child_process'; import detect from 'detect-port'; import isRoot from 'is-root'; import chalk from 'chalk'; -import inquirer from 'inquirer'; +import prompts from 'prompts'; const isInteractive = process.stdout.isTTY; @@ -101,7 +101,7 @@ export default async function choosePort( if (isInteractive) { clearConsole(); const existingProcess = getProcessForPort(defaultPort); - const question: Record = { + const question: prompts.PromptObject = { type: 'confirm', name: 'shouldChangePort', message: `${chalk.yellow( @@ -109,10 +109,10 @@ export default async function choosePort( 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: any) => { - if (answer.shouldChangePort) { + prompts(question).then((answer: any) => { + if (answer.shouldChangePort === true) { resolve(port); } else { resolve(null); diff --git a/yarn.lock b/yarn.lock index 71118d4ac4be..a251ae4343fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3338,14 +3338,6 @@ dependencies: "@types/node" "*" -"@types/inquirer@^6.5.0": - version "6.5.0" - resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-6.5.0.tgz#b83b0bf30b88b8be7246d40e51d32fe9d10e09be" - integrity sha512-rjaYQ9b9y/VFGOpqBEXRavc3jh0a+e6evAbI31tMda8VlPaSy0AZJfXsvmIe3wklc7W6C3zCSfleuMXR7NOyXw== - dependencies: - "@types/through" "*" - rxjs "^6.4.0" - "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff" @@ -3706,13 +3698,6 @@ resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.6.tgz#a9ca4b70a18b270ccb2bc0aaafefd1d486b7ea74" integrity sha512-W+bw9ds02rAQaMvaLYxAbJ6cvguW/iJXNT6lTssS1ps6QdrMKttqEAMEG/b5CR8TZl3/L7/lH0ZV5nNR1LXikA== -"@types/through@*": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/through/-/through-0.0.30.tgz#e0e42ce77e897bd6aead6f6ea62aeb135b8a3895" - integrity sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg== - dependencies: - "@types/node" "*" - "@types/uglify-js@*": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.5.tgz#2c70d5c68f6e002e3b2e4f849adc5f162546f633" @@ -10922,7 +10907,7 @@ inquirer@^6.2.0, inquirer@^6.5.1: strip-ansi "^5.1.0" through "^2.3.6" -inquirer@^7.0.0, inquirer@^7.2.0: +inquirer@^7.0.0: version "7.2.0" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.2.0.tgz#63ce99d823090de7eb420e4bb05e6f3449aa389a" integrity sha512-E0c4rPwr9ByePfNlTIB8z51kK1s2n6jrHuJeEHENl/sbq2G/S1auvibgEwNR4uSyiU+PiYHqSwsgGiXjG8p5ZQ==