-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
sb migrate
doesn't work with npx
#7602
Comments
Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-beta.20 containing PR #7649 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Still doesn't work:
|
Oddly enough, |
It's working for me. Will investigate if other people are seeing this problem. |
My workaround was to run the command on a parent level instead of project directory. Looks like it interfered with my local packages in some way |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
I tried running it from the parent directory, it did not fail anymore at the babel issue but still failed at a later point at |
I just tried to run the migration and I'm getting the same error as @fabb. Our stories are all written in TS in separate files in a stories directory, so I ran (from the project directory): The error returned is:
Any ideas? We're really excited to get everything converted to CSF and to start using the new Docs addon. Thanks! Looks like maybe this is a duplicate of #8209? |
Based on the info in #8209 I ran the command again using version 5.2.0, and it was able to run. Unfortunately most of the conversions failed, it looks like due to unrecognized TypeScript syntax. For example any story that had a declaration like: Are there known issues like this around stories written in TS? |
@kevinkuebler there's this one: #8091 |
@shilman Thanks, I didn't know about the parser switch. So, it looks like I should have been using In the meantime, I think I'll try temporarily commenting out all of the |
@kevinkuebler there's a good chance the migrate script won't work with typescript even once that bug is fixed. it's doing an analysis of the parsed abstract syntax tree (AST) to do the source-to-source transformation, and that AST will be different for typescript. however the code is only written to handle the JS AST. It's still worth a try, because there's probably a high degree of overlap, and the codemod can save you time, even though it might not get 100% of the cases. But don't set your hopes too high. |
@shilman Got it, thanks for the info! I'll try to touch up our stories a bit (like commenting out the interfaces) and see if that gets us most of the way there. UPDATE: Just commenting out the interfaces isn't enough, usually because we have a class component defined in the story that uses the TS generic syntax (e.g. |
For me the transformation of typescript stories worked fine, since I don‘t have any interfaces or the like defined in these files. I needed to install the storybook cli and react globally to make the above mentioned errors disappear. Unfortunately no |
@kevinkuebler i don't think that's something i'd go out of my way to support, but if you or anybody else sees super common TS patterns that break |
@shilman No problem, I understand. Just to add a bit more context, here's why our stories are written the way they are. I'm curious to know if anybody else does this or if we were maybe not using Storybook in a recommended way when we started writing these. Let's say we have a fairly simple, fully controlled React component named
We have quite a few stories written this way. Usually it's because they're illustrating how an application component would use the actual component that the story is ultimately about, in regards to managing state, etc. I realize that may not be how Storybook is intended to be used, since the component being passed to Storybook is not the actual component that we're trying to document. That issue aside, the ideal scenario for the migration would be that it basically ignores everything except the call to the |
@kevinkuebler maybe @Hypnosphi has more to say about this, but storybook now supports hooks out of the box: both react hooks and also a framework independent hook implementation. i'd guess that would be a much more compact/convenient way to do the same thing. |
@shilman Oh, for sure. We haven't made the move to hooks yet in our production code, but it's on the horizon. A lot of the stories we're converting were written before hooks were even a thing. For something simple like this example, I would definitely do what's shown in that example you linked when writing new stories. Some of our more complex components though would probably still require a separate story component to wrap the component we're documenting in Storybook (although in some cases we may be able to make better use of decorators to accomplish that). Anyway, I don't want to wander too far from the original point of this issue, which was the migration. 😄 And since the migration tool doesn't TS syntax, I'm ok with manually converting our stories. Thanks again! |
Had to strip out the typescript but worked ok (globally install |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
For me, the error was due to missing storybook cli. This command worked like a charm: |
Hi! I am going through and cleaning up old issues in the repo. We just shipped a ton of improvements in Storybook 7.0, and I suspect this bug might be fixed already. Can you please try it out? If this issue persists with the latest version, please open a new bug report with a 7.x reproduction. Thank you so much! 🙏🏼 |
The text was updated successfully, but these errors were encountered: