-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
CLI: Add prompts abstraction #31521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI: Add prompts abstraction #31521
Conversation
|
View your CI Pipeline Execution ↗ for commit 3a55010.
☁️ Nx Cloud last updated this comment at |
5da8350 to
313befc
Compare
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| 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 |
2ec42d9 to
50e1bd2
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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
| value: any; | |
| value: T; |
| const baseOptions: PromptOptions = { | ||
| onCancel: () => process.exit(0), | ||
| }; |
There was a problem hiding this comment.
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
| return result.value; | ||
| }; |
There was a problem hiding this comment.
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
| return result.value; | |
| }; | |
| if (result.value === undefined) { | |
| throw new Error('Prompt was cancelled'); | |
| } | |
| return result.value; | |
| }; |
| expect(normalizeLineBreaks(prompt.logBox.mock.calls[0][0])).toMatchInlineSnapshot(` | ||
| "undefined: | ||
| Some error message | ||
| Successful migrations: | ||
| You can find the full logs in undefined |
There was a problem hiding this comment.
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
| 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, | ||
| }); |
There was a problem hiding this comment.
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
| 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; |
| return prompt.logBox(messages.filter(Boolean).join(segmentDivider), { | ||
| title, | ||
| borderColor: hasFailures ? 'red' : 'green', | ||
| }); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
721aba0
into
valentin/monorepo-enhancements
Closes #
What I did
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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 runningnpx [email protected] sandboxor in an existing project withnpx [email protected] upgrade.More information
0.0.0-pr-31521-sha-313befc5yann/prompts-abstraction313befc51747753264)To request a new release of this pull request, mention the
@storybookjs/coreteam.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=31521Greptile 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.
code/core/src/common/prompts/index.tsimplementing text inputs, confirmations, selections, and styled message boxespromptsusage withprompt.text()andprompt.select()incode/lib/cli-storybook/src/sandbox.tsand other CLI filesboxenwithprompt.logBox()for consistent message display across the codebasecode/lib/cli-storybook/src/util.tsas its functionality is now part of the prompts abstraction