Skip to content
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 "features" question & auto-install test addon & improve test-addon compatibility #30202

Merged
merged 216 commits into from
Feb 11, 2025

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jan 7, 2025

Closes #30196

What I did

  • We started building a new CLI using ink, however we ran out of time, and decided to only do the following:
  • We add a intents question at the start of create-storybook. The usefulness of this question will be expanded upon in the future. for now the only answer that has any effect is:
  • When the user answers yes to the testing intent, we automatically check for compatibility and add the experimental-addon-test to the user's project.
  • Additionally we improved the vitest config file compatibility. We now are able to modify an existing workspace config file (most of the time) as well as deal with more variations.

We spoke about placing the storybook specific workspace config inside of the .storybook folder, but ended up not doing that.

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

When running the create-storybook CLI (you can use the canary) you should be prompted a question at the start for what you intent to use storybook for.
All 3 options should be auto-checked by default.

If you enable / leave enabled the testing intent, you should expect the experimental-addon-test to be added, as well as vitest config to be setup automatically.

This can be skipped if the framework or config was deemed incompatible.

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-30202-sha-f7878745. 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-30202-sha-f7878745
Triggered by @ndelangen
Repository storybookjs/storybook
Branch norbert/cli-with-ink
Commit f7878745
Datetime Tue Feb 4 21:08:52 UTC 2025 (1738703332)
Workflow run 13144868393

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=30202

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 80.5 MB 80.5 MB 0 B 1.03 0%
initSize 80.5 MB 80.5 MB 0 B -0.63 0%
diffSize 97 B 97 B 0 B -0.65 0%
buildSize 7.24 MB 7.24 MB -39 B 0.76 0%
buildSbAddonsSize 1.87 MB 1.87 MB -39 B 0.38 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.88 MB 1.88 MB 0 B 0.17 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.94 MB 3.94 MB -39 B 0.31 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B 0.99 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 13.1s 24.8s 11.7s 0.56 47.1%
generateTime 18.5s 23.8s 5.2s 4.43 🔺22.1%
initTime 4.1s 5.4s 1.2s -0.45 22.6%
buildTime 8.8s 10.9s 2.1s 1.68 🔺19.4%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.6s 4.9s 300ms -0.62 6.1%
devManagerResponsive 3.5s 3.6s 89ms -0.71 2.4%
devManagerHeaderVisible 632ms 800ms 168ms 0.25 21%
devManagerIndexVisible 701ms 813ms 112ms 0 13.8%
devStoryVisibleUncached 2.5s 4s 1.5s 0.28 37.6%
devStoryVisible 702ms 892ms 190ms 0.55 21.3%
devAutodocsVisible 616ms 817ms 201ms 0.6 24.6%
devMDXVisible 683ms 750ms 67ms 0.21 8.9%
buildManagerHeaderVisible 685ms 792ms 107ms -0.29 13.5%
buildManagerIndexVisible 760ms 938ms 178ms -0.23 19%
buildStoryVisible 672ms 777ms 105ms -0.19 13.5%
buildAutodocsVisible 480ms 663ms 183ms -0.23 27.6%
buildMDXVisible 522ms 711ms 189ms 0.45 26.6%

Greptile Summary

This PR significantly enhances the Storybook CLI with new features for test addon integration and improved framework compatibility checks.

  • Added new "intents" question during initialization to determine if users plan to use Storybook for development, documentation, or testing in code/lib/create-storybook/src/initiate.ts
  • Implemented framework compatibility checks for test addon in code/lib/create-storybook/src/ink/steps/checks/frameworkTest.tsx
  • Added Vitest configuration validation and auto-setup in code/lib/create-storybook/src/ink/steps/checks/vitestConfigFiles.tsx
  • Modernized CLI architecture with Zod validation and TypeScript improvements in code/lib/create-storybook/src/bin/modernInputs.ts
  • Switched from CommonJS to ESM modules across CLI packages with proper error handling

The changes look comprehensive but the commented-out render functions in several new files suggest some UI components may not be fully implemented yet.

Copy link

nx-cloud bot commented Jan 7, 2025

View your CI Pipeline Execution ↗ for commit 865a0c0.

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

☁️ Nx Cloud last updated this comment at 2025-02-11 11:24:50 UTC

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Jan 7, 2025

Package Benchmarks

Commit: 865a0c0, ran on 11 February 2025 at 11:30:34 UTC

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

@storybook/core

Before After Difference
Dependency count 52 52 0
Self size 19.26 MB 19.18 MB 🎉 -75 KB 🎉
Dependency size 14.19 MB 14.19 MB 0 B
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 53 53 0
Self size 23 KB 24 KB 🚨 +1 KB 🚨
Dependency size 33.45 MB 33.38 MB 🎉 -75 KB 🎉
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 54 54 0
Self size 1 KB 1 KB 0 B
Dependency size 33.47 MB 33.40 MB 🎉 -74 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 387 358 🎉 -29 🎉
Self size 503 KB 261 KB 🎉 -242 KB 🎉
Dependency size 75.44 MB 83.84 MB 🚨 +8.40 MB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 276 276 0
Self size 617 KB 617 KB 🎉 -157 B 🎉
Dependency size 65.51 MB 65.44 MB 🎉 -75 KB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 111 7 🎉 -104 🎉
Self size 1.11 MB 10.20 MB 🚨 +9.09 MB 🚨
Dependency size 42.63 MB 2.24 MB 🎉 -40.39 MB 🎉
Bundle Size Analyzer Link Link

@ndelangen ndelangen self-assigned this Jan 8, 2025
directory: '.',
};

// TODO @ghengeveld, I am in the process of removing the context
Copy link
Member Author

Choose a reason for hiding this comment

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

@ghengeveld We should remove the context IMHO and module-mock instead

Copy link
Member

Choose a reason for hiding this comment

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

Sure, go for it.

@ghengeveld ghengeveld changed the title CLI: Add "intents" question & auto-install test addon & improve test-addon compatibility CLI: Add "features" question & auto-install test addon & improve test-addon compatibility Feb 11, 2025
@ghengeveld ghengeveld merged commit 875cd97 into next Feb 11, 2025
60 checks passed
@ghengeveld ghengeveld deleted the norbert/cli-with-ink branch February 11, 2025 12:24
@ghengeveld ghengeveld added the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Feb 17, 2025
@ghengeveld ghengeveld self-assigned this Feb 17, 2025
@valentinpalkovic valentinpalkovic removed the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Feb 24, 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.

[Tracking]: Storybook Test onboarding via storybook init
4 participants