CLI: Modernize Storybook CLI with new init workflow, Clack UI, and Generator System#32717
Merged
valentinpalkovic merged 352 commits intonextfrom Nov 19, 2025
Merged
CLI: Modernize Storybook CLI with new init workflow, Clack UI, and Generator System#32717valentinpalkovic merged 352 commits intonextfrom
valentinpalkovic merged 352 commits intonextfrom
Conversation
Contributor
📝 WalkthroughWalkthroughModularized create/init flows, centralized command execution and logging/prompting, consolidated mocking utilities, introduced typed enums (frameworks, renderers, builders, features, languages, project types), reworked generator and command modules, refactored Vitest addon/postinstall and builder mocking integrations, and updated CI test-init features to include a11y. Changes
Sequence Diagram(s)%% Primary init/create-storybook flow (high level)
sequenceDiagram
autonumber
actor User
participant CLI as "create-storybook CLI"
participant Pre as "PreflightCheck"
participant Detect as "ProjectDetection"
participant Frm as "FrameworkDetection"
participant Pref as "UserPreferences"
participant Gen as "GeneratorExecution"
participant Dep as "DependencyInstallation"
participant Add as "AddonConfiguration"
participant Fin as "Finalization"
User->>CLI: initiate(options)
CLI->>Pre: execute(options)
Pre-->>CLI: { packageManager, isEmptyProject }
CLI->>Detect: execute(...)
Detect-->>CLI: { projectType, language }
CLI->>Frm: execute(...)
Frm-->>CLI: { renderer, builder, framework }
CLI->>Pref: execute(...)
Pref-->>CLI: { selectedFeatures }
CLI->>Gen: execute(...)
Gen-->>CLI: { configDir?, storybookCommand?, extraAddons }
CLI->>Dep: execute(...)
Dep-->>CLI: { status }
CLI->>Add: execute(...)
Add-->>CLI: { status }
CLI->>Fin: execute(...)
Fin-->>CLI: done
%% Addon Vitest interactions (high level)
sequenceDiagram
autonumber
participant Caller
participant AddV as "AddonVitestService"
participant PM as "JsPackageManager"
Caller->>AddV: validateCompatibility(opts)
AddV-->>Caller: { compatible, reasons? }
Caller->>AddV: collectDependencies(PM)
AddV-->>Caller: [packages]
Caller->>AddV: validateConfigFiles(directory)
AddV-->>Caller: { compatible, reasons? }
Caller->>AddV: installPlaywright(PM, { yes? })
AddV-->>Caller: errors[]
Estimated code review effort🎯 5 (Critical) | ⏱️ ~150 minutes
Possibly related issues
Possibly related PRs
✨ Finishing touches
Comment |
|
View your CI Pipeline Execution ↗ for commit b01def1
☁️ Nx Cloud last updated this comment at |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 414 KB | 181 KB | 🎉 -232 KB 🎉 |
| Dependency size | 2.97 MB | 2.97 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/addon-vitest
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 6 | 2 | 🎉 -4 🎉 |
| Self size | 441 KB | 375 KB | 🎉 -66 KB 🎉 |
| Dependency size | 570 KB | 338 KB | 🎉 -232 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 11 | 17 | 🚨 +6 🚨 |
| Self size | 291 KB | 304 KB | 🚨 +13 KB 🚨 |
| Dependency size | 1.30 MB | 2.00 MB | 🚨 +701 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 187 | 191 | 🚨 +4 🚨 |
| Self size | 66 KB | 75 KB | 🚨 +9 KB 🚨 |
| Dependency size | 31.98 MB | 32.19 MB | 🚨 +215 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 44 | 39 | 🎉 -5 🎉 |
| Self size | 21.70 MB | 19.20 MB | 🎉 -2.50 MB 🎉 |
| Dependency size | 17.16 MB | 16.40 MB | 🎉 -755 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 187 | 191 | 🚨 +4 🚨 |
| Self size | 114 KB | 118 KB | 🚨 +3 KB 🚨 |
| Dependency size | 29.99 MB | 30.22 MB | 🚨 +224 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 191 | 195 | 🚨 +4 🚨 |
| Self size | 15 KB | 15 KB | 0 B |
| Dependency size | 28.69 MB | 28.91 MB | 🚨 +224 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/html-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 14 | 20 | 🚨 +6 🚨 |
| Self size | 22 KB | 22 KB | 🚨 +12 B 🚨 |
| Dependency size | 1.63 MB | 2.34 MB | 🚨 +715 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 533 | 537 | 🚨 +4 🚨 |
| Self size | 645 KB | 645 KB | 🎉 -5 B 🎉 |
| Dependency size | 58.91 MB | 59.13 MB | 🚨 +224 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 124 | 128 | 🚨 +4 🚨 |
| Self size | 1.12 MB | 1.12 MB | 🚨 +85 B 🚨 |
| Dependency size | 21.72 MB | 21.95 MB | 🚨 +229 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/preact-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 14 | 20 | 🚨 +6 🚨 |
| Self size | 13 KB | 13 KB | 🚨 +12 B 🚨 |
| Dependency size | 1.61 MB | 2.33 MB | 🚨 +715 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 156 | 160 | 🚨 +4 🚨 |
| Self size | 30 KB | 30 KB | 0 B |
| Dependency size | 22.90 MB | 23.13 MB | 🚨 +229 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 114 | 118 | 🚨 +4 🚨 |
| Self size | 35 KB | 35 KB | 🚨 +112 B 🚨 |
| Dependency size | 19.52 MB | 19.75 MB | 🚨 +229 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 273 | 277 | 🚨 +4 🚨 |
| Self size | 24 KB | 24 KB | 🚨 +12 B 🚨 |
| Dependency size | 43.85 MB | 44.08 MB | 🚨 +224 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 199 | 203 | 🚨 +4 🚨 |
| Self size | 16 KB | 16 KB | 0 B |
| Dependency size | 33.23 MB | 33.45 MB | 🚨 +224 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/svelte-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 19 | 24 | 🚨 +5 🚨 |
| Self size | 56 KB | 56 KB | 0 B |
| Dependency size | 26.75 MB | 27.00 MB | 🚨 +255 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/sveltekit
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 20 | 25 | 🚨 +5 🚨 |
| Self size | 56 KB | 56 KB | 🎉 -24 B 🎉 |
| Dependency size | 26.80 MB | 27.06 MB | 🚨 +255 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 109 | 114 | 🚨 +5 🚨 |
| Self size | 35 KB | 35 KB | 🎉 -24 B 🎉 |
| Dependency size | 43.90 MB | 44.15 MB | 🚨 +255 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/web-components-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 15 | 21 | 🚨 +6 🚨 |
| Self size | 19 KB | 19 KB | 🎉 -12 B 🎉 |
| Dependency size | 1.65 MB | 2.37 MB | 🚨 +715 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 188 | 173 | 🎉 -15 🎉 |
| Self size | 840 KB | 770 KB | 🎉 -70 KB 🎉 |
| Dependency size | 71.37 MB | 66.17 MB | 🎉 -5.21 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 170 | 166 | 🎉 -4 🎉 |
| Self size | 30 KB | 30 KB | 🎉 -25 B 🎉 |
| Dependency size | 67.91 MB | 64.74 MB | 🎉 -3.17 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 45 | 40 | 🎉 -5 🎉 |
| Self size | 1.45 MB | 998 KB | 🎉 -454 KB 🎉 |
| Dependency size | 38.86 MB | 35.60 MB | 🎉 -3.25 MB 🎉 |
| Bundle Size Analyzer | node | node |
…init-features job
…clean up type definitions - Changed framework property in FrameworkDetectionResult to be required instead of optional. - Updated getFramework method to throw an error if a framework cannot be found, improving error handling. - Removed unused type definition for Builder in project_types.ts to streamline code.
…work handling and type definitions - Updated generatorOptions to include framework and renderer properties for better configuration. - Simplified the getFrameworkDetails function to improve clarity and error handling. - Removed unused builder details logic to streamline the baseGenerator function. - Adjusted types in GeneratorOptions to reflect the new structure.
- Removed the externalFrameworks function to simplify framework detection logic. - Updated getFrameworkDetails to enhance clarity by directly applying the require wrapper on the framework package. - Improved overall readability and maintainability of the baseGenerator code.
- Added a prompt to ask users if they want to use Compodoc for documentation in Angular projects. - Improved user experience by providing information about the benefits of Compodoc. - Updated the logic to determine Compodoc usage based on user input instead of a fixed feature flag.
… addon configuration - Updated the `doInitiate` function to pass `projectType` to user preferences and generator execution. - Simplified the `executeGeneratorExecution` function to accept a single options object. - Enhanced the `UserPreferencesCommand` to determine selected features based on project type. - Adjusted addon configuration logic to utilize `extraAddons` from generator execution results. - Improved overall code readability and maintainability by streamlining function signatures and logic.
…turn structure - Updated the `GeneratorExecutionResult` type to improve clarity and structure by formatting the return type. - Adjusted the return statement in `executeProjectGenerator` to conditionally include `configDir` based on the generator result. - Improved overall readability and maintainability of the `GeneratorExecutionCommand` class.
- Updated the logging in `useStatics` to display relative paths for static directories instead of absolute paths, enhancing clarity. - Removed unused `Builder` type imports and replaced them with `SupportedBuilder` in various files to improve type consistency and maintainability.
- Replaced string literals with SupportedBuilder constants in the AddonManager test cases for improved type safety and consistency. - Enhanced clarity in the tests by using the defined types for builder options.
…aths - Updated the `useStatics` function to utilize `getProjectRoot` for calculating relative static directory paths, enhancing accuracy in logging. - Changed the logger to use `CLI_COLORS` for improved visual consistency in log messages.
- Consolidated the logging message in the `promptForCompoDocs` function to a single line for better clarity and maintainability. - Enhanced user experience by providing a concise message about the benefits of using Compodoc for documentation in Angular projects.
- Included the `yes` option in the `GeneratorExecutionCommand` to allow automatic confirmation for prompts. - Enhanced the command's flexibility by enabling users to bypass interactive prompts based on their preferences.
- Updated postinstall function to accept logger and prompt from options. - Enhanced ClackPromptProvider to manage task logging more effectively. - Streamlined logger usage in add and postinstallAddon functions. - Removed redundant task messages in baseGenerator for cleaner output.
- Removed leading arrows from logger messages in various files to standardize output format. - Introduced ConsoleLogger and StyledConsoleLogger classes for enhanced logging functionality. - Added new console logger methods to improve logging capabilities and maintainability.
This was referenced Nov 26, 2025
This was referenced Dec 8, 2025
This was referenced Jan 7, 2026
8 tasks
This was referenced Jan 26, 2026
8 tasks
This was referenced Feb 17, 2026
Merged
This was referenced Mar 4, 2026
This was referenced Mar 11, 2026
This was referenced Mar 20, 2026
This was referenced Mar 30, 2026
This was referenced Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25389
Closes #32043
Closes #32778
Closes #31880
Closes #31914
What I did
This PR represents a massive refactor and modernization of the Storybook CLI, primarily focused on the
initcommand. The original initiate.ts file, a monolithic, 900+ line behemoth, was brittle, hard to maintain, and difficult to test.This new architecture replaces it with a clean, command-based pipeline that is modular, testable, and far more extensible. We've also swapped our CLI's user interface from prompts to @clack/prompts, providing a significantly improved, modern, and interactive experience for users.
Highlights of the Change
Command-Based init Workflow: The entire init process is now orchestrated as a series of discrete, testable commands:
New Generator System:
Introduced a generatorRegistry and a new GeneratorModule interface.
All framework generators (React, Angular, Next.js, Nuxt, etc.) have been refactored to this new, modular standard, separating metadata and configuration logic .
Modern Clack UI:
prompts,ora, andboxenwith@clack/promptsacross the entire CLI (init, add, upgrade, automigrate) for a unified, beautiful, and interactive experience.Centralized Addon & Feature Logic:
a11y in
recommended:The test feature now also includes @storybook/addon-a11y by default, as it's a prerequisite for accessibility testing.
New Next.js-Vite Support:
The Next.js generator now defaults to @storybook/nextjs-vite (Vite builder) for new projects. It intelligently detects custom webpack.config.js or .babelrc files and prompts the user to fall back to @storybook/nextjs (Webpack 5) if needed.
Added a new nextjs-to-nextjs-vite automigration to help users move from the old Webpack-based setup .
Rsbuild Support during initialization:
Enhanced Logging & Error Handling:
debug-storybook.logfile on failure, making debugging much easier.Introduced new StorybookError subclasses for CLI failures (e.g., AddonVitestPostinstallError)
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This is a massive change. Please test the init and add commands thoroughly.
storybook initcdinto a new React + Vite project.npx storybook@<canary> init.cdinto a new React + Vite project.npx storybook@<canary> init --yes.cdinto a new React + Vite project.npx storybook@latest init --features docs a11y.cdinto a clean Next.js project. Run init --yes.rm -rf .storybookand add awebpack(config) { return config; }block to next.config.js.storybook addcdinto a project without the test feature (e.g., init --features docs).npx storybook@<canary> add @storybook/addon-vitest.storybook automigratecdinto a project using the old @storybook/nextjs (Webpack).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-32717-sha-7a16d827. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-32717-sha-7a16d827 sandboxor in an existing project withnpx storybook@0.0.0-pr-32717-sha-7a16d827 upgrade.More information
0.0.0-pr-32717-sha-7a16d827valentin/cli-init-rework7a16d8271763547934)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 publish.yml --field pr=32717Summary by CodeRabbit
New Features
Improvements
Tests