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

feat(cli): add Button codemods #596

Merged
merged 12 commits into from
Jun 4, 2020
Merged

feat(cli): add Button codemods #596

merged 12 commits into from
Jun 4, 2020

Conversation

connor-baer
Copy link
Member

@connor-baer connor-baer commented May 29, 2020

Purpose

Circuit UI v2 comes with a lot of breaking changes — most small and component-specific, but together they add up to a lot of manual work for the users. We can automate these changes with codemods, small scripts that modify the source code automatically.

Approach and changes

  • set up jscodeshift, a library to write, test, and run codemods
  • add codemods to migrate the Button and LoadingButton props (see v2.0.0-alpha.15)
  • add a CLI to run the codemods through Circuit UI:
yarn circuit-ui migrate

Automatically transforms your source code to Circuit UI's latest APIs

Options:
  --help           Show help                                           [boolean]
  --version        Show version number                                 [boolean]
  --transform, -t  The transform to be applied to the source code
                            [string] [required] [choices: "button-variant-enum"]
  --language, -l   The programming language of the files to be transformed
                       [string] [required] [choices: "TypeScript", "JavaScript"]
  --path, -p       A path to the folder that contains the files to be
                   transformed                           [string] [default: "."]

The output looks something like this:

Processing 393 files... 
Spawning 7 workers...
Sending 50 files to free worker...
[...]
Sending 43 files to free worker...
All done. 
Results: 
0 errors
392 unmodified
0 skipped
1 ok
Time elapsed: 4.348seconds 

I chose to only allow one codemod at a time to force the users to apply the transforms incrementally and review the changes before continuing.

Definition of done

  • Development completed
  • Reviewers assigned
  • Unit and integration tests
  • Meets minimum browser support
  • Meets accessibility requirements

tech/compile-jsx
@codecov
Copy link

codecov bot commented May 29, 2020

Codecov Report

Merging #596 into alpha will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##            alpha     #596   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files         137      137           
  Lines        2183     2183           
  Branches      622      622           
=======================================
  Hits         2057     2057           
  Misses        103      103           
  Partials       23       23           

@vercel
Copy link

vercel bot commented May 29, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sumup-oss/circuit-ui/e8i88yqol
✅ Preview: https://circuit-ui-git-feature-codemod-button.sumup-oss.now.sh

@connor-baer connor-baer changed the base branch from alpha to tech/compile-jsx May 29, 2020 08:56
@connor-baer connor-baer added this to the v2.0 milestone May 29, 2020
@connor-baer connor-baer added the 🛠️ tech Changes to the tech stack or infrastructure label May 29, 2020
@connor-baer connor-baer marked this pull request as ready for review May 29, 2020 09:30
tech/compile-jsx

tech/compile-jsx
The flat variant could be used with the primary and secondary variants. It affected the border and shadow, not the color. Mapping it the secondary variant was therefore inaccurate.

feature/codemod-button
@fernandofleury
Copy link
Contributor

@connor-baer by looking into it, it doesn't cover dynamic props, right? Not that I think we have to, but just checking it. (Something like <Button {...props} />)

@connor-baer
Copy link
Member Author

@fernandofleury Yes, dynamic props are not covered. The codemods are meant to help with the bulk of the work, but cannot cover every edge case.

Base automatically changed from tech/compile-jsx to alpha June 1, 2020 07:23
Copy link
Contributor

@fernandofleury fernandofleury left a comment

Choose a reason for hiding this comment

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

In which PR do we cover documentation?

I made some minor comments

src/cli/migrate/button-props.ts Outdated Show resolved Hide resolved
src/cli/migrate/button-props.ts Outdated Show resolved Hide resolved
.eslintrc.js Show resolved Hide resolved
@connor-baer
Copy link
Member Author

@fernandofleury Documentation is covered in #599.

@connor-baer connor-baer merged commit 0a6454f into alpha Jun 4, 2020
@connor-baer connor-baer deleted the feature/codemod-button branch June 4, 2020 09:00
@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2020

🎉 This PR is included in version 2.0.0-alpha.22 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2020

🎉 This PR is included in version 2.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ tech Changes to the tech stack or infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants