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: Improve Storybook packages version management #11342

Merged
merged 7 commits into from
Jul 15, 2020

Conversation

gaetanmaisse
Copy link
Member

@gaetanmaisse gaetanmaisse commented Jun 28, 2020

What I did

  • ♻️ Refactor script to extract and save versions of all SB packages:
    The previous script was only extracting version for packages under app directory. Now, all @storybook packages are processed and save with their current version in the monorepo in versions.json. This file will be used to find out which version of the packages should be installed when running sb init.

  • 🆕 Use versions.json to get SB packages versions

  • 🗑️ Remove all Storybook packages listed as devDeps:
    These deps were only there to help to find out which version should be installed when using the CLI. This is now done with a dedicated versions.json file so they are not needed in package.json anymore.
    Bonus: it removes some 6.0.0-alpha.0 SB packages that were required by "@storybook/react-native": "6.0.0-alpha.0"

  • ➕ Add some dependencies to be able to run addon-docs with Yarn 2 out of the box:

    • @storybook/addon-docs is needed as a 1st level dep as we are importing things from @storybook/addon-docs/blocks in mdx stories.
    • @mdx-js/react, SB won't deal with mdx file without adding this dep (so this is a temporary work-around). I need to discuss with you @shilman to deeply understand how mdx stories are working.
  • 🤖 CLI now generates projects with addon-essential so it enables addon-viewport by default. I added a simple test to check that viewport is properly loaded:

    • Go to Welcome Story
    • Click on Viewport button in the toolbar
    • Select "Small Mobile"
    • Check that Welcome Story is still displayed

How to test

  • CI should be 🟢

@gaetanmaisse gaetanmaisse added in progress maintenance User-facing maintenance tasks cli labels Jun 28, 2020
@gaetanmaisse gaetanmaisse force-pushed the tech/improve-versions-management-in-cli branch 3 times, most recently from 760a39b to d9976cf Compare June 30, 2020 19:32
@gaetanmaisse gaetanmaisse force-pushed the tech/improve-versions-management-in-cli branch 3 times, most recently from 0611769 to 75cfc53 Compare July 7, 2020 19:06
@gaetanmaisse gaetanmaisse marked this pull request as ready for review July 7, 2020 19:41
Comment on lines +35 to +38
"prepare": "node ../../scripts/prepare.js && node -r esm ./scripts/generate-sb-packages-versions.js",
"test": "cd test && ./run_tests.sh",
"test-yarn-2": "cd test && ./run_tests_yarn_2.sh",
"postversion": "node -r esm ./scripts/generate-app-versions.js"
"postversion": "node -r esm ./scripts/generate-sb-packages-versions.js"
Copy link
Member Author

Choose a reason for hiding this comment

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

@shilman can you confirm that with these 2 lines, versions.json will be recreated during the release process (after the version bump) and then committed to the repo?

…ckages

The previous script was only extracting version for packages under `app`
directory. Now, all `@storybook` packages are processed and save with
their current version in the monorepo in `versions.json`. This file will
be use to find out which version of the packages should be installed
when running `sb init`.
Previously it used `devDep` of `package.json`. It was working but doing
so all Storybook packages had to be added to `devDep`.

Moreover, as `@storybook/react-native` was not part of the monorepo
anymore it's version was stuck to `6.0.0-alpha.0` causing a download
of `6.0.0-alpha.0` SB packages when running `yarn install`.
These deps were only there to help to find out which version should be
installed when using the CLI. This is now done with a dedicated
`versions.json` file not theya re not needed in `package.json` anymore.

Bonus: it removes some `6.0.0-alpha.0` SB packages that were required by
`"@storybook/react-native": "6.0.0-alpha.0"`
`@babel/plugin-transform-react-jsx` should be resolved in the context
of `addon-docs` and not in the one of SB user projects (as it's done
for the others loaders too). The goal of that is to ensure we are using
a deps that is properly declared either as dep or peerDep
@gaetanmaisse gaetanmaisse force-pushed the tech/improve-versions-management-in-cli branch 3 times, most recently from 531b8cf to 44348e8 Compare July 11, 2020 11:12
@gaetanmaisse gaetanmaisse mentioned this pull request Jul 12, 2020
CLI now generates project with `addon-essential` so it enable `addon-viewport` by default.
I added a simple test to check that viewport is properly loaded:
 - Go to Welcome Story
 - Click on Viewport button in the toolbar
 - Select "Small Mobile"
 - Check that Welcome Story is still displayed
@gaetanmaisse gaetanmaisse force-pushed the tech/improve-versions-management-in-cli branch from 44348e8 to 3e13343 Compare July 12, 2020 14:16
@yannbf yannbf mentioned this pull request Jul 12, 2020
2 tasks
@gaetanmaisse gaetanmaisse requested a review from yannbf July 12, 2020 14:49
@gaetanmaisse
Copy link
Member Author

I discussed a bit with @shilman about mdx and tried to make addon-docs work with Yarn 2 without adding @mdx-js/react as a dependency but I didn't find a way to do that. So, I suggest merging this PR to fix Yarn 2 compatibility (and merge cli improvements). And give a second look to that when mdx v2 will be released (mdx-js/mdx#1041) and updated in SB.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Looks great @gaetanmaisse !!! 👏 👏 👏

@gaetanmaisse
Copy link
Member Author

@shilman can I merge this PR or should I wait as we are now in RC?

@shilman shilman changed the title Cli: Improve Storybook packages versions management CLI: Improve Storybook packages versions management Jul 15, 2020
@shilman shilman changed the title CLI: Improve Storybook packages versions management CLI: Improve Storybook packages version management Jul 15, 2020
@shilman shilman merged commit 50367f9 into next Jul 15, 2020
@shilman shilman added this to the 6.0 milestone Jul 15, 2020
@stof stof deleted the tech/improve-versions-management-in-cli branch May 25, 2022 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants