Merge pull request #30605 from storybookjs/fix-printing-selected-features

CLI: Fix printing of selected features
This commit is contained in:
Valentin Palkovic 2025-02-21 12:58:20 +01:00 committed by GitHub
commit fea7c5d32c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -299,13 +299,12 @@ export async function doInitiate(options: CommandOptions): Promise<
test: { name: 'Testing', description: 'Fast browser-based component tests, watch mode' },
};
const printFeatures = (features: Set<GeneratorFeature>) =>
Array.from(features)
.map((f) => selectableFeatures[f].name)
.join(', ') || 'none';
let selectedFeatures = new Set<GeneratorFeature>();
selectedFeatures.toString = () =>
selectedFeatures.size === 0
? 'none'
: Array.from(selectedFeatures)
.map((f) => selectableFeatures[f].name)
.join(', ');
if (options.features?.length > 0) {
if (options.features.includes('docs')) {
@ -314,7 +313,7 @@ export async function doInitiate(options: CommandOptions): Promise<
if (options.features.includes('test')) {
selectedFeatures.add('test');
}
logger.log(`Selected features: ${selectedFeatures}`);
logger.log(`Selected features: ${printFeatures(selectedFeatures)}`);
} else if (options.yes || !isInteractive) {
selectedFeatures.add('docs');
@ -322,7 +321,7 @@ export async function doInitiate(options: CommandOptions): Promise<
// Don't automatically add test feature in CI
selectedFeatures.add('test');
}
logger.log(`Selected features: ${selectedFeatures}`);
logger.log(`Selected features: ${printFeatures(selectedFeatures)}`);
} else {
const out = await prompts({
type: 'multiselect',
@ -527,7 +526,7 @@ export async function doInitiate(options: CommandOptions): Promise<
boxen(
dedent`
Storybook was successfully installed in your project! 🎉
Additional features: ${selectedFeatures}
Additional features: ${printFeatures(selectedFeatures)}
To run Storybook manually, run ${picocolors.yellow(
picocolors.bold(storybookCommand)