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 Yarn 2 compatibility #9866

Merged
merged 10 commits into from
Feb 18, 2020
Merged

Conversation

gaetanmaisse
Copy link
Member

@gaetanmaisse gaetanmaisse commented Feb 15, 2020

Issue:
Part of #9527

What I did

  • Make SB CLI compatible with Yarn 2 by handling command used to fetch package versions on NPM registry. => Will need a refactoring, much easier to do if I migrate the package to TS first.
  • Add tests to check CLI and Yarn 2 compatibility: These tests mimic the ones done to test SB CLI with "classic" yarn. However, some magic setup and package.json customization are needed in order to make Yarn 2 works inside a Yarn v1 workspace.

⚠️ CLI is working with Yarn 2 but it does not mean that running yarn sb init will not fails because all frameworks or the SB integration are currently not compatible with Yarn 2. Especially projects using:

  • Angular as Angular is not working with Yarn 2
  • Marko => Cause: Error: Unable to load tag ([.yarn/berry/cache/marko-npm-4.18.46-d693c4c719-2.zip/node_modules/marko/src/core-tags/cache/marko.json → <cached-fragment>])
  • React Static => Error: Couldn't find preset "./babel-preset.js" relative to directory ".yarn/berry/cache/react-static-npm-5.9.12-e804e3b66e-2.zip/node_modules/react-static"
  • Vue => https://github.com/nickmessing/babel-plugin-jsx-event-modifiers is not compatible with Yarn 2, it is deprecated too, so we will need to do something about it

How to test

I add a new GitHub Actions workflow running tests related to SB CLI with Yarn 2.
It should be 🟢.

…ir own functions

Preparatory refactoring to simplify future compatibility with Yarn 2.
@gaetanmaisse gaetanmaisse force-pushed the yarn-2-cli-sb-init-compatibility branch from 65ec39f to 03ccdc8 Compare February 16, 2020 08:23
@@ -35,6 +42,7 @@ export default async (npmOptions, { storyFormat = 'csf' }) => {
`@storybook/mithril@${storybookVersion}`,
`@storybook/addon-actions@${actionsVersion}`,
`@storybook/addon-links@${linksVersion}`,
`@storybook/addon-knobs@${knobsVersion}`,
Copy link
Member Author

Choose a reason for hiding this comment

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

I added knobs because it is listed in addons of the configuration: https://github.com/storybookjs/storybook/blob/3dd714d3532687d958c41e093187b84ffca603ee/lib/cli/src/generators/MITHRIL/template-csf/.storybook/main.js but it is not used in template stories so maybe it should be deleted from configuration instead? 🤷‍♂

At the opposite @storybook/addon-links is added and used in template stories but is not declared in addons config, so we can maybe remove it?

@@ -43,6 +45,7 @@ export default async (npmOptions, { storyFormat = 'csf' }) => {
`@storybook/react@${storybookVersion}`,
`@storybook/addon-actions@${actionsVersion}`,
`@storybook/addon-links@${linksVersion}`,
`@storybook/addon-knobs@${knobsVersion}`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Before, it was assumed that "When working with `create-react-app@>=2.0.0`, we know `babel-loader` is installed."
But `babel` is a peer dependency of `@storybook/core` (itself dep of `@storybook/react`) and so it must be added to the project's `package.json`
These tests mimic the ones done to test SB CLI with "classic" yarn.
However, some magic setup and `package.json` customization are needed in order to make Yarn 2 works inside a Yarn v1 workspace.
`riot-tmpl` is a peerDependency of `riot-compiler`
@gaetanmaisse gaetanmaisse force-pushed the yarn-2-cli-sb-init-compatibility branch from 03ccdc8 to e629f50 Compare February 16, 2020 15:10
@gaetanmaisse gaetanmaisse added this to the 6.0.0 milestone Feb 16, 2020
@gaetanmaisse gaetanmaisse marked this pull request as ready for review February 16, 2020 15:26
@gaetanmaisse
Copy link
Member Author

@Hypnosphi there are 2 broken TeamCity checks, should I mind or rely on all other checks only?

@ndelangen
Copy link
Member

@gaetanmaisse you can ignore the TeamCity checks for now.

@gaetanmaisse gaetanmaisse merged commit 781a472 into next Feb 18, 2020
@gaetanmaisse gaetanmaisse deleted the yarn-2-cli-sb-init-compatibility branch February 18, 2020 19:59
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