Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# macOS
.DS_Store

# Logs
Expand Down
6 changes: 0 additions & 6 deletions .vscode/extensions.json

This file was deleted.

36 changes: 0 additions & 36 deletions biome.json

This file was deleted.

17 changes: 0 additions & 17 deletions build.preset.ts

This file was deleted.

4 changes: 2 additions & 2 deletions examples/basic/autocomplete-multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ${color.cyan('Filter and select multiple items in a single interface:')}
- Press ${color.yellow('Enter')} when done selecting all items
- Press ${color.yellow('Ctrl+C')} to cancel
`,
'Instructions'
'Instructions',
);

// Frameworks in alphabetical order
Expand Down Expand Up @@ -80,7 +80,7 @@ ${color.cyan('Filter and select multiple items in a single interface:')}
// Display selected frameworks with detailed information
p.note(
`You selected ${color.green(selectedFrameworks.length)} frameworks:`,
'Selection Complete'
'Selection Complete',
);

// Show each selected framework with its details
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ${color.cyan('This example demonstrates the type-ahead autocomplete feature:')}
- Press ${color.yellow('Enter')} to select the highlighted option
- Press ${color.yellow('Ctrl+C')} to cancel
`,
'Instructions'
'Instructions',
);

const countries = [
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function main() {
p.cancel('Operation cancelled.');
process.exit(0);
},
}
},
);

if (project.install) {
Expand Down
14 changes: 7 additions & 7 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{
"name": "@example/basic",
"private": true,
"version": "0.0.0",
"type": "module",
"dependencies": {
"@clack/prompts": "workspace:*",
"arktype": "^2.2.0",
"picocolors": "^1.0.0",
"jiti": "^1.17.0"
},
"private": true,
"scripts": {
"start": "jiti ./index.ts",
"stream": "jiti ./stream.ts",
Expand All @@ -20,6 +14,12 @@
"spinner-timer": "jiti ./spinner-timer.ts",
"task-log": "jiti ./task-log.ts"
},
"dependencies": {
"@clack/prompts": "workspace:*",
"arktype": "^2.2.0",
"picocolors": "^1.0.0",
"jiti": "^1.17.0"
},
"devDependencies": {
"cross-env": "^7.0.3"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/spinner-cancel-advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function main() {
onCancel: () => {
p.note(
'You cancelled during processing. Any completed work will be saved.',
'Processing Cancelled'
'Processing Cancelled',
);
},
});
Expand Down Expand Up @@ -114,7 +114,7 @@ async function main() {
onCancel: () => {
p.note(
'Final operation was cancelled, but processing results are still valid.',
'Final Stage Cancelled'
'Final Stage Cancelled',
);
},
});
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function main() {
await setTimeout(1000);
}
}
})()
})(),
);

p.outro(`Problems? ${color.underline(color.cyan('https://example.com/issues'))}`);
Expand Down
4 changes: 2 additions & 2 deletions examples/changesets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function main() {
const major = Array.isArray(results.major) ? results.major : [];
const minor = Array.isArray(results.minor) ? results.minor : [];
const possiblePackages = packages.filter(
(pkg) => !major.includes(pkg) && !minor.includes(pkg)
(pkg) => !major.includes(pkg) && !minor.includes(pkg),
);
if (possiblePackages.length === 0) return;
const note = possiblePackages.join(color.dim(', '));
Expand All @@ -67,7 +67,7 @@ async function main() {
},
{
onCancel,
}
},
);

const message = await p.multiline({
Expand Down
13 changes: 6 additions & 7 deletions examples/changesets/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "@example/changesets",
"private": true,
"version": "0.0.0",
"type": "module",
"dependencies": {
"jiti": "^1.17.0",
"@clack/prompts": "workspace:*",
"picocolors": "^1.0.0"
},
"private": true,
"scripts": {
"start": "jiti ./index.ts"
},
"devDependencies": {}
"dependencies": {
"@clack/prompts": "workspace:*",
"jiti": "^1.17.0",
"picocolors": "^1.0.0"
}
}
3 changes: 0 additions & 3 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"workspaces": {
".": {
"ignore": ["build.preset.ts"]
},
"examples/*": {
"entry": "*.ts!",
"project": "*.ts"
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{
"name": "@clack/root",
"private": true,
"type": "module",
"private": true,
"scripts": {
"stub": "pnpm -r run build --stub",
"build": "pnpm --filter \"@clack/*\" run build",
"start": "pnpm run dev",
"dev": "pnpm --filter @example/changesets run start",
"format": "biome check --write",
"lint": "biome lint --write --unsafe",
"format": "bsh format",
Comment thread
mixto marked this conversation as resolved.
Resolved
"lint": "bsh lint",
"types": "tsc --noEmit",
"deps": "pnpm exec knip --production",
"test": "pnpm --color -r run test",
"test": "bsh test",
"pretest": "pnpm run build"
},
"devDependencies": {
"@biomejs/biome": "^2.5.12",
"@bomb.sh/tools": "^0.8.0",
"@changesets/changelog-github": "^0.7.0",
"@changesets/cli": "^2.31.0",
"@types/node": "^20.19.39",
"jsr": "^0.13.4",
"knip": "^5.62.0",
"typescript": "^6.0.3",
"unbuild": "^3.6.0"
"@changesets/cli": "^2.31.1",
"@types/node": "^20.19.43",
"jsr": "^0.13.5",
"knip": "^6.44.1",
"typescript": "^6.0.3"
},
"packageManager": "pnpm@10.33.0",
"volta": {
Expand Down
7 changes: 0 additions & 7 deletions packages/core/build.config.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"node": ">= 20.12.0"
},
"scripts": {
"build": "unbuild",
"build": "bsh build",
"prepack": "pnpm build",
"test": "vitest run"
"test": "bsh test"
},
"dependencies": {
"fast-string-width": "^3.0.2",
Expand All @@ -61,6 +61,6 @@
},
"devDependencies": {
"arktype": "^2.2.0",
"vitest": "^3.2.4"
"vitest": "^5.0.0"
}
}
10 changes: 6 additions & 4 deletions packages/core/src/prompts/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type FilterFunction<T extends OptionLike> = (search: string, opt: T) => boolean;

function getCursorForValue<T extends OptionLike>(
selected: T['value'] | undefined,
items: T[]
items: T[],
): number {
if (selected === undefined) {
return 0;
Expand Down Expand Up @@ -46,8 +46,10 @@ function normalisedValue<T>(multiple: boolean, values: T[] | undefined): T | T[]
return values[0];
}

export interface AutocompleteOptions<T extends OptionLike>
extends PromptOptions<T['value'] | T['value'][], AutocompletePrompt<T>> {
export interface AutocompleteOptions<T extends OptionLike> extends PromptOptions<
T['value'] | T['value'][],
AutocompletePrompt<T>
> {
options: T[] | ((this: AutocompletePrompt<T>) => T[]);
filter?: FilterFunction<T>;
multiple?: boolean;
Expand Down Expand Up @@ -170,7 +172,7 @@ export default class AutocompletePrompt<T extends OptionLike> extends Prompt<
placeholder !== undefined &&
placeholder !== '' &&
options.some(
(opt) => !opt.disabled && (this.#filterFn ? this.#filterFn(placeholder, opt) : true)
(opt) => !opt.disabled && (this.#filterFn ? this.#filterFn(placeholder, opt) : true),
);
if (key.name === 'tab' && isEmptyOrOnlyTab && placeholderMatchesOption) {
if (this.userInput === '\t') {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/prompts/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function segmentBounds(
type: 'year' | 'month' | 'day',
ctx: { year: number; month: number },
minDate: Date | undefined,
maxDate: Date | undefined
maxDate: Date | undefined,
): { min: number; max: number } {
const minP = minDate
? {
Expand Down Expand Up @@ -206,7 +206,7 @@ export default class DatePrompt extends Prompt<Date> {
if (!segment) return undefined;
this.#cursor.positionInSegment = Math.max(
0,
Math.min(this.#cursor.positionInSegment, segment.len - 1)
Math.min(this.#cursor.positionInSegment, segment.len - 1),
);
return { segment, index };
}
Expand All @@ -218,7 +218,7 @@ export default class DatePrompt extends Prompt<Date> {
if (!ctx) return;
this.#cursor.segmentIndex = Math.max(
0,
Math.min(this.#segments.length - 1, ctx.index + direction)
Math.min(this.#segments.length - 1, ctx.index + direction),
);
this.#cursor.positionInSegment = 0;
this.#segmentSelected = true;
Expand All @@ -235,7 +235,7 @@ export default class DatePrompt extends Prompt<Date> {
segment.type,
parse(this.#segmentValues),
this.#minDate,
this.#maxDate
this.#maxDate,
);

let next: number;
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/prompts/group-multiselect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Prompt, { type PromptOptions } from './prompt.js';

export interface GroupMultiSelectOptions<T extends { value: any }>
extends PromptOptions<T['value'][], GroupMultiSelectPrompt<T>> {
export interface GroupMultiSelectOptions<T extends { value: any }> extends PromptOptions<
T['value'][],
GroupMultiSelectPrompt<T>
> {
options: Record<string, T[]>;
initialValues?: T['value'][];
required?: boolean;
Expand Down Expand Up @@ -39,7 +41,7 @@ export default class GroupMultiSelectPrompt<T extends { value: any }> extends Pr
const groupedItems = this.getGroupItems(group);
if (this.isGroupSelected(group)) {
this.value = this.value.filter(
(v: string) => groupedItems.findIndex((i) => i.value === v) === -1
(v: string) => groupedItems.findIndex((i) => i.value === v) === -1,
);
} else {
this.value = [...this.value, ...groupedItems.map((i) => i.value)];
Expand All @@ -64,7 +66,7 @@ export default class GroupMultiSelectPrompt<T extends { value: any }> extends Pr
this.value = [...(opts.initialValues ?? [])];
this.cursor = Math.max(
this.options.findIndex(({ value }) => value === opts.cursorAt),
this.#selectableGroups ? 0 : 1
this.#selectableGroups ? 0 : 1,
);

this.on('key', (char, key) => {
Expand Down
Loading
Loading