···11import * as p from '@clack/prompts';
22-import color from 'picocolors';
22+import { styleText } from 'node:util';
3344/**
55 * Example demonstrating the integrated autocomplete multiselect component
···99async function main() {
1010 console.clear();
11111212- p.intro(`${color.bgCyan(color.black(' Integrated Autocomplete Multiselect Example '))}`);
1212+ p.intro(`${styleText('bgCyan', styleText('black', ' Integrated Autocomplete Multiselect Example '))}`);
13131414 p.note(
1515 `
1616-${color.cyan('Filter and select multiple items in a single interface:')}
1717-- ${color.yellow('Type')} to filter the list in real-time
1818-- Use ${color.yellow('up/down arrows')} to navigate with improved stability
1919-- Press ${color.yellow('Space')} to select/deselect the highlighted item ${color.green('(multiple selections allowed)')}
2020-- Use ${color.yellow('Backspace')} to modify your filter text when searching for different options
2121-- Press ${color.yellow('Enter')} when done selecting all items
2222-- Press ${color.yellow('Ctrl+C')} to cancel
1616+${styleText('cyan', 'Filter and select multiple items in a single interface:')}
1717+- ${styleText('yellow', 'Type')} to filter the list in real-time
1818+- Use ${styleText('yellow', 'up/down arrows')} to navigate with improved stability
1919+- Press ${styleText('yellow', 'Space')} to select/deselect the highlighted item ${styleText('green', '(multiple selections allowed)')}
2020+- Use ${styleText('yellow', 'Backspace')} to modify your filter text when searching for different options
2121+- Press ${styleText('yellow', 'Enter')} when done selecting all items
2222+- Press ${styleText('yellow', 'Ctrl+C')} to cancel
2323 `,
2424 'Instructions'
2525 );
···79798080 // Display selected frameworks with detailed information
8181 p.note(
8282- `You selected ${color.green(selectedFrameworks.length)} frameworks:`,
8282+ `You selected ${styleText('green', `${selectedFrameworks.length}`)} frameworks:`,
8383 'Selection Complete'
8484 );
8585···8888 .map((value) => {
8989 const framework = frameworks.find((f) => f.value === value);
9090 return framework
9191- ? `${color.cyan(framework.label)} ${color.dim(`- ${framework.hint}`)}`
9191+ ? `${styleText('cyan', framework.label)} ${styleText('dim', `- ${framework.hint}`)}`
9292 : value;
9393 })
9494 .join('\n');
95959696 p.log.message(selectedDetails);
9797- p.outro(`Successfully selected ${color.green(selectedFrameworks.length)} frameworks.`);
9797+ p.outro(`Successfully selected ${styleText('green', `${selectedFrameworks.length}`)} frameworks.`);
9898}
9999100100main().catch(console.error);
+14-8
examples/basic/autocomplete.ts
···11import * as p from '@clack/prompts';
22-import color from 'picocolors';
22+import { styleText } from 'node:util';
3344async function main() {
55 console.clear();
6677- p.intro(`${color.bgCyan(color.black(' Autocomplete Example '))}`);
77+ p.intro(`${styleText('bgCyan', styleText('black', ' Autocomplete Example '))}`);
8899 p.note(
1010 `
1111-${color.cyan('This example demonstrates the type-ahead autocomplete feature:')}
1212-- ${color.yellow('Type')} to filter the list in real-time
1313-- Use ${color.yellow('up/down arrows')} to navigate the filtered results
1414-- Press ${color.yellow('Enter')} to select the highlighted option
1515-- Press ${color.yellow('Ctrl+C')} to cancel
1111+${styleText('cyan', 'This example demonstrates the type-ahead autocomplete feature:')}
1212+- ${styleText('yellow', 'Type')} to filter the list in real-time
1313+- Use ${styleText('yellow', 'up/down arrows')} to navigate the filtered results
1414+- Press ${styleText('yellow', 'Enter')} to select the highlighted option
1515+- Press ${styleText('yellow', 'Ctrl+C')} to cancel
1616 `,
1717 'Instructions'
1818 );
···5353 }
54545555 const selected = countries.find((c) => c.value === result);
5656- p.outro(`You selected: ${color.cyan(selected?.label)} (${color.yellow(selected?.hint)})`);
5656+5757+ if (!selected) {
5858+ p.outro('No country selected.');
5959+ process.exit(1);
6060+ }
6161+6262+ p.outro(`You selected: ${styleText('cyan', selected?.label)} (${styleText('yellow', selected?.hint)})`);
5763}
58645965main().catch(console.error);
+2-2
examples/basic/default-value.ts
···11import * as p from '@clack/prompts';
22-import color from 'picocolors';
22+import { styleText } from 'node:util';
3344async function main() {
55 const defaultPath = 'my-project';
···2424 process.exit(0);
2525 }
26262727- p.outro(`Let's bootstrap the project in ${color.cyan(result)}`);
2727+ p.outro(`Let's bootstrap the project in ${styleText('cyan', result)}`);
2828}
29293030main().catch(console.error);
+3-3
examples/basic/index.ts
···11import { setTimeout } from 'node:timers/promises';
22import * as p from '@clack/prompts';
33-import color from 'picocolors';
33+import { styleText } from 'node:util';
4455async function main() {
66 console.clear();
···1616 },
1717 });
18181919- p.intro(`${color.bgCyan(color.black(' create-app '))}`);
1919+ p.intro(`${styleText('bgCyan', styleText('black', ' create-app '))}`);
20202121 const project = await p.group(
2222 {
···87878888 p.note(nextSteps, 'Next steps.');
89899090- p.outro(`Problems? ${color.underline(color.cyan('https://example.com/issues'))}`);
9090+ p.outro(`Problems? ${styleText('underline', styleText('cyan', 'https://example.com/issues'))}`);
9191}
92929393main().catch(console.error);
···1414const s = p.spinner();
1515let progress = 0;
1616let counter = 0;
1717-let loop: NodeJS.Timer;
1717+let loop: NodeJS.Timeout;
18181919p.intro('Running spinner in CI environment');
2020s.start('spinner.start');
+3-3
examples/basic/stream.ts
···11import { setTimeout } from 'node:timers/promises';
22import * as p from '@clack/prompts';
33-import color from 'picocolors';
33+import { styleText } from 'node:util';
4455async function main() {
66 console.clear();
7788 await setTimeout(1000);
991010- p.intro(`${color.bgCyan(color.black(' create-app '))}`);
1010+ p.intro(`${styleText('bgCyan', styleText('black', ' create-app '))}`);
11111212 await p.stream.step(
1313 (async function* () {
···2525 })()
2626 );
27272828- p.outro(`Problems? ${color.underline(color.cyan('https://example.com/issues'))}`);
2828+ p.outro(`Problems? ${styleText('underline', styleText('cyan', 'https://example.com/issues'))}`);
2929}
30303131const lorem = [
+2
examples/basic/text-validation.ts
···99 message: 'Enter your name (letters and spaces only)',
1010 initialValue: 'John123', // Invalid initial value with numbers
1111 validate: (value) => {
1212+ if (!value) return 'Name is required';
1213 if (!/^[a-zA-Z\s]+$/.test(value)) return 'Name can only contain letters and spaces';
1314 return undefined;
1415 },
···2526 message: 'Enter another name (letters and spaces only)',
2627 initialValue: 'John Doe', // Valid initial value
2728 validate: (value) => {
2929+ if (!value) return 'Name is required';
2830 if (!/^[a-zA-Z\s]+$/.test(value)) return 'Name can only contain letters and spaces';
2931 return undefined;
3032 },
+7-7
examples/changesets/index.ts
···11import { setTimeout } from 'node:timers/promises';
22import * as p from '@clack/prompts';
33-import color from 'picocolors';
33+import { styleText } from 'node:util';
4455function onCancel() {
66 p.cancel('Operation cancelled.');
···12121313 await setTimeout(1000);
14141515- p.intro(`${color.bgCyan(color.black(' changesets '))}`);
1515+ p.intro(`${styleText('bgCyan', styleText('black', ' changesets '))}`);
16161717 const changeset = await p.group(
1818 {
···3535 major: ({ results }) => {
3636 const packages = results.packages ?? [];
3737 return p.multiselect({
3838- message: `Which packages should have a ${color.red('major')} bump?`,
3838+ message: `Which packages should have a ${styleText('red', 'major')} bump?`,
3939 options: packages.map((value) => ({ value })),
4040 required: false,
4141 });
···4646 const possiblePackages = packages.filter((pkg) => !major.includes(pkg));
4747 if (possiblePackages.length === 0) return;
4848 return p.multiselect({
4949- message: `Which packages should have a ${color.yellow('minor')} bump?`,
4949+ message: `Which packages should have a ${styleText('yellow', 'minor')} bump?`,
5050 options: possiblePackages.map((value) => ({ value })),
5151 required: false,
5252 });
···5959 (pkg) => !major.includes(pkg) && !minor.includes(pkg)
6060 );
6161 if (possiblePackages.length === 0) return;
6262- const note = possiblePackages.join(color.dim(', '));
6262+ const note = possiblePackages.join(styleText('dim', ', '));
63636464- p.log.step(`These packages will have a ${color.green('patch')} bump.\n${color.dim(note)}`);
6464+ p.log.step(`These packages will have a ${styleText('green', 'patch')} bump.\n${styleText('dim', note)}`);
6565 return possiblePackages;
6666 },
6767 },
···7979 return onCancel();
8080 }
81818282- p.outro(`Changeset added! ${color.underline(color.cyan('.changeset/orange-crabs-sing.md'))}`);
8282+ p.outro(`Changeset added! ${styleText('underline', styleText('cyan', '.changeset/orange-crabs-sing.md'))}`);
8383}
84848585main().catch(console.error);
···11-import color from 'picocolors';
11+import { styleText } from 'node:util';
22import Prompt, { type PromptOptions } from './prompt.js';
3344interface TextOptions extends PromptOptions<string, TextPrompt> {
···1717 }
1818 const s1 = userInput.slice(0, this.cursor);
1919 const [s2, ...s3] = userInput.slice(this.cursor);
2020- return `${s1}${color.inverse(s2)}${s3.join('')}`;
2020+ return `${s1}${styleText(['inverse'], s2)}${s3.join('')}`;
2121 }
2222 get cursor() {
2323 return this._cursor;
-1
packages/core/test/prompts/confirm.test.ts
···11-import color from 'picocolors';
21import { cursor } from 'sisteransi';
32import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
43import { default as ConfirmPrompt } from '../../src/prompts/confirm.js';
···11-import color from 'picocolors';
21import { cursor } from 'sisteransi';
32import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
43import { default as SelectPrompt } from '../../src/prompts/select.js';
+2-2
packages/core/test/prompts/text.test.ts
···11-import color from 'picocolors';
11+import { styleText } from "node:util"
22import { cursor } from 'sisteransi';
33import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
44import { default as TextPrompt } from '../../src/prompts/text.js';
···9393 input.emit('keypress', keys[i], { name: keys[i] });
9494 }
9595 input.emit('keypress', 'left', { name: 'left' });
9696- expect(instance.userInputWithCursor).to.equal(`fo${color.inverse('o')}`);
9696+ expect(instance.userInputWithCursor).to.equal(`fo${styleText('inverse', 'o')}`);
9797 });
98989999 test('shows cursor at end if beyond value', () => {