feat(cli): Support passing class flags on CLI #317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on transforming our legacy codebase I'm finding that we have hundreds of files that are not completely converted and need additional processing. I added react-codemod as a starting point to go from createReactClass -> React.createClass -> class extends React.Component, which is in the middle of our codemod stack. I was able to use the class transform in isolation running directly from in node and filling in the options/jscodeshiftapi/etc. Unfortunately this doesn't work for all files. I found many issues with jscodeshift getting into infinite loops that did not appear when invoking react-codemod from the terminal.
The problem with invoking from the terminal in node via something like
execSync
is that it uses inquirer to be interactive. This PR makes it so that all class options can be specified on the terminal.Here is an example of what the command I'm running looks like now: