fix: formatting

This commit is contained in:
Davor Racić 2026-02-03 10:27:50 +01:00
parent 3e2da9c728
commit 1ff3323c87
2 changed files with 27 additions and 53 deletions

View File

@ -268,14 +268,14 @@ async function autocompleteMultiselect(options) {
const hasPlaceholder = userInput === '' && placeholder !== undefined;
// Show placeholder or user input with cursor
const searchDisplay = this.isNavigating || hasPlaceholder
? color.dim(hasPlaceholder ? placeholder : userInput)
: this.userInputWithCursor;
const searchDisplay =
this.isNavigating || hasPlaceholder ? color.dim(hasPlaceholder ? placeholder : userInput) : this.userInputWithCursor;
const allOptions = this.options;
const matchCount = this.filteredOptions.length === allOptions.length
? ''
: color.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? '' : 'es'})`);
const matchCount =
this.filteredOptions.length === allOptions.length
? ''
: color.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? '' : 'es'})`);
// Render option with checkbox
const renderOption = (opt, isHighlighted) => {
@ -283,9 +283,7 @@ async function autocompleteMultiselect(options) {
const label = opt.label ?? String(opt.value ?? '');
const hintText = opt.hint && opt.value === this.focusedValue ? color.dim(` (${opt.hint})`) : '';
const checkbox = isSelected ? color.green(clack.S_CHECKBOX_SELECTED) : color.dim(clack.S_CHECKBOX_INACTIVE);
return isHighlighted
? `${checkbox} ${label}${hintText}`
: `${checkbox} ${color.dim(label)}`;
return isHighlighted ? `${checkbox} ${label}${hintText}` : `${checkbox} ${color.dim(label)}`;
};
switch (this.state) {
@ -299,19 +297,11 @@ async function autocompleteMultiselect(options) {
default: {
// Always show "SPACE:" regardless of isNavigating state
const hints = [
`${color.dim('↑/↓')} to navigate`,
`${color.dim('TAB/SPACE:')} select`,
`${color.dim('ENTER:')} confirm`,
];
const hints = [`${color.dim('↑/↓')} to navigate`, `${color.dim('TAB/SPACE:')} select`, `${color.dim('ENTER:')} confirm`];
const noMatchesLine = this.filteredOptions.length === 0 && userInput
? [`${bar} ${color.yellow('No matches found')}`]
: [];
const noMatchesLine = this.filteredOptions.length === 0 && userInput ? [`${bar} ${color.yellow('No matches found')}`] : [];
const errorLine = this.state === 'error'
? [`${bar} ${color.yellow(this.error)}`]
: [];
const errorLine = this.state === 'error' ? [`${bar} ${color.yellow(this.error)}`] : [];
const headerLines = [
...`${title}${bar}`.split('\n'),
@ -320,10 +310,7 @@ async function autocompleteMultiselect(options) {
...errorLine,
];
const footerLines = [
`${bar} ${color.dim(hints.join(' • '))}`,
`${barEnd}`,
];
const footerLines = [`${bar} ${color.dim(hints.join(' • '))}`, `${barEnd}`];
const optionLines = clack.limitOptions({
cursor: this.cursor,
@ -334,11 +321,7 @@ async function autocompleteMultiselect(options) {
rowPadding: headerLines.length + footerLines.length,
});
return [
...headerLines,
...optionLines.map((line) => `${bar} ${line}`),
...footerLines,
].join('\n');
return [...headerLines, ...optionLines.map((line) => `${bar} ${line}`), ...footerLines].join('\n');
}
}
},
@ -551,12 +534,12 @@ async function prompt(questions) {
default: typeof defaultValue === 'function' ? defaultValue(answers) : defaultValue,
validate: validate
? (val) => {
const result = validate(val, answers);
if (result instanceof Promise) {
throw new TypeError('Async validation is not supported by @clack/prompts. Please use synchronous validation.');
const result = validate(val, answers);
if (result instanceof Promise) {
throw new TypeError('Async validation is not supported by @clack/prompts. Please use synchronous validation.');
}
return result === true ? undefined : result;
}
return result === true ? undefined : result;
}
: undefined,
});
break;
@ -594,12 +577,12 @@ async function prompt(questions) {
message,
validate: validate
? (val) => {
const result = validate(val, answers);
if (result instanceof Promise) {
throw new TypeError('Async validation is not supported by @clack/prompts. Please use synchronous validation.');
const result = validate(val, answers);
if (result instanceof Promise) {
throw new TypeError('Async validation is not supported by @clack/prompts. Please use synchronous validation.');
}
return result === true ? undefined : result;
}
return result === true ? undefined : result;
}
: undefined,
});
break;

View File

@ -402,9 +402,7 @@ class UI {
});
// Sort initialValues to match display order
const sortedInitialValues = sortedTools
.filter((ide) => configuredIdes.includes(ide.value))
.map((ide) => ide.value);
const sortedInitialValues = sortedTools.filter((ide) => configuredIdes.includes(ide.value)).map((ide) => ide.value);
const upgradeSelected = await prompts.autocompleteMultiselect({
message: 'Select tools to install:',
@ -488,9 +486,7 @@ class UI {
// - User selected nothing from recommended (so they can pick from everything)
// Otherwise, show only "other" tools as additional options
const showAllTools = wantsBrowseAll || filteredRecommended.length === 0;
const toolsToShow = showAllTools
? [...preferredIdes, ...otherIdes]
: otherIdes;
const toolsToShow = showAllTools ? [...preferredIdes, ...otherIdes] : otherIdes;
if (toolsToShow.length > 0) {
const allToolOptions = toolsToShow.map((ide) => {
@ -506,10 +502,7 @@ class UI {
});
// Pre-select: previously configured tools + any recommended tools already selected
const initialValues = [
...configuredIdes,
...filteredRecommended,
].filter((v, i, arr) => arr.indexOf(v) === i); // dedupe
const initialValues = [...configuredIdes, ...filteredRecommended].filter((v, i, arr) => arr.indexOf(v) === i); // dedupe
// Use "additional" only if user already selected some recommended tools
const isAdditional = !wantsBrowseAll && filteredRecommended.length > 0;
@ -530,9 +523,7 @@ class UI {
// Combine selections:
// - If "Browse All" was used, the second prompt contains ALL selections
// - Otherwise, combine recommended + additional
const allSelectedIdes = wantsBrowseAll
? selectedAdditionalOrAll
: [...filteredRecommended, ...selectedAdditionalOrAll];
const allSelectedIdes = wantsBrowseAll ? selectedAdditionalOrAll : [...filteredRecommended, ...selectedAdditionalOrAll];
// ─────────────────────────────────────────────────────────────────────────────
// STEP 3: Confirm if no tools selected
@ -1008,7 +999,7 @@ class UI {
console.log(
chalk.gray(`Directory exists and contains ${files.length} item(s)`) +
(hasBmadInstall ? chalk.yellow(` including existing BMAD installation (${path.basename(bmadResult.bmadDir)})`) : ''),
(hasBmadInstall ? chalk.yellow(` including existing BMAD installation (${path.basename(bmadResult.bmadDir)})`) : ''),
);
} else {
console.log(chalk.gray('Directory exists and is empty'));