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

fix(codemod): Pass codemod options to jscodeshift script #2137

Merged
merged 1 commit into from
Apr 7, 2023

Conversation

alanbsmith
Copy link
Member

Summary

Fixes: #2136

The codemod was ignoring valid JSCodeshift options that are helpful to optimize the script. This patch allows --ignore-pattern, --ignore-config, and --verbose to be passed through. I also set the codemod to ignore node_modules directories by default and updated the docs.

Release Category

Codemods


Checklist

  • MDX documentation adheres to Canvas Kit's standard MDX template
  • Label ready for review has been added to PR

For the Reviewer

  • PR title is short and descriptive
  • PR summary describes the change (Fixes/Resolves linked correctly)
  • PR Release Notes describes additional information useful to call out in a release message or removed if not applicable
  • Breaking Changes provides useful information to upgrade to this code or removed if not applicable

Where Should the Reviewer Start?

Areas for Feedback? (optional)

  • Code
  • Documentation
  • Testing
  • Codemods

Testing Manually

There's not a great way to test this manually, but if the codemod tests pass, it works. I added the output of running this updated script in another consumer repo to show that it works as expected.

Screenshots or GIFs (if applicable)

 🐠  yarn canvas-kit-codemod v5 src/ --ignore-config=".gitignore" --verbose=2                                                                                                         (base)
yarn run v1.22.19
$ /../../node_modules/.bin/canvas-kit-codemod v5 src/ --ignore-config=.gitignore --verbose=2

Applying v5 transform to 'src/'

Processing 660 files...

...

All done.

Results:
0 errors
660 unmodified
0 skipped
0 ok

Time elapsed: 15.310seconds

Thank You Gif (optional)

a smiling Shiba Inu typing on a laptop

@codesandbox
Copy link

codesandbox bot commented Apr 7, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

Comment on lines +10 to +27
.options({
'ignore-config': {
type: 'string',
describe: 'Ignore files if they match patterns sourced from a configuration file (e.g. a .gitignore)',
default: '',
},
'ignore-pattern': {
type: 'string',
describe: 'Ignore files that match a provided glob expression (e.g. **/dist/**)',
default: '**/node_modules/**',
},
verbose: {
type: 'number',
describe: 'Show more information about the transform process',
default: 0,
choices: [0, 1, 2]
},
})
Copy link
Member Author

Choose a reason for hiding this comment

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

Putting these options here allows them to be available for all our codemod scripts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Options are pulls from the jscodeshift docs: https://github.com/facebook/jscodeshift#usage-cli

@alanbsmith alanbsmith added ready for review Code is ready for review 8.x bug Something isn't working labels Apr 7, 2023
@github-actions github-actions bot requested a review from jamesfan April 7, 2023 18:23
@cypress
Copy link

cypress bot commented Apr 7, 2023

Passing run #5521 ↗︎

0 779 2 0 Flakiness 0

Details:

Merge d51e3d1 into 5e956b0...
Project: canvas-kit Commit: 54f764ac5a ℹ️
Status: Passed Duration: 06:10 💡
Started: Apr 7, 2023 6:23 PM Ended: Apr 7, 2023 6:29 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

```

> Note: These codemods only work on .js, .jsx, .ts, and .tsx extensions. You may need to make some manual changes in other file types (.json, .mdx, .md, etc.).
> Note: These codemods only work on .js, .jsx, .ts, and .tsx extensions. You may need to make some
> manual changes in other file types (.json, .mdx, .md, etc.).
Copy link
Contributor

Choose a reason for hiding this comment

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

why is in highlighted differently here?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's GitHub trying to syntax highlight correctly and making a mistake. It thinks it's a keyword.

@mannycarrera4
Copy link
Contributor

should this go into support as well?

@alanbsmith
Copy link
Member Author

It could go to support, but I'm mostly wanting these improvement for folks who still need to move to v8 (and eventually v9). Most consumers are on v7 already.

@alanbsmith alanbsmith added approved Code has been reviewed and approved (ship it) automerge and removed ready for review Code is ready for review labels Apr 7, 2023
@alanbsmith alanbsmith merged commit edbde73 into Workday:master Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x approved Code has been reviewed and approved (ship it) automerge bug Something isn't working
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

fix: Codemod does not pass along JSCodeshift options
2 participants