Skip to content

Commit

Permalink
Chore: Remove cli-spinners as a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Sep 15, 2024
1 parent c17cd67 commit 826ff4a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions packages/core/core.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { describe, it, expect, vi } from 'vitest';
import { render } from '@inquirer/testing';
import stripAnsi from 'strip-ansi';
import ansiEscapes from 'ansi-escapes';
import spinners from 'cli-spinners';
import {
createPrompt,
useEffect,
Expand Down Expand Up @@ -368,8 +367,8 @@ describe('createPrompt()', () => {
it('usePrefix() renders loader and prefix', async () => {
vi.useFakeTimers();
const delay = 300;
const { interval } = spinners.dots;
const totalDuration = interval * spinners.dots.frames.length;
let totalDuration = 0;
let interval = 0;

const Prompt = (config: { message: string }, done: (value: string) => void) => {
const theme = makeTheme({
Expand All @@ -381,6 +380,9 @@ describe('createPrompt()', () => {
const [status, setStatus] = useState<Status>('loading');
const prefix = usePrefix({ status, theme });

interval = theme.spinner.interval;
totalDuration = interval * theme.spinner.frames.length;

useEffect(() => {
setTimeout(
AsyncResource.bind(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@types/node": "^22.5.5",
"@types/wrap-ansi": "^3.0.0",
"ansi-escapes": "^4.3.2",
"cli-spinners": "^2.9.2",
"cli-width": "^4.1.0",
"mute-stream": "^1.0.0",
"signal-exit": "^4.1.0",
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/lib/theme.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import colors from 'yoctocolors-cjs';
import spinners from 'cli-spinners';
import figures from '@inquirer/figures';
import type { Prettify } from '@inquirer/type';

Expand Down Expand Up @@ -34,6 +33,8 @@ type DefaultTheme = {
/**
* Configuration for the spinner that is displayed when the prompt is in the
* `'loading'` state.
*
* We recommend the use of {@link https://github.com/sindresorhus/cli-spinners|cli-spinners} for a list of available spinners.
*/
spinner: {
/**
Expand Down Expand Up @@ -170,8 +171,10 @@ export const defaultTheme: DefaultTheme = {
done: colors.green(figures.tick),
},
spinner: {
interval: spinners.dots.interval,
frames: spinners.dots.frames.map((frame) => colors.yellow(frame)),
interval: 80,
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'].map((frame) =>
colors.yellow(frame),
),
},
style: {
answer: colors.cyan,
Expand Down
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ __metadata:
"@types/node": "npm:^22.5.5"
"@types/wrap-ansi": "npm:^3.0.0"
ansi-escapes: "npm:^4.3.2"
cli-spinners: "npm:^2.9.2"
cli-width: "npm:^4.1.0"
mute-stream: "npm:^1.0.0"
signal-exit: "npm:^4.1.0"
Expand Down Expand Up @@ -2616,7 +2615,7 @@ __metadata:
languageName: node
linkType: hard

"cli-spinners@npm:^2.5.0, cli-spinners@npm:^2.9.2":
"cli-spinners@npm:^2.5.0":
version: 2.9.2
resolution: "cli-spinners@npm:2.9.2"
checksum: 10/a0a863f442df35ed7294424f5491fa1756bd8d2e4ff0c8736531d886cec0ece4d85e8663b77a5afaf1d296e3cbbebff92e2e99f52bbea89b667cbe789b994794
Expand Down

0 comments on commit 826ff4a

Please sign in to comment.