Skip to content

Commit

Permalink
replace prompt-confirm with enquirer
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed Sep 30, 2021
1 parent d3145a4 commit 5935180
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions packages/bottender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"deep-object-diff": "^1.1.0",
"delay": "^5.0.0",
"dotenv": "^10.0.0",
"enquirer": "^2.3.6",
"express": "^4.17.1",
"facebook-batch": "1.0.6",
"figures": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Confirm from 'prompt-confirm';
import { Confirm } from 'enquirer';
import { MessengerClient } from 'messaging-api-messenger';
import { mocked } from 'ts-jest/utils';

Expand All @@ -8,7 +8,9 @@ import { setWebhook } from '../webhook';
import * as log from '../../../../shared/log';

jest.mock('messaging-api-messenger');
jest.mock('prompt-confirm');
jest.mock('enquirer', () => ({
Confirm: jest.fn(),
}));

jest.mock('../../../../shared/getWebhookFromNgrok');
jest.mock('../../../../shared/log');
Expand Down
9 changes: 5 additions & 4 deletions packages/bottender/src/cli/providers/messenger/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Confirm from 'prompt-confirm';
import Table from 'cli-table3';
import chalk from 'chalk';
import invariant from 'invariant';
import { Confirm } from 'enquirer';
import { MessengerClient } from 'messaging-api-messenger';

import getChannelConfig from '../../../shared/getChannelConfig';
Expand Down Expand Up @@ -80,9 +80,10 @@ export async function setWebhook(ctx: CliContext): Promise<void> {

if (!webhook) {
warn('We can not find the webhook callback URL you provided.');
const prompt = new Confirm(
`Are you using ngrok (get URL from ngrok server on http://127.0.0.1:${ngrokPort})?`
);
const prompt = new Confirm({
name: 'question',
message: `Are you using ngrok (get URL from ngrok server on http://127.0.0.1:${ngrokPort})?`,
});
const result = await prompt.run();
if (result) {
webhook = `${await getWebhookFromNgrok(ngrokPort)}${path}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Confirm from 'prompt-confirm';
import { Confirm } from 'enquirer';
import { TelegramClient } from 'messaging-api-telegram';
import { mocked } from 'ts-jest/utils';

Expand All @@ -8,7 +8,9 @@ import { setWebhook } from '../webhook';
import * as log from '../../../../shared/log';

jest.mock('messaging-api-telegram');
jest.mock('prompt-confirm');
jest.mock('enquirer', () => ({
Confirm: jest.fn(),
}));

jest.mock('../../../../shared/getWebhookFromNgrok');
jest.mock('../../../../shared/log');
Expand Down
9 changes: 5 additions & 4 deletions packages/bottender/src/cli/providers/telegram/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Confirm from 'prompt-confirm';
import invariant from 'invariant';
import { Confirm } from 'enquirer';
import { TelegramClient } from 'messaging-api-telegram';

import getChannelConfig from '../../../shared/getChannelConfig';
Expand Down Expand Up @@ -71,9 +71,10 @@ export async function setWebhook(ctx: CliContext): Promise<void> {

if (!webhook) {
warn('We can not find the webhook callback URL you provided.');
const prompt = new Confirm(
`Are you using ngrok (get URL from ngrok server on http://127.0.0.1:${ngrokPort})?`
);
const prompt = new Confirm({
name: 'question',
message: `Are you using ngrok (get URL from ngrok server on http://127.0.0.1:${ngrokPort})?`,
});
const result = await prompt.run();
if (result) {
webhook = `${await getWebhookFromNgrok(ngrokPort)}${path}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Confirm from 'prompt-confirm';
import { Confirm } from 'enquirer';
import { ViberClient } from 'messaging-api-viber';
import { mocked } from 'ts-jest/utils';

Expand All @@ -8,7 +8,9 @@ import { setWebhook } from '../webhook';
import * as log from '../../../../shared/log';

jest.mock('messaging-api-viber');
jest.mock('prompt-confirm');
jest.mock('enquirer', () => ({
Confirm: jest.fn(),
}));

jest.mock('../../../../shared/getWebhookFromNgrok');
jest.mock('../../../../shared/log');
Expand Down
9 changes: 5 additions & 4 deletions packages/bottender/src/cli/providers/viber/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Confirm from 'prompt-confirm';
import invariant from 'invariant';
import { Confirm } from 'enquirer';
import { ViberClient, ViberTypes } from 'messaging-api-viber';

import getChannelConfig from '../../../shared/getChannelConfig';
Expand Down Expand Up @@ -50,9 +50,10 @@ export async function setWebhook(ctx: CliContext): Promise<void> {
if (!webhook) {
warn('We can not find the webhook callback URL you provided.');

const prompt = new Confirm(
`Are you using ngrok (get URL from ngrok server on http://127.0.0.1:${ngrokPort})?`
);
const prompt = new Confirm({
name: 'question',
message: `Are you using ngrok (get URL from ngrok server on http://127.0.0.1:${ngrokPort})?`,
});

const result = await prompt.run();

Expand Down
1 change: 1 addition & 0 deletions types/enquirer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'enquirer';
1 change: 0 additions & 1 deletion types/prompt-confirm.d.ts

This file was deleted.

0 comments on commit 5935180

Please sign in to comment.