fix(cli): flexible tool selection (skip recommended or additional) + fix spacing

This commit is contained in:
Davor Racić 2026-02-02 22:33:50 +01:00
parent 25ad95327c
commit ec63026bbb
2 changed files with 30 additions and 48 deletions

View File

@ -697,9 +697,6 @@ class Installer {
config.skipIde = toolSelection.skipIde; config.skipIde = toolSelection.skipIde;
const ideConfigurations = toolSelection.configurations; const ideConfigurations = toolSelection.configurations;
// Add spacing after prompts before installation progress
console.log('');
if (spinner.isSpinning) { if (spinner.isSpinning) {
spinner.text = 'Continuing installation...'; spinner.text = 'Continuing installation...';
} else { } else {

View File

@ -381,7 +381,7 @@ class UI {
} }
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
// STEP 1: Recommended Tools (multiselect) // STEP 1: Recommended Tools (multiselect) - optional, user can skip
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
const recommendedOptions = preferredIdes.map((ide) => { const recommendedOptions = preferredIdes.map((ide) => {
const isConfigured = configuredPreferred.includes(ide.value); const isConfigured = configuredPreferred.includes(ide.value);
@ -391,12 +391,6 @@ class UI {
}; };
}); });
// Add "__NONE__" option at the end
recommendedOptions.push({
label: '⚠ None - I am not installing any tools',
value: '__NONE__',
});
// Pre-select previously configured preferred tools // Pre-select previously configured preferred tools
const recommendedInitialValues = configuredPreferred.length > 0 ? configuredPreferred : undefined; const recommendedInitialValues = configuredPreferred.length > 0 ? configuredPreferred : undefined;
@ -404,31 +398,16 @@ class UI {
message: `Select recommended tools ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`, message: `Select recommended tools ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`,
options: recommendedOptions, options: recommendedOptions,
initialValues: recommendedInitialValues, initialValues: recommendedInitialValues,
required: true, required: false,
}); });
// Handle "__NONE__" selection const selectedRecommended = recommendedSelected || [];
if (recommendedSelected && recommendedSelected.includes('__NONE__')) {
if (recommendedSelected.length > 1) {
console.log();
console.log(chalk.yellow('⚠️ "None - I am not installing any tools" was selected, so no tools will be configured.'));
console.log();
}
return {
ides: [],
skipIde: true,
};
}
// Filter out any special values from recommended selection
const selectedRecommended = (recommendedSelected || []).filter((v) => v !== '__NONE__');
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
// STEP 2: "Add more tools?" confirmation // STEP 2: Additional Tools - show if user has configured "other" tools,
// selected no recommended tools, or wants to add more
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
// Auto-show additional tools prompt if user has configured "other" tools let showAdditionalPrompt = configuredOther.length > 0 || selectedRecommended.length === 0;
// Otherwise, ask if they want to add more
let showAdditionalPrompt = configuredOther.length > 0;
if (!showAdditionalPrompt && otherIdes.length > 0) { if (!showAdditionalPrompt && otherIdes.length > 0) {
console.log(''); console.log('');
@ -440,9 +419,6 @@ class UI {
let selectedAdditional = []; let selectedAdditional = [];
// ─────────────────────────────────────────────────────────────────────────────
// STEP 3: Additional Tools (autocompleteMultiselect with search)
// ─────────────────────────────────────────────────────────────────────────────
if (showAdditionalPrompt && otherIdes.length > 0) { if (showAdditionalPrompt && otherIdes.length > 0) {
// Build options for additional tools, excluding any already selected in recommended // Build options for additional tools, excluding any already selected in recommended
const additionalOptions = otherIdes const additionalOptions = otherIdes
@ -455,37 +431,46 @@ class UI {
}; };
}); });
// Add "__SKIP__" option at the end
additionalOptions.push({
label: '⚠ Skip - Keep recommended selections only',
value: '__SKIP__',
});
// Pre-select previously configured other tools // Pre-select previously configured other tools
const additionalInitialValues = configuredOther.length > 0 ? configuredOther : undefined; const additionalInitialValues = configuredOther.length > 0 ? configuredOther : undefined;
console.log(''); console.log('');
const additionalSelected = await prompts.autocompleteMultiselect({ const additionalSelected = await prompts.autocompleteMultiselect({
message: 'Select additional tools:', message: `Select additional tools ${chalk.dim('(type to search, SPACE toggles, ENTER to confirm)')}:`,
options: additionalOptions, options: additionalOptions,
initialValues: additionalInitialValues, initialValues: additionalInitialValues,
required: true, required: false,
maxItems: 6, maxItems: 6,
placeholder: 'Type to search...', placeholder: 'Type to search...',
}); });
// Handle "__SKIP__" selection selectedAdditional = additionalSelected || [];
if (additionalSelected && additionalSelected.includes('__SKIP__')) {
// User chose to skip - keep only recommended selections
selectedAdditional = [];
} else {
selectedAdditional = (additionalSelected || []).filter((v) => v !== '__SKIP__');
}
} }
// Combine selections // Combine selections
const allSelectedIdes = [...selectedRecommended, ...selectedAdditional]; const allSelectedIdes = [...selectedRecommended, ...selectedAdditional];
// ─────────────────────────────────────────────────────────────────────────────
// STEP 3: Confirm if no tools selected
// ─────────────────────────────────────────────────────────────────────────────
if (allSelectedIdes.length === 0) {
console.log('');
const confirmNoTools = await prompts.confirm({
message: 'No tools selected. Continue without installing any tools?',
default: false,
});
if (!confirmNoTools) {
// User wants to select tools - recurse
return this.promptToolSelection(projectDir);
}
return {
ides: [],
skipIde: true,
};
}
return { return {
ides: allSelectedIdes, ides: allSelectedIdes,
skipIde: allSelectedIdes.length === 0, skipIde: allSelectedIdes.length === 0,