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 81 commits into
base: next
Choose a base branch
from
Draft

CLI: Use ink in CLI #30202

wants to merge 81 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 0.91 0%
initSize 131 MB 132 MB 812 kB 59.73 0.6%
diffSize 52.9 MB 53.8 MB 812 kB 120.26 1.5%
buildSize 7.19 MB 7.19 MB -33 B -0.11 0%
buildSbAddonsSize 1.85 MB 1.85 MB 0 B -0.5 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB -61 B -1.02 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.39 0%
buildPreviewSize 3.28 MB 3.28 MB 28 B 5.77 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 22s 26.4s 4.3s 1.84 🔺16.6%
generateTime 23.1s 21.1s -2s -14ms -0.04 -9.5%
initTime 15.2s 13.1s -2s -62ms -0.95 -15.6%
buildTime 9.9s 8.9s -1s -43ms -0.81 -11.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.5s 4.2s -271ms -1.6 🔰-6.4%
devManagerResponsive 3.3s 3.2s -174ms -1.47 🔰-5.4%
devManagerHeaderVisible 552ms 532ms -20ms -1.16 -3.8%
devManagerIndexVisible 580ms 556ms -24ms -1.28 -4.3%
devStoryVisibleUncached 1.9s 1.8s -122ms -0.22 -6.8%
devStoryVisible 581ms 557ms -24ms -1.3 -4.3%
devAutodocsVisible 481ms 451ms -30ms -1.14 -6.7%
devMDXVisible 495ms 468ms -27ms -1.3 🔰-5.8%
buildManagerHeaderVisible 514ms 486ms -28ms -1.53 🔰-5.8%
buildManagerIndexVisible 609ms 576ms -33ms -1.65 🔰-5.7%
buildStoryVisible 505ms 479ms -26ms -1.41 🔰-5.4%
buildAutodocsVisible 403ms 394ms -9ms -1.64 -2.3%
buildMDXVisible 416ms 405ms -11ms -1.44 -2.7%

Copy link

nx-cloud bot commented Jan 7, 2025

View your CI Pipeline Execution ↗ for commit 4bf774d.

Command Status Duration Result
nx affected -t check -c production --parallel=7 ✅ Succeeded <1s View ↗
nx run-many -t build -c production --parallel=3 ✅ Succeeded 2m 47s View ↗

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

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Jan 7, 2025

Package Benchmarks

Commit: 4bf774d, ran on 17 January 2025 at 15:54:16 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 832 KB 776 KB 🎉 -56 KB 🎉
Dependency size 14.15 MB 14.15 MB 🚨 +31 B 🚨
Bundle Size Analyzer Link Link

@storybook/core

Before After Difference
Dependency count 54 54 0
Self size 19.09 MB 19.60 MB 🚨 +514 KB 🚨
Dependency size 14.43 MB 14.72 MB 🚨 +288 KB 🚨
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 55 55 0
Self size 22 KB 24 KB 🚨 +2 KB 🚨
Dependency size 33.52 MB 34.32 MB 🚨 +802 KB 🚨
Bundle Size Analyzer Link Link

sb

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

@storybook/cli

Before After Difference
Dependency count 399 400 🚨 +1 🚨
Self size 503 KB 248 KB 🎉 -255 KB 🎉
Dependency size 75.57 MB 77.52 MB 🚨 +1.95 MB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 277 277 0
Self size 612 KB 612 KB 🎉 -2 B 🎉
Dependency size 65.37 MB 66.17 MB 🚨 +802 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 113 114 🚨 +1 🚨
Self size 1.11 MB 1.86 MB 🚨 +751 KB 🚨
Dependency size 42.66 MB 43.86 MB 🚨 +1.20 MB 🚨
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