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: Update stories glob in mdx codemod and not in mdx automigration #21809

Merged
merged 5 commits into from
Mar 30, 2023

Conversation

kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Mar 29, 2023

closes #21543, closes #21544

What I did

Update the mdx stories glob in the mdx codemod instead of the automigration.
At first I planned to move the logic to the codemod package.

But at some point I realized that I needed to move whole directories of the cli to the common-core package (for example the JSPackageManager files). So instead of decided to simply run the automigration in the migrate.ts file of the cli package.

I splitted the logic of the automigration function, so that you can apply fixes without having to call the whole automigration function.

It looks like this:

image

image

This PR also installs the @storybook/blocks package in the codemod.

How to test

  1. Create a new application for example: yarn create vite . --template react-ts
  2. Run sb init on it.
  3. Change the main.js file so that it has this glob:
    stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)']
  4. See that the glob gets updated when running
    sb migrate mdx-to-csf --glob="**/src/**/*.stories.mdx"

Also remove, the @storybook/blocks package from your package.json and then see it gets reinstalled by the codemod:

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@kasperpeulen kasperpeulen changed the title Update stories glob in mdx codemod and not in mdx automigration CLI: Update stories glob in mdx codemod and not in mdx automigration Mar 29, 2023
@kasperpeulen kasperpeulen force-pushed the kasper/mdx-update-glob-in-codemod branch from 01bbf5b to bd31273 Compare March 29, 2023 14:42
@kasperpeulen kasperpeulen force-pushed the kasper/mdx-update-glob-in-codemod branch from 91eb6b3 to 299293a Compare March 29, 2023 15:02
…odemod

# Conflicts:
#	code/lib/cli/src/migrate.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants