-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
v1.0.0 Codemod skipping all files #11369
Comments
Same problem here |
I believe the renaming of the imports must be done before passing the codemod |
Ah yes, I see what you mean. |
Even though I renamed the imports, only a few files are changed. I believe that the codemod only changes lines like import { Card, CardContent } from '@material-ui/core'; But not lines like import Card, { CardContent } from '@material-ui/core/Card'; Which is a pity since the latter is the recommended way according to the doc... |
@andokai you shouldn't close the issue, it's far from resolved IMO |
It certainly still required manual intervention on my part. The following wasn't transformed for me. |
It should be working. It's the previous pattern used by all our demos. The demos were migrated with the script. However, I have just realized that the test for the codemod has been transformed. I'm restoring them so we can move forward: #11376. |
Can anyone provide a source file example that isn't transformed but should be? |
That's very strange. I also had this issue until I renamed my imports from: Looking at my files after the script, everything looks good. I will post back if something looks out of place. |
@oliviertassinari react-admin@v2.0.0-RC3 would be a good test project (the code to migrate is in By the way, the codemod only helps with... code. That means that all the text files (documentation) have to be updated by hand. |
I can confirm that the codemod updated some files after I renamed the import path to |
it's already migrated to rc.0 in master (refs marmelab/react-admin#1824) (by hand) |
All my typescript files?! |
Looks like ListSubheader is also a problem in the docs:
|
@lookfirst I can't do much about jscodeshift not supporting TypeScript :/. I have added a comment, facebook/jscodeshift#180 (comment). |
All files are skipped using |
@psamim Is your source code using |
@oliviertassinari I have this line in the code:
|
@psamim You need to change the imports from Flattening the imports is a long and tedious work, so we automated it. Renaming |
Aha, thanks. |
jscodeshift -t <color-imports.js> --importPath='mui/styles/colors' --targetPath='mui/colors' Use this command and put the codmod script path, your source path and change the import and target path accordingly . |
We weren't able to get the codemod to work on our project. It kept erroring out saying "error at token export" or something similar yesterday. We ended up writing our own, which handles We ran it with |
Thank you @Auchindoun! |
Just for everyone else coming here, wondering like me what this means:
it actually means doing a global search+replace on the I suggest making this crystal clear here: https://github.com/mui-org/material-ui/tree/master/packages/material-ui-codemod#import-path . For someone who has never used codemod before, reading that doc, this is not the behavior I expected. I was holding back on doing a global search+replace because I couldn't believe that a script that would flatten imports wouldn't as well rename the imports, if ultimately the latter is a prerequisite for the former (and yes, I spend a good amount of time thinking I was stupid :D ). |
@sacdallago I'm all in with you 💯. Is that something you would like to contribute to the project? :) |
Quick fix in ref to mui#11369 (comment) : suggest users to perform search+replace
@oliviertassinari 🙏 I'm super glad for your (and everyone else's) contributions on this project. I was truly just speaking about a cosmetic change on the documentation (which I have proposed in #11647), rather than a full blown script. @Auchindoun from what I see, you basically have done exactly this pre-flattening step (aka: find+replace) in your script. That could be a nice addition to https://github.com/mui-org/material-ui/blob/master/packages/material-ui-codemod/src/v1.0.0/import-path.js |
Quick fix in ref to #11369 (comment) : suggest users to perform search+replace
@sacdallago comment should greatly reduce the confusion. I'm closing. |
Quick fix in ref to mui#11369 (comment) : suggest users to perform search+replace
So am I understanding correctly that these migrations do not work for TypeScript projects? If so, can you please advise on how to go about migrating a TypeScript project? |
@devuxer I have seen people using the codemod with TypeScript: facebook/jscodeshift#180 (comment). |
Expected Behavior
It should update source files as described.
Current Behavior
It skips all the source files.
Your Environment
The text was updated successfully, but these errors were encountered: