-
Notifications
You must be signed in to change notification settings - Fork 26
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: add postcss codemod #893
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really awesome!
Shouldn't we target the v10 branch? |
@emmenko Why? This way consumers can migrate prior to the release of the branch. There's nothing stopping them from doing it now. Both new and old custom properties exist. |
Ah you want to keep it separated? I thought we just include it in the migration script with the other codemods for v10 so that we only need to run 1 migration script once. |
Since I'm not sure when exactly we will release v10, I think it makes sense to get this in first. As part of the v10 release we can update the mapping file as we make more changes 🤷♂. Since this just replaces deprecated custom properties, I don't see why we need to wait on a breaking release to get this in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codemod looks cool!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dope!
|
||
First, start by installing `postcss-cli`. You will use this to run the css transformation. | ||
|
||
`yarn add -D postcss-cli` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe recommend to use npx
to run the command, as it's usually a one time thing, so there is no need to have an extra dependency installed
@@ -0,0 +1,46 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we scope those changes into "version folders", so we make them "immutable"?
codemods/custom-property-replacer/v10/variable-mapping.json
Then in the future we can have more of them...
@@ -0,0 +1,40 @@ | |||
import postcss from 'postcss'; | |||
import path from 'path'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: define imports for nodejs modules first
return css => { | ||
css.walkDecls(decl => { | ||
if (!opts || !opts.file) { | ||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error should be thrown above, since you already try to read from the file.
48c2f09
to
52759db
Compare
@emmenko your changes have been implemented 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary
To make it easier to update to the upcoming UI-Kit version 10, we can provide a postcss codemod to replace outdated custom properties with their replacements.
Before
Run the command
After
What do you think?
I was thinking if this is useful to create it as a separate repo / package, and then we would just keep the variable-mapping jsons in UI Kit.