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

Core: Split Storybook CLI #28519

Merged
merged 50 commits into from
Aug 5, 2024
Merged

Core: Split Storybook CLI #28519

merged 50 commits into from
Aug 5, 2024

Conversation

kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Jul 10, 2024

What I did

Implements the CLI split RFC:
#23590

The build and dev command is moved to @storybook/core/cli together with other shared CLI logic.
The init command is moved to create-storybook
All other commands are moved @storybook/cli.

In the storybook package there is a proxy.ts file that orchestrates the storybook package to forward the command with npx to the right package:

import { spawn } from 'child_process';
import { versions } from '@storybook/core/common';
const args = process.argv.slice(2);
if (['dev', 'build'].includes(args[0])) {
require('@storybook/core/cli/bin');
} else {
const proxiedArgs =
args[0] === 'init'
? [`create-storybook@${versions.storybook}`, ...args.slice(1)]
: [`@storybook/cli@${versions.storybook}`, ...args];
const command = ['npx', '--yes', ...proxiedArgs];
const child = spawn(command[0], command.slice(1), { stdio: 'inherit' });
child.on('exit', (code) => {
if (code != null) {
process.exit(code);
}
process.exit(1);
});
}

By using npx, the user doesn't have to install a bunch of dependencies, such as jscodeshift, that are not needed for basic storybook commands. It now only needs to download that when it actually needs it.

This makes sure that the storybook package is as lean as possible. We remove 370 packages and 70MB install size with this PR.

Next to that, we can now consolidate the @storybook/core package with storybook in a follow-up PR cc @ndelangen, which would clean up our code base quite a bit.

  Install size Packages added Lock file increase
storybook@~8.1 130M 596 5560 lines
storybook@~8.2 133M 470 4436 lines
toolbox split 72M 117 1186 lines
full CLI split (this PR) 63M 101 1071 lines

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/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-28519-sha-8fbf6907. 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-28519-sha-8fbf6907
Triggered by @ndelangen
Repository storybookjs/storybook
Branch kasper/cli-split
Commit 8fbf6907
Datetime Thu Aug 1 15:31:59 UTC 2024 (1722526319)
Workflow run 10201282970

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

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 76.3 MB 76.3 MB 0 B -1.98 0%
initSize 198 MB 172 MB -25.9 MB -312.14 🔰-15.1%
diffSize 122 MB 95.6 MB -25.9 MB -321.01 🔰-27.1%
buildSize 7.6 MB 7.58 MB -12 kB -52.97 -0.2%
buildSbAddonsSize 1.63 MB 1.63 MB 0 B 1.35 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.29 MB -12 kB -2304.69 -0.5%
buildSbPreviewSize 349 kB 349 kB 0 B 1.36 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.47 MB 4.46 MB -12 kB -77.34 -0.3%
buildPreviewSize 3.12 MB 3.12 MB 6 B 0.64 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 19.3s 11.6s -7s -728ms -0.43 -66.3%
generateTime 20.8s 31.2s 10.3s 4.28 🔺33.2%
initTime 21.6s 24.6s 3s 0.65 12.3%
buildTime 13.7s 14.3s 684ms 0.08 4.8%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 7.3s 7.7s 428ms -0.62 5.5%
devManagerResponsive 5s 4.8s -227ms -0.93 -4.7%
devManagerHeaderVisible 730ms 817ms 87ms -0.32 10.6%
devManagerIndexVisible 762ms 841ms 79ms -0.35 9.4%
devStoryVisibleUncached 1.3s 889ms -458ms -1.66 🔰-51.5%
devStoryVisible 783ms 868ms 85ms -0.34 9.8%
devAutodocsVisible 638ms 731ms 93ms -0.64 12.7%
devMDXVisible 633ms 751ms 118ms -0.27 15.7%
buildManagerHeaderVisible 725ms 902ms 177ms 0.44 19.6%
buildManagerIndexVisible 728ms 909ms 181ms 0.43 19.9%
buildStoryVisible 779ms 965ms 186ms 0.44 19.3%
buildAutodocsVisible 666ms 734ms 68ms -0.39 9.3%
buildMDXVisible 626ms 813ms 187ms 0.7 23%

@kasperpeulen kasperpeulen changed the title WIP Core: Split Storybook CLI Jul 10, 2024
@ndelangen ndelangen disabled auto-merge August 1, 2024 15:30
@kasperpeulen kasperpeulen merged commit 0eac7a5 into next Aug 5, 2024
104 checks passed
@kasperpeulen kasperpeulen deleted the kasper/cli-split branch August 5, 2024 14:26
@github-actions github-actions bot mentioned this pull request Aug 5, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:daily Run the CI jobs that normally run in the daily job. maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants