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: Use ink in CLI #30202

Draft
wants to merge 62 commits into
base: next
Choose a base branch
from
Draft

CLI: Use ink in CLI #30202

wants to merge 62 commits into from

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jan 7, 2025

Closes #

What I did

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>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.9 MB 77.9 MB 0 B 1.73 0%
initSize 131 MB 132 MB 812 kB 54.05 0.6%
diffSize 52.9 MB 53.7 MB 812 kB 90.57 1.5%
buildSize 7.19 MB 7.19 MB -33 B 0.66 0%
buildSbAddonsSize 1.85 MB 1.85 MB 0 B -1.22 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB -61 B -0.37 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.91 MB 3.91 MB -61 B -1.35 0%
buildPreviewSize 3.28 MB 3.28 MB 28 B 9.01 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 6.5s 11.4s 4.9s -0.18 43.1%
generateTime 19.4s 20.7s 1.2s -0.04 6%
initTime 12.7s 15s 2.2s 0.54 15%
buildTime 8.6s 7.9s -704ms -1.54 🔰-8.8%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.7s 4.8s 72ms -0.44 1.5%
devManagerResponsive 3.4s 3.5s 66ms -0.5 1.9%
devManagerHeaderVisible 641ms 579ms -62ms -0.63 -10.7%
devManagerIndexVisible 676ms 604ms -72ms -0.72 -11.9%
devStoryVisibleUncached 1.8s 2s 213ms 0.54 10.5%
devStoryVisible 675ms 606ms -69ms -0.74 -11.4%
devAutodocsVisible 569ms 539ms -30ms -0.25 -5.6%
devMDXVisible 573ms 480ms -93ms -0.9 -19.4%
buildManagerHeaderVisible 555ms 546ms -9ms -0.55 -1.6%
buildManagerIndexVisible 641ms 645ms 4ms -0.35 0.6%
buildStoryVisible 536ms 533ms -3ms -0.54 -0.6%
buildAutodocsVisible 495ms 464ms -31ms -0.28 -6.7%
buildMDXVisible 450ms 422ms -28ms -0.91 -6.6%

Copy link

nx-cloud bot commented Jan 7, 2025

View your CI Pipeline Execution ↗ for commit bbdae44.

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

☁️ Nx Cloud last updated this comment at 2025-01-15 07:58:29 UTC

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Jan 7, 2025

Package Benchmarks

Commit: bbdae44, ran on 15 January 2025 at 08:03:50 UTC

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

@storybook/experimental-addon-test

Before After Difference
Dependency count 60 60 0
Self size 762 KB 776 KB 🚨 +14 KB 🚨
Dependency size 14.15 MB 14.15 MB 🚨 +49 B 🚨
Bundle Size Analyzer Link Link

@storybook/core

Before After Difference
Dependency count 53 54 🚨 +1 🚨
Self size 19.08 MB 19.60 MB 🚨 +519 KB 🚨
Dependency size 14.43 MB 14.72 MB 🚨 +291 KB 🚨
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 54 55 🚨 +1 🚨
Self size 22 KB 24 KB 🚨 +2 KB 🚨
Dependency size 33.51 MB 34.32 MB 🚨 +809 KB 🚨
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 55 56 🚨 +1 🚨
Self size 1 KB 1 KB 🎉 -2 B 🎉
Dependency size 33.54 MB 34.35 MB 🚨 +811 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 398 399 🚨 +1 🚨
Self size 504 KB 248 KB 🎉 -256 KB 🎉
Dependency size 75.55 MB 76.92 MB 🚨 +1.37 MB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 276 277 🚨 +1 🚨
Self size 612 KB 612 KB 🎉 -8 B 🎉
Dependency size 65.36 MB 66.17 MB 🚨 +809 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 112 113 🚨 +1 🚨
Self size 1.11 MB 1.67 MB 🚨 +556 KB 🚨
Dependency size 42.65 MB 43.46 MB 🚨 +811 KB 🚨
Bundle Size Analyzer Link Link

@ndelangen ndelangen self-assigned this Jan 8, 2025
Copy link
Member

@ghengeveld ghengeveld left a comment

Choose a reason for hiding this comment

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

Can you avoid the dependency between modernProgram and legacyProgram somehow? Seems a bit convoluted and confusing.

.name('Initialize Storybook into your project.')
const createStorybookProgram = program.name('Initialize Storybook into your project.');

const modernProgram = Object.entries(modernInputs.shape).reduce((acc, [key, schema]) => {
Copy link
Member

Choose a reason for hiding this comment

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

It's not immediately obvious what this reduce is for. Could you add a comment?

Copy link
Member Author

@ndelangen ndelangen Jan 13, 2025

Choose a reason for hiding this comment

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

This converts the zod runtime interface to a program.options()-chain for commander.
I added a comment higher up in the file.

Comment on lines 36 to 45
if (typeName.match('String')) {
acc.option(`--${flag} <option>`, description, value);
} else if (typeName.match('Enum')) {
acc.option(`--${flag} <option>`, description, value);
} else if (typeName.match('Boolean')) {
acc.option(`--${flag}`, description, value);
if (value === true) {
acc.option(`--no-${flag}`, `inverted --${flag}`);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Can't we extend modernInputs to include the legacy formats, so we don't have to map them here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This makes it easier to remove the legacy options, keeping them separate.

The legacy options don't use zod, and use the shorthand flags, which I'm not supporting here, since I don't deem it necessary.

I'm open to not using zod though, but this ensures we don't have any flags that do not result in state, as well as verify the user is passing valid options.

code/lib/create-storybook/src/bin/index.ts Outdated Show resolved Hide resolved
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.

2 participants