Skip to content

Commit 9f8ae99

Browse files
authored
chore: replace inquirer with prompts (#1010)
* chore: replace inquirer with enquirer * fix install pods prompt * fix ios deploy prompt * replace enquirer with prompts
1 parent fa73dd1 commit 9f8ae99

File tree

7 files changed

+69
-78
lines changed

7 files changed

+69
-78
lines changed

packages/cli-types/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from './android';
1414
import {Ora} from 'ora';
1515

16-
export type InquirerPrompt = any;
16+
export type Prompt = any;
1717

1818
export type CommandFunction<Args = Object> = (
1919
argv: Array<string>,
@@ -112,7 +112,7 @@ export interface Dependency {
112112
preunlink?: string;
113113
postunlink?: string;
114114
};
115-
params: InquirerPrompt[];
115+
params: Prompt[];
116116
}
117117

118118
export type ProjectConfig = {

packages/cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"fs-extra": "^8.1.0",
4646
"glob": "^7.1.3",
4747
"graceful-fs": "^4.1.3",
48-
"inquirer": "^3.0.6",
4948
"joi": "^17.2.1",
5049
"leven": "^3.1.0",
5150
"lodash": "^4.17.15",
@@ -60,6 +59,7 @@
6059
"node-stream-zip": "^1.9.1",
6160
"ora": "^3.4.0",
6261
"pretty-format": "^26.6.2",
62+
"prompts": "^2.4.0",
6363
"semver": "^6.3.0",
6464
"serve-static": "^1.13.1",
6565
"strip-ansi": "^5.2.0",
@@ -79,6 +79,7 @@
7979
"@types/lodash": "^4.14.149",
8080
"@types/minimist": "^1.2.0",
8181
"@types/mkdirp": "^0.5.2",
82+
"@types/prompts": "^2.0.9",
8283
"@types/semver": "^6.0.2",
8384
"@types/wcwidth": "^1.0.0",
8485
"slash": "^3.0.0",

packages/cli/src/commands/doctor/healthchecks/iosDeploy.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import execa from 'execa';
22
import chalk from 'chalk';
3-
// @ts-ignore untyped
4-
import inquirer from 'inquirer';
3+
import prompts from 'prompts';
54
import {isSoftwareNotInstalled, PACKAGE_MANAGERS} from '../checkInstallation';
65
import {packageManager} from './packageManagers';
76
import {logError, removeMessage} from './common';
@@ -72,13 +71,16 @@ export default {
7271
)} ${chalk.reset('or')} ${chalk.bold(
7372
'npm',
7473
)} ${chalk.reset()}, which one do you want to use?`;
75-
const installWithYarn = 'yarn';
76-
const installWithNpm = 'npm';
77-
const skipInstallation = 'Skip installation';
78-
79-
const {chosenPackageManager} = await inquirer.prompt([
74+
const installWithYarn = {title: 'yarn', value: 'yarn'};
75+
const installWithNpm = {title: 'npm', value: 'npm'};
76+
const skipInstallation = {
77+
title: 'Skip installation',
78+
value: 'skip',
79+
};
80+
81+
const {chosenPackageManager} = await prompts([
8082
{
81-
type: 'list',
83+
type: 'select',
8284
name: 'chosenPackageManager',
8385
message: promptQuestion,
8486
choices: [installWithYarn, installWithNpm, skipInstallation],
@@ -87,7 +89,10 @@ export default {
8789

8890
removeMessage(`? ${promptQuestion} ${chosenPackageManager}`);
8991

90-
if (chosenPackageManager === skipInstallation) {
92+
if (
93+
chosenPackageManager === skipInstallation.value ||
94+
!chosenPackageManager // e.g. when user presses Esc
95+
) {
9196
loader.fail();
9297

9398
// Then we just print out the URL that the user can head to download the library
@@ -99,7 +104,8 @@ export default {
99104
return;
100105
}
101106

102-
const shouldInstallWithYarn = chosenPackageManager === installWithYarn;
107+
const shouldInstallWithYarn =
108+
chosenPackageManager === installWithYarn.value;
103109

104110
return installLibrary({
105111
installationCommand: shouldInstallWithYarn

packages/cli/src/commands/doctor/healthchecks/jdk.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export default {
5454
loader.fail(e);
5555
}
5656
},
57-
runAutomaticFix: async ({logManualInstallation}) => {
57+
runAutomaticFix: async ({logManualInstallation, loader}) => {
58+
loader.fail();
5859
logManualInstallation({
5960
healthcheck: 'JDK',
6061
url: 'https://openjdk.java.net/',

packages/cli/src/commands/link/pollParams.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
// @ts-ignore untyped
9-
import {prompt, QuestionCollection, Answers} from 'inquirer';
8+
import prompts from 'prompts';
109

11-
export default (questions: QuestionCollection) =>
12-
new Promise<Answers>((resolve, reject) => {
10+
export default (questions: any[]) =>
11+
new Promise<Object>((resolve, reject) => {
1312
if (!questions) {
1413
resolve({});
1514
return;
1615
}
1716

18-
prompt(questions).then(resolve, reject);
17+
prompts(questions).then(resolve, reject);
1918
});

packages/cli/src/tools/installPods.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import fs from 'fs';
22
import execa from 'execa';
33
import chalk from 'chalk';
44
import ora from 'ora';
5-
// @ts-ignore untyped
6-
import inquirer from 'inquirer';
5+
import prompts from 'prompts';
76
import {logger} from '@react-native-community/cli-tools';
87
import {NoopLoader} from './loader';
98
// @ts-ignore untyped
@@ -96,22 +95,23 @@ async function promptCocoaPodsInstallationQuestion(): Promise<
9695
const installWithGem = 'Yes, with gem (may require sudo)';
9796
const installWithHomebrew = 'Yes, with Homebrew';
9897

99-
const {shouldInstallCocoaPods} = await inquirer.prompt([
98+
const {installMethod} = await prompts([
10099
{
101-
type: 'list',
102-
name: 'shouldInstallCocoaPods',
100+
type: 'select',
101+
name: 'installMethod',
103102
message: promptQuestion,
104-
choices: [installWithGem, installWithHomebrew],
103+
choices: [
104+
{title: installWithGem, value: 'gem'},
105+
{title: installWithHomebrew, value: 'homebrew'},
106+
],
105107
},
106108
]);
107109

108-
const shouldInstallWithGem = shouldInstallCocoaPods === installWithGem;
109-
110110
return {
111-
installMethod: shouldInstallWithGem ? 'gem' : 'homebrew',
111+
installMethod,
112112
// This is used for removing the message in `doctor` after it's answered
113113
promptQuestion: `? ${promptQuestion} ${
114-
shouldInstallWithGem ? installWithGem : installWithHomebrew
114+
installMethod === 'gem' ? installWithGem : installWithHomebrew
115115
}`,
116116
};
117117
}

yarn.lock

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,13 @@
24522452
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.0.tgz#dc85454b953178cc6043df5208b9e949b54a3bc4"
24532453
integrity sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q==
24542454

2455+
"@types/prompts@^2.0.9":
2456+
version "2.0.9"
2457+
resolved "https://registry.yarnpkg.com/@types/prompts/-/prompts-2.0.9.tgz#19f419310eaa224a520476b19d4183f6a2b3bd8f"
2458+
integrity sha512-TORZP+FSjTYMWwKadftmqEn6bziN5RnfygehByGsjxoK5ydnClddtv6GikGWPvCm24oI+YBwck5WDxIIyNxUrA==
2459+
dependencies:
2460+
"@types/node" "*"
2461+
24552462
"@types/q@^1.5.1":
24562463
version "1.5.2"
24572464
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8"
@@ -2716,7 +2723,7 @@ ansi-colors@^4.1.1:
27162723
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
27172724
integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
27182725

2719-
ansi-escapes@^3.0.0, ansi-escapes@^3.2.0:
2726+
ansi-escapes@^3.2.0:
27202727
version "3.2.0"
27212728
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
27222729
integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==
@@ -3629,11 +3636,6 @@ char-regex@^1.0.2:
36293636
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
36303637
integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==
36313638

3632-
chardet@^0.4.0:
3633-
version "0.4.2"
3634-
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
3635-
integrity sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=
3636-
36373639
chardet@^0.7.0:
36383640
version "0.7.0"
36393641
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
@@ -5354,15 +5356,6 @@ extend@~3.0.2:
53545356
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa"
53555357
integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==
53565358

5357-
external-editor@^2.0.4:
5358-
version "2.2.0"
5359-
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5"
5360-
integrity sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==
5361-
dependencies:
5362-
chardet "^0.4.0"
5363-
iconv-lite "^0.4.17"
5364-
tmp "^0.0.33"
5365-
53665359
external-editor@^3.0.3:
53675360
version "3.1.0"
53685361
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495"
@@ -6181,7 +6174,7 @@ [email protected]:
61816174
resolved "https://registry.yarnpkg.com/i/-/i-0.3.6.tgz#d96c92732076f072711b6b10fd7d4f65ad8ee23d"
61826175
integrity sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=
61836176

6184-
[email protected], iconv-lite@^0.4.17, iconv-lite@^0.4.24, iconv-lite@~0.4.13:
6177+
[email protected], iconv-lite@^0.4.24, iconv-lite@~0.4.13:
61856178
version "0.4.24"
61866179
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
61876180
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
@@ -6334,26 +6327,6 @@ init-package-json@^1.10.3:
63346327
validate-npm-package-license "^3.0.1"
63356328
validate-npm-package-name "^3.0.0"
63366329

6337-
inquirer@^3.0.6:
6338-
version "3.3.0"
6339-
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9"
6340-
integrity sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==
6341-
dependencies:
6342-
ansi-escapes "^3.0.0"
6343-
chalk "^2.0.0"
6344-
cli-cursor "^2.1.0"
6345-
cli-width "^2.0.0"
6346-
external-editor "^2.0.4"
6347-
figures "^2.0.0"
6348-
lodash "^4.3.0"
6349-
mute-stream "0.0.7"
6350-
run-async "^2.2.0"
6351-
rx-lite "^4.0.8"
6352-
rx-lite-aggregates "^4.0.8"
6353-
string-width "^2.1.0"
6354-
strip-ansi "^4.0.0"
6355-
through "^2.3.6"
6356-
63576330
inquirer@^6.2.0:
63586331
version "6.5.2"
63596332
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca"
@@ -7796,11 +7769,21 @@ lodash.uniq@^4.5.0:
77967769
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
77977770
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
77987771

7799-
lodash@^4.17.10, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0:
7772+
lodash@^4.17.10, lodash@^4.2.1:
7773+
version "4.17.13"
7774+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93"
7775+
integrity sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA==
7776+
7777+
lodash@^4.17.12, lodash@^4.17.19:
78007778
version "4.17.20"
78017779
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
78027780
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
78037781

7782+
lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4:
7783+
version "4.17.15"
7784+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
7785+
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
7786+
78047787
log-symbols@^2.2.0:
78057788
version "2.2.0"
78067789
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"
@@ -9935,6 +9918,14 @@ prompts@^2.0.1:
99359918
kleur "^3.0.3"
99369919
sisteransi "^1.0.4"
99379920

9921+
prompts@^2.4.0:
9922+
version "2.4.0"
9923+
resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.0.tgz#4aa5de0723a231d1ee9121c40fdf663df73f61d7"
9924+
integrity sha512-awZAKrk3vN6CroQukBL+R9051a4R3zCZBlJm/HBfrSZ8iTpYix3VX1vU4mveiLpiwmOJT4wokTF9m6HUk4KqWQ==
9925+
dependencies:
9926+
kleur "^3.0.3"
9927+
sisteransi "^1.0.5"
9928+
99389929
promzard@^0.3.0:
99399930
version "0.3.0"
99409931
resolved "https://registry.yarnpkg.com/promzard/-/promzard-0.3.0.tgz#26a5d6ee8c7dee4cb12208305acfb93ba382a9ee"
@@ -10586,18 +10577,6 @@ run-queue@^1.0.0, run-queue@^1.0.3:
1058610577
dependencies:
1058710578
aproba "^1.1.1"
1058810579

10589-
rx-lite-aggregates@^4.0.8:
10590-
version "4.0.8"
10591-
resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be"
10592-
integrity sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=
10593-
dependencies:
10594-
rx-lite "*"
10595-
10596-
rx-lite@*, rx-lite@^4.0.8:
10597-
version "4.0.8"
10598-
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444"
10599-
integrity sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=
10600-
1060110580
rxjs@^6.4.0:
1060210581
version "6.5.4"
1060310582
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c"
@@ -10838,6 +10817,11 @@ sisteransi@^1.0.4:
1083810817
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.4.tgz#386713f1ef688c7c0304dc4c0632898941cad2e3"
1083910818
integrity sha512-/ekMoM4NJ59ivGSfKapeG+FWtrmWvA1p6FBZwXrqojw90vJu8lBmrTxCMuBCydKtkaUe2zt4PlxeTKpjwMbyig==
1084010819

10820+
sisteransi@^1.0.5:
10821+
version "1.0.5"
10822+
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
10823+
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
10824+
1084110825
slash@^2.0.0:
1084210826
version "2.0.0"
1084310827
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"

0 commit comments

Comments
 (0)