Skip to content

Commit f17f349

Browse files
committed
Chore: Bump dependencies (and Prettier 3 formatting)
1 parent 4c139f5 commit f17f349

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+476
-376
lines changed

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,27 @@
4848
"devDependencies": {
4949
"@sindresorhus/tsconfig": "^3.0.1",
5050
"@types/mute-stream": "^0.0.1",
51-
"@types/node": "^20.3.3",
51+
"@types/node": "^20.4.1",
5252
"@types/prettier": "^2.7.3",
5353
"@types/wrap-ansi": "^3.0.0",
54-
"@typescript-eslint/eslint-plugin": "^5.60.1",
55-
"@typescript-eslint/parser": "^5.60.1",
56-
"@vitest/coverage-v8": "^0.32.2",
57-
"@vitest/ui": "^0.32.2",
54+
"@typescript-eslint/eslint-plugin": "^6.0.0",
55+
"@typescript-eslint/parser": "^6.0.0",
56+
"@vitest/coverage-v8": "^0.33.0",
57+
"@vitest/ui": "^0.33.0",
5858
"eslint": "^8.44.0",
5959
"eslint-config-prettier": "^8.8.0",
6060
"eslint-config-xo": "^0.43.1",
6161
"eslint-plugin-n": "^16.0.1",
62-
"eslint-plugin-prettier": "^4.2.1",
62+
"eslint-plugin-prettier": "^5.0.0",
6363
"eslint-plugin-unicorn": "^47.0.0",
64-
"globby": "^13.2.1",
64+
"globby": "^13.2.2",
6565
"husky": "^8.0.3",
6666
"lerna": "^7.1.1",
6767
"lint-staged": "^13.2.3",
68-
"prettier": "^2.8.8",
68+
"prettier": "^3.0.0",
6969
"ts-node": "^10.9.1",
7070
"typescript": "^5.1.6",
71-
"vitest": "^0.32.2"
71+
"vitest": "^0.33.0"
7272
},
7373
"workspaces": [
7474
"packages/*",

packages/checkbox/src/index.mts

+14-14
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ type Config<Value> = {
3434
};
3535

3636
function isSelectableChoice<T>(
37-
choice: undefined | Separator | Choice<T>
37+
choice: undefined | Separator | Choice<T>,
3838
): choice is Choice<T> {
3939
return choice != null && !Separator.isSeparator(choice) && !choice.disabled;
4040
}
4141

4242
export default createPrompt(
4343
<Value extends unknown>(
4444
config: Config<Value>,
45-
done: (value: Array<Value>) => void
45+
done: (value: Array<Value>) => void,
4646
): string => {
4747
const { prefix = usePrefix(), instructions } = config;
4848
const paginator = useRef(new Paginator()).current;
4949

5050
const [status, setStatus] = useState('pending');
5151
const [choices, setChoices] = useState<Array<Separator | Choice<Value>>>(() =>
52-
config.choices.map((choice) => ({ ...choice }))
52+
config.choices.map((choice) => ({ ...choice })),
5353
);
5454
const [cursorPosition, setCursorPosition] = useState(0);
5555
const [showHelpTip, setShowHelpTip] = useState(true);
@@ -61,7 +61,7 @@ export default createPrompt(
6161
done(
6262
choices
6363
.filter((choice) => isSelectableChoice(choice) && choice.checked)
64-
.map((choice) => (choice as Choice<Value>).value)
64+
.map((choice) => (choice as Choice<Value>).value),
6565
);
6666
} else if (isUpKey(key) || isDownKey(key)) {
6767
const offset = isUpKey(key) ? -1 : 1;
@@ -83,22 +83,22 @@ export default createPrompt(
8383
}
8484

8585
return choice;
86-
})
86+
}),
8787
);
8888
} else if (key.name === 'a') {
8989
const selectAll = Boolean(
90-
choices.find((choice) => isSelectableChoice(choice) && !choice.checked)
90+
choices.find((choice) => isSelectableChoice(choice) && !choice.checked),
9191
);
9292
setChoices(
9393
choices.map((choice) =>
94-
isSelectableChoice(choice) ? { ...choice, checked: selectAll } : choice
95-
)
94+
isSelectableChoice(choice) ? { ...choice, checked: selectAll } : choice,
95+
),
9696
);
9797
} else if (key.name === 'i') {
9898
setChoices(
9999
choices.map((choice) =>
100-
isSelectableChoice(choice) ? { ...choice, checked: !choice.checked } : choice
101-
)
100+
isSelectableChoice(choice) ? { ...choice, checked: !choice.checked } : choice,
101+
),
102102
);
103103
} else if (isNumberKey(key)) {
104104
// Adjust index to start at 1
@@ -117,7 +117,7 @@ export default createPrompt(
117117
}
118118

119119
return choice;
120-
})
120+
}),
121121
);
122122
}
123123
});
@@ -128,7 +128,7 @@ export default createPrompt(
128128
const selection = choices
129129
.filter((choice) => isSelectableChoice(choice) && choice.checked)
130130
.map(
131-
(choice) => (choice as Choice<Value>).name || (choice as Choice<Value>).value
131+
(choice) => (choice as Choice<Value>).name || (choice as Choice<Value>).value,
132132
);
133133
return `${prefix} ${message} ${chalk.cyan(selection.join(', '))}`;
134134
}
@@ -175,10 +175,10 @@ export default createPrompt(
175175
const windowedChoices = paginator.paginate(
176176
allChoices,
177177
cursorPosition,
178-
config.pageSize
178+
config.pageSize,
179179
);
180180
return `${prefix} ${message}${helpTip}\n${windowedChoices}${ansiEscapes.cursorHide}`;
181-
}
181+
},
182182
);
183183

184184
export { Separator };

packages/core/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const confirm = createPrompt<boolean, { message: string; default?: boolean }>(
5151

5252
const message = chalk.bold(config.message);
5353
return `${prefix} ${message}${defaultValue} ${formattedValue}`;
54-
}
54+
},
5555
);
5656

5757
/**

packages/core/core.test.mts

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('createPrompt()', () => {
2828
const { answer } = await renderingDone;
2929
expect(viewFunction).toHaveBeenLastCalledWith(
3030
expect.objectContaining({ message: 'Async message:' }),
31-
expect.any(Function)
31+
expect.any(Function),
3232
);
3333

3434
answer.cancel();
@@ -47,7 +47,7 @@ describe('createPrompt()', () => {
4747
const { answer } = await renderingDone;
4848
expect(viewFunction).toHaveBeenLastCalledWith(
4949
expect.objectContaining({ message: 'Async message:' }),
50-
expect.any(Function)
50+
expect.any(Function),
5151
);
5252

5353
answer.cancel();
@@ -311,7 +311,7 @@ describe('createPrompt()', () => {
311311
events.keypress('enter');
312312

313313
await expect(answer).rejects.toThrowErrorMatchingInlineSnapshot(
314-
'"Prompt was canceled"'
314+
'"Prompt was canceled"',
315315
);
316316
});
317317

@@ -330,7 +330,7 @@ describe('createPrompt()', () => {
330330
const { answer, events, getScreen } = await render(
331331
prompt,
332332
{ message: 'Question' },
333-
{ clearPromptOnDone: true }
333+
{ clearPromptOnDone: true },
334334
);
335335

336336
expect(getScreen()).toMatchInlineSnapshot('"Question"');
@@ -360,7 +360,7 @@ it('allow cancelling the prompt multiple times', async () => {
360360
events.keypress('enter');
361361

362362
await expect(answer).rejects.toThrowErrorMatchingInlineSnapshot(
363-
'"Prompt was canceled"'
363+
'"Prompt was canceled"',
364364
);
365365
});
366366

@@ -441,7 +441,7 @@ describe('Error handling', () => {
441441
const { answer } = await render(prompt, { message: 'Question' });
442442

443443
await expect(answer).rejects.toThrowErrorMatchingInlineSnapshot(
444-
'"useEffect return value must be a cleanup function or nothing."'
444+
'"useEffect return value must be a cleanup function or nothing."',
445445
);
446446
});
447447

@@ -466,12 +466,12 @@ describe('Error handling', () => {
466466
process.emit('SIGINT');
467467

468468
await expect(answer).rejects.toMatchInlineSnapshot(
469-
'[Error: User force closed the prompt with CTRL+C]'
469+
'[Error: User force closed the prompt with CTRL+C]',
470470
);
471471

472472
const output = getFullOutput();
473473
expect(output.lastIndexOf(ansiEscapes.cursorHide)).toBeLessThan(
474-
output.lastIndexOf(ansiEscapes.cursorShow)
474+
output.lastIndexOf(ansiEscapes.cursorShow),
475475
);
476476
});
477477
});
@@ -489,7 +489,7 @@ describe('Separator', () => {
489489

490490
it('renders separator', () => {
491491
expect(stripAnsi(new Separator().separator)).toMatchInlineSnapshot(
492-
'"──────────────"'
492+
'"──────────────"',
493493
);
494494
expect(new Separator('===').separator).toEqual('===');
495495
});

packages/core/src/index.mts

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function cleanupHook(index: number) {
4646
}
4747

4848
function mergeStateUpdates<T extends (...args: any) => any>(
49-
fn: T
49+
fn: T,
5050
): (...args: Parameters<T>) => ReturnType<T> {
5151
const wrapped = (...args: any): ReturnType<T> => {
5252
let shouldUpdate = false;
@@ -69,7 +69,7 @@ function mergeStateUpdates<T extends (...args: any) => any>(
6969
}
7070

7171
export function useState<Value>(
72-
defaultValue: NotFunction<Value> | (() => Value)
72+
defaultValue: NotFunction<Value> | (() => Value),
7373
): [Value, (newValue: Value) => void] {
7474
const _idx = index;
7575
index++;
@@ -98,7 +98,7 @@ export function useState<Value>(
9898

9999
export function useEffect(
100100
cb: (rl: InquirerReadline) => void | (() => void),
101-
depArray: unknown[]
101+
depArray: unknown[],
102102
): void {
103103
const rl = sessionRl;
104104

@@ -121,18 +121,18 @@ export function useEffect(
121121
const cleanFn = cb(rl);
122122
if (cleanFn != null && typeof cleanFn !== 'function') {
123123
throw new Error(
124-
'useEffect return value must be a cleanup function or nothing.'
124+
'useEffect return value must be a cleanup function or nothing.',
125125
);
126126
}
127127
hooksCleanup[_idx] = cleanFn;
128-
})
128+
}),
129129
);
130130
}
131131
hooks[_idx] = depArray;
132132
}
133133

134134
export function useKeypress(
135-
userHandler: (event: KeypressEvent, rl: InquirerReadline) => void
135+
userHandler: (event: KeypressEvent, rl: InquirerReadline) => void,
136136
) {
137137
const rl = sessionRl;
138138

@@ -169,13 +169,13 @@ export type ResolvedPromptConfig = {
169169
export function createPrompt<Value, Config extends AsyncPromptConfig>(
170170
view: (
171171
config: Config & ResolvedPromptConfig,
172-
done: (value: Value) => void
173-
) => string | [string, string | undefined]
172+
done: (value: Value) => void,
173+
) => string | [string, string | undefined],
174174
) {
175175
const prompt: Prompt<Value, Config> = (config, context) => {
176176
if (sessionRl) {
177177
throw new Error(
178-
'An inquirer prompt is already running.\nMake sure you await the result of the previous prompt before calling another prompt.'
178+
'An inquirer prompt is already running.\nMake sure you await the result of the previous prompt before calling another prompt.',
179179
);
180180
}
181181

packages/core/src/lib/Separator.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class Separator {
1717
}
1818

1919
static isSeparator(
20-
choice: undefined | Separator | Record<string, unknown>
20+
choice: undefined | Separator | Record<string, unknown>,
2121
): choice is Separator {
2222
return Boolean(choice && choice.type === 'separator');
2323
}

packages/core/src/lib/options.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AsyncPromptConfig, ResolvedPromptConfig } from '../index.mjs';
22

33
export async function getPromptConfig<In extends AsyncPromptConfig>(
4-
option: In
4+
option: In,
55
): Promise<In & ResolvedPromptConfig> {
66
const message =
77
typeof option.message === 'function' ? option.message() : option.message;

packages/core/src/lib/screen-manager.mts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class ScreenManager {
9090
? ansiEscapes.cursorDown(this.extraLinesUnderPrompt)
9191
: '',
9292
ansiEscapes.eraseLines(this.height),
93-
].join('')
93+
].join(''),
9494
);
9595

9696
this.extraLinesUnderPrompt = 0;
@@ -106,7 +106,7 @@ export default class ScreenManager {
106106
? ansiEscapes.cursorDown(this.extraLinesUnderPrompt)
107107
: '',
108108
'\n',
109-
].join('')
109+
].join(''),
110110
);
111111
this.rl.output.mute();
112112
}

packages/demo/demos/confirm.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ const demo = async () => {
66
'Answer:',
77
await confirm({
88
message: 'Confirm?',
9-
})
9+
}),
1010
);
1111

1212
console.log(
1313
'Answer:',
1414
await confirm({
1515
message: 'Confirm with default to no?',
1616
default: false,
17-
})
17+
}),
1818
);
1919

2020
console.log(
2121
'Answer:',
2222
await confirm({
2323
message: 'Confirm with your custom transformer function?',
2424
transformer: (answer) => (answer ? '👍' : '👎'),
25-
})
25+
}),
2626
);
2727

2828
console.log('This next prompt will be cleared on exit');
2929
console.log(
3030
'Cleared prompt answer:',
31-
await confirm({ message: 'Confirm?' }, { clearPromptOnDone: true })
31+
await confirm({ message: 'Confirm?' }, { clearPromptOnDone: true }),
3232
);
3333
};
3434

packages/demo/demos/editor.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const demo = async () => {
1313

1414
return true;
1515
},
16-
})
16+
}),
1717
);
1818

1919
console.log(
@@ -22,7 +22,7 @@ const demo = async () => {
2222
message: 'Automatically opened editor',
2323
default: '# This prompt was automatically opened. You can write anything:\n\n',
2424
waitForUseInput: false,
25-
})
25+
}),
2626
);
2727
};
2828

packages/demo/demos/input.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const demo = async () => {
3232
new Promise((resolve) => {
3333
setTimeout(
3434
() => resolve(!Number.isNaN(Number(value)) || 'You must provide a number'),
35-
3000
35+
3000,
3636
);
3737
}),
3838
});

packages/demo/demos/password.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const demo = async () => {
66
'Answer:',
77
await password({
88
message: 'Enter a silent password?',
9-
})
9+
}),
1010
);
1111

1212
console.log(
1313
'Answer:',
1414
await password({
1515
message: 'Enter a masked password?',
1616
mask: '*',
17-
})
17+
}),
1818
);
1919
};
2020

0 commit comments

Comments
 (0)