From 595d75519487690f72d381dc32d74837b1d4c5b5 Mon Sep 17 00:00:00 2001 From: Simon Boudrias Date: Tue, 25 Jun 2024 17:10:19 -0400 Subject: [PATCH] Chore(inquirer): Drop cli-cursor dependency --- packages/inquirer/lib/prompts/checkbox.js | 6 +++--- packages/inquirer/lib/prompts/list.js | 5 ++--- packages/inquirer/lib/utils/screen-manager.js | 3 ++- packages/inquirer/package.json | 1 - yarn.lock | 1 - 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/inquirer/lib/prompts/checkbox.js b/packages/inquirer/lib/prompts/checkbox.js index bf292c6a0..2e7c77ef2 100644 --- a/packages/inquirer/lib/prompts/checkbox.js +++ b/packages/inquirer/lib/prompts/checkbox.js @@ -2,8 +2,8 @@ * `list` type prompt */ +import ansiEscapes from 'ansi-escapes'; import chalk from 'chalk'; -import cliCursor from 'cli-cursor'; import figures from '@inquirer/figures'; import { map, takeUntil } from 'rxjs'; import observe from '../utils/events.js'; @@ -69,7 +69,6 @@ export default class CheckboxPrompt extends Base { events.iKey.pipe(takeUntil(validation.success)).forEach(this.onInverseKey.bind(this)); // Init the prompt - cliCursor.hide(); this.render(); this.firstRender = false; @@ -136,6 +135,8 @@ export default class CheckboxPrompt extends Base { bottomContent = chalk.red('>> ') + error; } + message += ansiEscapes.cursorHide; + this.screen.render(message, bottomContent); } @@ -150,7 +151,6 @@ export default class CheckboxPrompt extends Base { this.render(); this.screen.done(); - cliCursor.show(); this.done(state.value); } diff --git a/packages/inquirer/lib/prompts/list.js b/packages/inquirer/lib/prompts/list.js index eebe91d31..17eb2e957 100644 --- a/packages/inquirer/lib/prompts/list.js +++ b/packages/inquirer/lib/prompts/list.js @@ -2,9 +2,9 @@ * `list` type prompt */ +import ansiEscapes from 'ansi-escapes'; import chalk from 'chalk'; import figures from '@inquirer/figures'; -import cliCursor from 'cli-cursor'; import runAsync from 'run-async'; import { flatMap, map, take, takeUntil } from 'rxjs'; import observe from '../utils/events.js'; @@ -66,7 +66,6 @@ export default class ListPrompt extends Base { .forEach(this.onSubmit.bind(this)); // Init the prompt - cliCursor.hide(); this.render(); return this; @@ -118,6 +117,7 @@ export default class ListPrompt extends Base { '\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize); } + message += ansiEscapes.cursorHide; this.firstRender = false; this.screen.render(message); @@ -134,7 +134,6 @@ export default class ListPrompt extends Base { this.render(); this.screen.done(); - cliCursor.show(); this.done(value); } diff --git a/packages/inquirer/lib/utils/screen-manager.js b/packages/inquirer/lib/utils/screen-manager.js index ad11b2138..4fac13848 100644 --- a/packages/inquirer/lib/utils/screen-manager.js +++ b/packages/inquirer/lib/utils/screen-manager.js @@ -1,3 +1,4 @@ +import ansiEscapes from 'ansi-escapes'; import cliWidth from 'cli-width'; import wrapAnsi from 'wrap-ansi'; import stripAnsi from 'strip-ansi'; @@ -131,7 +132,7 @@ export default class ScreenManager { done() { this.rl.setPrompt(''); this.rl.output.unmute(); - this.rl.output.write('\n'); + this.rl.output.write(`\n${ansiEscapes.cursorShow}`); } releaseCursor() { diff --git a/packages/inquirer/package.json b/packages/inquirer/package.json index d556df1fe..bf1e18a63 100644 --- a/packages/inquirer/package.json +++ b/packages/inquirer/package.json @@ -63,7 +63,6 @@ "@ljharb/through": "^2.3.13", "ansi-escapes": "^4.3.2", "chalk": "^5.3.0", - "cli-cursor": "^3.1.0", "cli-width": "^4.1.0", "external-editor": "^3.1.0", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index 1c5882869..625d5dd5a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4343,7 +4343,6 @@ __metadata: "@ljharb/through": "npm:^2.3.13" ansi-escapes: "npm:^4.3.2" chalk: "npm:^5.3.0" - cli-cursor: "npm:^3.1.0" cli-width: "npm:^4.1.0" external-editor: "npm:^3.1.0" lodash: "npm:^4.17.21"