Skip to content

CLI: Fix init not running dev when it should#32457

Merged
ndelangen merged 1 commit into
nextfrom
norbert/fix-init
Sep 16, 2025
Merged

CLI: Fix init not running dev when it should#32457
ndelangen merged 1 commit into
nextfrom
norbert/fix-init

Conversation

@ndelangen
Copy link
Copy Markdown
Member

@ndelangen ndelangen commented Sep 15, 2025

Closes #32379

What I did

The wrong function was being used to init, causing only a subset of the procedure to run.

That caused the final step to not be called, thus dev wouldn't be executed.

I modified the bin code so it imports the correct function

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 PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

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

Greptile Summary

Updated On: 2025-09-15 12:29:56 UTC

This PR fixes a critical bug in the Storybook CLI initialization process where the development server was not automatically launching after project setup when using pnpm create storybook@next. The root cause was an incorrect import path in the create-storybook package's bin entry point.

The key change is in code/lib/create-storybook/src/bin/run.ts, where the import statement was corrected from importing initiate from the package's top-level index (which exported doInitiate as initiate) to importing initiate directly from the initiate.ts file. Based on the codebase context, doInitiate is an internal function that only performs the setup steps, while initiate is the complete public API wrapper that includes additional logic to launch the development server when appropriate.

The change also includes cleanup in build-config.ts by removing unused imports (join from node:path). This fix ensures feature parity between the beta version (@next) and stable version (@latest) where the dev server was correctly starting after initialization, resolving the user experience issue where developers had to manually run storybook dev after the init process completed.

Confidence score: 4/5

  • This PR addresses a specific, well-documented bug with a targeted fix that maintains existing behavior
  • The change involves correcting an import path to use the intended function, which is a low-risk modification
  • Careful attention should be paid to the import changes to ensure the correct function is being called across different entry points

@ndelangen ndelangen changed the title use correct init function CLI: Init not running dev when it should fixed Sep 15, 2025
@ndelangen ndelangen self-assigned this Sep 15, 2025
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Sep 15, 2025

View your CI Pipeline Execution ↗ for commit 7c388ba

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

☁️ Nx Cloud last updated this comment at 2025-09-15 13:38:06 UTC

@ndelangen ndelangen marked this pull request as ready for review September 15, 2025 12:28
Copy link
Copy Markdown
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.

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@ndelangen ndelangen requested a review from shilman September 16, 2025 06:38
Copy link
Copy Markdown
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Thanks!! Any idea why doInitiate is re-exported as initiate in the first place?

@ndelangen ndelangen requested a review from yannbf September 16, 2025 08:03
@ndelangen
Copy link
Copy Markdown
Member Author

No, I assumed that that was intentional, because that was not changed recently.

@kasperpeulen made it like that:
#28519

@ndelangen ndelangen merged commit 5c1784e into next Sep 16, 2025
64 of 68 checks passed
@ndelangen ndelangen deleted the norbert/fix-init branch September 16, 2025 08:05
@github-actions github-actions Bot mentioned this pull request Sep 16, 2025
24 tasks
@ndelangen
Copy link
Copy Markdown
Member Author

@shilman The sandbox command uses that:

const { initiate } = await import('create-storybook');

So it's intentional: as a sandbox uses initiate, but shouldn't auto-dev

@github-actions github-actions Bot mentioned this pull request Sep 16, 2025
23 tasks
@shilman shilman changed the title CLI: Init not running dev when it should fixed CLI: Fix init not running dev when it should Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SB10-beta]: Storybook does not start automatically on init

2 participants