Skip to content

Conversation

@yannbf
Copy link
Member

@yannbf yannbf commented May 20, 2025

Closes #

What I did

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-31521-sha-313befc5. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-31521-sha-313befc5
Triggered by @yannbf
Repository storybookjs/storybook
Branch yann/prompts-abstraction
Commit 313befc5
Datetime Tue May 20 15:01:04 UTC 2025 (1747753264)
Workflow run 15141016309

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=31521

Greptile Summary

This PR introduces a new prompts abstraction layer in the CLI to standardize user interactions, replacing direct usage of the 'prompts' and 'boxen' packages with a unified interface.

  • Added new code/core/src/common/prompts/index.ts implementing text inputs, confirmations, selections, and styled message boxes
  • Replaced direct prompts usage with prompt.text() and prompt.select() in code/lib/cli-storybook/src/sandbox.ts and other CLI files
  • Replaced boxen with prompt.logBox() for consistent message display across the codebase
  • Removed code/lib/cli-storybook/src/util.ts as its functionality is now part of the prompts abstraction
  • Updated test files to use new prompt mocks instead of direct logger calls

@yannbf yannbf added maintenance User-facing maintenance tasks cli labels May 20, 2025
@nx-cloud
Copy link

nx-cloud bot commented May 20, 2025

View your CI Pipeline Execution ↗ for commit 3a55010.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 25s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-22 11:18:37 UTC

@yannbf yannbf force-pushed the yann/prompts-abstraction branch from 5da8350 to 313befc Compare May 20, 2025 15:00
@storybook-app-bot
Copy link

storybook-app-bot bot commented May 20, 2025

Package Benchmarks

Commit: 3a55010, ran on 22 May 2025 at 11:20:26 UTC

The following packages have significant changes to their size or dependencies:

@storybook/addon-a11y

Before After Difference
Dependency count 0 2 🚨 +2 🚨
Self size 0 B 513 KB 🚨 +513 KB 🚨
Dependency size 0 B 2.80 MB 🚨 +2.80 MB 🚨
Bundle Size Analyzer Link Link

@storybook/addon-actions

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 574 B 🚨 +574 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-backgrounds

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 590 B 🚨 +590 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-controls

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 578 B 🚨 +578 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-docs

Before After Difference
Dependency count 0 12 🚨 +12 🚨
Self size 0 B 2.42 MB 🚨 +2.42 MB 🚨
Dependency size 0 B 8.92 MB 🚨 +8.92 MB 🚨
Bundle Size Analyzer Link Link

@storybook/addon-jest

Before After Difference
Dependency count 0 2 🚨 +2 🚨
Self size 0 B 38 KB 🚨 +38 KB 🚨
Dependency size 0 B 53 KB 🚨 +53 KB 🚨
Bundle Size Analyzer Link Link

@storybook/addon-links

Before After Difference
Dependency count 0 1 🚨 +1 🚨
Self size 0 B 20 KB 🚨 +20 KB 🚨
Dependency size 0 B 5 KB 🚨 +5 KB 🚨
Bundle Size Analyzer Link Link

@storybook/addon-measure

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 574 B 🚨 +574 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-onboarding

Before After Difference
Dependency count 0 0 0
Self size 0 B 223 KB 🚨 +223 KB 🚨
Dependency size 0 B 658 B 🚨 +658 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-outline

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 574 B 🚨 +574 B 🚨
Bundle Size Analyzer Link Link

storybook-addon-pseudo-states

Before After Difference
Dependency count 0 0 0
Self size 0 B 46 KB 🚨 +46 KB 🚨
Dependency size 0 B 677 B 🚨 +677 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-themes

Before After Difference
Dependency count 0 1 🚨 +1 🚨
Self size 0 B 20 KB 🚨 +20 KB 🚨
Dependency size 0 B 28 KB 🚨 +28 KB 🚨
Bundle Size Analyzer Link Link

@storybook/addon-toolbars

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 578 B 🚨 +578 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-viewport

Before After Difference
Dependency count 0 0 0
Self size 0 B 3 KB 🚨 +3 KB 🚨
Dependency size 0 B 578 B 🚨 +578 B 🚨
Bundle Size Analyzer Link Link

@storybook/addon-vitest

Before After Difference
Dependency count 0 6 🚨 +6 🚨
Self size 0 B 629 KB 🚨 +629 KB 🚨
Dependency size 0 B 1.49 MB 🚨 +1.49 MB 🚨
Bundle Size Analyzer Link Link

@storybook/builder-vite

Before After Difference
Dependency count 0 5 🚨 +5 🚨
Self size 0 B 448 KB 🚨 +448 KB 🚨
Dependency size 0 B 826 KB 🚨 +826 KB 🚨
Bundle Size Analyzer Link Link

@storybook/builder-webpack5

Before After Difference
Dependency count 0 198 🚨 +198 🚨
Self size 0 B 80 KB 🚨 +80 KB 🚨
Dependency size 0 B 31.25 MB 🚨 +31.25 MB 🚨
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 0 49 🚨 +49 🚨
Self size 0 B 31.51 MB 🚨 +31.51 MB 🚨
Dependency size 0 B 17.40 MB 🚨 +17.40 MB 🚨
Bundle Size Analyzer Link Link

@storybook/angular

Before After Difference
Dependency count 0 208 🚨 +208 🚨
Self size 0 B 606 KB 🚨 +606 KB 🚨
Dependency size 0 B 29.54 MB 🚨 +29.54 MB 🚨
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 0 208 🚨 +208 🚨
Self size 0 B 28 KB 🚨 +28 KB 🚨
Dependency size 0 B 28.82 MB 🚨 +28.82 MB 🚨
Bundle Size Analyzer Link Link

@storybook/html-vite

Before After Difference
Dependency count 0 8 🚨 +8 🚨
Self size 0 B 23 KB 🚨 +23 KB 🚨
Dependency size 0 B 1.32 MB 🚨 +1.32 MB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 0 534 🚨 +534 🚨
Self size 0 B 216 KB 🚨 +216 KB 🚨
Dependency size 0 B 58.69 MB 🚨 +58.69 MB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 0 127 🚨 +127 🚨
Self size 0 B 2.39 MB 🚨 +2.39 MB 🚨
Dependency size 0 B 22.05 MB 🚨 +22.05 MB 🚨
Bundle Size Analyzer Link Link

@storybook/preact-vite

Before After Difference
Dependency count 0 8 🚨 +8 🚨
Self size 0 B 13 KB 🚨 +13 KB 🚨
Dependency size 0 B 1.30 MB 🚨 +1.30 MB 🚨
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 0 160 🚨 +160 🚨
Self size 0 B 35 KB 🚨 +35 KB 🚨
Dependency size 0 B 23.19 MB 🚨 +23.19 MB 🚨
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 0 120 🚨 +120 🚨
Self size 0 B 32 KB 🚨 +32 KB 🚨
Dependency size 0 B 20.16 MB 🚨 +20.16 MB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 0 284 🚨 +284 🚨
Self size 0 B 25 KB 🚨 +25 KB 🚨
Dependency size 0 B 43.48 MB 🚨 +43.48 MB 🚨
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 0 210 🚨 +210 🚨
Self size 0 B 17 KB 🚨 +17 KB 🚨
Dependency size 0 B 32.52 MB 🚨 +32.52 MB 🚨
Bundle Size Analyzer Link Link

@storybook/svelte-vite

Before After Difference
Dependency count 0 17 🚨 +17 🚨
Self size 0 B 53 KB 🚨 +53 KB 🚨
Dependency size 0 B 25.92 MB 🚨 +25.92 MB 🚨
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 0 18 🚨 +18 🚨
Self size 0 B 51 KB 🚨 +51 KB 🚨
Dependency size 0 B 25.98 MB 🚨 +25.98 MB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 0 103 🚨 +103 🚨
Self size 0 B 34 KB 🚨 +34 KB 🚨
Dependency size 0 B 42.69 MB 🚨 +42.69 MB 🚨
Bundle Size Analyzer Link Link

@storybook/web-components-vite

Before After Difference
Dependency count 0 9 🚨 +9 🚨
Self size 0 B 20 KB 🚨 +20 KB 🚨
Dependency size 0 B 1.35 MB 🚨 +1.35 MB 🚨
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 0 50 🚨 +50 🚨
Self size 0 B 1 KB 🚨 +1 KB 🚨
Dependency size 0 B 48.91 MB 🚨 +48.91 MB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 0 324 🚨 +324 🚨
Self size 0 B 173 KB 🚨 +173 KB 🚨
Dependency size 0 B 97.57 MB 🚨 +97.57 MB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 0 267 🚨 +267 🚨
Self size 0 B 31 KB 🚨 +31 KB 🚨
Dependency size 0 B 81.93 MB 🚨 +81.93 MB 🚨
Bundle Size Analyzer Link Link

@storybook/core-webpack

Before After Difference
Dependency count 0 1 🚨 +1 🚨
Self size 0 B 16 KB 🚨 +16 KB 🚨
Dependency size 0 B 28 KB 🚨 +28 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 0 1 🚨 +1 🚨
Self size 0 B 11.07 MB 🚨 +11.07 MB 🚨
Dependency size 0 B 98 KB 🚨 +98 KB 🚨
Bundle Size Analyzer Link Link

@storybook/csf-plugin

Before After Difference
Dependency count 0 3 🚨 +3 🚨
Self size 0 B 10 KB 🚨 +10 KB 🚨
Dependency size 0 B 788 KB 🚨 +788 KB 🚨
Bundle Size Analyzer Link Link

eslint-plugin-storybook

Before After Difference
Dependency count 0 33 🚨 +33 🚨
Self size 0 B 321 KB 🚨 +321 KB 🚨
Dependency size 0 B 3.36 MB 🚨 +3.36 MB 🚨
Bundle Size Analyzer Link Link

@storybook/react-dom-shim

Before After Difference
Dependency count 0 0 0
Self size 0 B 10 KB 🚨 +10 KB 🚨
Dependency size 0 B 786 B 🚨 +786 B 🚨
Bundle Size Analyzer Link Link

@storybook/preset-create-react-app

Before After Difference
Dependency count 0 68 🚨 +68 🚨
Self size 0 B 18 KB 🚨 +18 KB 🚨
Dependency size 0 B 5.89 MB 🚨 +5.89 MB 🚨
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 0 175 🚨 +175 🚨
Self size 0 B 24 KB 🚨 +24 KB 🚨
Dependency size 0 B 30.32 MB 🚨 +30.32 MB 🚨
Bundle Size Analyzer Link Link

@storybook/preset-server-webpack

Before After Difference
Dependency count 0 10 🚨 +10 🚨
Self size 0 B 10 KB 🚨 +10 KB 🚨
Dependency size 0 B 1.20 MB 🚨 +1.20 MB 🚨
Bundle Size Analyzer Link Link

@storybook/html

Before After Difference
Dependency count 0 2 🚨 +2 🚨
Self size 0 B 38 KB 🚨 +38 KB 🚨
Dependency size 0 B 32 KB 🚨 +32 KB 🚨
Bundle Size Analyzer Link Link

@storybook/preact

Before After Difference
Dependency count 0 2 🚨 +2 🚨
Self size 0 B 23 KB 🚨 +23 KB 🚨
Dependency size 0 B 32 KB 🚨 +32 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 0 2 🚨 +2 🚨
Self size 0 B 1.66 MB 🚨 +1.66 MB 🚨
Dependency size 0 B 16 KB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

@storybook/server

Before After Difference
Dependency count 0 3 🚨 +3 🚨
Self size 0 B 13 KB 🚨 +13 KB 🚨
Dependency size 0 B 716 KB 🚨 +716 KB 🚨
Bundle Size Analyzer Link Link

@storybook/svelte

Before After Difference
Dependency count 0 2 🚨 +2 🚨
Self size 0 B 64 KB 🚨 +64 KB 🚨
Dependency size 0 B 230 KB 🚨 +230 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3

Before After Difference
Dependency count 0 3 🚨 +3 🚨
Self size 0 B 83 KB 🚨 +83 KB 🚨
Dependency size 0 B 212 KB 🚨 +212 KB 🚨
Bundle Size Analyzer Link Link

@storybook/web-components

Before After Difference
Dependency count 0 3 🚨 +3 🚨
Self size 0 B 57 KB 🚨 +57 KB 🚨
Dependency size 0 B 47 KB 🚨 +47 KB 🚨
Bundle Size Analyzer Link Link

@yannbf yannbf changed the base branch from next to valentin/monorepo-enhancements May 21, 2025 14:33
@yannbf yannbf force-pushed the yann/prompts-abstraction branch from 2ec42d9 to 50e1bd2 Compare May 22, 2025 09:40
@yannbf yannbf marked this pull request as ready for review May 22, 2025 11:55
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

import prompts from 'prompts';

type Option = {
value: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using any type reduces type safety. Consider using a generic type parameter for value to maintain type checking

Suggested change
value: any;
value: T;

Comment on lines +34 to +36
const baseOptions: PromptOptions = {
onCancel: () => process.exit(0),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Calling process.exit(0) directly in onCancel may prevent cleanup code from running. Consider allowing custom cancel handlers to be passed in

Comment on lines +50 to +51
return result.value;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: No error handling if result.value is undefined (e.g. if user cancels). Should handle this case explicitly

Suggested change
return result.value;
};
if (result.value === undefined) {
throw new Error('Prompt was cancelled');
}
return result.value;
};

Comment on lines +104 to +108
expect(normalizeLineBreaks(prompt.logBox.mock.calls[0][0])).toMatchInlineSnapshot(`
"undefined:
Some error message
Successful migrations:
You can find the full logs in undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Multiple undefined values in snapshot suggest missing template variables or configuration in the implementation

Comment on lines +186 to 190
const glob = await prompt.text({
message:
'Enter a custom glob pattern to scan for story files (or press enter to use default):',
initial: defaultGlob,
initialValue: defaultGlob,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Consider adding error handling for the case where prompt.text() fails or returns undefined

Suggested change
const glob = await prompt.text({
message:
'Enter a custom glob pattern to scan for story files (or press enter to use default):',
initial: defaultGlob,
initialValue: defaultGlob,
});
const glob = await prompt.text({
message:
'Enter a custom glob pattern to scan for story files (or press enter to use default):',
initialValue: defaultGlob,
}) || defaultGlob;

Comment on lines +91 to 94
return prompt.logBox(messages.filter(Boolean).join(segmentDivider), {
title,
borderColor: hasFailures ? 'red' : 'green',
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Consider handling edge case where messages array is empty after filtering - could result in an empty box being displayed

`.trim(),
{ borderStyle: 'round', padding: 1, borderColor: '#F1618C' } as any
)
{ borderStyle: 'round', padding: 1, borderColor: '#F1618C' } as any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: unnecessary type assertion to any - BoxenOptions type should be used instead

message: 'Select a template',
options: choices.map(toChoices),
});
return selected as Choice;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: type assertion could be avoided by properly typing the prompt.select generic parameter

@yannbf yannbf merged commit 721aba0 into valentin/monorepo-enhancements May 22, 2025
53 of 56 checks passed
@yannbf yannbf deleted the yann/prompts-abstraction branch May 22, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal cli maintenance User-facing maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants