Skip to content

Conversation

shilman
Copy link
Member

@shilman shilman commented Aug 28, 2025

Closes N/A.

What I did

Introduces logic to detect and report the Storybook version used to initiate a project by inspecting the ancestry of process commands. The main changes add a dependency for process ancestry inspection, implement a utility to extract the Storybook version from the ancestry, and update telemetry reporting to include this version specifier. Comprehensive tests were added to verify the new utility

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

  • Publish to verdaccio
  • Run init commands with STORYBOOK_TELEMETRY_DEBUG=1

🦋 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>

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.

3 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

ancestry: ReturnType<typeof getProcessAncestry>
): string | undefined {
for (const ancestor of ancestry) {
const match = ancestor.command?.match(/[ \-]storybook@([^\s]+)/);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The regex pattern could potentially match false positives. Consider using a more specific pattern like /(?:^|\s|-)storybook@([^\s]+)/ to ensure proper word boundaries.

Comment on lines +161 to +163
const ancestry = [{ command: 'node' }, { command: '[email protected]' }, { command: 'npm' }];
expect(getStorybookVersionFromAncestry(ancestry as any)).toBeUndefined();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Test name 'possible storybook path' is unclear - consider renaming to 'returns undefined for storybook command without create/init keywords'

Suggested change
const ancestry = [{ command: 'node' }, { command: '[email protected]' }, { command: 'npm' }];
expect(getStorybookVersionFromAncestry(ancestry as any)).toBeUndefined();
});
it('returns undefined for storybook command without create/init keywords', () => {
const ancestry = [{ command: 'node' }, { command: '[email protected]' }, { command: 'npm' }];
expect(getStorybookVersionFromAncestry(ancestry as any)).toBeUndefined();
});

@shilman shilman added maintenance User-facing maintenance tasks cli patch:yes Bugfix & documentation PR that need to be picked to main branch ci:normal labels Aug 28, 2025
@shilman shilman requested a review from JReinhold August 28, 2025 12:26
Copy link

nx-cloud bot commented Aug 28, 2025

View your CI Pipeline Execution ↗ for commit f3e5667

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

☁️ Nx Cloud last updated this comment at 2025-09-11 11:28:56 UTC

@shilman shilman force-pushed the shilman/init-version-specifier branch from 398da27 to d97fd4d Compare August 28, 2025 12:52
@shilman
Copy link
Member Author

shilman commented Aug 28, 2025

Make more specific to match create-storybook.

Also search in reverse order because storybook@latest init calls [email protected] so the latter is lower in the stack.

Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

LGTM, only one minor nit.

@storybook-pr-benchmarking
Copy link

Package Benchmarks

Commit: f3e5667, ran on 11 September 2025 at 11:10:59 UTC

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

storybook

Before After Difference
Dependency count 48 48 0
Self size 30.74 MB 30.62 MB 🎉 -119 KB 🎉
Dependency size 17.61 MB 17.61 MB 0 B
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 204 219 🚨 +15 🚨
Self size 879 KB 879 KB 🎉 -90 B 🎉
Dependency size 81.72 MB 81.82 MB 🚨 +104 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 173 188 🚨 +15 🚨
Self size 35 KB 35 KB 🎉 -12 B 🎉
Dependency size 76.79 MB 76.89 MB 🚨 +100 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 49 49 0
Self size 1.52 MB 1.52 MB 🚨 +5 KB 🚨
Dependency size 48.35 MB 48.23 MB 🎉 -119 KB 🎉
Bundle Size Analyzer node node

@ndelangen ndelangen changed the title CLI: Capture the version specifier used in create-storybook CLI: Capture the version specifier used in create-storybook Sep 11, 2025
@ndelangen ndelangen merged commit 98c4d9a into next Sep 11, 2025
56 checks passed
@ndelangen ndelangen deleted the shilman/init-version-specifier branch September 11, 2025 11:43
ndelangen added a commit that referenced this pull request Sep 12, 2025
…fier

CLI: Capture the version specifier used in `create-storybook`
(cherry picked from commit 98c4d9a)
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 patch:yes Bugfix & documentation PR that need to be picked to main branch telemetry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants